bot-base / telegram-bot-template

Telegram bot template based on grammY
296 stars 48 forks source link

inline-query error #478

Closed hisunny520 closed 2 months ago

hisunny520 commented 4 months ago

err: { "type": "Error", "message": "Cannot access session data because this update does not belong to a chat, so the session key is undefined!", "stack": Error: Cannot access session data because this update does not belong to a chat, so the session key is undefined! at Context.get [as session] (E:\Projects\webbot\node_modules\.pnpm\grammy@1.23.0\node_modules\grammy\out\convenience\session.js:201:27) at getNegotiatedLocale (E:\Projects\webbot\node_modules\.pnpm\@grammyjs+i18n@1.0.2_grammy@1.23.0\node_modules\@grammyjs\i18n\script\src\i18n.js:116:43) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async negotiateLocale (E:\Projects\webbot\node_modules\.pnpm\@grammyjs+i18n@1.0.2_grammy@1.23.0\node_modules\@grammyjs\i18n\script\src\i18n.js:135:38) at async E:\Projects\webbot\node_modules\.pnpm\@grammyjs+i18n@1.0.2_grammy@1.23.0\node_modules\@grammyjs\i18n\script\src\i18n.js:157:9 at async E:\Projects\webbot\node_modules\.pnpm\grammy@1.23.0\node_modules\grammy\out\composer.js:61:13 at async E:\Projects\webbot\node_modules\.pnpm\grammy@1.23.0\node_modules\grammy\out\convenience\session.js:65:9 at async E:\Projects\webbot\node_modules\.pnpm\grammy@1.23.0\node_modules\grammy\out\composer.js:61:13 at async E:\Projects\webbot\node_modules\.pnpm\grammy@1.23.0\node_modules\grammy\out\composer.js:61:13 at async hydrateReply (E:\Projects\webbot\node_modules\.pnpm\@grammyjs+parse-mode@1.10.0_grammy@1.23.0\node_modules\@grammyjs\parse-mode\dist\hydrate.js:73:5) }

deptyped commented 4 months ago

Inline query does not belong to a chat (ctx.chat is undefined), so the default session key resolver will not work. You need to specify a custom getSessionKey function: https://grammy.dev/plugins/session.html#session-keys