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

fix(qq): internal api #232

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading