Skip to content

Commit 0615993

Browse files
authored
fix: 修复注销牛牛无法进行累加收费的问题&&优化代码 (FloatTech#1178)
* fix:修复注销牛牛无法进行累加收费的问题 * 修改牛牛商店的循环条件为商品变量的长度
1 parent 1c0d914 commit 0615993

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugin/niuniu/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func init() {
6565
messages = append(messages, ctxext.FakeSenderForwardNode(ctx, message.Text("牛牛拍卖行有以下牛牛")))
6666
for _, info := range auction {
6767
msg := fmt.Sprintf("商品序号: %d\n牛牛原所属: %d\n牛牛价格: %d%s\n牛牛大小: %.2fcm",
68-
info.ID+1, info.UserID, info.Money, wallet.GetWalletName(), info.Length)
68+
info.ID, info.UserID, info.Money, wallet.GetWalletName(), info.Length)
6969
messages = append(messages, ctxext.FakeSenderForwardNode(ctx, message.Text(msg)))
7070
}
7171
if id := ctx.Send(messages).ID(); id == 0 {
@@ -90,7 +90,6 @@ func init() {
9090
ctx.SendChain(message.Text("ERROR: ", err))
9191
return
9292
}
93-
n--
9493
msg, err := niu.Auction(gid, uid, n)
9594
if err != nil {
9695
ctx.SendChain(message.Text("ERROR:", err))
@@ -151,7 +150,7 @@ func init() {
151150

152151
var messages message.Message
153152
messages = append(messages, ctxext.FakeSenderForwardNode(ctx, message.Text("牛牛商店当前售卖的物品如下")))
154-
for id := range propMap {
153+
for id := 1; id <= len(propMap); id++ {
155154
product := propMap[id]
156155
productInfo := fmt.Sprintf("商品%d\n商品名: %s\n商品价格: %dATRI币\n商品作用域: %s\n商品描述: %s\n使用次数:%d",
157156
id, product.name, product.cost, product.scope, product.description, product.count)
@@ -380,6 +379,9 @@ func init() {
380379
)))
381380

382381
if c.Count >= 4 {
382+
if c.Count == 6 {
383+
return
384+
}
383385
id := ctx.SendPrivateMessage(adduser,
384386
message.Text(fmt.Sprintf("你在%d群里已经被厥冒烟了,快去群里赎回你原本的牛牛!\n发送:`赎牛牛`即可!", gid)))
385387
if id == 0 {
@@ -394,7 +396,7 @@ func init() {
394396
key := fmt.Sprintf("%d_%d", gid, uid)
395397
data, ok := register.Load(key)
396398
switch {
397-
case !ok || time.Since(data.TimeLimit) > time.Hour*12:
399+
case !ok || time.Since(data.TimeLimit) > time.Hour*24:
398400
data = &lastLength{
399401
TimeLimit: time.Now(),
400402
Count: 1,
@@ -404,6 +406,7 @@ func init() {
404406
ctx.SendChain(message.Text("你的钱不够你注销牛牛了,这次注销需要", data.Count*50, wallet.GetWalletName()))
405407
return
406408
}
409+
data.Count++
407410
}
408411
register.Store(key, data)
409412
msg, err := niu.Cancel(gid, uid)

0 commit comments

Comments
 (0)