🔒 防止昵称CQ码注入

This commit is contained in:
Yiwen-Chan 2021-04-21 13:10:14 +08:00
parent 4252548f4c
commit 117225fb72

View File

@ -5,27 +5,30 @@ import (
"strings" "strings"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
) )
func init() { // 插件主体 func init() { // 插件主体
// 菜单 // 菜单
zero.OnFullMatch("群管系统", zero.AdminPermission).SetBlock(true).FirstPriority(). zero.OnFullMatch("群管系统", zero.AdminPermission).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
ctx.Send(`====群管==== ctx.SendChain(message.Text(
- 禁言@QQ 1分钟 "====群管====", "\n",
- 解除禁言 @QQ "- 禁言@QQ 1分钟", "\n",
- 我要自闭 1分钟 "- 解除禁言 @QQ", "\n",
- 开启全员禁言 "- 我要自闭 1分钟", "\n",
- 解除全员禁言 "- 开启全员禁言", "\n",
- 升为管理@QQ "- 解除全员禁言", "\n",
- 取消管理@QQ "- 升为管理@QQ", "\n",
- 修改名片@QQ XXX "- 取消管理@QQ", "\n",
- 修改头衔@QQ XXX "- 修改名片@QQ XXX", "\n",
- 申请头衔 XXX "- 修改头衔@QQ XXX", "\n",
- 踢出群聊@QQ "- 申请头衔 XXX", "\n",
- 退出群聊 1234 "- 踢出群聊@QQ", "\n",
- 群聊转发 1234 XXX "- 退出群聊 1234", "\n",
- 私聊转发 0000 XXX`) "- 群聊转发 1234 XXX", "\n",
"- 私聊转发 0000 XXX",
))
return return
}) })
// 升为管理 // 升为管理
@ -41,7 +44,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq strToInt(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq
false, false,
).Get("nickname").Str ).Get("nickname").Str
ctx.Send(nickname + " 升为了管理~") ctx.SendChain(message.Text(nickname + " 升为了管理~"))
return return
}) })
// 取消管理 // 取消管理
@ -57,7 +60,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq strToInt(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq
false, false,
).Get("nickname").Str ).Get("nickname").Str
ctx.Send("残念~ " + nickname + " 暂时失去了管理员的资格") ctx.SendChain(message.Text("残念~ " + nickname + " 暂时失去了管理员的资格"))
return return
}) })
// 踢出群聊 // 踢出群聊
@ -73,7 +76,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq strToInt(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq
false, false,
).Get("nickname").Str ).Get("nickname").Str
ctx.Send("残念~ " + nickname + " 被放逐") ctx.SendChain(message.Text("残念~ " + nickname + " 被放逐"))
return return
}) })
// 退出群聊 // 退出群聊
@ -92,7 +95,7 @@ func init() { // 插件主体
ctx.Event.GroupID, ctx.Event.GroupID,
true, true,
) )
ctx.Send("全员自闭开始~") ctx.SendChain(message.Text("全员自闭开始~"))
return return
}) })
// 解除全员禁言 // 解除全员禁言
@ -102,7 +105,7 @@ func init() { // 插件主体
ctx.Event.GroupID, ctx.Event.GroupID,
false, false,
) )
ctx.Send("全员自闭结束~") ctx.SendChain(message.Text("全员自闭结束~"))
return return
}) })
// 禁言 // 禁言
@ -127,7 +130,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 要禁言的人的qq strToInt(ctx.State["regex_matched"].([]string)[1]), // 要禁言的人的qq
duration*60, // 要禁言的时间(分钟) duration*60, // 要禁言的时间(分钟)
) )
ctx.Send("小黑屋收留成功~") ctx.SendChain(message.Text("小黑屋收留成功~"))
return return
}) })
// 解除禁言 // 解除禁言
@ -138,7 +141,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 要解除禁言的人的qq strToInt(ctx.State["regex_matched"].([]string)[1]), // 要解除禁言的人的qq
0, 0,
) )
ctx.Send("小黑屋释放成功~") ctx.SendChain(message.Text("小黑屋释放成功~"))
return return
}) })
// 自闭禁言 // 自闭禁言
@ -163,7 +166,7 @@ func init() { // 插件主体
ctx.Event.UserID, ctx.Event.UserID,
duration*60, // 要自闭的时间(分钟) duration*60, // 要自闭的时间(分钟)
) )
ctx.Send("那我就不手下留情了~") ctx.SendChain(message.Text("那我就不手下留情了~"))
return return
}) })
// 修改名片 // 修改名片
@ -174,7 +177,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人 strToInt(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人
ctx.State["regex_matched"].([]string)[2], // 修改成的群名片 ctx.State["regex_matched"].([]string)[2], // 修改成的群名片
) )
ctx.Send("嗯!已经修改了") ctx.SendChain(message.Text("嗯!已经修改了"))
return return
}) })
// 修改头衔 // 修改头衔
@ -185,7 +188,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人 strToInt(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人
ctx.State["regex_matched"].([]string)[2], // 修改成的群头衔 ctx.State["regex_matched"].([]string)[2], // 修改成的群头衔
) )
ctx.Send("嗯!已经修改了") ctx.SendChain(message.Text("嗯!已经修改了"))
return return
}) })
// 申请头衔 // 申请头衔
@ -196,7 +199,7 @@ func init() { // 插件主体
ctx.Event.UserID, // 被修改群头衔的人 ctx.Event.UserID, // 被修改群头衔的人
ctx.State["regex_matched"].([]string)[1], // 修改成的群头衔 ctx.State["regex_matched"].([]string)[1], // 修改成的群头衔
) )
ctx.Send("嗯!不错的头衔呢~") ctx.SendChain(message.Text("嗯!不错的头衔呢~"))
return return
}) })
// 群聊转发 // 群聊转发
@ -210,7 +213,7 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 需要发送的群 strToInt(ctx.State["regex_matched"].([]string)[1]), // 需要发送的群
content, // 需要发送的信息 content, // 需要发送的信息
) )
ctx.Send("📧 --> " + ctx.State["regex_matched"].([]string)[1]) ctx.SendChain(message.Text("📧 --> " + ctx.State["regex_matched"].([]string)[1]))
return return
}) })
// 私聊转发 // 私聊转发
@ -224,14 +227,14 @@ func init() { // 插件主体
strToInt(ctx.State["regex_matched"].([]string)[1]), // 需要发送的人的qq strToInt(ctx.State["regex_matched"].([]string)[1]), // 需要发送的人的qq
content, // 需要发送的信息 content, // 需要发送的信息
) )
ctx.Send("📧 --> " + ctx.State["regex_matched"].([]string)[1]) ctx.SendChain(message.Text("📧 --> " + ctx.State["regex_matched"].([]string)[1]))
return return
}) })
// 入群欢迎 // 入群欢迎
zero.OnNotice().SetBlock(false).SetPriority(40). zero.OnNotice().SetBlock(false).SetPriority(40).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
if ctx.Event.NoticeType == "group_increase" { if ctx.Event.NoticeType == "group_increase" {
ctx.Send("欢迎~") ctx.SendChain(message.Text("欢迎~"))
} }
return return
}) })
@ -239,7 +242,7 @@ func init() { // 插件主体
zero.OnNotice().SetBlock(false).SetPriority(40). zero.OnNotice().SetBlock(false).SetPriority(40).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
if ctx.Event.NoticeType == "group_decrease" { if ctx.Event.NoticeType == "group_decrease" {
ctx.Send("有人跑路了~") ctx.SendChain(message.Text("有人跑路了~"))
} }
return return
}) })
@ -249,7 +252,7 @@ func init() { // 插件主体
var cmd = ctx.State["regex_matched"].([]string)[1] var cmd = ctx.State["regex_matched"].([]string)[1]
cmd = strings.ReplaceAll(cmd, "[", "[") cmd = strings.ReplaceAll(cmd, "[", "[")
cmd = strings.ReplaceAll(cmd, "]", "]") cmd = strings.ReplaceAll(cmd, "]", "]")
ctx.Send(cmd) ctx.SendChain(message.Text(cmd))
}) })
} }