mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
feat: GuildMessageRecalledEvent
This commit is contained in:
parent
abe1fe7770
commit
06bc0bba17
@ -238,6 +238,14 @@ type (
|
||||
NewChannelInfo *ChannelInfo
|
||||
}
|
||||
|
||||
GuildMessageRecalledEvent struct {
|
||||
OperatorId uint64
|
||||
GuildId uint64
|
||||
ChannelId uint64
|
||||
MessageId uint64
|
||||
RecallTime int64
|
||||
}
|
||||
|
||||
GuildChannelOperationEvent struct {
|
||||
OperatorId uint64
|
||||
GuildId uint64
|
||||
|
@ -16,6 +16,7 @@ type eventHandlers struct {
|
||||
selfGroupMessageHandlers []func(*QQClient, *message.GroupMessage)
|
||||
guildChannelMessageHandlers []func(*QQClient, *message.GuildChannelMessage)
|
||||
guildMessageReactionsUpdatedHandlers []func(*QQClient, *GuildMessageReactionsUpdatedEvent)
|
||||
guildMessageRecalledHandlers []func(*QQClient, *GuildMessageRecalledEvent)
|
||||
guildChannelUpdatedHandlers []func(*QQClient, *GuildChannelUpdatedEvent)
|
||||
guildChannelCreatedHandlers []func(*QQClient, *GuildChannelOperationEvent)
|
||||
guildChannelDestroyedHandlers []func(*QQClient, *GuildChannelOperationEvent)
|
||||
@ -82,6 +83,10 @@ func (s *GuildService) OnGuildMessageReactionsUpdated(f func(*QQClient, *GuildMe
|
||||
s.c.eventHandlers.guildMessageReactionsUpdatedHandlers = append(s.c.eventHandlers.guildMessageReactionsUpdatedHandlers, f)
|
||||
}
|
||||
|
||||
func (s *GuildService) OnGuildMessageRecalled(f func(*QQClient, *GuildMessageRecalledEvent)) {
|
||||
s.c.eventHandlers.guildMessageRecalledHandlers = append(s.c.eventHandlers.guildMessageRecalledHandlers, f)
|
||||
}
|
||||
|
||||
func (s *GuildService) OnGuildChannelUpdated(f func(*QQClient, *GuildChannelUpdatedEvent)) {
|
||||
s.c.eventHandlers.guildChannelUpdatedHandlers = append(s.c.eventHandlers.guildChannelUpdatedHandlers, f)
|
||||
}
|
||||
@ -282,6 +287,17 @@ func (c *QQClient) dispatchGuildMessageReactionsUpdatedEvent(e *GuildMessageReac
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QQClient) dispatchGuildMessageRecalledEvent(e *GuildMessageRecalledEvent) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
for _, f := range c.eventHandlers.guildMessageRecalledHandlers {
|
||||
cover(func() {
|
||||
f(c, e)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QQClient) dispatchGuildChannelUpdatedEvent(e *GuildChannelUpdatedEvent) {
|
||||
if e == nil {
|
||||
return
|
||||
|
@ -195,7 +195,14 @@ func (c *QQClient) processGuildEventBody(m *channel.ChannelMsgContent, eventBody
|
||||
Member: info,
|
||||
})
|
||||
case eventBody.UpdateMsg != nil:
|
||||
if eventBody.UpdateMsg.GetEventType() == 1 || eventBody.UpdateMsg.GetEventType() == 2 { // todo: 撤回消息
|
||||
if eventBody.UpdateMsg.GetEventType() == 1 || eventBody.UpdateMsg.GetEventType() == 2 {
|
||||
c.dispatchGuildMessageRecalledEvent(&GuildMessageRecalledEvent{
|
||||
OperatorId: eventBody.UpdateMsg.GetOperatorTinyid(),
|
||||
GuildId: m.Head.RoutingHead.GetGuildId(),
|
||||
ChannelId: m.Head.RoutingHead.GetChannelId(),
|
||||
MessageId: eventBody.UpdateMsg.GetMsgSeq(),
|
||||
RecallTime: int64(m.Head.ContentHead.GetTime()),
|
||||
})
|
||||
return
|
||||
}
|
||||
if eventBody.UpdateMsg.GetEventType() == 4 { // 消息贴表情更新 (包含添加或删除)
|
||||
|
Loading…
x
Reference in New Issue
Block a user