Refactor bot and integrate services
This commit is contained in:
36
main.py
Normal file
36
main.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import asyncio
|
||||
import socket
|
||||
from datetime import datetime
|
||||
from app import bot, dp, cfg, ADMIN_ID
|
||||
from keyboards import menu_kb
|
||||
from services.docker import discover_containers, docker_watchdog
|
||||
from services.notify import notify
|
||||
import state
|
||||
import handlers.menu
|
||||
import handlers.status
|
||||
import handlers.docker
|
||||
import handlers.backup
|
||||
import handlers.artifacts
|
||||
import handlers.system
|
||||
import handlers.help
|
||||
import handlers.callbacks
|
||||
|
||||
|
||||
async def notify_start():
|
||||
await bot.send_message(
|
||||
ADMIN_ID,
|
||||
f"🤖 Bot started\n🖥 {socket.gethostname()}\n🕒 {datetime.now():%Y-%m-%d %H:%M}",
|
||||
reply_markup=menu_kb,
|
||||
)
|
||||
|
||||
|
||||
async def main():
|
||||
state.DOCKER_MAP = await discover_containers(cfg)
|
||||
if cfg.get("docker", {}).get("watchdog", True):
|
||||
asyncio.create_task(docker_watchdog(state.DOCKER_MAP, notify, bot, ADMIN_ID))
|
||||
await notify_start()
|
||||
await dp.start_polling(bot)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user