From bc99e19c4ccb7748cf010bd2318bb8a8941ec2ba Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 28 Jul 2016 15:12:00 -0400 Subject: Fix bug where messages are answered in a wrong Telegram chat --- project/botmanager.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'project/botmanager.py') diff --git a/project/botmanager.py b/project/botmanager.py index 1a3e037..01f9c10 100644 --- a/project/botmanager.py +++ b/project/botmanager.py @@ -71,23 +71,16 @@ class BotManager(object): songs = ["Ace of Spades", "Mökkitie", "Alpha Russian XXL Night Mixtape", "teekkarihymni"] - def action_now_playing(self, msg): - """Placeholder action for testing commands""" - TelegramCommunicator.send_raw("Radiossa soi {}!".format(random.choice(BotManager.songs))) - def action_not_supported(self, msg): """Notify the user that the given command is not supported""" - TelegramCommunicator.send_raw("Tätä toimintoa ei ole tuettu.") + chat_id = msg["chat"] + TelegramCommunicator.send_raw("Tätä toimintoa ei ole tuettu.", chat_id) def parse_message(self, msg): """Determine which action to take for an incoming Telegram text message""" t = msg["text"] content_type, chat_type, chat_id = telepot.glance(msg) - if "/nowplaying" in t: - self.action_now_playing(msg) - elif "/start" in t: - self.action_not_supported(msg) - elif "/stop" in t: + if t in ("/start", "/stop"): self.action_not_supported(msg) elif str(chat_id) == TelegramCommunicator.chat_id.strip(): self.action_send_to_shoutbox(msg) -- cgit v1.3