-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not handle commands from channels #147
Conversation
(ctx): ctx is CommandContext<C> => { | ||
const msg = ctx.message ?? ctx.channelPost; | ||
const txt = msg.text ?? msg.caption; | ||
const entities = msg.entities ?? msg.caption_entities; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This not only removes support for commands in channels but also for commands on media messages with captions?
Not sure if that even works normally, never tried that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammY used to support commands in captions in its early days, but a lot of people in the community complained that it is not intuitive for command handlers to trigger when e.g. an image caption contains a command. Hence, the support was remove by changing the filter query from ::bot_command
to :entities:bot_command
.
The code that was removed here was essentially dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can mix it, it's perfect!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mix? Do you mean merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get in gear!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are doing what they are meant to do. Commands aren't handled in channels, anymore.
Were commands handled in channels before? |
Oh well. I tested this once again, and interestingly enough the entities are not rendered in any client, but bots receive them. Hence, the assumption that the server does not parse the command entities in channels is wrong. As a result, we cannot drop this feature without doing a breaking change. I will close this unmerged. Note that if you still want bot.on('message').command('start', ctx => {
const name = ctx.from.first_name // `ctx.from` is present now!
}) |
The dead code you mentioned about the commands on captions should still be removed I guess? |
They don't exist anyway (the server does not parse the command entities in channels) so we might as well drop this.
#108 will add command handling that does not rely on parsed entities.
This PR has the advantage that
ctx.from
will now always be present afterbot.command
.