@@ -48,7 +48,8 @@ const (
48
48
"- 取消在\" cron\" 的提醒\n " +
49
49
"- 列出所有提醒\n " +
50
50
"- 翻牌\n " +
51
- "- 设置欢迎语XXX\n " +
51
+ "- 设置欢迎语XXX(可加{at}在欢迎时@对方)\n " +
52
+ "- 测试欢迎语\n " +
52
53
"- [开启 | 关闭]入群验证"
53
54
)
54
55
@@ -210,6 +211,10 @@ func init() { // 插件主体
210
211
// 修改名片
211
212
engine .OnRegex (`^修改名片.*?(\d+).*?\s(.*)` , zero .OnlyGroup , zero .AdminPermission ).SetBlock (true ).
212
213
Handle (func (ctx * zero.Ctx ) {
214
+ if len (ctx .State ["regex_matched" ].([]string )[2 ]) > 60 {
215
+ ctx .SendChain (message .Text ("名字太长啦!" ))
216
+ return
217
+ }
213
218
ctx .SetGroupCard (
214
219
ctx .Event .GroupID ,
215
220
math .Str2Int64 (ctx .State ["regex_matched" ].([]string )[1 ]), // 被修改群名片的人
@@ -220,6 +225,10 @@ func init() { // 插件主体
220
225
// 修改头衔
221
226
engine .OnRegex (`^修改头衔.*?(\d+).*?\s(.*)` , zero .OnlyGroup , zero .AdminPermission ).SetBlock (true ).
222
227
Handle (func (ctx * zero.Ctx ) {
228
+ if len (ctx .State ["regex_matched" ].([]string )[1 ]) > 18 {
229
+ ctx .SendChain (message .Text ("头衔太长啦!" ))
230
+ return
231
+ }
223
232
ctx .SetGroupSpecialTitle (
224
233
ctx .Event .GroupID ,
225
234
math .Str2Int64 (ctx .State ["regex_matched" ].([]string )[1 ]), // 被修改群头衔的人
@@ -230,6 +239,10 @@ func init() { // 插件主体
230
239
// 申请头衔
231
240
engine .OnRegex (`^申请头衔(.*)` , zero .OnlyGroup ).SetBlock (true ).
232
241
Handle (func (ctx * zero.Ctx ) {
242
+ if len (ctx .State ["regex_matched" ].([]string )[1 ]) > 18 {
243
+ ctx .SendChain (message .Text ("头衔太长啦!" ))
244
+ return
245
+ }
233
246
ctx .SetGroupSpecialTitle (
234
247
ctx .Event .GroupID ,
235
248
ctx .Event .UserID , // 被修改群头衔的人
@@ -369,7 +382,7 @@ func init() { // 插件主体
369
382
var w welcome
370
383
err := db .Find ("welcome" , & w , "where gid = " + strconv .FormatInt (ctx .Event .GroupID , 10 ))
371
384
if err == nil {
372
- ctx .SendChain ( message .Text ( w .Msg ))
385
+ ctx .SendGroupMessage ( ctx . Event . GroupID , message .ParseMessageFromString ( strings . ReplaceAll ( w .Msg , "{at}" , "[CQ:at,qq=" + strconv . FormatInt ( ctx . Event . UserID , 10 ) + "]" ) ))
373
386
} else {
374
387
ctx .SendChain (message .Text ("欢迎~" ))
375
388
}
@@ -436,6 +449,17 @@ func init() { // 插件主体
436
449
ctx .SendChain (message .Text ("出错啦: " , err ))
437
450
}
438
451
})
452
+ // 测试欢迎语
453
+ engine .OnFullMatch ("测试欢迎语" , zero .OnlyGroup , zero .AdminPermission ).SetBlock (true ).
454
+ Handle (func (ctx * zero.Ctx ) {
455
+ var w welcome
456
+ err := db .Find ("welcome" , & w , "where gid = " + strconv .FormatInt (ctx .Event .GroupID , 10 ))
457
+ if err == nil {
458
+ ctx .SendGroupMessage (ctx .Event .GroupID , message .ParseMessageFromString (strings .ReplaceAll (w .Msg , "{at}" , "[CQ:at,qq=" + strconv .FormatInt (ctx .Event .UserID , 10 )+ "]" )))
459
+ } else {
460
+ ctx .SendChain (message .Text ("欢迎~" ))
461
+ }
462
+ })
439
463
// 入群后验证开关
440
464
engine .OnRegex (`^(.*)入群验证$` , zero .OnlyGroup , zero .AdminPermission ).SetBlock (true ).
441
465
Handle (func (ctx * zero.Ctx ) {
0 commit comments