()
| 13 | ) |
| 14 | |
| 15 | func init() { |
| 16 | engine.OnRegex(`^装备(`+strings.Join(poleList, "|")+`)$`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { |
| 17 | uid := ctx.Event.UserID |
| 18 | equipInfo, err := dbdata.getUserEquip(uid) |
| 19 | if err != nil { |
| 20 | ctx.SendChain(message.Text("[ERROR at pole.go.1]:", err)) |
| 21 | return |
| 22 | } |
| 23 | thingName := ctx.State["regex_matched"].([]string)[1] |
| 24 | articles, err := dbdata.getUserThingInfo(uid, thingName) |
| 25 | if err != nil { |
| 26 | ctx.SendChain(message.Text("[ERROR at pole.go.2]:", err)) |
| 27 | return |
| 28 | } |
| 29 | if len(articles) == 0 { |
| 30 | ctx.SendChain(message.Text("你的背包不存在该物品")) |
| 31 | return |
| 32 | } |
| 33 | poles := make([]equip, 0, len(articles)) |
| 34 | if thingName != "美西螈" { |
| 35 | for _, info := range articles { |
| 36 | poleInfo := strings.Split(info.Other, "/") |
| 37 | durable, _ := strconv.Atoi(poleInfo[0]) |
| 38 | maintenance, _ := strconv.Atoi(poleInfo[1]) |
| 39 | induceLevel, _ := strconv.Atoi(poleInfo[2]) |
| 40 | favorLevel, _ := strconv.Atoi(poleInfo[3]) |
| 41 | poles = append(poles, equip{ |
| 42 | ID: uid, |
| 43 | Equip: info.Name, |
| 44 | Durable: durable, |
| 45 | Maintenance: maintenance, |
| 46 | Induce: induceLevel, |
| 47 | Favor: favorLevel, |
| 48 | }) |
| 49 | } |
| 50 | } else { |
| 51 | poles = append(poles, equip{ |
| 52 | ID: uid, |
| 53 | Equip: thingName, |
| 54 | Durable: 999, |
| 55 | }) |
| 56 | } |
| 57 | check := false |
| 58 | index := 0 |
| 59 | if len(poles) > 1 { |
| 60 | msg := make(message.Message, 0, 3+len(articles)) |
| 61 | msg = append(msg, message.Reply(ctx.Event.MessageID), message.Text("找到以下鱼竿:\n")) |
| 62 | for i, info := range poles { |
| 63 | msg = append(msg, message.Text("[", i, "] ", info.Equip, " : 耐", info.Durable, "/修", info.Maintenance, |
| 64 | "/诱", enchantLevel[info.Induce], "/眷顾", enchantLevel[info.Favor], "\n")) |
| 65 | } |
| 66 | msg = append(msg, message.Text("————————\n")) |
| 67 | msg = append(msg, message.Text("- 输入对应序号进行装备\n")) |
| 68 | msg = append(msg, message.Text("- 输入“取消”终止本次操作\n")) |
| 69 | msg = append(msg, message.Text("- 鱼竿数量请使用钓鱼背包查看")) |
| 70 | ctx.Send(msg) |
| 71 | // 等待用户下一步选择 |
| 72 | recv, cancel := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(取消|\d+)$`), zero.CheckUser(ctx.Event.UserID)).Repeat() |
nothing calls this directly
no test coverage detected