Skip to content

Commit

Permalink
Update manager.go (FloatTech#132)
Browse files Browse the repository at this point in the history
* Update manager.go

修改 自定义欢迎语可带图
添加 修改名片/修改头衔/申请头衔字数限制

* Update manager.go

* Update manager.go

添加 测试欢迎语

* Update manager.go

* Update manager.go

* Update manager.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
  • Loading branch information
Jiang-Red and fumiama committed Feb 23, 2022
1 parent dc348f8 commit b2cff86
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions plugin_manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const (
"- 取消在\"cron\"的提醒\n" +
"- 列出所有提醒\n" +
"- 翻牌\n" +
"- 设置欢迎语XXX\n" +
"- 设置欢迎语XXX(可加{at}在欢迎时@对方)\n" +
"- 测试欢迎语\n" +
"- [开启 | 关闭]入群验证"
)

Expand Down Expand Up @@ -210,6 +211,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]), // 被修改群名片的人
Expand All @@ -220,6 +225,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]), // 被修改群头衔的人
Expand All @@ -230,6 +239,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, // 被修改群头衔的人
Expand Down Expand Up @@ -369,7 +382,7 @@ 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))
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("欢迎~"))
}
Expand Down Expand Up @@ -436,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) {
Expand Down

0 comments on commit b2cff86

Please sign in to comment.