Skip to content

Commit

Permalink
Allow bot token to be specified via BOT_TOKEN_FROM_FILE
Browse files Browse the repository at this point in the history
  • Loading branch information
Anze committed Dec 7, 2019
1 parent bec3678 commit 7e8d459
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pingcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,15 @@ def do_ping(*args, **job_info):

backend_url = os.environ.get('BACKEND_URL')
bot_token = os.environ.get('BOT_TOKEN')
if not bot_token:
# bot token can also be specified via contents of a file:
bot_token_from_file = os.environ.get('BOT_TOKEN_FROM_FILE')
if bot_token_from_file:
with open(bot_token_from_file, 'rt') as f:
bot_token = f.read()

if not backend_url or not bot_token:
raise Exception("Please specify BACKEND_URL and BOT_TOKEN env vars.")
raise Exception("Please specify BACKEND_URL and BOT_TOKEN / BOT_TOKEN_FROM_FILE env vars.")
jobs_refresh_interval = int(os.environ.get('JOBS_REFRESH_INTERVAL', 120))

c = PingCollector(backend_url, bot_token, jobs_refresh_interval)
Expand Down

0 comments on commit 7e8d459

Please sign in to comment.