-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
触发者撤回时也自动撤回
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} |