move sensitive config to container vars
This commit is contained in:
parent
5ab4204fe2
commit
914d7034d0
1 changed files with 8 additions and 5 deletions
13
pgbot
13
pgbot
|
@ -20,14 +20,17 @@ def init(args: list) -> tuple:
|
||||||
try:
|
try:
|
||||||
with open('pgbot.yml', 'r', encoding='utf-8') as data:
|
with open('pgbot.yml', 'r', encoding='utf-8') as data:
|
||||||
config = yaml.safe_load(data.read())
|
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)
|
sys.exit(err)
|
||||||
|
|
||||||
client = telethon.TelegramClient(
|
client = telethon.TelegramClient('bot_session', api_id, api_hash)
|
||||||
'bot_session', config['api_id'],
|
client.start(bot_token=bot_token)
|
||||||
config['api_hash']).start(bot_token=config['bot_token'])
|
|
||||||
|
|
||||||
db_conn = pgbotlib.dbstuff.DBConn(config['db_spec'])
|
db_conn = pgbotlib.dbstuff.DBConn(db_spec)
|
||||||
|
|
||||||
return config, db_conn, client
|
return config, db_conn, client
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue