-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
46 lines (33 loc) · 1.06 KB
/
bot.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
37
38
39
40
41
42
43
44
45
46
# Main
import asyncio
import logging
# Env
from dotenv import load_dotenv
# Init and backend
import os
from aiogram import Dispatcher, Bot
from aiogram.contrib.fsm_storage.memory import MemoryStorage
# Handlers
from handlers.base import register_handler_base
from handlers.vps import register_handler_vps
from handlers.balance import register_handler_balance
logger = logging.getLogger(__name__)
async def main():
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(name)s - %(message)s'
)
logger.info('Getting environment variables')
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path)
logger.info('Starting Monitoring bot')
bot = Bot(token=os.getenv('API_BOT_TOKEN'))
dp = Dispatcher(bot, storage=MemoryStorage())
logger.info('Register handlers')
register_handler_base(dp)
register_handler_balance(dp)
register_handler_vps(dp)
await dp.start_polling()
if __name__ == '__main__':
asyncio.run(main())