Skip to content

Commit

Permalink
[mcfish] Add one click selling (#894)
Browse files Browse the repository at this point in the history
* [mcfish]  Add one click selling

Add one click waste selling function to mcfish plugin

给mcfish 添加一键售卖垃圾功能

* 🔖 v1.7.8

* chore: del aipaint due to 过气

* chore: del baidu due to 使えない

* chore: del cangtoushi due to 使えない

* chore: del dress due to 删库

* chore: del heisi due to 跑路

* chore: del jiami due to 跑路

* chore: del jiuejuezi due to 跑路

* chore: del quan due to 跑路

* chore: del wangyiyun due to 跑路

* chore: del wenben due to 跑路

* fix: atri 早安 conflict with sleep_manage & add 回应表情

* fix: version limit

* fix: version limit

* fix: version limit

* chore: update deps

* fix(searcher): forward node

* 💩👌 make lint happy

* revert: fix(searcher): forward node

* fix(github): get api method

* chore: del imgfinder due to 跑路

* optimize: saucenao head

* chore: tidy

* chore: del vtbxxx due to 跑路

* fix(drawlots): draw gif noise

* fix(emojimix): connection issue in some regions

* 💩👌 make lint happy

* fix(drawlots): draw gif noise

* fix(emojimix): add more logs

* feat: add uwu logo

* optimize: README uwu icon

* chore: update deps

* optimize: 赞我 触发失败时静默

* fix: update img pool

* fix: imgpool on LLOB

* fix(manager): 回应表情

* ✨ 修复b站小程序解析 (#895)

* add control for saucenao & bilibili_parse (#839)

* add control for saucenao&bilibili_parse

* not only group

* update control

* reuse variables

---------

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>

* fix(bilibili): parse config

* fix(manager): 撤回

* fix: reply face

* fix: reply face

* 💩👌 make lint happy

* feat: add option `-mirror`

* chore: update deps

* chore: update deps

* chore: update deps

* chore: update deps

* chore: update deps

* chore: update deps

* chore: update deps

* 🔖 v1.8.0

* revert: emojimix http2

* 📝 update README

* [mcfish]  Add one click selling

Add one click waste selling function to mcfish plugin

给mcfish 添加一键售卖垃圾功能

* Update robbery plugin

Update robbery plugin
修改打劫功能

---------

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
Co-authored-by: himawari <54976075+guohuiyuan@users.noreply.github.com>
Co-authored-by: 莫思潋 <55676105+shudorcl@users.noreply.github.com>
  • Loading branch information
4 people authored May 6, 2024
1 parent 78c64ac commit d1b83f4
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 钓鱼商店
- [x] 购买xxx [数量]
- [x] 出售xxx [数量]
- [x] 出售[xxx [数量]|所有垃圾]
- [x] 钓鱼背包
- [x] 装备[xx竿|三叉戟|美西螈]
- [x] 附魔[诱钓|海之眷顾]
Expand Down
22 changes: 21 additions & 1 deletion plugin/mcfish/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var (
DisableOnDefault: false,
Brief: "钓鱼",
Help: "一款钓鱼模拟器\n----------指令----------\n" +
"- 钓鱼看板/钓鱼商店\n- 购买xxx\n- 购买xxx [数量]\n- 出售xxx\n- 出售xxx [数量]\n" +
"- 钓鱼看板/钓鱼商店\n- 购买xxx\n- 购买xxx [数量]\n- 出售xxx\n- 出售xxx [数量]\n- 出售所有垃圾\n" +
"- 钓鱼背包\n- 装备[xx竿|三叉戟|美西螈]\n- 附魔[诱钓|海之眷顾]\n- 修复鱼竿\n- 合成[xx竿|三叉戟]\n- 消除[绑定|宝藏]诅咒\n- 消除[绑定|宝藏]诅咒 [数量]\n" +
"- 进行钓鱼\n- 进行n次钓鱼\n- 当前装备概率明细\n" +
"规则V" + version + ":\n" +
Expand Down Expand Up @@ -530,6 +530,26 @@ func (sql *fishdb) getNumberFor(uid int64, thing string) (number int, err error)
return
}

// 获取用户的某类物品信息
func (sql *fishdb) getUserTypeInfo(uid int64, thingType string) (thingInfos []article, err error) {
name := strconv.FormatInt(uid, 10) + "Pack"
sql.Lock()
defer sql.Unlock()
userInfo := article{}
err = sql.db.Create(name, &userInfo)
if err != nil {
return
}
if !sql.db.CanFind(name, "where Type = '"+thingType+"'") {
return
}
err = sql.db.FindFor(name, &userInfo, "where Type = '"+thingType+"'", func() error {
thingInfos = append(thingInfos, userInfo)
return nil
})
return
}

/*********************************************************/
/************************商店相关函数***********************/
/*********************************************************/
Expand Down
71 changes: 71 additions & 0 deletions plugin/mcfish/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,77 @@ func init() {
}
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("出售成功,你赚到了", pice*number, msg)))
})
engine.OnRegex(`^出售所有垃圾`, getdb, refreshFish).SetBlock(true).Limit(limitSet).Handle(func(ctx *zero.Ctx) {
uid := ctx.Event.UserID

articles, err := dbdata.getUserTypeInfo(uid, "waste")
if err != nil {
ctx.SendChain(message.Text("[ERROR]:获取背包信息错误", err))
return
}
if len(articles) == 0 {
ctx.SendChain(message.Text("你的背包不存在该物品"))
return
}
if len(articles) > 1 {
msg := make(message.Message, 0, 3+len(articles))
msg = append(msg, message.Reply(ctx.Event.MessageID), message.Text("找到以下物品:\n"))
for i, info := range articles {
msg = append(msg, message.Text(
"[", i, "]", info.Name, " 数量: ", info.Number, "\n"))
}
ctx.Send(msg)
}

pice := 0
for _, info := range articles {
pice += (priceList[info.Name] * discountList[info.Name] / 100) * info.Number * 8 / 10
}

ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("是否接受商店将以", pice, "收购全部垃圾", "?\n回答\"\"\"\"")))
// 等待用户下一步选择
recv, cancel1 := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(是|否)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
defer cancel1()
buy := false
for {
select {
case <-time.After(time.Second * 60):
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("等待超时,取消钓鱼")))
return
case e := <-recv:
nextcmd := e.Event.Message.String()
if nextcmd == "否" {
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("已取消出售")))
return
}
buy = true
}
if buy {
break
}
}

msg := ""
curse, err := dbdata.getNumberFor(uid, "宝藏诅咒")
if err != nil {
ctx.SendChain(message.Text("[ERROR at store.go.9.3]:", err))
return
}
if curse != 0 {
msg = "\n(你身上绑定了" + strconv.Itoa(curse) + "层诅咒)"
pice = pice * (100 - 10*curse) / 100
}

for _, info := range articles {
info.Number = 0
err = dbdata.updateUserThingInfo(uid, info)
if err != nil {
ctx.SendChain(message.Text("[ERROR at store.go.6]:", err))
return
}
}
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("出售成功,你赚到了", pice, msg)))
})
engine.OnRegex(`^购买(`+strings.Join(thingList, "|")+`)\s*(\d*)$`, getdb, refreshFish).SetBlock(true).Limit(limitSet).Handle(func(ctx *zero.Ctx) {
uid := ctx.Event.UserID
numberOfPole, err := dbdata.getNumberFor(uid, "竿")
Expand Down

0 comments on commit d1b83f4

Please sign in to comment.