Skip to content

Commit

Permalink
✨ add plugin autowithdraw
Browse files Browse the repository at this point in the history
触发者撤回时也自动撤回
  • Loading branch information
fumiama committed Jan 9, 2023
1 parent 8ca7196 commit df1c207
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" // 百度内容审核
Expand Down
29 changes: 29 additions & 0 deletions plugin/autowithdraw/main.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}

0 comments on commit df1c207

Please sign in to comment.