mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
定制退群提醒+调整煎蛋网无聊图触发 (#166)
* 优化在两个命令中使用空格分隔的体验 - fortune的设置底图功能 - b14的加密功能 * 优化四个插件中使用空格分隔的体验 - 加密 - 哔哩哔哩推送 - 藏头诗 - 运势 * 优化并修正了上一个commit - 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?` - 调整藏头诗和加密的正则触发,使其不必多此一举 - 删去了未被发现的测试代码 * - 删去了遗漏的Trim * 优化了更多插件中使用空格的体验 - 优化了music bilibili image_finder 中使用空格的体验 - 补上了plugin_bilibili中未实现的vup开头触发 - 为plugin_bilibili_parse输出的消息加上一个换行符,优化排版 * 小调整 - 考虑到屌字既难打又有碍观瞻,改为正则匹配`[屌|弔|吊]图` - 增加了退群提醒的定制 * - 修复退群提醒本身忘记修改了的问题
This commit is contained in:
parent
81a4297eb1
commit
87e3297904
@ -350,8 +350,8 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
- **b站视频链接解析** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili_parse"`
|
||||
- [x] https://www.bilibili.com/video/BV1xx411c7BF | https://www.bilibili.com/video/av1605 | https://b23.tv/I8uzWCA | https://www.bilibili.com/video/bv1xx411c7BF
|
||||
- **煎蛋网无聊图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan"`
|
||||
- [x] 来份屌图
|
||||
- [x] 更新屌图
|
||||
- [x] 来份[屌|弔|吊]图
|
||||
- [x] 更新[屌|弔|吊]图
|
||||
- **月幕galgame图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"`
|
||||
- [x] 随机galCG
|
||||
- [x] 随机gal表情包
|
||||
|
||||
@ -25,7 +25,7 @@ const (
|
||||
func init() {
|
||||
engine := control.Register("jandan", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "煎蛋网无聊图\n- 来份屌图\n- 更新屌图\n",
|
||||
Help: "煎蛋网无聊图\n- 来份[屌|弔|吊]图\n- 更新[屌|弔|吊]图\n",
|
||||
PublicDataFolder: "Jandan",
|
||||
})
|
||||
|
||||
@ -44,7 +44,7 @@ func init() {
|
||||
logrus.Printf("[jandan]读取%d张图片", n)
|
||||
}()
|
||||
|
||||
engine.OnFullMatch("来份屌图").SetBlock(true).
|
||||
engine.OnRegex(`来份[屌|弔|吊]图`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
u, err := getRandomPicture()
|
||||
if err != nil {
|
||||
@ -54,7 +54,7 @@ func init() {
|
||||
ctx.SendChain(message.Image(u))
|
||||
})
|
||||
|
||||
engine.OnFullMatch("更新屌图", zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`更新[屌|弔|吊]图`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女更新中...")
|
||||
webpageURL := api
|
||||
|
||||
@ -48,8 +48,10 @@ const (
|
||||
"- 取消在\"cron\"的提醒\n" +
|
||||
"- 列出所有提醒\n" +
|
||||
"- 翻牌\n" +
|
||||
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] {at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像\n" +
|
||||
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{id}] {at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {id}是被欢迎者QQ号\n" +
|
||||
"- 测试欢迎语\n" +
|
||||
"- 设置告别辞 参数同设置欢迎语\n" +
|
||||
"- 测试告别辞\n" +
|
||||
"- [开启 | 关闭]入群验证"
|
||||
)
|
||||
|
||||
@ -76,6 +78,10 @@ func init() { // 插件主体
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = db.Create("farewell", &welcome{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
// 升为管理
|
||||
@ -430,9 +436,15 @@ func init() { // 插件主体
|
||||
engine.OnNotice().SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if ctx.Event.NoticeType == "group_decrease" {
|
||||
var w welcome
|
||||
err := db.Find("farewell", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
if err == nil {
|
||||
ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(welcometocq(ctx, w.Msg)))
|
||||
} else {
|
||||
userid := ctx.Event.UserID
|
||||
ctx.SendChain(message.Text(ctx.CardOrNickName(userid), "(", userid, ")", "离开了我们..."))
|
||||
}
|
||||
}
|
||||
})
|
||||
// 设置欢迎语
|
||||
engine.OnRegex(`^设置欢迎语([\s\S]*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
@ -459,6 +471,32 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("欢迎~"))
|
||||
}
|
||||
})
|
||||
// 设置告别辞
|
||||
engine.OnRegex(`^设置告别辞([\s\S]*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
w := &welcome{
|
||||
GrpID: ctx.Event.GroupID,
|
||||
Msg: ctx.State["regex_matched"].([]string)[1],
|
||||
}
|
||||
err := db.Insert("farewell", w)
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("记住啦!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("出错啦: ", err))
|
||||
}
|
||||
})
|
||||
// 测试告别辞
|
||||
engine.OnFullMatch("测试告别辞", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var w welcome
|
||||
err := db.Find("farewell", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
if err == nil {
|
||||
ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(welcometocq(ctx, w.Msg)))
|
||||
} else {
|
||||
userid := ctx.Event.UserID
|
||||
ctx.SendChain(message.Text(ctx.CardOrNickName(userid), "(", userid, ")", "离开了我们..."))
|
||||
}
|
||||
})
|
||||
// 入群后验证开关
|
||||
engine.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@ -543,11 +581,13 @@ func init() { // 插件主体
|
||||
|
||||
// 传入 ctx 和 welcome格式string 返回cq格式string 使用方法:welcometocq(ctx,w.Msg)
|
||||
func welcometocq(ctx *zero.Ctx, welcome string) string {
|
||||
nickname := ctx.GetGroupMemberInfo(ctx.Event.GroupID, ctx.Event.UserID, false).Get("nickname").Str
|
||||
at := "[CQ:at,qq=" + strconv.FormatInt(ctx.Event.UserID, 10) + "]"
|
||||
avatar := "[CQ:image,file=" + "http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(ctx.Event.UserID, 10) + "&s=640]"
|
||||
id := strconv.FormatInt(ctx.Event.UserID, 10)
|
||||
nickname := ctx.CardOrNickName(ctx.Event.UserID)
|
||||
cqstring := strings.ReplaceAll(welcome, "{at}", at)
|
||||
cqstring = strings.ReplaceAll(cqstring, "{nickname}", nickname)
|
||||
cqstring = strings.ReplaceAll(cqstring, "{avatar}", avatar)
|
||||
cqstring = strings.ReplaceAll(cqstring, "{id}", id)
|
||||
return cqstring
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user