()
| 23 | ) |
| 24 | |
| 25 | func init() { |
| 26 | engine.OnFullMatch("钓鱼背包", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { |
| 27 | uid := ctx.Event.UserID |
| 28 | equipInfo, err := dbdata.getUserEquip(uid) |
| 29 | if err != nil { |
| 30 | ctx.SendChain(message.Text("[ERROR at pack.go.1]:", err)) |
| 31 | return |
| 32 | } |
| 33 | articles, err := dbdata.getUserPack(uid) |
| 34 | if err != nil { |
| 35 | ctx.SendChain(message.Text("[ERROR at pack.go.2]:", err)) |
| 36 | return |
| 37 | } |
| 38 | pic, err := drawPackImage(uid, equipInfo, articles) |
| 39 | if err != nil { |
| 40 | ctx.SendChain(message.Text("[ERROR at pack.go.3]:", err)) |
| 41 | return |
| 42 | } |
| 43 | ctx.SendChain(message.ImageBytes(pic)) |
| 44 | }) |
| 45 | engine.OnRegex(`^消除(绑定|宝藏)诅咒(\d*)$`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { |
| 46 | uid := ctx.Event.UserID |
| 47 | number, _ := strconv.Atoi(ctx.State["regex_matched"].([]string)[2]) |
| 48 | if number == 0 { |
| 49 | number = 1 |
| 50 | } |
| 51 | number1, err := dbdata.getNumberFor(uid, "宝藏诅咒") |
| 52 | if err != nil { |
| 53 | ctx.SendChain(message.Text("[ERROR at fish.go.3.1]:", err)) |
| 54 | return |
| 55 | } |
| 56 | if number1 == 0 { |
| 57 | ctx.SendChain(message.Text("你没有绑定任何诅咒")) |
| 58 | return |
| 59 | } |
| 60 | if number1 < number { |
| 61 | number = number1 |
| 62 | } |
| 63 | number2, err := dbdata.getNumberFor(uid, "净化书") |
| 64 | if err != nil { |
| 65 | ctx.SendChain(message.Text("[ERROR at fish.go.3.2]:", err)) |
| 66 | return |
| 67 | } |
| 68 | if number2 < number { |
| 69 | ctx.SendChain(message.Text("你没有足够的解除诅咒的道具")) |
| 70 | return |
| 71 | } |
| 72 | articles, err := dbdata.getUserThingInfo(uid, "净化书") |
| 73 | if err != nil { |
| 74 | ctx.SendChain(message.Text("[ERROR at store.go.3.3]:", err)) |
| 75 | return |
| 76 | } |
| 77 | articles[0].Number -= number |
| 78 | err = dbdata.updateUserThingInfo(uid, articles[0]) |
| 79 | if err != nil { |
| 80 | ctx.SendChain(message.Text("[ERROR at store.go.3.4]:", err)) |
| 81 | return |
| 82 | } |
nothing calls this directly
no test coverage detected