aboutsummaryrefslogtreecommitdiffstats
path: root/radiodiodibot.py
diff options
context:
space:
mode:
authorJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-07-16 12:23:19 +0300
committerJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-07-16 12:23:19 +0300
commit46380f5907c6e8e9e0e655d064dececb0978a3ce (patch)
tree6abf32f1248d82bd6ca9d4750320aab911f8e790 /radiodiodibot.py
parent68e8ef4f35d8145dd8277e65cb2473e865ace60c (diff)
Add option for chat_id, refine logging
Diffstat (limited to 'radiodiodibot.py')
-rwxr-xr-xradiodiodibot.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/radiodiodibot.py b/radiodiodibot.py
index a9c8c68..6fe394e 100755
--- a/radiodiodibot.py
+++ b/radiodiodibot.py
@@ -4,6 +4,15 @@ import sys, argparse
import botmanager
import logging
+try: # Python 2.7+
+ from logging import NullHandler
+except ImportError:
+ class NullHandler(logging.Handler):
+ def emit(self, record):
+ pass
+
+logging.getLogger(__name__).addHandler(NullHandler())
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
# Try to import telepot
@@ -22,17 +31,23 @@ def main():
parser = argparse.ArgumentParser(description="Telegram bot for the Radiodiodi Student Radio broadcast.")
parser.add_argument("telegram_bot_token", help="Telegram Bot API token")
parser.add_argument("-U", "--shoutbox-api-url", help="Shoutbox API URL")
+ parser.add_argument("-C", "--telegram-chat-id", help="Telegram Chat ID")
args = parser.parse_args()
token = args.telegram_bot_token
shoutbox_api_url = args.shoutbox_api_url
+ telegram_chat_id = args.telegram_chat_id
manager = botmanager.BotManager(token)
if (shoutbox_api_url != None):
manager.shoutbox_api_url = shoutbox_api_url
+ if telegram_chat_id != None:
+ manager.telegram_chat_id = telegram_chat_id
+
logging.info("Using Shoutbox API URL: {}".format(manager.shoutbox_api_url))
+ logging.info("Using Telegram Chat ID: {}".format(manager.telegram_chat_id))
manager.start()