diff --git a/telegram/ext/commandhandler.py b/telegram/ext/commandhandler.py index b33dc7959..feb5c7c04 100644 --- a/telegram/ext/commandhandler.py +++ b/telegram/ext/commandhandler.py @@ -134,7 +134,7 @@ class CommandHandler(Handler): message = update.message or update.edited_message if message.text: - command = message.text[1:].split(' ')[0].split('@') + command = message.text[1:].split(None, 1)[0].split('@') command.append( message.bot.username) # in case the command was send without a username diff --git a/tests/test_commandhandler.py b/tests/test_commandhandler.py index fb1aafa1f..373476ec0 100644 --- a/tests/test_commandhandler.py +++ b/tests/test_commandhandler.py @@ -165,6 +165,15 @@ class TestCommandHandler(object): dp.process_update(Update(0, message=message)) 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): handler = CommandHandler('test', self.callback_data_1, pass_user_data=True) dp.add_handler(handler)