@@ -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 {
@@ -81,7 +81,7 @@ func init() {
8181 for {
8282 select {
8383 case <- timer .C :
84- ctx .SendChain (message .At (uid ), message .Text (" 超时, 已自动取消" ))
84+ ctx .SendChain (message .At (uid ), message .Text (" 超时, 已自动取消" ))
8585 return
8686 case r := <- recv :
8787 answer = r .Event .Message .String ()
@@ -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 ))
@@ -109,6 +108,12 @@ func init() {
109108 ctx .SendChain (message .Text ("ERROR:" , err ))
110109 return
111110 }
111+ // 数据库操作成功之后,及时删除残留的缓存
112+ key := fmt .Sprintf ("%d_%d" , gid , uid )
113+ _ , ok := jjCount .Load (key )
114+ if ok {
115+ jjCount .Delete (key )
116+ }
112117 ctx .SendChain (message .Reply (ctx .Event .MessageID ), message .Text (sell ))
113118 })
114119 en .OnFullMatch ("牛牛背包" , zero .OnlyGroup ).SetBlock (true ).Handle (func (ctx * zero.Ctx ) {
@@ -145,7 +150,7 @@ func init() {
145150
146151 var messages message.Message
147152 messages = append (messages , ctxext .FakeSenderForwardNode (ctx , message .Text ("牛牛商店当前售卖的物品如下" )))
148- for id := range propMap {
153+ for id := 1 ; id <= len ( propMap ); id ++ {
149154 product := propMap [id ]
150155 productInfo := fmt .Sprintf ("商品%d\n 商品名: %s\n 商品价格: %dATRI币\n 商品作用域: %s\n 商品描述: %s\n 使用次数:%d" ,
151156 id , product .name , product .cost , product .scope , product .description , product .count )
@@ -165,7 +170,7 @@ func init() {
165170 for {
166171 select {
167172 case <- timer .C :
168- ctx .SendChain (message .At (uid ), message .Text (" 超时, 已自动取消" ))
173+ ctx .SendChain (message .At (uid ), message .Text (" 超时, 已自动取消" ))
169174 return
170175 case r := <- recv :
171176 answer = r .Event .Message .String ()
@@ -196,16 +201,16 @@ func init() {
196201 }
197202
198203 if time .Since (last .TimeLimit ) > time .Hour {
199- ctx .SendChain (message .Text ("时间已经过期了, 牛牛已被收回!" ))
204+ ctx .SendChain (message .Text ("时间已经过期了, 牛牛已被收回!" ))
200205 jjCount .Delete (fmt .Sprintf ("%d_%d" , gid , uid ))
201206 return
202207 }
203208
204209 if last .Count < 4 {
205- ctx .SendChain (message .Text ("你还没有被厥够4次呢, 不能赎牛牛" ))
210+ ctx .SendChain (message .Text ("你还没有被厥够4次呢, 不能赎牛牛" ))
206211 return
207212 }
208- ctx .SendChain (message .Text ("再次确认一下哦, 这次赎牛牛,牛牛长度将会变成" , last .Length , "cm\n 还需要嘛【是|否】" ))
213+ ctx .SendChain (message .Text ("再次确认一下哦, 这次赎牛牛,牛牛长度将会变成" , last .Length , "cm\n 还需要嘛【是|否】" ))
209214 recv , cancel := zero .NewFutureEvent ("message" , 999 , false , zero .CheckUser (uid ), zero .CheckGroup (gid ), zero .RegexRule (`^(是|否)$` )).Repeat ()
210215 defer cancel ()
211216 timer := time .NewTimer (2 * time .Minute )
@@ -222,11 +227,11 @@ func init() {
222227 return
223228 }
224229
225- if err := niu .Redeem (gid , uid , last .Length ); err = = nil {
230+ if err := niu .Redeem (gid , uid , last .Length ); err ! = nil {
226231 ctx .SendChain (message .Text ("ERROR:" , err ))
227232 return
228233 }
229-
234+ // 成功赎回,删除残留的缓存。
230235 jjCount .Delete (fmt .Sprintf ("%d_%d" , gid , uid ))
231236
232237 ctx .SendChain (message .At (uid ), message .Text (fmt .Sprintf ("恭喜你!成功赎回牛牛,当前长度为:%.2fcm" , last .Length )))
@@ -342,8 +347,9 @@ func init() {
342347 j := fmt .Sprintf ("%d_%d" , gid , adduser )
343348 count , ok := jjCount .Load (j )
344349 var c lastLength
345- // 按照最后一次被jj时的时间计算 ,超过60分钟则重置
350+ // 按照最后一次被 jj 时的时间计算 ,超过60分钟则重置
346351 if ! ok {
352+ // 第一次被 jj
347353 c = lastLength {
348354 TimeLimit : time .Now (),
349355 Count : 1 ,
@@ -355,6 +361,7 @@ func init() {
355361 Count : count .Count + 1 ,
356362 Length : count .Length ,
357363 }
364+ // 超时了,重置
358365 if time .Since (c .TimeLimit ) > time .Hour {
359366 c = lastLength {
360367 TimeLimit : time .Now (),
@@ -372,6 +379,9 @@ func init() {
372379 )))
373380
374381 if c .Count >= 4 {
382+ if c .Count == 6 {
383+ return
384+ }
375385 id := ctx .SendPrivateMessage (adduser ,
376386 message .Text (fmt .Sprintf ("你在%d群里已经被厥冒烟了,快去群里赎回你原本的牛牛!\n 发送:`赎牛牛`即可!" , gid )))
377387 if id == 0 {
@@ -386,7 +396,7 @@ func init() {
386396 key := fmt .Sprintf ("%d_%d" , gid , uid )
387397 data , ok := register .Load (key )
388398 switch {
389- case ! ok || time .Since (data .TimeLimit ) > time .Hour * 12 :
399+ case ! ok || time .Since (data .TimeLimit ) > time .Hour * 24 :
390400 data = & lastLength {
391401 TimeLimit : time .Now (),
392402 Count : 1 ,
@@ -396,6 +406,7 @@ func init() {
396406 ctx .SendChain (message .Text ("你的钱不够你注销牛牛了,这次注销需要" , data .Count * 50 , wallet .GetWalletName ()))
397407 return
398408 }
409+ data .Count ++
399410 }
400411 register .Store (key , data )
401412 msg , err := niu .Cancel (gid , uid )
0 commit comments