From 60f10fa72e4f359e247648366207cc716e71cc19 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 29 Mar 2017 09:32:38 +0200 Subject: [PATCH] New configuration system, this time for real --- .gitignore | 3 --- royalbotconfig.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 royalbotconfig.py diff --git a/.gitignore b/.gitignore index b108dbc7..a2870570 100644 --- a/.gitignore +++ b/.gitignore @@ -92,9 +92,6 @@ ENV/ .idea/ -# config file -royalbotconfig.py - # grandbot.py files diario.txt diff --git a/royalbotconfig.py b/royalbotconfig.py new file mode 100644 index 00000000..6f150f45 --- /dev/null +++ b/royalbotconfig.py @@ -0,0 +1,19 @@ +import os + +class MissingTokenError(Exception): + pass + +if "telegram_token" in os.environ: + telegram_token = os.environ["telegram_token"] +else: + raise MissingTokenError("telegram_token") + +if "discord_token" in os.environ: + discord_token = os.environ["discord_token"] +else: + raise MissingTokenError("discord_token") + +if "discord_webhook" in os.environ: + discord_webhook = os.environ["discord_webhook"] +else: + raise MissingTokenError("discord_webhook")