forked from OrudoCA/qBitDownload-Bot
54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
|
#!/usr/bin/python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
#####################
|
||
|
# Aiogram bot logic #
|
||
|
#####################
|
||
|
|
||
|
# Imports
|
||
|
from asyncio import run
|
||
|
|
||
|
from tubot.db.abc import CacheDB
|
||
|
from tubot.dirgetter.abc import DirGetter
|
||
|
from tubot.static.init import init_modules
|
||
|
from tubot.static.controller import Controller
|
||
|
from tubot.static.env import BOT_TOKEN
|
||
|
from tubot.torrent.abc import TorrentAPI
|
||
|
|
||
|
from aiogram import Bot, Dispatcher, Router
|
||
|
|
||
|
# Init
|
||
|
|
||
|
## --- Modules --- ##
|
||
|
cache: CacheDB
|
||
|
dirgetter: DirGetter
|
||
|
torrent_api: TorrentAPI
|
||
|
ctrl: Controller
|
||
|
|
||
|
## --- Bot --- ##
|
||
|
bot: Bot
|
||
|
router: Router
|
||
|
dp: Dispatcher
|
||
|
|
||
|
|
||
|
async def initialize() -> None:
|
||
|
# --- Modules --- #
|
||
|
global cache, dirgetter, torrent_api, ctrl
|
||
|
torrent_api, dirgetter, cache = await init_modules()
|
||
|
ctrl = Controller(torrent_api, dirgetter, cache)
|
||
|
# --- Bot --- #
|
||
|
global router, dp, bot
|
||
|
router = Router()
|
||
|
dp = Dispatcher()
|
||
|
dp.include_router(router)
|
||
|
bot = Bot(BOT_TOKEN()())
|
||
|
await dp.start_polling(bot)
|
||
|
|
||
|
|
||
|
def main() -> None:
|
||
|
run(initialize())
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|