From 90bf26c09b69627d817a0b82e08107cd2204cefc Mon Sep 17 00:00:00 2001 From: Eldinnie Date: Tue, 25 Apr 2017 10:37:06 +0200 Subject: [PATCH] Issue 566 (#577) * stripping token of whitespaces before starting bot * Line feed * - Case insensitivity for commandhandler - Ignore pylint case on windows. --- telegram/ext/commandhandler.py | 2 +- telegram/ext/messagequeue.py | 2 +- tests/test_updater.py | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/telegram/ext/commandhandler.py b/telegram/ext/commandhandler.py index e7a1f66bf..52bc02ac4 100644 --- a/telegram/ext/commandhandler.py +++ b/telegram/ext/commandhandler.py @@ -110,7 +110,7 @@ class CommandHandler(Handler): res = self.filters(message) return res and (message.text.startswith('/') and command[0] == self.command - and command[1] == update.message.bot.username) + and command[1].lower() == update.message.bot.username.lower()) else: return False diff --git a/telegram/ext/messagequeue.py b/telegram/ext/messagequeue.py index 6d512a27f..f4b516b63 100644 --- a/telegram/ext/messagequeue.py +++ b/telegram/ext/messagequeue.py @@ -38,7 +38,7 @@ else: # on Windows, the best available is time.clock while time.time is on # another platforms (M. Lutz, "Learning Python," 4ed, p.630-634) if sys.version_info.major == 3 and sys.version_info.minor >= 3: - curtime = time.perf_counter + curtime = time.perf_counter # pylint: disable=E1101 else: curtime = time.clock if sys.platform[:3] == 'win' else time.time diff --git a/tests/test_updater.py b/tests/test_updater.py index 5ed7c4c20..123510e79 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -250,6 +250,10 @@ class UpdaterTest(BaseTest, unittest.TestCase): queue.put(Update(update_id=0, message=message)) sleep(.1) self.assertEqual(self.received_message, '/test@MockBot') + message.text = "/test@mockbot" + queue.put(Update(update_id=0, message=message)) + sleep(.1) + self.assertEqual(self.received_message, '/test@mockbot') # directed at other bot self.reset()