From 9918dd8ec846f6187bcfbdc32119bc76dbf0cbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 14 Oct 2023 13:37:45 +0900 Subject: [PATCH] finish intent --- define.go | 20 ++++++++++++++++++++ handler.go | 30 ++++++++++++++++++++++++++++++ openapi_audio.go | 10 ++++++++++ openapi_message.go | 7 ++++++- 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/define.go b/define.go index d1c930e..0ae1b5b 100644 --- a/define.go +++ b/define.go @@ -47,3 +47,23 @@ type WebsocketPayload struct { S int `json:"s"` T string `json:"t"` } + +// https://bot.q.qq.com/wiki/develop/api/gateway/intents.html +const ( + IntentGuilds = 1 << 0 + IntentGuildMembers = 1 << 1 + IntentGuildMessages = 1 << 9 + IntentGuildMessageReactions = 1 << 10 + IntentDirectMessage = 1 << 12 + IntentOpenForumsEvent = 1 << 18 + IntentAudioOrLiveChannelMember = 1 << 19 + IntentInteraction = 1 << 26 + IntentMessageAudit = 1 << 27 + IntentForumsEvent = 1 << 28 + IntentAudioAction = 1 << 29 + IntentPublicGuildMessages = 1 << 30 + + IntentAll = IntentGuilds | IntentGuildMembers | IntentGuildMessages | IntentGuildMessageReactions | + IntentDirectMessage | IntentOpenForumsEvent | IntentAudioOrLiveChannelMember | IntentInteraction | + IntentMessageAudit | IntentForumsEvent | IntentAudioAction | IntentPublicGuildMessages +) diff --git a/handler.go b/handler.go index 2000a6c..104e5eb 100644 --- a/handler.go +++ b/handler.go @@ -43,4 +43,34 @@ type Handler struct { OnOpenForumPostDelete func(s int, bot *Bot, d *Post) OnOpenForumReplyCreate func(s int, bot *Bot, d *Reply) OnOpenForumReplyDelete func(s int, bot *Bot, d *Reply) + // AUDIO_OR_LIVE_CHANNEL_MEMBER (1 << 19) // 音视频/直播子频道成员进出事件 + + OnAudioOrLiveChannelMemberEnter func(s int, bot *Bot, d *AudioLiveChannelUsersChange) + OnAudioOrLiveChannelMemberExit func(s int, bot *Bot, d *AudioLiveChannelUsersChange) + // INTERACTION (1 << 26) 事件结构不明 + + // MESSAGE_AUDIT (1 << 27) + + OnMessageAuditPass func(s int, bot *Bot, d *MessageAudited) + OnMessageAuditReject func(s int, bot *Bot, d *MessageAudited) + // FORUMS_EVENT (1 << 28) // 论坛事件,仅 *私域* 机器人能够设置此 intents。 + + OnForumThreadCreate func(s int, bot *Bot, d *Thread) + OnForumThreadUpdate func(s int, bot *Bot, d *Thread) + OnForumThreadDelete func(s int, bot *Bot, d *Thread) + OnForumPostCreate func(s int, bot *Bot, d *Post) + OnForumPostDelete func(s int, bot *Bot, d *Post) + OnForumReplyCreate func(s int, bot *Bot, d *Reply) + OnForumReplyDelete func(s int, bot *Bot, d *Reply) + OnForumPublishAuditResult func(s int, bot *Bot, d *AuditResult) + // AUDIO_ACTION (1 << 29) + + OnAudioStart func(s int, bot *Bot, d *AudioAction) + OnAudioFinish func(s int, bot *Bot, d *AudioAction) + OnAudioOnMic func(s int, bot *Bot, d *AudioAction) + OnAudioOffMic func(s int, bot *Bot, d *AudioAction) + // PUBLIC_GUILD_MESSAGES (1 << 30) // 消息事件,此为公域的消息事件 + + OnAtMessageCreate func(s int, bot *Bot, d *Message) + OnPublicMessageDelete func(s int, bot *Bot, d *Message) } diff --git a/openapi_audio.go b/openapi_audio.go index 7d174cd..2af1bb6 100644 --- a/openapi_audio.go +++ b/openapi_audio.go @@ -49,3 +49,13 @@ func (bot *Bot) OpenMicInChannel(id string) error { func (bot *Bot) CloseMicInChannel(id string) error { return bot.DeleteOpenAPI("/channels/"+id+"/mic", "", nil) } + +// AudioLiveChannelUsersChange 音视频/直播子频道成员进出事件 +// +// https://bot.q.qq.com/wiki/develop/api/gateway/audio_or_live_channel_member.html +type AudioLiveChannelUsersChange struct { + GuildID string `json:"guild_id"` + ChannelID string `json:"channel_id"` + ChannelType int `json:"channel_type"` + UserID string `json:"user_id"` +} diff --git a/openapi_message.go b/openapi_message.go index d089b36..1ae6bfd 100644 --- a/openapi_message.go +++ b/openapi_message.go @@ -99,7 +99,12 @@ type MessageDelete struct { // // https://bot.q.qq.com/wiki/develop/api/openapi/message/model.html#%E6%B6%88%E6%81%AF%E5%AE%A1%E6%A0%B8%E5%AF%B9%E8%B1%A1-messageaudited type MessageAudited struct { - AuditID string `json:"audit_id"` + AuditID string `json:"audit_id"` + AuditTime time.Time `json:"audit_time"` + ChannelID string `json:"channel_id"` + CreateTime time.Time `json:"create_time"` + GuildID string `json:"guild_id"` + MessageID string `json:"message_id"` } // GetMessageFromChannel 获取子频道 channel_id 下的消息 message_id 的详情