move sensitive config to container vars

This commit is contained in:
Von Random 2024-12-12 22:15:18 +02:00
parent 5ab4204fe2
commit 914d7034d0

13
pgbot
View file

@ -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