Skip to content

Commit df1c207

Browse files
committed
✨ add plugin autowithdraw
触发者撤回时也自动撤回
1 parent 8ca7196 commit df1c207

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ print("run[CQ:image,file="+j["img"]+"]")
397397

398398
- [x] 支付宝到账 1
399399

400+
</details>
401+
<details>
402+
<summary>触发者撤回时也自动撤回</summary>
403+
404+
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw"`
405+
406+
- [x] 撤回一条消息
407+
400408
</details>
401409
<details>
402410
<summary>base16384加解密</summary>

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import (
6161
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aipaint" // ai绘图
6262
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
6363
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
64+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回
6465
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
6566
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
6667
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核

plugin/autowithdraw/main.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Package autowithdraw 触发者撤回时也自动撤回
2+
package autowithdraw
3+
4+
import (
5+
"github.com/FloatTech/floatbox/process"
6+
ctrl "github.com/FloatTech/zbpctrl"
7+
"github.com/FloatTech/zbputils/control"
8+
zero "github.com/wdvxdr1123/ZeroBot"
9+
"github.com/wdvxdr1123/ZeroBot/message"
10+
)
11+
12+
func init() {
13+
control.Register("autowithdraw", &ctrl.Options[*zero.Ctx]{
14+
DisableOnDefault: false,
15+
Brief: "触发者撤回时也自动撤回",
16+
Help: "- 撤回一条消息\n",
17+
}).OnNotice(func(ctx *zero.Ctx) bool {
18+
return ctx.Event.NoticeType == "group_recall" || ctx.Event.NoticeType == "friend_recall"
19+
}).SetBlock(false).Handle(func(ctx *zero.Ctx) {
20+
id, ok := ctx.Event.MessageID.(int64)
21+
if !ok {
22+
return
23+
}
24+
for _, msg := range zero.GetTriggeredMessages(message.NewMessageIDFromInteger(id)) {
25+
process.SleepAbout1sTo2s()
26+
ctx.DeleteMessage(msg)
27+
}
28+
})
29+
}

0 commit comments

Comments
 (0)