You've already forked Travel-Agent
feat: Added redis as storage for states, improvements in docker compose, added /cancel command, small improvements
This commit is contained in:
+18
-16
@@ -4,6 +4,7 @@ from typing import Optional
|
||||
|
||||
from aiogram import Bot, Dispatcher
|
||||
from aiogram.enums import ParseMode
|
||||
from aiogram.fsm.storage.redis import RedisStorage
|
||||
|
||||
from app.callbacks import profile
|
||||
from app.config import Config
|
||||
@@ -12,22 +13,23 @@ from app.middlewares.throttling import ThrottlingMiddleware
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
dp = Dispatcher()
|
||||
|
||||
bot_token: Optional[str] = Config.BOT_TOKEN
|
||||
if bot_token is not None:
|
||||
bot = Bot(bot_token, parse_mode=ParseMode.HTML)
|
||||
|
||||
dp.message.middleware(ThrottlingMiddleware(0.5))
|
||||
# type: ignore
|
||||
dp.include_routers(
|
||||
start_command.router,
|
||||
profile_command.router,
|
||||
profile.router,
|
||||
help_command.router,
|
||||
)
|
||||
|
||||
await bot.delete_webhook(drop_pending_updates=True)
|
||||
await dp.start_polling(bot)
|
||||
else:
|
||||
if bot_token is None:
|
||||
exit("BOT_TOKEN is not set")
|
||||
|
||||
storage = RedisStorage.from_url(Config.REDIS_URL)
|
||||
dp = Dispatcher(storage=storage)
|
||||
bot = Bot(bot_token, parse_mode=ParseMode.HTML)
|
||||
|
||||
dp.message.middleware(ThrottlingMiddleware(0.5))
|
||||
# type: ignore
|
||||
dp.include_routers(
|
||||
start_command.router,
|
||||
profile_command.router,
|
||||
profile.router, # type: ignore
|
||||
help_command.router,
|
||||
)
|
||||
|
||||
await bot.delete_webhook(drop_pending_updates=True)
|
||||
await dp.start_polling(bot)
|
||||
|
||||
Reference in New Issue
Block a user