feat: generate and validate config.ini
All checks were successful
Build / Upload to production (push) Successful in 1m38s
All checks were successful
Build / Upload to production (push) Successful in 1m38s
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
c64075f84d
commit
e448cbc45f
7 changed files with 113 additions and 77 deletions
11
main.py
11
main.py
|
@ -1,10 +1,9 @@
|
|||
import logging
|
||||
import os
|
||||
import config
|
||||
|
||||
from telegram.ext import CommandHandler, InlineQueryHandler, ApplicationBuilder
|
||||
|
||||
from config import general
|
||||
|
||||
logging.basicConfig(
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
|
||||
)
|
||||
|
@ -15,6 +14,8 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def main() -> None:
|
||||
config.init_config()
|
||||
|
||||
application = ApplicationBuilder().token(get_token()).build()
|
||||
|
||||
import commands
|
||||
|
@ -39,11 +40,11 @@ def get_token() -> str:
|
|||
if os.getenv("BOT_TOKEN") is not None:
|
||||
return os.getenv("BOT_TOKEN")
|
||||
|
||||
if general.token != "":
|
||||
return general.token
|
||||
if config.general.token != "":
|
||||
return config.general.token
|
||||
|
||||
print(
|
||||
"Set BOT_TOKEN environment variable or use General.Token in config.ini to set bot token."
|
||||
f"Set BOT_TOKEN environment variable or use 'Token' option in section [General] in {config.config_file} to set bot token."
|
||||
)
|
||||
exit(1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue