mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-26 16:38:53 +01:00
Fix command not recognized if it is directly followed by a newline (#869)
fixes #868
This commit is contained in:
parent
bfad2fa1f3
commit
ec9b16ac7b
2 changed files with 10 additions and 1 deletions
|
@ -134,7 +134,7 @@ class CommandHandler(Handler):
|
||||||
message = update.message or update.edited_message
|
message = update.message or update.edited_message
|
||||||
|
|
||||||
if message.text:
|
if message.text:
|
||||||
command = message.text[1:].split(' ')[0].split('@')
|
command = message.text[1:].split(None, 1)[0].split('@')
|
||||||
command.append(
|
command.append(
|
||||||
message.bot.username) # in case the command was send without a username
|
message.bot.username) # in case the command was send without a username
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,15 @@ class TestCommandHandler(object):
|
||||||
dp.process_update(Update(0, message=message))
|
dp.process_update(Update(0, message=message))
|
||||||
assert self.test_flag
|
assert self.test_flag
|
||||||
|
|
||||||
|
def test_newline(self, dp, message):
|
||||||
|
handler = CommandHandler('test', self.callback_basic)
|
||||||
|
dp.add_handler(handler)
|
||||||
|
|
||||||
|
message.text = '/test\nfoobar'
|
||||||
|
assert handler.check_update(Update(0, message))
|
||||||
|
dp.process_update(Update(0, message))
|
||||||
|
assert self.test_flag
|
||||||
|
|
||||||
def test_pass_user_or_chat_data(self, dp, message):
|
def test_pass_user_or_chat_data(self, dp, message):
|
||||||
handler = CommandHandler('test', self.callback_data_1, pass_user_data=True)
|
handler = CommandHandler('test', self.callback_data_1, pass_user_data=True)
|
||||||
dp.add_handler(handler)
|
dp.add_handler(handler)
|
||||||
|
|
Loading…
Add table
Reference in a new issue