Skip to content
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

CommandHandler - ignore strings in entities and "/" followed by whitespace #1020

Merged
merged 4 commits into from
Mar 1, 2018

Conversation

PaulSonOfLars
Copy link
Contributor

Telegram entities show that / test is not a valid command. However,
PTB accepts this as a valid command due to how the message splitting is
done.

This commit makes sure that any commands are indeed in the format of
/test, with no space between / and test.

PaulSonOfLars and others added 3 commits February 24, 2018 13:03
Telegram entities show that `/ test` is not a valid command. However,
PTB accepts this as a valid command due to how the message splitting is
done.

This commit makes sure that any commands are indeed in the format of
`/test`, with no space between `/` and `test`.
@tsnoam
Copy link
Member

tsnoam commented Feb 25, 2018

@PaulSonOfLars
Thanks for your contribution. It is a great observation that leading spaces should be properly handled, as well as ignoring commands if they are part of a markup entity.

I pushed a really small fix for the PR and making sure that unitest pass.
I'm not sure why the unitests on Windows failed before, but if they'll pass this time I'll merge, otherwise I'll look into the failure more thoroughly.

@Eldinnie
Copy link
Member

Small question, why do you check on message.text_markdown instead of message.text?

@tsnoam
Copy link
Member

tsnoam commented Feb 25, 2018

@Eldinnie That's a smart change. Suppose the message sent to the bot is __/start__ - this is not a command...

@Eldinnie
Copy link
Member

@tsnoam Ah that is indeed true. However /吴语 isn't a command either, and we do accept those as commands. Changing the behavior breaks with what people axpect and this changes more then only the proposed change.

@tsnoam
Copy link
Member

tsnoam commented Feb 25, 2018

@Eldinnie We'll still support "/吴语" (up to potential problems with py2)
however, a single "/" with a space afterwards is definitely not a command, i really don't think we should support that.

@tsnoam tsnoam changed the title Ensure only valid commands are accepted. CommandHandler - ignore strings in entities and "/" followed by whitespace Feb 25, 2018
@tsnoam
Copy link
Member

tsnoam commented Feb 25, 2018

Fixed the PR title to be a bit more accurate.

@Eldinnie
Copy link
Member

Ok so I found out what the trouble was. (And I;m pretty surprised it didn't give any trouble on other platforms).
The test bot we use has the username ptb_test_bot which was only escaped properly on AppVeyor to ptb\_text\_bot Why this only happened on appveyor is a mystery for me. But it seems using text_html instead of text_markdown fixes the problem for this PR.

If CI finishes properly now it;s good to merge

@PaulSonOfLars
Copy link
Contributor Author

Awesome, glad I could help! And thanks for the debugging, I really had no clue what was going on there... Let me know if there's anything else that should be changed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants