From a29bbec1daedd10a825b989636b37782bacd2c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:52:58 +0800 Subject: [PATCH 01/12] Update main.go --- plugin/niuniu/main.go | 110 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 95 insertions(+), 15 deletions(-) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index 8d75b9d594..56312ad219 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -3,19 +3,26 @@ package niuniu import ( "fmt" - "math/rand" - "strconv" - "strings" - "time" - + "github.com/FloatTech/AnimeAPI/wallet" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/extension/rate" "github.com/wdvxdr1123/ZeroBot/message" + "math/rand" + "strconv" + "strings" + "sync" + "time" ) +type lastLength struct { + TimeLimit time.Time + Count int + Length float64 +} + var ( en = control.AutoRegister(&ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, @@ -31,9 +38,52 @@ var ( }) dajiaoLimiter = rate.NewManager[string](time.Second*90, 1) jjLimiter = rate.NewManager[string](time.Second*150, 1) + jjCount = make(map[string]lastLength) + lock sync.RWMutex ) func init() { + en.OnFullMatch("赎牛牛", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) { + gid := ctx.Event.GroupID + uid := ctx.Event.UserID + last, ok := jjCount[fmt.Sprintf("%d_%d", gid, uid)] + if !ok { + ctx.SendChain(message.Text("你还没有被厥呢")) + return + } + if time.Now().Sub(last.TimeLimit) > time.Minute*30 { + ctx.SendChain(message.Text("时间已经过期了,牛牛已被收回!")) + lock.Lock() + delete(jjCount, fmt.Sprintf("%d_%d", gid, uid)) + lock.Unlock() + return + } + if last.Count < 6 { + ctx.SendChain(message.Text("你还没有被厥够6次呢,不能赎牛牛")) + return + } + money := wallet.GetWalletOf(uid) + if money < 100 { + ctx.SendChain(message.Text("赎牛牛需要100ATRI币,快去赚钱吧")) + return + } + err := wallet.InsertWalletOf(uid, -100) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + u := &userInfo{ + UID: uid, + Length: last.Length, + UserCount: 0, + } + err = db.insertniuniu(u, gid) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.At(uid), message.Text(fmt.Sprintf("恭喜你!成功赎回牛牛,当前长度为:%.2f", last.Length))) + }) en.OnFullMatch("牛子长度排行", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) { gid := ctx.Event.GroupID niuniuList, err := db.readAllTable(gid) @@ -47,8 +97,8 @@ func init() { return } var messages strings.Builder - messages.WriteString("牛子长度排行\n") - for i, user := range niuniuList.sort(true) { + messages.WriteString("牛子长度排行榜\n") + for i, user := range m.sort(true) { messages.WriteString(fmt.Sprintf("第%d名 id:%s 长度:%.2fcm\n", i+1, ctx.CardOrNickName(user.UID), user.Length)) } @@ -71,7 +121,7 @@ func init() { } var messages strings.Builder messages.WriteString("牛牛深度排行榜\n") - for i, user := range niuniuList.sort(false) { + for i, user := range m.sort(false) { messages.WriteString(fmt.Sprintf("第%d名 id:%s 长度:%.2fcm\n", i+1, ctx.CardOrNickName(user.UID), user.Length)) } @@ -130,8 +180,9 @@ func init() { } messages, f := generateRandomStingTwo(niuniu) u := userInfo{ - UID: uid, - Length: f, + UID: uid, + Length: f, + UserCount: 0, } ctx.SendChain(message.Text(messages)) if err = db.insertniuniu(&u, gid); err != nil { @@ -146,14 +197,14 @@ func init() { ctx.SendChain(message.Text("你已经注册过了")) return } - // 获取初始长度 + //获取初始长度 long := db.randLength() u := userInfo{ UID: uid, Length: long, UserCount: 0, } - // 添加数据进入表 + //添加数据进入表 err := db.insertniuniu(&u, gid) if err != nil { err = db.createGIDTable(gid) @@ -210,17 +261,46 @@ func init() { return } fencingResult, f, f1 := fencing(myniuniu, adduserniuniu) - err = db.insertniuniu(&userInfo{UID: uid, Length: f}, gid) + err = db.insertniuniu(&userInfo{UID: uid, Length: f, UserCount: 0}, gid) if err != nil { ctx.SendChain(message.Text("ERROR:", err)) return } - err = db.insertniuniu(&userInfo{UID: adduser, Length: f1}, gid) + err = db.insertniuniu(&userInfo{UID: adduser, Length: f1, UserCount: 0}, gid) if err != nil { ctx.SendChain(message.Text("ERROR:", err)) return } - ctx.SendChain(message.At(uid), message.Text(fencingResult)) + ctx.SendChain(message.At(uid), message.Text(" ", fencingResult)) + lock.RLock() + count, ok := jjCount[fmt.Sprintf("%d_%d", gid, adduser)] + lock.RUnlock() + var c lastLength + if !ok { + c = lastLength{ + TimeLimit: time.Now(), + Count: 1, + Length: adduserniuniu, + } + } else { + c = lastLength{ + TimeLimit: c.TimeLimit, + Count: count.Count + 1, + Length: count.Length, + } + } + lock.Lock() + jjCount[fmt.Sprintf("%d_%d", gid, adduser)] = c + lock.Unlock() + if c.Count > 5 { + ctx.SendChain(message.Text(fmt.Sprintf("你们太厉害了,对方已经被你们打了%d次了,你们可以继续找他🤺", c.Count))) + id := ctx.SendPrivateMessage(adduser, + message.Text(fmt.Sprintf("你在%d群里已经被厥冒烟了,快去群里赎回你原本的牛牛!\n发送:`赎牛牛`即可!", gid))) + if id == 0 { + ctx.SendChain(message.At(adduser), message.Text("快发送`赎牛牛`来赎回你原本的牛牛!")) + } + } + }) en.OnFullMatch("注销牛牛", getdb, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { uid := ctx.Event.UserID From c22079e38b7dba78812e2a696d298cf51163c07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:53:18 +0800 Subject: [PATCH 02/12] Update model.go --- plugin/niuniu/model.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugin/niuniu/model.go b/plugin/niuniu/model.go index 153335e01b..44152a1366 100644 --- a/plugin/niuniu/model.go +++ b/plugin/niuniu/model.go @@ -2,16 +2,15 @@ package niuniu import ( + fcext "github.com/FloatTech/floatbox/ctxext" + sql "github.com/FloatTech/sqlite" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" "math/rand" "sort" "strconv" "sync" "time" - - fcext "github.com/FloatTech/floatbox/ctxext" - sql "github.com/FloatTech/sqlite" - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/message" ) type model struct { @@ -24,6 +23,7 @@ type userInfo struct { Length float64 UserCount int } + type users []*userInfo var ( @@ -39,21 +39,21 @@ var ( }) ) -func (m users) positive() []userInfo { - var m1 []userInfo +func (m users) positive() users { + var m1 []*userInfo for _, i2 := range m { if i2.Length > 0 { - m1 = append(m1, *i2) + m1 = append(m1, i2) } } return m1 } -func (m users) negative() []userInfo { - var m1 []userInfo +func (m users) negative() users { + var m1 []*userInfo for _, i2 := range m { if i2.Length <= 0 { - m1 = append(m1, *i2) + m1 = append(m1, i2) } } return m1 @@ -61,7 +61,7 @@ func (m users) negative() []userInfo { func (m users) sort(isDesc bool) users { t := func(i, j int) bool { - return m[i].UserCount < m[j].UserCount + return m[i].Length < m[j].Length } if isDesc { t = func(i, j int) bool { From 78e9d1aa0966fb54f798cbf35af04e09e785a488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:53:41 +0800 Subject: [PATCH 03/12] Update utils.go --- plugin/niuniu/utils.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugin/niuniu/utils.go b/plugin/niuniu/utils.go index 85a7ff8989..96d462107d 100644 --- a/plugin/niuniu/utils.go +++ b/plugin/niuniu/utils.go @@ -107,27 +107,26 @@ func fencing(myLength, oppoLength float64) (string, float64, float64) { switch { case oppoLength <= -100 && myLength > 0 && 10 < probability && probability <= 20: oppoLength *= 0.85 - change := -math.Min(math.Abs(lossLimit*myLength), math.Abs(1.5*myLength)) + change := math.Min(math.Abs(lossLimit*myLength), math.Abs(1.5*myLength)) myLength += change - return fmt.Sprintf("对方身为魅魔诱惑了你,你同化成魅魔!当前长度%.2fcm!", myLength), myLength, oppoLength + return fmt.Sprintf("对方身为魅魔诱惑了你,你同化成魅魔!当前长度%.2fcm!", -myLength), -myLength, oppoLength case oppoLength >= 100 && myLength > 0 && 10 < probability && probability <= 20: oppoLength *= 0.85 - change := -math.Min(math.Abs(devourLimit*myLength), math.Abs(1.5*myLength)) + change := math.Min(math.Abs(devourLimit*myLength), math.Abs(1.5*myLength)) myLength += change - return fmt.Sprintf("对方以牛头人的荣誉摧毁了你的牛牛!当前长度%.2fcm!", myLength), myLength, oppoLength + return fmt.Sprintf("对方以牛头人的荣誉摧毁了你的牛牛!当前长度%.2fcm!", myLength-oppoLength), myLength - oppoLength, oppoLength case myLength <= -100 && oppoLength > 0 && 10 < probability && probability <= 20: myLength *= 0.85 - change := math.Min(math.Abs(lossLimit*oppoLength), math.Abs(1.5*oppoLength)) + change := oppoLength * 0.7 oppoLength -= change + myLength -= change return fmt.Sprintf("你身为魅魔诱惑了对方,吞噬了对方部分长度!当前长度%.2fcm!", myLength), myLength, oppoLength case myLength >= 100 && oppoLength > 0 && 10 < probability && probability <= 20: myLength *= 0.85 - change := math.Min(math.Abs(devourLimit*oppoLength), math.Abs(1.5*oppoLength)) - oppoLength += change + oppoLength -= 0.8 * myLength return fmt.Sprintf("你以牛头人的荣誉摧毁了对方的牛牛!当前长度%.2fcm!", myLength), myLength, oppoLength - default: return determineResultBySkill(myLength, oppoLength) } @@ -166,6 +165,7 @@ func applySkill(myLength, oppoLength float64, increaseLength1 bool) (string, flo return fmt.Sprintf("哦吼!?你的牛牛在长大欸!长大了%.2fcm!", reduce), myLength, oppoLength } return fmt.Sprintf("你以绝对的长度让对方屈服了呢!你的长度增加%.2fcm,当前长度%.2fcm!", reduce, myLength), myLength, oppoLength + } myLength -= reduce oppoLength += 0.8 * reduce @@ -173,6 +173,7 @@ func applySkill(myLength, oppoLength float64, increaseLength1 bool) (string, flo return fmt.Sprintf("哦吼!?看来你的牛牛因为击剑而凹进去了呢🤣🤣🤣!凹进去了%.2fcm!", reduce), myLength, oppoLength } return fmt.Sprintf("对方以绝对的长度让你屈服了呢!你的长度减少%.2fcm,当前长度%.2fcm!", reduce, myLength), myLength, oppoLength + } // fence From 4f9c58f55e158b64d940f4947d524fe89e24e276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:54:28 +0800 Subject: [PATCH 04/12] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7782f407b8..d3f5fbc0a0 100644 --- a/README.md +++ b/README.md @@ -1037,6 +1037,8 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] jj[@xxx] +- [x] 赎牛牛 + - [x] 注册牛牛 - [x] 注销牛牛 From 66afee9f044e411fe5afcf49ba55afb03a5d6bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:57:33 +0800 Subject: [PATCH 05/12] Update main.go --- plugin/niuniu/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index 56312ad219..183b98cea1 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -82,7 +82,7 @@ func init() { ctx.SendChain(message.Text("ERROR:", err)) return } - ctx.SendChain(message.At(uid), message.Text(fmt.Sprintf("恭喜你!成功赎回牛牛,当前长度为:%.2f", last.Length))) + ctx.SendChain(message.At(uid), message.Text(fmt.Sprintf("恭喜你!成功赎回牛牛,当前长度为:%.2fcm", last.Length))) }) en.OnFullMatch("牛子长度排行", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) { gid := ctx.Event.GroupID From be5ec000f92f795b17410d8b9c98f12a0209f7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:57:17 +0800 Subject: [PATCH 06/12] Update main.go --- plugin/niuniu/main.go | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index 183b98cea1..f5dd9e1f25 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -4,17 +4,18 @@ package niuniu import ( "fmt" "github.com/FloatTech/AnimeAPI/wallet" + "math/rand" + "strconv" + "strings" + "sync" + "time" + ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/extension/rate" "github.com/wdvxdr1123/ZeroBot/message" - "math/rand" - "strconv" - "strings" - "sync" - "time" ) type lastLength struct { @@ -38,24 +39,22 @@ var ( }) dajiaoLimiter = rate.NewManager[string](time.Second*90, 1) jjLimiter = rate.NewManager[string](time.Second*150, 1) - jjCount = make(map[string]lastLength) - lock sync.RWMutex + jjCount = sync.Map{} ) func init() { en.OnFullMatch("赎牛牛", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) { gid := ctx.Event.GroupID uid := ctx.Event.UserID - last, ok := jjCount[fmt.Sprintf("%d_%d", gid, uid)] + l, ok := jjCount.Load(fmt.Sprintf("%d_%d", gid, uid)) + last := l.(lastLength) if !ok { ctx.SendChain(message.Text("你还没有被厥呢")) return } - if time.Now().Sub(last.TimeLimit) > time.Minute*30 { + if time.Since(last.TimeLimit) > time.Minute*30 { ctx.SendChain(message.Text("时间已经过期了,牛牛已被收回!")) - lock.Lock() - delete(jjCount, fmt.Sprintf("%d_%d", gid, uid)) - lock.Unlock() + jjCount.Delete(fmt.Sprintf("%d_%d", gid, uid)) return } if last.Count < 6 { @@ -180,9 +179,8 @@ func init() { } messages, f := generateRandomStingTwo(niuniu) u := userInfo{ - UID: uid, - Length: f, - UserCount: 0, + UID: uid, + Length: f, } ctx.SendChain(message.Text(messages)) if err = db.insertniuniu(&u, gid); err != nil { @@ -197,14 +195,14 @@ func init() { ctx.SendChain(message.Text("你已经注册过了")) return } - //获取初始长度 + // 获取初始长度 long := db.randLength() u := userInfo{ UID: uid, Length: long, UserCount: 0, } - //添加数据进入表 + // 添加数据进入表 err := db.insertniuniu(&u, gid) if err != nil { err = db.createGIDTable(gid) @@ -272,9 +270,9 @@ func init() { return } ctx.SendChain(message.At(uid), message.Text(" ", fencingResult)) - lock.RLock() - count, ok := jjCount[fmt.Sprintf("%d_%d", gid, adduser)] - lock.RUnlock() + j := fmt.Sprintf("%d_%d", gid, adduser) + cou, ok := jjCount.Load(j) + count := cou.(lastLength) var c lastLength if !ok { c = lastLength{ @@ -289,9 +287,7 @@ func init() { Length: count.Length, } } - lock.Lock() - jjCount[fmt.Sprintf("%d_%d", gid, adduser)] = c - lock.Unlock() + jjCount.Store(j, c) if c.Count > 5 { ctx.SendChain(message.Text(fmt.Sprintf("你们太厉害了,对方已经被你们打了%d次了,你们可以继续找他🤺", c.Count))) id := ctx.SendPrivateMessage(adduser, From 22e2447720010a049948b85abf09c169d4cdd4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:59:09 +0800 Subject: [PATCH 07/12] Update model.go --- plugin/niuniu/model.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/niuniu/model.go b/plugin/niuniu/model.go index 44152a1366..e9ce5a1b45 100644 --- a/plugin/niuniu/model.go +++ b/plugin/niuniu/model.go @@ -2,15 +2,16 @@ package niuniu import ( - fcext "github.com/FloatTech/floatbox/ctxext" - sql "github.com/FloatTech/sqlite" - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/message" "math/rand" "sort" "strconv" "sync" "time" + + fcext "github.com/FloatTech/floatbox/ctxext" + sql "github.com/FloatTech/sqlite" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" ) type model struct { From 05a28c9630d15cf684dfd2b33c212f2565ba4fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Mon, 2 Sep 2024 13:34:34 +0800 Subject: [PATCH 08/12] Update main.go --- plugin/niuniu/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index f5dd9e1f25..6ece9b500d 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -81,6 +81,7 @@ func init() { ctx.SendChain(message.Text("ERROR:", err)) return } + jjCount.Delete(fmt.Sprintf("%d_%d", gid, uid)) ctx.SendChain(message.At(uid), message.Text(fmt.Sprintf("恭喜你!成功赎回牛牛,当前长度为:%.2fcm", last.Length))) }) en.OnFullMatch("牛子长度排行", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) { From fa0c9d8eb4843a3cf67bcfd96e550c2d8117921a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:02:47 +0800 Subject: [PATCH 09/12] Update main.go --- plugin/niuniu/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index 6ece9b500d..f2920070a0 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -291,10 +291,13 @@ func init() { jjCount.Store(j, c) if c.Count > 5 { ctx.SendChain(message.Text(fmt.Sprintf("你们太厉害了,对方已经被你们打了%d次了,你们可以继续找他🤺", c.Count))) - id := ctx.SendPrivateMessage(adduser, + // 保证只发送一次 + if c. Count < 7 { + id := ctx.SendPrivateMessage(adduser, message.Text(fmt.Sprintf("你在%d群里已经被厥冒烟了,快去群里赎回你原本的牛牛!\n发送:`赎牛牛`即可!", gid))) - if id == 0 { + if id == 0 { ctx.SendChain(message.At(adduser), message.Text("快发送`赎牛牛`来赎回你原本的牛牛!")) + } } } From 83ee8b6334b39a83ede075de6d216bfc1e2fccbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:47:22 +0800 Subject: [PATCH 10/12] Update main.go --- plugin/niuniu/main.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index f2920070a0..4b47b03b21 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -3,16 +3,16 @@ package niuniu import ( "fmt" - "github.com/FloatTech/AnimeAPI/wallet" "math/rand" "strconv" "strings" - "sync" "time" + "github.com/FloatTech/AnimeAPI/wallet" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" + "github.com/RomiChan/syncx" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/extension/rate" "github.com/wdvxdr1123/ZeroBot/message" @@ -39,15 +39,14 @@ var ( }) dajiaoLimiter = rate.NewManager[string](time.Second*90, 1) jjLimiter = rate.NewManager[string](time.Second*150, 1) - jjCount = sync.Map{} + jjCount = syncx.Map[string, *lastLength]{} ) func init() { en.OnFullMatch("赎牛牛", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) { gid := ctx.Event.GroupID uid := ctx.Event.UserID - l, ok := jjCount.Load(fmt.Sprintf("%d_%d", gid, uid)) - last := l.(lastLength) + last, ok := jjCount.Load(fmt.Sprintf("%d_%d", gid, uid)) if !ok { ctx.SendChain(message.Text("你还没有被厥呢")) return @@ -272,8 +271,7 @@ func init() { } ctx.SendChain(message.At(uid), message.Text(" ", fencingResult)) j := fmt.Sprintf("%d_%d", gid, adduser) - cou, ok := jjCount.Load(j) - count := cou.(lastLength) + count, ok := jjCount.Load(j) var c lastLength if !ok { c = lastLength{ @@ -288,19 +286,18 @@ func init() { Length: count.Length, } } - jjCount.Store(j, c) + jjCount.Store(j, &c) if c.Count > 5 { - ctx.SendChain(message.Text(fmt.Sprintf("你们太厉害了,对方已经被你们打了%d次了,你们可以继续找他🤺", c.Count))) - // 保证只发送一次 - if c. Count < 7 { + ctx.SendChain(message.Text(randomChoice([]string{fmt.Sprintf("你们太厉害了,对方已经被你们打了%d次了,你们可以继续找他🤺", c.Count), + fmt.Sprintf("你们不要再找ta🤺啦!")}))) + if c.Count < 7 { id := ctx.SendPrivateMessage(adduser, - message.Text(fmt.Sprintf("你在%d群里已经被厥冒烟了,快去群里赎回你原本的牛牛!\n发送:`赎牛牛`即可!", gid))) + message.Text(fmt.Sprintf("你在%d群里已经被厥冒烟了,快去群里赎回你原本的牛牛!\n发送:`赎牛牛`即可!", gid))) if id == 0 { - ctx.SendChain(message.At(adduser), message.Text("快发送`赎牛牛`来赎回你原本的牛牛!")) + ctx.SendChain(message.At(adduser), message.Text("快发送`赎牛牛`来赎回你原本的牛牛!")) } } } - }) en.OnFullMatch("注销牛牛", getdb, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { uid := ctx.Event.UserID From dd676ad577298fc35c65e2a6898d56c83d415365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:09:15 +0800 Subject: [PATCH 11/12] Update main.go --- plugin/niuniu/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index 4b47b03b21..8d1fd54c6b 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -289,7 +289,7 @@ func init() { jjCount.Store(j, &c) if c.Count > 5 { ctx.SendChain(message.Text(randomChoice([]string{fmt.Sprintf("你们太厉害了,对方已经被你们打了%d次了,你们可以继续找他🤺", c.Count), - fmt.Sprintf("你们不要再找ta🤺啦!")}))) + "你们不要再找ta🤺啦!"}))) if c.Count < 7 { id := ctx.SendPrivateMessage(adduser, message.Text(fmt.Sprintf("你在%d群里已经被厥冒烟了,快去群里赎回你原本的牛牛!\n发送:`赎牛牛`即可!", gid))) From 85ca08afa7486364ce9383733171f9ddf69114a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87=E5=AE=87?= <158024940+xyy0411@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:55:50 +0800 Subject: [PATCH 12/12] Update main.go --- plugin/niuniu/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/niuniu/main.go b/plugin/niuniu/main.go index 8d1fd54c6b..53f82865be 100644 --- a/plugin/niuniu/main.go +++ b/plugin/niuniu/main.go @@ -29,6 +29,7 @@ var ( DisableOnDefault: false, Brief: "牛牛大作战", Help: "- 打胶\n" + + "- 赎牛牛 (cd:30分钟)\n" + "- 注册牛牛\n" + "- 注销牛牛\n" + "- 查看我的牛牛\n" +