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