diff --git a/adapters/discord/src/message.ts b/adapters/discord/src/message.ts index 4762c430..3fae6dce 100644 --- a/adapters/discord/src/message.ts +++ b/adapters/discord/src/message.ts @@ -175,10 +175,10 @@ export class DiscordMessageEncoder extends MessageEncoder { label, style: 1, } - } else if (attrs.type === 'completion') { + } else if (attrs.type === 'input') { return { type: ComponentType.BUTTON, - custom_id: 'completion:' + attrs.text, + custom_id: 'input:' + attrs.text, label, style: 1, } diff --git a/adapters/discord/src/utils.ts b/adapters/discord/src/utils.ts index 4b8bc408..f71197b4 100644 --- a/adapters/discord/src/utils.ts +++ b/adapters/discord/src/utils.ts @@ -248,7 +248,7 @@ export async function adaptSession(bot: DiscordBot, input: Discord.Gateway.Paylo session.event.argv = decodeArgv(data, command) } else if (input.t === 'INTERACTION_CREATE' && input.d.type === Discord.Interaction.Type.MODAL_SUBMIT) { const data = input.d.data as Discord.InteractionData.ModalSubmit - if (!data.custom_id.startsWith('completion:')) return + if (!data.custom_id.startsWith('input:')) return // @ts-ignore const user_input = data.components[0].components[0].value await bot.internal.createInteractionResponse(input.d.id, input.d.token, { @@ -264,7 +264,7 @@ export async function adaptSession(bot: DiscordBot, input: Discord.Gateway.Paylo session.content = user_input } else if (input.t === 'INTERACTION_CREATE' && input.d.type === Discord.Interaction.Type.MESSAGE_COMPONENT) { const id = (input.d.data as Discord.InteractionData.MessageComponent).custom_id - if (id.startsWith('completion:')) { + if (id.startsWith('input:')) { await bot.internal.createInteractionResponse(input.d.id, input.d.token, { type: Discord.Interaction.CallbackType.MODAL, data: { @@ -276,7 +276,7 @@ export async function adaptSession(bot: DiscordBot, input: Discord.Gateway.Paylo custom_id: id, type: Discord.ComponentType.TEXT_INPUT, label: 'auto complete', - value: id.slice('completion:'.length), + value: id.slice('input:'.length), style: 1, }], }], diff --git a/adapters/qq/src/message.ts b/adapters/qq/src/message.ts index 39e128ae..9700519c 100644 --- a/adapters/qq/src/message.ts +++ b/adapters/qq/src/message.ts @@ -207,7 +207,7 @@ export class QQMessageEncoder extends MessageEncoder { style: 0, }, action: { - type: attrs.type === 'completion' ? 2 + type: attrs.type === 'input' ? 2 : (attrs.type === 'link' ? 0 : 1), permission: { type: 2, diff --git a/adapters/telegram/src/message.ts b/adapters/telegram/src/message.ts index 208ea633..9934c908 100644 --- a/adapters/telegram/src/message.ts +++ b/adapters/telegram/src/message.ts @@ -100,7 +100,7 @@ export class TelegramMessageEncoder extends MessageEncoder { text: label, callback_data: attrs.id, } - } else if (attrs.type === 'completion') { + } else if (attrs.type === 'input') { return { text: label, switch_inline_query_current_chat: attrs.text, diff --git a/packages/core/src/bot.ts b/packages/core/src/bot.ts index 96e4879c..b8238b8b 100644 --- a/packages/core/src/bot.ts +++ b/packages/core/src/bot.ts @@ -129,8 +129,8 @@ export abstract class Bot implements Login { return `${this.platform}:${this.selfId}` } - session(body: Partial = {}) { - return new Session(this, body) + session(event: Partial = {}) { + return new Session(this, event) } dispatch(session: Session) {