### Setup Project with uv Source: https://docs.aiogram.dev/en/latest/contributing.html Clones the aiogram repository and installs all dependencies using uv, automatically creating a virtual environment. ```bash git clone https://github.com/aiogram/aiogram.git cd aiogram uv sync --all-extras --group dev --group test uv run pre-commit install ``` -------------------------------- ### Setup Project with Pip (Windows) Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Installs aiogram in editable mode along with development, testing, documentation, and other optional dependencies on Windows. ```bash pip install -e .[dev,test,docs,fast,redis,mongo,proxy,i18n] ``` -------------------------------- ### Setup Project with Pip (Linux/macOS) Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Installs aiogram in editable mode along with development, testing, documentation, and other optional dependencies. ```bash pip install -e ."[dev,test,docs,fast,redis,mongo,proxy,i18n]" ``` -------------------------------- ### Setup Project with uv Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Clones the aiogram repository and installs all dependencies, including development extras, using uv. This command also automatically creates a .venv directory. ```bash git clone https://github.com/aiogram/aiogram.git cd aiogram uv sync --all-extras --group dev --group test ``` -------------------------------- ### Start Documentation Server (uv) Source: https://docs.aiogram.dev/en/latest/contributing.html Starts the documentation server using sphinx-autobuild, executed within the uv managed environment. ```bash uv run sphinx-autobuild --watch aiogram/ docs/ docs/_build/ ``` -------------------------------- ### Install uv (Windows) Source: https://docs.aiogram.dev/en/latest/contributing.html Installs the uv package manager using PowerShell on Windows. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install uv using pip Source: https://docs.aiogram.dev/en/latest/contributing.html Installs the uv package manager using pip. ```bash pip install uv ``` -------------------------------- ### Start Documentation Server with sphinx-autobuild (uv) Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Starts a local documentation server that automatically rebuilds on changes, using sphinx-autobuild within the uv-managed environment. ```bash uv run sphinx-autobuild --watch aiogram/ docs/ docs/_build/ ``` -------------------------------- ### Complete FSM Example Source: https://docs.aiogram.dev/en/latest/_sources/dispatcher/finite_state_machine/index.rst.txt A complete example demonstrating the implementation of a finite state machine for a multi-step conversation flow. ```python import logging from aiogram import Bot, Dispatcher, executor, types from aiogram.contrib.fsm_storage.memory import MemoryStorage from aiogram.dispatcher import FSMContext from aiogram.dispatcher.filters.state import State, StatesGroup from aiogram.utils.markdown import hbold API_TOKEN = '...' # log logging.basicConfig(level=logging.INFO) # states class Form(StatesGroup): name = State() # Will be represented in the storage as 'Form:name' like_bots = State() language = State() # All handlers should be attached to the Router (or Dispatcher) @dp.message_handler(commands=['start']) async def command_start(message: types.Message): # Set state await Form.name.set() # Send a message await message.reply("What is your name?") @dp.message_handler(state=Form.name) async def process_name(message: types.Message): # Update state and data async with state.proxy() as data: data['name'] = message.text # Change state await Form.next() await message.reply(f"Hi {hbold(message.text)}! What bots do you like to write?") @dp.message_handler(state=Form.like_bots, text='yes') async def process_like_write_bots(message: types.Message): # Update state and data async with state.proxy() as data: data['like_bots'] = message.text.lower() # Change state await Form.next() await message.reply("What language do you use to write bots?") @dp.message_handler(state=Form.like_bots, text='no') async def process_dont_like_write_bots(message: types.Message): # Update state and data async with state.proxy() as data: data['like_bots'] = message.text.lower() # Change state await Form.next() await message.reply("What language do you use to write bots?") @dp.message_handler(state=Form.like_bots) async def process_unknown_write_bots(message: types.Message): # Update state and data async with state.proxy() as data: data['like_bots'] = message.text.lower() # Change state await Form.next() await message.reply("What language do you use to write bots?") @dp.message_handler(state=Form.language) async def process_language(message: types.Message): # Update state and data async with state.proxy() as data: data['language'] = message.text.lower() # Update state and data await state.finish() await message.reply(f""" Thank you! Your data: Name: {hbold(data.get('name'))} Bots: {hbold(data.get('like_bots'))} Language: {hbold(data.get('language'))} """) @dp.message_handler(state='*', commands='cancel') @dp.message_handler(state='*', text='cancel') async def cancel_handler(message: types.Message): # Get current state current_state = await state.get_state() if current_state is None: # User is not in any state return # Cancel state await state.finish() # And remove keyboard await message.reply('Cancelled.', reply_markup=types.ReplyKeyboardRemove()) if __name__ == '__main__': executor.start_polling(dp, skip_updates=True) ``` -------------------------------- ### Create Basic Start Link Source: https://docs.aiogram.dev/en/latest/_sources/utils/deep_linking.rst.txt Use `create_start_link` to generate a Telegram bot start link with a simple payload. The payload is appended directly to the URL. ```python from aiogram.utils.deep_linking import create_start_link link = await create_start_link(bot, 'foo') # result: 'https://t.me/MyBot?start=foo' ``` -------------------------------- ### Serve Documentation with Makefile Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Start the documentation live preview server using the provided Makefile. ```bash make docs-serve ``` -------------------------------- ### Echo Bot Webhook Example Source: https://docs.aiogram.dev/en/latest/_sources/dispatcher/webhook.rst.txt Example of an echo bot using aiohttp for webhook handling. This snippet demonstrates the basic setup for receiving and responding to Telegram updates via a webhook. ```python import logging import ssl from aiohttp import web from aiogram import Bot, Dispatcher, types from aiogram.webhook.aiohttp_server import SimpleRequestHandler, TokenBasedRequestHandler API_TOKEN = "5512345678:AAHmeM... ``` -------------------------------- ### Serve Documentation with Sphinx-Autobuild (uv) Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Start a live preview server for documentation using uv and sphinx-autobuild. Watch for changes in the aiogram directory. ```bash uv run --extra docs sphinx-autobuild --watch aiogram/ docs/ docs/_build/ ``` -------------------------------- ### Get User Chat Boosts as Bot Method Source: https://docs.aiogram.dev/en/latest/_sources/api/methods/get_user_chat_boosts.rst.txt Example of calling the getUserChatBoosts method directly on the bot object. ```python result: UserChatBoosts = await bot.get_user_chat_boosts(...) ``` -------------------------------- ### Serve Translated Documentation (Traditional) Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Start a live preview server for documentation, specifying the language code to view translated content. ```bash sphinx-autobuild --watch aiogram/ docs/ docs/_build/ -D language= ``` -------------------------------- ### Serve Translated Documentation (uv) Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Start a live preview server for documentation using uv, specifying the language code to view translated content. ```bash uv run --extra docs sphinx-autobuild --watch aiogram/ docs/ docs/_build/ -D language= ``` -------------------------------- ### Get Game High Scores as Bot Method Source: https://docs.aiogram.dev/en/latest/_sources/api/methods/get_game_high_scores.rst.txt Example of calling the get_game_high_scores method directly on the bot object. Ensure you have the necessary parameters for the method. ```python result: list[GameHighScore] = await bot.get_game_high_scores(...) ``` -------------------------------- ### Simple Echo Bot using Long-Polling Source: https://docs.aiogram.dev/en/latest/_sources/dispatcher/long_polling.rst.txt This example demonstrates how to create a basic echo bot that responds to messages using the long-polling method. Ensure you have aiogram installed. ```python import logging from aiogram import Bot, Dispatcher, types from aiogram.utils import executor API_TOKEN = 'YOUR API TOKEN' # For this example we'll send # all پولled messages to all subscribed chats # Configure logging logging.basicConfig(level=logging.INFO) # Initialize bot and dispatcher bot = Bot(token=API_TOKEN) dp = Dispatcher(bot) @dp.message_handler() async def echo(message: types.Message): """ This handler will be called when any user sends a message. It echoes the message back to the user. """ # Do something with message await message.answer(message.text) if __name__ == '__main__': # Start polling executor.start_polling(dp, skip_updates=True) ``` -------------------------------- ### Serve Documentation with Sphinx-Autobuild (Traditional) Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Start a live preview server for documentation using sphinx-autobuild. Watch for changes in the aiogram directory. ```bash sphinx-autobuild --watch aiogram/ docs/ docs/_build/ ``` -------------------------------- ### Register Shipping Query Handler Source: https://docs.aiogram.dev/en/latest/_sources/dispatcher/router.rst.txt Example for registering a handler to process shipping queries, which are part of the Telegram Payments API. This is used to get shipping details from the user. ```python @router.shipping_query() async def shipping_query_handler(shipping_query: types.ShippingQuery) -> Any: pass ``` -------------------------------- ### Example Usage Source: https://docs.aiogram.dev/en/latest/api/defaults.html Demonstrates how to initialize a Bot with default properties and how to override them for specific requests. ```APIDOC ## Example ### Setting Default Parse Mode ```python bot = Bot( token=..., default=DefaultBotProperties( parse_mode=ParseMode.HTML, ) ) ``` This sets the default parse mode to HTML for all messages sent by the bot. ### Overriding Default Properties To override a default property for a specific request, pass an explicit value to the method: ```python # Override parse_mode to MarkdownV2 await bot.send_message(chat_id, text, parse_mode=ParseMode.MARKDOWN_V2) # Override parse_mode to None (no parse mode) await bot.send_message(chat_id, text, parse_mode=None) # Sending a message with entities and no parse mode await bot.send_message( chat_id=chat_id, text=text, entities=[MessageEntity(type='bold', offset=0, length=4)], parse_mode=None ) ``` ``` -------------------------------- ### Get User Chat Boosts with Specific Bot Instance Source: https://docs.aiogram.dev/en/latest/_sources/api/methods/get_user_chat_boosts.rst.txt Example of calling the GetUserChatBoosts method object with a specific bot instance. Ensure necessary imports are made. ```python from aiogram.methods.get_user_chat_boosts import GetUserChatBoosts result: UserChatBoosts = await bot(GetUserChatBoosts(...)) ``` ```python from aiogram.methods import GetUserChatBoosts result: UserChatBoosts = await bot(GetUserChatBoosts(...)) ``` -------------------------------- ### Serve documentation with sphinx-autobuild Source: https://docs.aiogram.dev/en/latest/contributing.html Start a live-preview server for Sphinx documentation. Changes in the docs directory will trigger automatic rebuilding and browser refresh. ```bash sphinx-autobuild --watch aiogram/ docs/ docs/_build/ ``` -------------------------------- ### Get Game High Scores as Method Object Source: https://docs.aiogram.dev/en/latest/_sources/api/methods/get_game_high_scores.rst.txt Example of using GetGameHighScores as a method object with a specific bot instance. This approach requires importing the GetGameHighScores class. ```python from aiogram.methods.get_game_high_scores import GetGameHighScores result: list[GameHighScore] = await bot(GetGameHighScores(...)) ``` -------------------------------- ### Example of a custom text filter Source: https://docs.aiogram.dev/en/latest/_sources/dispatcher/filters/index.rst.txt Demonstrates creating a simple text filter by subclassing aiogram.filters.base.Filter. This filter checks if the event text starts with a specific prefix and ends with a specific suffix. ```python from aiogram.filters import Filter from aiogram.types import Message class SimpleTextFilter(Filter): def __init__(self, prefix: str = '', suffix: str = '') -> None: self.prefix = prefix self.suffix = suffix async def __call__(self, message: Message) -> bool: return message.text.startswith(self.prefix) and message.text.endswith(self.suffix) ``` -------------------------------- ### Makefile Commands with uv support Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Demonstrates how to use Makefile commands that are configured to utilize uv for tasks like installation, linting, reformatting, and testing. ```bash make install make lint make reformat make test ``` -------------------------------- ### Python Webhook Setup with SSL Source: https://docs.aiogram.dev/en/latest/dispatcher/webhook.html This example demonstrates setting up a Telegram bot webhook using aiohttp with a self-signed SSL certificate. It includes bot token, server settings, webhook paths, and SSL certificate paths. Ensure you replace placeholder paths with your actual certificate and key locations. ```python """ This example shows how to use webhook with SSL certificate. """ import logging import ssl import sys from os import getenv from aiohttp import web from aiogram import Bot, Dispatcher, Router from aiogram.client.default import DefaultBotProperties from aiogram.enums import ParseMode from aiogram.filters import CommandStart from aiogram.types import FSInputFile, Message from aiogram.utils.markdown import hbold from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application # Bot token can be obtained via https://t.me/BotFather TOKEN = getenv("BOT_TOKEN") # Webserver settings # bind localhost only to prevent any external access WEB_SERVER_HOST = "127.0.0.1" # Port for incoming request from reverse proxy. Should be any available port WEB_SERVER_PORT = 8080 # Path to webhook route, on which Telegram will send requests WEBHOOK_PATH = "/webhook" # Secret key to validate requests from Telegram (optional) WEBHOOK_SECRET = "my-secret" # Base URL for webhook will be used to generate webhook URL for Telegram, # in this example it is used public address with TLS support BASE_WEBHOOK_URL = "https://aiogram.dev" # Path to SSL certificate and private key for self-signed certificate. WEBHOOK_SSL_CERT = "/path/to/cert.pem" WEBHOOK_SSL_PRIV = "/path/to/private.key" # All handlers should be attached to the Router (or Dispatcher) router = Router() @router.message(CommandStart()) async def command_start_handler(message: Message) -> None: """ This handler receives messages with `/start` command """ # Most event objects have aliases for API methods that can be called in events' context # For example if you want to answer to incoming message you can use `message.answer(...)` alias # and the target chat will be passed to :ref:`aiogram.methods.send_message.SendMessage` # method automatically or call API method directly via # Bot instance: `bot.send_message(chat_id=message.chat.id, ...)` await message.answer(f"Hello, {hbold(message.from_user.full_name)}!") @router.message() async def echo_handler(message: Message) -> None: """ Handler will forward receive a message back to the sender By default, message handler will handle all message types (like text, photo, sticker etc.) """ try: # Send a copy of the received message await message.send_copy(chat_id=message.chat.id) except TypeError: # But not all the types is supported to be copied so need to handle it await message.answer("Nice try!") async def on_startup(bot: Bot) -> None: # In case when you have a self-signed SSL certificate, you need to send the certificate # itself to Telegram servers for validation purposes # (see https://core.telegram.org/bots/self-signed) # But if you have a valid SSL certificate, you SHOULD NOT send it to Telegram servers. await bot.set_webhook( f"{BASE_WEBHOOK_URL}{WEBHOOK_PATH}", certificate=FSInputFile(WEBHOOK_SSL_CERT), secret_token=WEBHOOK_SECRET, ) def main() -> None: # Dispatcher is a root router dp = Dispatcher() # ... and all other routers should be attached to Dispatcher dp.include_router(router) # Register startup hook to initialize webhook dp.startup.register(on_startup) # Initialize Bot instance with default bot properties which will be passed to all API calls bot = Bot(token=TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML)) # Create aiohttp.web.Application instance app = web.Application() # Create an instance of request handler, # aiogram has few implementations for different cases of usage # In this example we use SimpleRequestHandler which is designed to handle simple cases webhook_requests_handler = SimpleRequestHandler( dispatcher=dp, bot=bot, secret_token=WEBHOOK_SECRET, ) # Register webhook handler on application webhook_requests_handler.register(app, path=WEBHOOK_PATH) # Mount dispatcher startup and shutdown hooks to aiohttp application setup_application(app, dp, bot=bot) # Generate SSL context context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) context.load_cert_chain(WEBHOOK_SSL_CERT, WEBHOOK_SSL_PRIV) # And finally start webserver web.run_app(app, host=WEB_SERVER_HOST, port=WEB_SERVER_PORT, ssl_context=context) if __name__ == "__main__": logging.basicConfig(level=logging.INFO, stream=sys.stdout) main() ``` -------------------------------- ### Install uv Package Manager Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Installs the uv package manager using a script for Linux/macOS or PowerShell for Windows. Alternatively, it can be installed via pip. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` ```bash pip install uv ``` -------------------------------- ### Initialize MediaGroupBuilder and add media Source: https://docs.aiogram.dev/en/latest/_sources/utils/media_group.rst.txt Demonstrates how to create a MediaGroupBuilder instance with an optional caption and add various media types like photos and videos, including using FSInputFile for local files. ```python media_group = MediaGroupBuilder(caption="Media group caption") # Add photo media_group.add_photo(media="https://picsum.photos/200/300") # Dynamically add photo with known type without using separate method media_group.add(type="photo", media="https://picsum.photos/200/300") # ... or video media_group.add(type="video", media=FSInputFile("media/video.mp4")) ``` -------------------------------- ### setup_application Source: https://docs.aiogram.dev/en/latest/_modules/aiogram/webhook/aiohttp_server.html Configures the startup and shutdown processes for an aiohttp application and an aiogram dispatcher. This function ensures that the dispatcher's startup and shutdown signals are emitted correctly when the aiohttp application starts or stops. ```APIDOC ## setup_application ### Description This function helps to configure a startup-shutdown process for an aiohttp application and an aiogram dispatcher. It connects the dispatcher's startup and shutdown events to the aiohttp application's lifecycle. ### Parameters * **app** (Application) - Required - The aiohttp application instance. * **dispatcher** (Dispatcher) - Required - The aiogram dispatcher instance. * **kwargs** (Any) - Optional - Additional data to be passed to the dispatcher's startup and shutdown events. ``` -------------------------------- ### emit_startup Source: https://docs.aiogram.dev/en/latest/_modules/aiogram/dispatcher/router.html Recursively calls startup callbacks for the current router and all its sub-routers. ```APIDOC ## emit_startup ### Description Recursively call startup callbacks. ### Parameters #### Path Parameters - **args** (Any) - Optional - Positional arguments to pass to the startup callbacks. - **kwargs** (Any) - Optional - Keyword arguments to pass to the startup callbacks. ``` -------------------------------- ### Install Babel for Translation Source: https://docs.aiogram.dev/en/latest/utils/i18n.html Install the Babel library, which is required for extracting translation strings from your code. ```bash pip install Babel ``` -------------------------------- ### Dispatcher Initialization and Basic Usage Source: https://docs.aiogram.dev/en/latest/_sources/dispatcher/dispatcher.rst.txt Demonstrates how to initialize a Dispatcher instance and set up a basic message handler. ```APIDOC ## Dispatcher() ### Description Initializes a new Dispatcher instance. ### Method __init__ ### Parameters None ### Request Example ```python dp = Dispatcher() ``` ### Response None ``` ```APIDOC ## @dp.message() ### Description Decorator to register a message handler. ### Method message() ### Parameters None ### Request Example ```python @dp.message() async def message_handler(message: types.Message) -> None: await SendMessage(chat_id=message.from_user.id, text=message.text) ``` ### Response None ``` -------------------------------- ### Install uv (Linux/macOS) Source: https://docs.aiogram.dev/en/latest/contributing.html Installs the uv package manager using a curl command on Linux or macOS. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Main Bot Execution Source: https://docs.aiogram.dev/en/latest/dispatcher/finite_state_machine/scene.html Sets up the Dispatcher and Bot, then starts polling for updates to run the bot. ```python async def main() -> None: dp = create_dispatcher() bot = Bot(token=TOKEN) await dp.start_polling(bot) ``` -------------------------------- ### Upgrade pip Source: https://docs.aiogram.dev/en/latest/_sources/contributing.rst.txt Ensures you have the latest version of pip installed in your virtual environment to prevent installation errors. ```bash python -m pip install --upgrade pip ``` -------------------------------- ### Install aiogram with i18n dependency Source: https://docs.aiogram.dev/en/latest/migration_2_to_3.html If your application uses translation functionality, install aiogram with the optional i18n dependency. ```bash pip install aiogram[i18n] ``` -------------------------------- ### Simple Usage of PreCheckoutQueryHandler Source: https://docs.aiogram.dev/en/latest/_sources/dispatcher/class_based_handlers/pre_checkout_query.rst.txt Demonstrates how to use PreCheckoutQueryHandler by subclassing it and decorating it with a router. This is the basic setup for handling pre-checkout queries. ```python from aiogram.handlers import PreCheckoutQueryHandler ... @router.pre_checkout_query() class MyHandler(PreCheckoutQueryHandler): async def handle(self) -> Any: ... ``` -------------------------------- ### Install aiogram Development Build from GitHub Source: https://docs.aiogram.dev/en/latest/_sources/install.rst.txt Install the latest development version of aiogram directly from its GitHub repository. ```bash pip install https://github.com/aiogram/aiogram/archive/refs/heads/dev-3.x.zip ``` -------------------------------- ### CommandStart Source: https://docs.aiogram.dev/en/latest/_modules/aiogram/filters/command.html A specific command filter for handling the '/start' command, with options for deep linking and case/mention sensitivity. ```APIDOC ## Class: CommandStart ### Description A filter for the "start" command. Supports deep linking. ### Initializer Parameters - **deep_link** (bool | None) - If True, the filter will try to extract a deep link from the command. If None, it will not process deep links. Defaults to None. - **deep_link_encoded** (bool) - If True, the deep link will be URL-decoded. Defaults to False. - **ignore_case** (bool) - If True, the command matching will be case-insensitive. Defaults to False. - **ignore_mention** (bool) - If True, the filter will ignore mentions in the command. Defaults to False. - **magic** (MagicFilter | None) - A magic filter to apply to the command. Defaults to None. ### Method #### async parse_command(text: str, bot: Bot) -> CommandObject Extract command from the text and validate. - **text** (str) - The input text to parse. - **bot** (Bot) - The bot instance. :return: A CommandObject representing the parsed command. ``` -------------------------------- ### Makefile Commands for uv Source: https://docs.aiogram.dev/en/latest/contributing.html Demonstrates Makefile commands that leverage uv for common development tasks like installation, linting, reformatting, and testing. ```makefile make install # Uses uv sync make lint # Uses uv run make reformat # Uses uv run make test # Uses uv run ``` -------------------------------- ### Install aiogram from PyPI Source: https://docs.aiogram.dev/en/latest/_sources/install.rst.txt Use this command to install the latest stable version of aiogram from the Python Package Index. ```bash pip install -U aiogram ``` -------------------------------- ### Send Photo Example Source: https://docs.aiogram.dev/en/latest/_modules/aiogram/types/inaccessible_message.html Example of sending a photo using the SendPhoto method. It automatically fills chat_id and other parameters. ```python return SendPhoto( chat_id=self.chat.id, reply_parameters=self.as_reply_parameters(), photo=photo, business_connection_id=business_connection_id, message_thread_id=message_thread_id, direct_messages_topic_id=direct_messages_topic_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, show_caption_above_media=show_caption_above_media, has_spoiler=has_spoiler, disable_notification=disable_notification, protect_content=protect_content, allow_paid_broadcast=allow_paid_broadcast, message_effect_id=message_effect_id, suggested_post_parameters=suggested_post_parameters, reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, **kwargs, ).as_(self._bot) ``` -------------------------------- ### Start Command Handler Source: https://docs.aiogram.dev/en/latest/dispatcher/finite_state_machine/scene.html Handles the /start command, closing any active scenes and providing introductory text to the user. ```python @quiz_router.message(Command("start")) async def command_start(message: Message, scenes: ScenesManager) -> None: await scenes.close() await message.answer( "Hi! This is a quiz bot. To start the quiz, use the /quiz command.", reply_markup=ReplyKeyboardRemove(), ) ``` -------------------------------- ### SendDocument Method Example Source: https://docs.aiogram.dev/en/latest/_modules/aiogram/types/chat_member_updated.html This example demonstrates how to use the SendDocument method to send a file with various optional parameters. ```python from aiogram.methods import SendDocument return SendDocument( chat_id=self.chat.id, document=document, business_connection_id=business_connection_id, message_thread_id=message_thread_id, direct_messages_topic_id=direct_messages_topic_id, thumbnail=thumbnail, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, disable_content_type_detection=disable_content_type_detection, disable_notification=disable_notification, protect_content=protect_content, allow_paid_broadcast=allow_paid_broadcast, message_effect_id=message_effect_id, suggested_post_parameters=suggested_post_parameters, reply_parameters=reply_parameters, reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, reply_to_message_id=reply_to_message_id, **kwargs, ).as_(self._bot) ``` -------------------------------- ### Serve documentation with uv and sphinx-autobuild Source: https://docs.aiogram.dev/en/latest/contributing.html Serve Sphinx documentation using uv for environment management. This command ensures all documentation build dependencies are met. ```bash uv run --extra docs sphinx-autobuild --watch aiogram/ docs/ docs/_build/ ``` -------------------------------- ### Get Chat Member Count Source: https://docs.aiogram.dev/en/latest/_modules/aiogram/types/chat.html Use this method to get the number of members in a chat. Returns an Integer on success. ```python from aiogram.methods import GetChatMemberCount return GetChatMemberCount( chat_id=self.id, **kwargs, ).as_(self._bot) ```