From 539664743c577c1e3a508d59d2c8223dab2ff995 Mon Sep 17 00:00:00 2001 From: Shizun Ge Date: Sun, 13 Feb 2022 17:26:16 -0800 Subject: [PATCH] read telegram token from file. --- src/bot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bot.py b/src/bot.py index 38559c7..695417e 100644 --- a/src/bot.py +++ b/src/bot.py @@ -164,7 +164,13 @@ def main(): else: data_dir = Path(data_dir) bot_persistence = PicklePersistence(filename=str(data_dir/"bot-data")) - bot_token = os.getenv("TELEGRAM_BOT_TOKEN") + bot_token_file_path = os.getenv("TELEGRAM_BOT_TOKEN_FILE") + if bot_token_file_path: + with open(bot_token_file_path, 'r') as f: + bot_token = f.readline().split()[0] + else: + bot_token = os.getenv("TELEGRAM_BOT_TOKEN") + updater = Updater(bot_token, persistence=bot_persistence, use_context=True)