-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBotMain.py
More file actions
36 lines (28 loc) · 1.24 KB
/
BotMain.py
File metadata and controls
36 lines (28 loc) · 1.24 KB
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
from aiogram import Bot
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.contrib.middlewares.logging import LoggingMiddleware
from common import ThrottlingMiddleware
from handlers import greeting, store, profile, dayShift, taxCheck, brawlOrder, help, casino
from BotConfigs import USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE_NAME, TOKEN, COMMAND_LIMIT
import BotDataBase
dbEngine = BotDataBase.Connect()
bot = Bot(token=TOKEN, parse_mode="HTML")
#storage = RedisStorage2('localhost', 6379, db=5, pool_size=10, prefix='gay')
storage = MemoryStorage()
dispatcher = Dispatcher(bot, storage=storage)
dispatcher.middleware.setup(ThrottlingMiddleware(60 / COMMAND_LIMIT))
greeting.register_handlers(dispatcher)
store.register_handlers(dispatcher)
profile.register_handlers(dispatcher)
dayShift.register_handlers(dispatcher)
taxCheck.register_handlers(dispatcher)
brawlOrder.register_handlers(dispatcher)
help.register_handlers(dispatcher)
casino.register_handlers(dispatcher)
async def onShutdown(dp: Dispatcher):
await dp.storage.close()
await dp.storage.wait_closed()
if __name__ == '__main__':
executor.start_polling(dispatcher, on_shutdown=onShutdown)