grammyjs / conversations

Conversational interfaces for grammY.
https://grammy.dev/plugins/conversations
MIT License
52 stars 17 forks source link

feat: add ConversationFn type #26

Closed Loskir closed 2 years ago

Loskir commented 2 years ago

Similar to React.FC

const greeting: ConversationFn<MyContext> = async (conversation, ctx) => {
    await ctx.reply("Hi there! What is your name?");
    const { message } = await conversation.wait();
    await ctx.reply(`Welcome to the chat, ${message.text}!`);
}

As suggested in https://t.me/grammyjs/66063

Loskir commented 2 years ago

Drawback: won't be possible to automatically get conversation name

KnorpelSenf commented 2 years ago

I am in favour of this.

Drawback: won't be possible to automatically get conversation name

This is incorrect.

> const foo = async () => {}
undefined
> foo.name
"foo"
> 
KnorpelSenf commented 2 years ago

Please review #48.