Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy0411 authored Oct 27, 2024
1 parent b5b783e commit dadb2ae
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions plugin/niuniu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,31 +482,30 @@ func init() {
}
t := fmt.Sprintf("%d_%d", gid, uid)
value, ok := countDeleteNiuNiu.Load(t)
if ok {
if time.Since(value.TimeLimit) < 24*time.Hour {
money := getMoneyForNumber(value.Count)
walletOf := wallet.GetWalletOf(uid)
if !(walletOf > money) {
ctx.SendChain(message.Text(fmt.Sprintf("你今天已经注销了%d次了,此次注销需要%d个ATRI币,没钱就等待明天重置吧", value.Count+1, money)))
return
}
if err = wallet.InsertWalletOf(uid, -money); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
countDeleteNiuNiu.Store(t, &propsCount{
Count: value.Count + 1,
})
} else {
countDeleteNiuNiu.Delete(t)
}
} else {
if !ok {
countDeleteNiuNiu.Store(t, &propsCount{
Count: 1,
TimeLimit: time.Now(),
})
value = &propsCount{}
}
if value.TimeLimit.IsZero() && time.Since(value.TimeLimit) < 24*time.Hour {
money := getMoneyForNumber(value.Count)
walletOf := wallet.GetWalletOf(uid)
if walletOf < money {
ctx.SendChain(message.Text(fmt.Sprintf("你今天已经注销了%d次了,此次注销需要%d个ATRI币,没钱就等待明天重置吧", value.Count+1, money)))
return
}
if err = wallet.InsertWalletOf(uid, -money); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
countDeleteNiuNiu.Store(t, &propsCount{
Count: value.Count + 1,
})
} else {
countDeleteNiuNiu.Delete(t)
}
err = db.deleteniuniu(gid, uid)
if err != nil {
ctx.SendChain(message.Text("注销失败"))
Expand Down

0 comments on commit dadb2ae

Please sign in to comment.