feat: generate and validate config.ini
All checks were successful
Build / Upload to production (push) Successful in 1m38s

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2025-06-09 01:02:01 +03:00
parent c64075f84d
commit e448cbc45f
Signed by: mctaylors
GPG key ID: 4EEF4F949A266EE2
7 changed files with 113 additions and 77 deletions

11
main.py
View file

@ -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)