diff options
| author | jantuomi <jans.tuomi@gmail.com> | 2016-07-15 12:23:07 +0300 |
|---|---|---|
| committer | jantuomi <jans.tuomi@gmail.com> | 2016-07-15 12:23:07 +0300 |
| commit | e4ec27720b022a45d69d4422b68b433d582c3563 (patch) | |
| tree | 2dc775f675649d5028668a19d7690c41e2b65ad4 /radiodiodibot.py | |
| parent | 23bb8cfbf650d11f20a6ce7141e8cce1a6a5f74d (diff) | |
Add start and stop, rudimentary API request placeholder
Diffstat (limited to 'radiodiodibot.py')
| -rw-r--r-- | radiodiodibot.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/radiodiodibot.py b/radiodiodibot.py index ce8abf5..edc10dc 100644 --- a/radiodiodibot.py +++ b/radiodiodibot.py @@ -4,13 +4,7 @@ import sys, argparse import botmanager import logging -logging.basicConfig(level=logging.INFO) - -# Make a globally accessible bot instance -bot = None - -# Boolean to track whether the bot has been /started or /stopped -started = False +logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s") # Try to import telepot # If not installed, inform user and fail gracefully @@ -19,20 +13,29 @@ try: except: print("radiodiodibot needs the telepot module to communicate with Telegram.") print("Please install telepot before using radiodiodibot.") - sys.exit() + sys.exit(1) + # Entry point def main(): - # Get the bot token as an argument from the user parser = argparse.ArgumentParser(description="Telegram bot for the Radiodiodi Student Radio broadcast.") - parser.add_argument("telegram_bot_token") + parser.add_argument("telegram_bot_token", help="Telegram Bot API token") + parser.add_argument("-U", "--shoutbox-api-url", help="Shoutbox API URL") args = parser.parse_args() token = args.telegram_bot_token + shoutbox_api_url = args.shoutbox_api_url manager = botmanager.BotManager(token) + + if (shoutbox_api_url != None): + manager.shoutbox_api_url = shoutbox_api_url + + logging.info("Using Shoutbox API URL: {}".format(manager.shoutbox_api_url)) + manager.start() + if __name__ == "__main__": main() |
