Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

群聊中撤回消息 #520

Merged
merged 4 commits into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ zerobot [-h] [-n nickname] [-t token] [-u url] [-p prefix] [-d|w] [-c|s config.j

- [ ] 同意好友请求

- [ ] 撤回[@xxx] [xxx]
- [x] 对信息回复: 撤回

- [ ] 警告[@xxx]

Expand Down
14 changes: 14 additions & 0 deletions plugin/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ func init() { // 插件主体
)
ctx.SendChain(message.Text("嗯!不错的头衔呢~"))
})
// 撤回
// 群聊中直接回复消息结尾带上撤回
// 权限够的话,可以把请求撤回的消息也一并撤回
engine.OnRegex(`^\[CQ:reply,id=(-?\d+)\].*撤回$`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
logrus.Infoln("[manager] 要撤回的的消息ID:", ctx.State["regex_matched"].([]string)[1])
logrus.Infoln("[manager] 请求撤回的消息ID:", ctx.Event.MessageID)
go func(i message.MessageID) {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
ctx.DeleteMessage(i)
}(message.NewMessageIDFromString(ctx.State["regex_matched"].([]string)[1]))
go func(i message.MessageID) {
ctx.DeleteMessage(i)
}(message.NewMessageIDFromInteger(ctx.Event.MessageID.(int64)))
fumiama marked this conversation as resolved.
Show resolved Hide resolved
})
// 群聊转发
engine.OnRegex(`^群聊转发.*?(\d+)\s(.*)`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
Expand Down