diff --git a/bot/__init__.py b/bot/__init__.py index ddf1b31..19b45d4 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -1,10 +1,10 @@ import logging import aria2p import threading -import telegram.ext as tg -from telegram import Bot import os -import configparser +from dotenv import load_dotenv +from telegram import Bot +import telegram.ext as tg import time botStartTime = time.time() @@ -16,13 +16,12 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s handlers=[logging.FileHandler('log.txt'), logging.StreamHandler()], level=logging.INFO) -config = configparser.ConfigParser() -config.read('bot/config.ini') +load_dotenv('config.env') Interval = [] def getConfig(name: str): - return config['DEFAULT'][name] + return os.environ[name] LOGGER = logging.getLogger(__name__) @@ -75,7 +74,7 @@ except KeyError as e: LOGGER.error("One or more env variables missing! Exiting now") exit(1) -bot = Bot(BOT_TOKEN) +bot = Bot(BOT_TOKEN) updater = tg.Updater(token=BOT_TOKEN) dispatcher = updater.dispatcher diff --git a/requirements.txt b/requirements.txt index b2ac741..c1155bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ google-api-python-client>=1.7.11,<1.7.20 google-auth-httplib2>=0.0.3,<0.1.0 google-auth-oauthlib>=0.4.1,<0.10.0 aria2p>=0.3.0,<0.10.0 +python-dotenv>=0.10