Deprecate filters factory (#976)

* Deprecate filters factory

* Added changelog

* Update filters usage in docs and examples
This commit is contained in:
Alex Root Junior 2022-08-14 18:40:41 +03:00 committed by GitHub
parent c1341ba2df
commit 0e0dbe7e59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 67 additions and 23 deletions

View file

@ -1,6 +1,7 @@
import logging
from aiogram import Bot, Dispatcher, types
from aiogram.filters import Command
from aiogram.types import Message
TOKEN = "42:TOKEN"
@ -9,7 +10,7 @@ dp = Dispatcher()
logger = logging.getLogger(__name__)
@dp.message(commands=["start"])
@dp.message(Command(commands=["start"]))
async def command_start_handler(message: Message) -> None:
"""
This handler receive messages with `/start` command

View file

@ -5,6 +5,7 @@ from os import getenv
from typing import Any, Dict
from aiogram import Bot, Dispatcher, F, Router, html
from aiogram.filters import Command
from aiogram.fsm.context import FSMContext
from aiogram.fsm.state import State, StatesGroup
from aiogram.types import KeyboardButton, Message, ReplyKeyboardMarkup, ReplyKeyboardRemove
@ -18,7 +19,7 @@ class Form(StatesGroup):
language = State()
@form_router.message(commands=["start"])
@form_router.message(Command(commands=["start"]))
async def command_start(message: Message, state: FSMContext) -> None:
await state.set_state(Form.name)
await message.answer(
@ -27,7 +28,7 @@ async def command_start(message: Message, state: FSMContext) -> None:
)
@form_router.message(commands=["cancel"])
@form_router.message(Command(commands=["cancel"]))
@form_router.message(F.text.casefold() == "cancel")
async def cancel_handler(message: Message, state: FSMContext) -> None:
"""

View file

@ -1,6 +1,7 @@
import logging
from aiogram import Bot, Dispatcher, Router
from aiogram.filters import Command
from aiogram.types import (
CallbackQuery,
ChatMemberUpdated,
@ -16,7 +17,7 @@ logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
@dp.message(commands=["start"])
@dp.message(Command(commands=["start"]))
async def command_start_handler(message: Message) -> None:
"""
This handler receive messages with `/start` command
@ -71,7 +72,7 @@ async def my_chat_member_change(chat_member: ChatMemberUpdated, bot: Bot) -> Non
def main() -> None:
# Initialize Bot instance with an default parse mode which will be passed to all API calls
# Initialize Bot instance with a default parse mode which will be passed to all API calls
bot = Bot(TOKEN, parse_mode="HTML")
sub_router.include_router(deep_dark_router)