-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
36 lines (25 loc) · 1001 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from dotenv import load_dotenv
# Specifies the path of the .env file which contains environment variables.
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
# Loads the .env file.
load_dotenv(dotenv_path)
# Gets the Bot API token from environment variable.
BOT_API = os.getenv('BOT_API')
# Gets the chat ID from environment variable and converts it to integer.
CHAT_ID = int(os.getenv('CHAT_ID'))
# Gets the start message from environment variable,
# defaults to 'Hello World!' if not set.
START_MSG = os.getenv('START_MSG', 'Hello World!')
def check_credentials():
"""
Checks if the Bot API token and chat ID are set in
the environment variables.
Returns:
str: Error message if either the Bot API token or chat ID is not set.
"""
if not [BOT_API, CHAT_ID]:
return 'You must create .env file with BOT_API and CHAT_ID'
# Calls the check_credentials function to ensure the
# Bot API token and chat ID are set.
check_credentials()