From db4f6792b84c70f6c2ed96dabb03629315f25883 Mon Sep 17 00:00:00 2001 From: ZJY <764763903@qq.com> Date: Tue, 26 Oct 2021 14:32:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=81=A2=E5=A4=8D=E8=B5=8C=E4=B8=80?= =?UTF-8?q?=E6=8A=8A=20=E9=80=81=E5=93=88=20=E6=85=8E=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/command.go | 206 +++++++++++++++++++++++----------------------- 1 file changed, 102 insertions(+), 104 deletions(-) diff --git a/models/command.go b/models/command.go index 107dcd6..1949164 100644 --- a/models/command.go +++ b/models/command.go @@ -407,123 +407,121 @@ var codeSignals = []CodeSignal{ return nil }, }, - /* - { - Command: []string{"我要钱", "给点钱", "我干", "给我钱", "给我", "我要"}, - Handle: func(sender *Sender) interface{} { - cost := Int(sender.JoinContens()) - if cost <= 0 { - cost = 1 - } - if !sender.IsAdmin { - if cost > 1 { - return "你只能获得1互助值" - } else { - AddCoin(sender.UserID) - return "太可怜了,给你1互助值" - } + { + Command: []string{"我要钱", "给点钱", "我干", "给我钱", "给我", "我要"}, + Handle: func(sender *Sender) interface{} { + cost := Int(sender.JoinContens()) + if cost <= 0 { + cost = 1 + } + if !sender.IsAdmin { + if cost > 1 { + return "你只能获得1互助值" } else { - AdddCoin(sender.UserID, cost) - sender.Reply(fmt.Sprintf("你获得%d枚互助值。", cost)) + AddCoin(sender.UserID) + return "太可怜了,给你1互助值" } - return nil - }, + } else { + AdddCoin(sender.UserID, cost) + sender.Reply(fmt.Sprintf("你获得%d枚互助值。", cost)) + } + return nil }, - { - Command: []string{"梭哈", "拼了", "梭了"}, - Handle: func(sender *Sender) interface{} { - u := &User{} - cost := GetCoin(sender.UserID) + }, + { + Command: []string{"梭哈", "拼了", "梭了"}, + Handle: func(sender *Sender) interface{} { + u := &User{} + cost := GetCoin(sender.UserID) - if cost <= 0 || cost > 10000 { - cost = 1 - } + if cost <= 0 || cost > 10000 { + cost = 1 + } - if err := db.Where("number = ?", sender.UserID).First(u).Error; err != nil || u.Coin < cost { - return "互助值不足,先去打卡吧。" + if err := db.Where("number = ?", sender.UserID).First(u).Error; err != nil || u.Coin < cost { + return "互助值不足,先去打卡吧。" + } else { + sender.Reply(fmt.Sprintf("你使用%d枚互助值。", cost)) + } + baga := 0 + if u.Coin > 100000 { + baga = u.Coin + cost = u.Coin + } + r := time.Now().Nanosecond() % 10 + if r < 7 || baga > 0 { + sender.Reply(fmt.Sprintf("很遗憾你失去了%d枚互助值。", cost)) + cost = -cost + } else { + if r == 9 { + cost *= 4 + sender.Reply(fmt.Sprintf("恭喜你4倍暴击获得%d枚互助值,20秒后自动转入余额。", cost)) + time.Sleep(time.Second * 20) } else { - sender.Reply(fmt.Sprintf("你使用%d枚互助值。", cost)) + sender.Reply(fmt.Sprintf("很幸运你获得%d枚互助值,10秒后自动转入余额。", cost)) + time.Sleep(time.Second * 10) } - baga := 0 - if u.Coin > 100000 { - baga = u.Coin - cost = u.Coin - } - r := time.Now().Nanosecond() % 10 - if r < 7 || baga > 0 { - sender.Reply(fmt.Sprintf("很遗憾你失去了%d枚互助值。", cost)) - cost = -cost - } else { - if r == 9 { - cost *= 4 - sender.Reply(fmt.Sprintf("恭喜你4倍暴击获得%d枚互助值,20秒后自动转入余额。", cost)) - time.Sleep(time.Second * 20) - } else { - sender.Reply(fmt.Sprintf("很幸运你获得%d枚互助值,10秒后自动转入余额。", cost)) - time.Sleep(time.Second * 10) - } - sender.Reply(fmt.Sprintf("%d枚互助值已到账。", cost)) - } - db.Model(u).Update("coin", gorm.Expr(fmt.Sprintf("coin + %d", cost))) - return nil - }, + sender.Reply(fmt.Sprintf("%d枚互助值已到账。", cost)) + } + db.Model(u).Update("coin", gorm.Expr(fmt.Sprintf("coin + %d", cost))) + return nil }, + }, - //{ - // Command: []string{"按许愿币更新排名"}, - // Admin: true, - // Handle: func(sender *Sender) interface{} { - // cookies:= GetJdCookies() - // for i := range cookies { - // cookie := cookies[i] - // if cookie.QQ { - // - // } - // cookie.Update(Priority,cookie.) - // } - // sender.handleJdCookies(func(ck *JdCookie) { - // sender.Reply(ck.Query()) - // }) - // return "已更新排行" - // }, - //}, - { - Command: []string{"赌一把"}, - Handle: func(sender *Sender) interface{} { + //{ + // Command: []string{"按许愿币更新排名"}, + // Admin: true, + // Handle: func(sender *Sender) interface{} { + // cookies:= GetJdCookies() + // for i := range cookies { + // cookie := cookies[i] + // if cookie.QQ { + // + // } + // cookie.Update(Priority,cookie.) + // } + // sender.handleJdCookies(func(ck *JdCookie) { + // sender.Reply(ck.Query()) + // }) + // return "已更新排行" + // }, + //}, + { + Command: []string{"赌一把"}, + Handle: func(sender *Sender) interface{} { - cost := Int(sender.JoinContens()) - if cost <= 0 || cost > 10000 { - cost = 1 - } - u := &User{} - if err := db.Where("number = ?", sender.UserID).First(u).Error; err != nil || u.Coin < cost { - return "互助值不足,先去打卡吧。" - } - baga := 0 - if u.Coin > 100000 { - baga = u.Coin - cost = u.Coin - } - r := time.Now().Nanosecond() % 10 - if r < 6 || baga > 0 { - sender.Reply(fmt.Sprintf("很遗憾你失去了%d枚互助值。", cost)) - cost = -cost + cost := Int(sender.JoinContens()) + if cost <= 0 || cost > 10000 { + cost = 1 + } + u := &User{} + if err := db.Where("number = ?", sender.UserID).First(u).Error; err != nil || u.Coin < cost { + return "互助值不足,先去打卡吧。" + } + baga := 0 + if u.Coin > 100000 { + baga = u.Coin + cost = u.Coin + } + r := time.Now().Nanosecond() % 10 + if r < 6 || baga > 0 { + sender.Reply(fmt.Sprintf("很遗憾你失去了%d枚互助值。", cost)) + cost = -cost + } else { + if r == 9 { + cost *= 2 + sender.Reply(fmt.Sprintf("恭喜你幸运暴击获得%d枚互助值,20秒后自动转入余额。", cost)) + time.Sleep(time.Second * 20) } else { - if r == 9 { - cost *= 2 - sender.Reply(fmt.Sprintf("恭喜你幸运暴击获得%d枚互助值,20秒后自动转入余额。", cost)) - time.Sleep(time.Second * 20) - } else { - sender.Reply(fmt.Sprintf("很幸运你获得%d枚互助值,10秒后自动转入余额。", cost)) - time.Sleep(time.Second * 10) - } - sender.Reply(fmt.Sprintf("%d枚互助值已到账。", cost)) + sender.Reply(fmt.Sprintf("很幸运你获得%d枚互助值,10秒后自动转入余额。", cost)) + time.Sleep(time.Second * 10) } - db.Model(u).Update("coin", gorm.Expr(fmt.Sprintf("coin + %d", cost))) - return nil - }, + sender.Reply(fmt.Sprintf("%d枚互助值已到账。", cost)) + } + db.Model(u).Update("coin", gorm.Expr(fmt.Sprintf("coin + %d", cost))) + return nil }, - */ + }, { Command: []string{"许愿", "愿望", "wish", "hope", "want"}, Handle: func(sender *Sender) interface{} {