From 914d7034d0e0ebd0be712ca793fb34b8d6fec664 Mon Sep 17 00:00:00 2001 From: Von Random Date: Thu, 12 Dec 2024 22:15:18 +0200 Subject: [PATCH] move sensitive config to container vars --- pgbot | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pgbot b/pgbot index e1052d9..87bada7 100755 --- a/pgbot +++ b/pgbot @@ -20,14 +20,17 @@ def init(args: list) -> tuple: try: with open('pgbot.yml', 'r', encoding='utf-8') as data: config = yaml.safe_load(data.read()) - except FileNotFoundError as err: + api_id = os.environ['API_ID'] + api_hash = os.environ['API_HASH'] + bot_token = os.environ['BOT_TOKEN'] + db_spec = os.environ['DB_SPEC'] + except (FileNotFoundError, KeyError) as err: sys.exit(err) - client = telethon.TelegramClient( - 'bot_session', config['api_id'], - config['api_hash']).start(bot_token=config['bot_token']) + client = telethon.TelegramClient('bot_session', api_id, api_hash) + client.start(bot_token=bot_token) - db_conn = pgbotlib.dbstuff.DBConn(config['db_spec']) + db_conn = pgbotlib.dbstuff.DBConn(db_spec) return config, db_conn, client