I'm using this library in my project and I need to handle a 'message' event from private and group chats with different behaviour. In original Grammy I can use bot.filter(chat => chat.type === 'private').on(...) and bot.filter(chat => chat.type !== 'private').on(...), but I can't do it here without if in handler code. For example:
@On('message')
// @UseGuards(AuthorizedUserGuard) -- this guard will be removed, because it's only for private chats
messageHandler(@GetContext() ctx: MyContext) {
if (ctx.chat.type === 'private') {
// here is behaviour for private chats and access checking without guard (bad pattern)
} else {
// here is an other behaviour
}
}
I think this is a really cool idea and it's pretty awesome to see that you already implemented it! I'm curious what the maintainers @drmikecrowe and @solidprinciples will think :)
Hello!
I'm using this library in my project and I need to handle a 'message' event from private and group chats with different behaviour. In original Grammy I can use
bot.filter(chat => chat.type === 'private').on(...)
andbot.filter(chat => chat.type !== 'private').on(...)
, but I can't do it here withoutif
in handler code. For example:And I want to do something like:
What do you think about this idea? I'm ready to submit PR if you approve my idea.
P.S. Sorry for my bad English.