diff --git a/README.md b/README.md index a3b0f5c9..f36715e2 100644 --- a/README.md +++ b/README.md @@ -397,6 +397,14 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 支付宝到账 1 + +
+ 触发者撤回时也自动撤回 + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw"` + + - [x] 撤回一条消息 +
base16384加解密 diff --git a/main.go b/main.go index 1a869a36..a3be4c50 100644 --- a/main.go +++ b/main.go @@ -61,6 +61,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/aipaint" // ai绘图 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核 diff --git a/plugin/autowithdraw/main.go b/plugin/autowithdraw/main.go new file mode 100644 index 00000000..1960b33e --- /dev/null +++ b/plugin/autowithdraw/main.go @@ -0,0 +1,29 @@ +// Package autowithdraw 触发者撤回时也自动撤回 +package autowithdraw + +import ( + "github.com/FloatTech/floatbox/process" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/FloatTech/zbputils/control" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +func init() { + control.Register("autowithdraw", &ctrl.Options[*zero.Ctx]{ + DisableOnDefault: false, + Brief: "触发者撤回时也自动撤回", + Help: "- 撤回一条消息\n", + }).OnNotice(func(ctx *zero.Ctx) bool { + return ctx.Event.NoticeType == "group_recall" || ctx.Event.NoticeType == "friend_recall" + }).SetBlock(false).Handle(func(ctx *zero.Ctx) { + id, ok := ctx.Event.MessageID.(int64) + if !ok { + return + } + for _, msg := range zero.GetTriggeredMessages(message.NewMessageIDFromInteger(id)) { + process.SleepAbout1sTo2s() + ctx.DeleteMessage(msg) + } + }) +}