add plugin autowithdraw

触发者撤回时也自动撤回
This commit is contained in:
源文雨 2023-01-09 21:55:20 +08:00
parent 8ca71967b6
commit df1c207d77
3 changed files with 38 additions and 0 deletions

View File

@ -397,6 +397,14 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 支付宝到账 1
</details>
<details>
<summary>触发者撤回时也自动撤回</summary>
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw"`
- [x] 撤回一条消息
</details>
<details>
<summary>base16384加解密</summary>

View File

@ -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" // 百度内容审核

View File

@ -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)
}
})
}