Feat: minimal configuration
This commit is contained in:
27
main.py
Normal file
27
main.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from sys import exit
|
||||
|
||||
import uvloop
|
||||
from aiogram import Bot, Dispatcher
|
||||
|
||||
from nwxraybot import Settings
|
||||
from nwxraybot.handlers import HelloHandler
|
||||
from nwxraybot.models import User
|
||||
|
||||
if __name__ == "__main__":
|
||||
config = Settings() # Load config from .env
|
||||
logging.basicConfig(level=logging.DEBUG if config.debug else logging.INFO)
|
||||
|
||||
print(config.postgres_url)
|
||||
|
||||
# Check if bot token is set
|
||||
if config.bot_token == 'token':
|
||||
logging.error("Bot token is not set")
|
||||
exit(1)
|
||||
|
||||
# Start bot
|
||||
bot = Bot(token=config.bot_token.get_secret_value())
|
||||
dp = Dispatcher()
|
||||
dp.include_routers(HelloHandler(bot)())
|
||||
uvloop.run(dp.start_polling(bot, skip_updates=True))
|
||||
Reference in New Issue
Block a user