Config.py (view raw)
1import logging
2from os import getenv
3from dotenv import load_dotenv
4load_dotenv()
5
6logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
7logging.getLogger("httpx").setLevel(logging.WARNING)
8logger = logging.getLogger(__name__)
9
10INLINE_SEP = 3 * "#"
11FEEDBACK_TIMEOUT = getenv("feedback_timeout", 3)
12
13def config_error():
14 logger.error("Please create and fill the .env file.")
15 exit(1)
16
17try:
18 TOKEN = str(getenv("token"))
19 GROUP_ID = int(getenv("group_id"))
20 CHANNEL_ID = int(getenv("channel_id"))
21 ADMIN_ID = int(getenv("admin_id"))
22except TypeError:
23 config_error()
24
25if '' in [TOKEN, GROUP_ID, CHANNEL_ID, ADMIN_ID]:
26 config_error()