Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update aiogram and aiogram-dialog #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

## Features

* ![aiogram 3](https://img.shields.io/badge/dev--3.x-aiogram-blue) as a main library
* ![aiogram 3](https://img.shields.io/badge/3.0.0-aiogram-blue) as a main library
* ![pyrogram](https://img.shields.io/badge/latest-pyrogram-orange) (Optional) for MTProto requests, such as bulk delete,
resolve by username and list participants in a group
* ![aiogram-dialog](https://img.shields.io/badge/beta--2.x-aiogram__dialog-green) (Optional) for creating multi-step
* ![aiogram-dialog](https://img.shields.io/badge/2.0.0-aiogram__dialog-green) (Optional) for creating multi-step
dialogs
* ☁️ Webhook and long polling with local Bot API server support
* 🎨 Beautiful and informative colored logs
Expand Down
20 changes: 10 additions & 10 deletions app/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,27 @@
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram.fsm.storage.redis import DefaultKeyBuilder, RedisStorage
from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application
from aiogram_dialog import DialogRegistry
from aiogram_dialog import setup_dialogs
from aiohttp import web
from pyrogram import Client

from app import db
from app.arguments import parse_arguments
from app.config import Config, parse_config
from app.db import close_orm, init_orm
from app.dialogs import register_dialogs
from app.dialogs import get_dialog_router
from app.handlers import get_handlers_router
from app.inline.handlers import get_inline_router
from app.middlewares import register_middlewares
from app.commands import remove_bot_commands, setup_bot_commands


async def on_startup(
dispatcher: Dispatcher, bot: Bot, config: Config, registry: DialogRegistry
):

async def on_startup(dispatcher: Dispatcher, bot: Bot, config: Config):
register_middlewares(dp=dispatcher, config=config)

dispatcher.include_router(get_handlers_router())
dispatcher.include_router(get_inline_router())

register_dialogs(registry)
dispatcher.include_router(get_dialog_router())

await setup_bot_commands(bot, config)

Expand Down Expand Up @@ -95,7 +91,11 @@ async def main():
except FileExistsError:
await db.migrate_models(tortoise_config)

session = AiohttpSession(api=TelegramAPIServer.from_base(config.api.bot_api_url, is_local=config.api.is_local))
session = AiohttpSession(
api=TelegramAPIServer.from_base(
config.api.bot_api_url, is_local=config.api.is_local
)
)
token = config.bot.token
bot_settings = {"session": session, "parse_mode": "HTML"}

Expand All @@ -113,7 +113,7 @@ async def main():
dp.startup.register(on_startup)
dp.shutdown.register(on_shutdown)

registry = DialogRegistry(dp)
registry = setup_dialogs(dp)

context_kwargs = {"config": config, "registry": registry}

Expand Down
12 changes: 8 additions & 4 deletions app/dialogs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from aiogram_dialog import DialogRegistry
from aiogram import Router


def register_dialogs(registry: DialogRegistry):
from . import sample_dialog
def get_dialog_router() -> Router:
from .sample_dialog import ui

registry.register(sample_dialog.ui)
dialog_routers = Router()

dialog_routers.include_router(ui)

return dialog_routers
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aerich
aiogram-dialog==2.0.0b11
aiogram==3.0.0b5
aiogram-dialog==2.0.0
aiogram==3.0.0
aiohttp
aiosqlite
cachetools
Expand Down