diff --git a/plugin/chips/insurance.go b/plugin/chips/insurance.go new file mode 100644 index 0000000..788042e --- /dev/null +++ b/plugin/chips/insurance.go @@ -0,0 +1,22 @@ +package chips + +import ( + redisrepo "amor/repository/redisRepo" + "strings" + + "github.com/spf13/cast" + zero "github.com/wdvxdr1123/ZeroBot" +) + +func Insurance(ctx *zero.Ctx) { + msg := strings.Split(ctx.Event.Message.String(), " ") + if len(msg) != 2 { + ctx.Send("命令格式错误") + return + } + userID := ctx.Event.UserID + chips := cast.ToInt64(msg[1]) + + redisrepo.AddUserBalance(userID, chips) + ctx.Send("索赔成功") +} diff --git a/router/router.go b/router/router.go index f469393..1e81dbd 100644 --- a/router/router.go +++ b/router/router.go @@ -20,6 +20,9 @@ func Router() { // 群内筹码排名 zero.OnFullMatch("rank").Handle(chips.Rank) + // 赔钱 + zero.OnCommand("我不玩了还我钱").Handle(chips.Insurance) + // 帮助 zero.OnFullMatch("help").Handle(plugin.Help)