From 1440f615d71b5efeec27b08d4a5c41dc24614e9f Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Wed, 23 Feb 2022 02:06:19 +0800 Subject: [PATCH 1/6] Update manager.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改 自定义欢迎语可带图 添加 修改名片/修改头衔/申请头衔字数限制 --- plugin_manager/manager.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index d2dc4afbad..5c322bdee4 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -210,6 +210,10 @@ func init() { // 插件主体 // 修改名片 engine.OnRegex(`^修改名片.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { + if len(ctx.State["regex_matched"].([]string)[2]) > 60 { + ctx.SendChain(message.Text("名字太长啦!")) + return + } ctx.SetGroupCard( ctx.Event.GroupID, math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人 @@ -220,6 +224,10 @@ func init() { // 插件主体 // 修改头衔 engine.OnRegex(`^修改头衔.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { + if len(ctx.State["regex_matched"].([]string)[1]) > 18 { + ctx.SendChain(message.Text("头衔太长啦!")) + return + } ctx.SetGroupSpecialTitle( ctx.Event.GroupID, math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人 @@ -230,6 +238,10 @@ func init() { // 插件主体 // 申请头衔 engine.OnRegex(`^申请头衔(.*)`, zero.OnlyGroup).SetBlock(true). Handle(func(ctx *zero.Ctx) { + if len(ctx.State["regex_matched"].([]string)[1]) > 18 { + ctx.SendChain(message.Text("头衔太长啦!")) + return + } ctx.SetGroupSpecialTitle( ctx.Event.GroupID, ctx.Event.UserID, // 被修改群头衔的人 @@ -369,7 +381,11 @@ func init() { // 插件主体 var w welcome err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) if err == nil { - ctx.SendChain(message.Text(w.Msg)) + WMsg := strings.ReplaceAll(w.Msg, "[", "[") + WMsg = strings.ReplaceAll(w.Msg, "]", "]") + WMsg = strings.ReplaceAll(w.Msg, "file=", "cache=") + WMsg = strings.ReplaceAll(w.Msg, "url=", "file=") + ctx.Send(WMsg) } else { ctx.SendChain(message.Text("欢迎~")) } From 15da5b90628dee616092f0f515e79b39b10d2c55 Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Wed, 23 Feb 2022 02:20:27 +0800 Subject: [PATCH 2/6] Update manager.go --- plugin_manager/manager.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index 5c322bdee4..48d89e9c64 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -48,7 +48,7 @@ const ( "- 取消在\"cron\"的提醒\n" + "- 列出所有提醒\n" + "- 翻牌\n" + - "- 设置欢迎语XXX\n" + + "- 设置欢迎语XXX(可加{at}在欢迎时@对方)\n" + "- [开启 | 关闭]入群验证" ) @@ -385,6 +385,7 @@ func init() { // 插件主体 WMsg = strings.ReplaceAll(w.Msg, "]", "]") WMsg = strings.ReplaceAll(w.Msg, "file=", "cache=") WMsg = strings.ReplaceAll(w.Msg, "url=", "file=") + WMsg = strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]") ctx.Send(WMsg) } else { ctx.SendChain(message.Text("欢迎~")) From ac89c62b2fbf584aa606190264717e0c08c9a8b9 Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Wed, 23 Feb 2022 02:29:51 +0800 Subject: [PATCH 3/6] Update manager.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 测试欢迎语 --- plugin_manager/manager.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index 48d89e9c64..fa00b495f7 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -49,6 +49,7 @@ const ( "- 列出所有提醒\n" + "- 翻牌\n" + "- 设置欢迎语XXX(可加{at}在欢迎时@对方)\n" + + "- 测试欢迎语\n" + "- [开启 | 关闭]入群验证" ) @@ -431,6 +432,16 @@ func init() { // 插件主体 } } }) + engine.OnFullMatch("测试欢迎语", zero.AdminPermission).SetBlock(true). + Handle(func(ctx *zero.Ctx) { + var w welcome + err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) + if err == nil { + ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(w.Msg)) + } else { + ctx.SendChain(message.Text("欢迎~")) + } + }) // 退群提醒 engine.OnNotice().SetBlock(false). Handle(func(ctx *zero.Ctx) { From ca199117efe38db6c309d0f609f705b32a7b7dc8 Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Wed, 23 Feb 2022 16:30:30 +0800 Subject: [PATCH 4/6] Update manager.go --- plugin_manager/manager.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index fa00b495f7..cdb8eac837 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -49,7 +49,6 @@ const ( "- 列出所有提醒\n" + "- 翻牌\n" + "- 设置欢迎语XXX(可加{at}在欢迎时@对方)\n" + - "- 测试欢迎语\n" + "- [开启 | 关闭]入群验证" ) @@ -382,12 +381,8 @@ func init() { // 插件主体 var w welcome err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) if err == nil { - WMsg := strings.ReplaceAll(w.Msg, "[", "[") - WMsg = strings.ReplaceAll(w.Msg, "]", "]") - WMsg = strings.ReplaceAll(w.Msg, "file=", "cache=") - WMsg = strings.ReplaceAll(w.Msg, "url=", "file=") - WMsg = strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]") - ctx.Send(WMsg) + wmsg := strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]") + ctx.Send(wmsg) } else { ctx.SendChain(message.Text("欢迎~")) } @@ -432,16 +427,6 @@ func init() { // 插件主体 } } }) - engine.OnFullMatch("测试欢迎语", zero.AdminPermission).SetBlock(true). - Handle(func(ctx *zero.Ctx) { - var w welcome - err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) - if err == nil { - ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(w.Msg)) - } else { - ctx.SendChain(message.Text("欢迎~")) - } - }) // 退群提醒 engine.OnNotice().SetBlock(false). Handle(func(ctx *zero.Ctx) { From d5f17e44f41ec9d7f20ae33542d35e21a234febf Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Wed, 23 Feb 2022 16:47:44 +0800 Subject: [PATCH 5/6] Update manager.go --- plugin_manager/manager.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index cdb8eac837..813264b45c 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -49,6 +49,7 @@ const ( "- 列出所有提醒\n" + "- 翻牌\n" + "- 设置欢迎语XXX(可加{at}在欢迎时@对方)\n" + + "- 测试欢迎语\n" + "- [开启 | 关闭]入群验证" ) @@ -381,8 +382,7 @@ func init() { // 插件主体 var w welcome err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) if err == nil { - wmsg := strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]") - ctx.Send(wmsg) + ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]"))) } else { ctx.SendChain(message.Text("欢迎~")) } @@ -427,6 +427,17 @@ func init() { // 插件主体 } } }) + // 测试欢迎语 + engine.OnFullMatch("测试欢迎语", zero.AdminPermission).SetBlock(true). + Handle(func(ctx *zero.Ctx) { + var w welcome + err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) + if err == nil { + ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]"))) + } else { + ctx.SendChain(message.Text("欢迎~")) + } + }) // 退群提醒 engine.OnNotice().SetBlock(false). Handle(func(ctx *zero.Ctx) { From b06d4ea8f56cf23d1bd8e369c6bc06739286e6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 23 Feb 2022 16:55:48 +0800 Subject: [PATCH 6/6] Update manager.go --- plugin_manager/manager.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index 813264b45c..49d3792c19 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -427,17 +427,6 @@ func init() { // 插件主体 } } }) - // 测试欢迎语 - engine.OnFullMatch("测试欢迎语", zero.AdminPermission).SetBlock(true). - Handle(func(ctx *zero.Ctx) { - var w welcome - err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) - if err == nil { - ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]"))) - } else { - ctx.SendChain(message.Text("欢迎~")) - } - }) // 退群提醒 engine.OnNotice().SetBlock(false). Handle(func(ctx *zero.Ctx) { @@ -460,6 +449,17 @@ func init() { // 插件主体 ctx.SendChain(message.Text("出错啦: ", err)) } }) + // 测试欢迎语 + engine.OnFullMatch("测试欢迎语", zero.OnlyGroup, zero.AdminPermission).SetBlock(true). + Handle(func(ctx *zero.Ctx) { + var w welcome + err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10)) + if err == nil { + ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]"))) + } else { + ctx.SendChain(message.Text("欢迎~")) + } + }) // 入群后验证开关 engine.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) {