diff options
Diffstat (limited to 'project')
| -rw-r--r-- | project/botmanager.py | 13 | ||||
| -rw-r--r-- | project/telegramapicommunicator.py | 5 |
2 files changed, 7 insertions, 11 deletions
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) diff --git a/project/telegramapicommunicator.py b/project/telegramapicommunicator.py index 7fdb29c..a4b6964 100644 --- a/project/telegramapicommunicator.py +++ b/project/telegramapicommunicator.py @@ -27,7 +27,10 @@ class TelegramCommunicator(BaseCommunicator): TelegramCommunicator.send_raw("{}: {}".format(data["user"], data["text"])) @staticmethod - def send_raw(message): + def send_raw(message, chat_id=None): + if chat_id is None: + chat_id = TelegramCommunicator.chat_id + try: TelegramCommunicator.bot.sendMessage(TelegramCommunicator.chat_id, message) |
