feat(bot): implement conversation flow for start command
add conversation handler for start command with name input and welcome message update locales for new conversation flow add @grammyjs/conversations dependency
This commit is contained in:
23
apps/bot/src/conversations/start.conversation.ts
Normal file
23
apps/bot/src/conversations/start.conversation.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Conversation, createConversation } from '@grammyjs/conversations';
|
||||
import { BotContext } from '../types';
|
||||
import { ConversationSlug } from './consts';
|
||||
|
||||
async function enterConversation(conversation: Conversation, ctx: BotContext) {
|
||||
const askNameText = await conversation.external((ctx: BotContext) =>
|
||||
ctx.t('start-ask-name')
|
||||
);
|
||||
|
||||
await ctx.reply(askNameText);
|
||||
|
||||
const { message } = await conversation.waitFor('message:text');
|
||||
const welcomeText = await conversation.external((ctx: BotContext) =>
|
||||
ctx.t('start-welcome', { user: message.text })
|
||||
);
|
||||
|
||||
await ctx.reply(welcomeText);
|
||||
}
|
||||
|
||||
export const startConversation = createConversation(
|
||||
enterConversation,
|
||||
ConversationSlug.START
|
||||
);
|
||||
Reference in New Issue
Block a user