Skip to content

Commit

Permalink
fix(qq): internal api (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX authored Jan 25, 2024
1 parent c1ea1ad commit 3ea40ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions adapters/qq/src/internal/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ declare module './internal' {
sendPrivateMessage(openid: string, data: QQ.Message.Request): Promise<any>
sendFilePrivate(openid: string, data: QQ.Message.File.Request): Promise<any>
sendFileGuild(group_openid: string, data: QQ.Message.File.Request): Promise<any>
acknowledgeInteraction(interaction_id: string, code: number): Promise<any>
acknowledgeInteraction(interaction_id: string, data: {
code: number
}): Promise<any>
}
}

Expand All @@ -31,7 +33,7 @@ GroupInternal.define(false, {
'/v2/groups/{channel.id}/files': {
POST: 'sendFileGuild',
},
'/interactions/{interaction.id}/{interaction.token}/callback': {
POST: 'acknowledgeInteraction',
'/interactions/{interaction.id}': {
PUT: 'acknowledgeInteraction',
},
})
6 changes: 4 additions & 2 deletions adapters/qq/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ export async function adaptSession<C extends Context = Context>(bot: QQBot<C>, i
if (!['GROUP_AT_MESSAGE_CREATE', 'C2C_MESSAGE_CREATE', 'FRIEND_ADD', 'FRIEND_DEL',
'GROUP_ADD_ROBOT', 'GROUP_DEL_ROBOT', 'INTERACTION_CREATE'].includes(input.t)) {
session = bot.guildBot.session()
session.setInternal(bot.guildBot.platform, input)
} else {
session.setInternal(bot.platform, input)
}

session.setInternal(bot.platform, input)
if (input.t === 'MESSAGE_CREATE' || input.t === 'AT_MESSAGE_CREATE' || input.t === 'DIRECT_MESSAGE_CREATE') {
if (bot.config.type === 'private' && input.t === 'AT_MESSAGE_CREATE' && bot.config.intents & QQ.Intents.GUILD_MESSAGES) return
session.type = 'message'
Expand Down Expand Up @@ -212,7 +214,7 @@ export async function adaptSession<C extends Context = Context>(bot: QQBot<C>, i

// {message: 'get header appid failed', code: 630006}
// {"message":"check app privilege not pass","code":11253
bot.internal.acknowledgeInteraction(input.d.id, 0).catch(() => {})
bot.internal.acknowledgeInteraction(input.d.id, { code: 0 }).catch(() => { })
} else if (input.t === 'GUILD_MEMBER_ADD' || input.t === 'GUILD_MEMBER_DELETE' || input.t === 'GUILD_MEMBER_UPDATE') {
session.type = {
GUILD_MEMBER_ADD: 'guild-member-added',
Expand Down

0 comments on commit 3ea40ef

Please sign in to comment.