add conversation handler for start command with name input and welcome message update locales for new conversation flow add @grammyjs/conversations dependency
24 lines
710 B
TypeScript
24 lines
710 B
TypeScript
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
|
|
);
|