aboutsummaryrefslogtreecommitdiffstats
path: root/telegramapicommunicator.py
diff options
context:
space:
mode:
authorjantuomi <jans.tuomi@gmail.com>2016-07-19 14:50:22 +0300
committerjantuomi <jans.tuomi@gmail.com>2016-07-19 14:50:22 +0300
commit9d94a01b631676b54f680c2571ae4dbba9ccd037 (patch)
tree2cac58eba2cd5d29ae0c2192efc5ca365dde7f74 /telegramapicommunicator.py
parent080cfd6cfe946e243239af201dea8466abaee020 (diff)
Restructure project
Diffstat (limited to 'telegramapicommunicator.py')
-rw-r--r--telegramapicommunicator.py47
1 files changed, 0 insertions, 47 deletions
diff --git a/telegramapicommunicator.py b/telegramapicommunicator.py
deleted file mode 100644
index 169a1ce..0000000
--- a/telegramapicommunicator.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import logging
-
-import sys
-import telepot
-
-from basecommunicator import BaseCommunicator
-
-
-class TelegramCommunicator(BaseCommunicator):
- """Class for communicating with the Telegram API"""
-
- chat_id = "default_id"
- bot = None
- token = "DEFAULT_TOKEN_123"
-
- @staticmethod
- def spawn_bot(token):
- TelegramCommunicator.bot = telepot.Bot(token)
-
- @staticmethod
- def fetch():
- raise Exception("""Attempted to fetch messages from Telegram manually.
- Please use telepot bot functionality for listening to messages.""")
-
- @staticmethod
- def send(data):
- TelegramCommunicator.send_raw("{}: {}".format(data["user"], data["text"]))
-
- @staticmethod
- def send_raw(message):
- try:
- TelegramCommunicator.bot.sendMessage(TelegramCommunicator.chat_id,
- message)
- except:
- logging.warning("Could not send message to Telegram chat id {}!".format(TelegramCommunicator.chat_id))
-
- @staticmethod
- def start_listening(handle):
- try:
- logging.info("Bot info: {}".format(TelegramCommunicator.bot.getMe()))
- except:
- logging.error("Could not fetch bot info. Check your token and connectivity to Telegram!")
- sys.exit(1)
-
- TelegramCommunicator.bot.message_loop(handle)
-
- logging.info("Listening for messages...")