mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 18:01:04 +00:00
Remove MkDocs
This commit is contained in:
parent
7dd80d281f
commit
e1cd7268a1
442 changed files with 4 additions and 9429 deletions
26
docs/dispatcher/class_based_handlers/base.rst
Normal file
26
docs/dispatcher/class_based_handlers/base.rst
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
.. _cbh-base-handler:
|
||||
|
||||
===========
|
||||
BaseHandler
|
||||
===========
|
||||
|
||||
Base handler is generic abstract class and should be used in all other class-based handlers.
|
||||
|
||||
Import: :code:`from aiogram.handler import BaseHandler`
|
||||
|
||||
By default you will need to override only method :code:`async def handle(self) -> Any: ...`
|
||||
|
||||
This class is also have an default initializer and you don't need to change it.
|
||||
Initializer accepts current event and all contextual data and which
|
||||
can be accessed from the handler through attributes: :code:`event: TelegramEvent` and :code:`data: Dict[Any, str]`
|
||||
|
||||
If instance of the bot is specified in context data or current context it can be accessed through *bot* class attribute.
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class MyHandler(BaseHandler[Message]):
|
||||
async def handle(self) -> Any:
|
||||
await self.event.answer("Hello!")
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
# Overview
|
||||
|
||||
A handler is a async callable which takes a event with contextual data and returns a response.
|
||||
In `aiogram` this can be more than just an async function, these allow you to use classes which can be used as Telegram event handlers to structure your event handlers and reuse code by harnessing inheritance and mixins.
|
||||
|
||||
There are some base class based handlers what you need to use in your own handlers:
|
||||
|
||||
- [BaseHandler](#basehandler)
|
||||
- [MessageHandler](message.md)
|
||||
- [CallbackQueryHandler](callback_query.md)
|
||||
- [ChosenInlineResultHandler](chosen_inline_result.md)
|
||||
- [InlineQueryHandler](inline_query.md)
|
||||
- [PollHandler](poll.md)
|
||||
- [PreCheckoutQueryHandler](pre_checkout_query.md)
|
||||
- [ShippingQueryHandler](shipping_query.md)
|
||||
|
||||
## BaseHandler
|
||||
|
||||
Base handler is generic abstract class and should be used in all other class-based handlers.
|
||||
|
||||
Import: `#!python3 from aiogram.hanler import BaseHandler`
|
||||
|
||||
By default you will need to override only method `#!python3 async def handle(self) -> Any: ...`
|
||||
|
||||
This class is also have an default initializer and you don't need to change it.
|
||||
Initializer accepts current event and all contextual data and which can be accessed from the handler through attributes: `event: TelegramEvent` and `data: Dict[Any, str]`
|
||||
|
||||
If instance of the bot is specified in context data or current context it can be accessed through `bot` class attribute.
|
||||
|
||||
|
||||
### For example:
|
||||
```python3
|
||||
class MyHandler(BaseHandler[Message]):
|
||||
async def handle(self) -> Any:
|
||||
await self.event.answer("Hello!")
|
||||
```
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
# CallbackQueryHandler
|
||||
|
||||
There is base class for callback query handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import CallbackQueryHandler
|
||||
|
||||
...
|
||||
|
||||
@router.callback_query()
|
||||
class MyHandler(CallbackQueryHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `self.from_user` is alias for `self.event.from_user`
|
||||
- `self.message` is alias for `self.event.message`
|
||||
- `self.callback_data` is alias for `self.event.data`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [CallbackQuery](../../api/types/callback_query.md)
|
||||
- [Router.callback_query](../router.md#callback-query)
|
||||
9
docs/dispatcher/class_based_handlers/callback_query.rst
Normal file
9
docs/dispatcher/class_based_handlers/callback_query.rst
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
####################
|
||||
CallbackQueryHandler
|
||||
####################
|
||||
|
||||
|
||||
.. automodule:: aiogram.dispatcher.handler.callback_query
|
||||
:members:
|
||||
:member-order: bysource
|
||||
:undoc-members: True
|
||||
28
docs/dispatcher/class_based_handlers/chat_member.rst
Normal file
28
docs/dispatcher/class_based_handlers/chat_member.rst
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
=================
|
||||
ChatMemberHandler
|
||||
=================
|
||||
|
||||
There is base class for chat member updated events.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import ChatMemberHandler
|
||||
|
||||
...
|
||||
|
||||
@router.chat_member()
|
||||
@router.my_chat_member()
|
||||
class MyHandler(ChatMemberHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of :ref:`BaseHandler <cbh-base-handler>` with some extensions:
|
||||
|
||||
- :code:`self.chat` is alias for :code:`self.event.chat`
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# ChosenInlineResultHandler
|
||||
|
||||
There is base class for chosen inline result handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import ChosenInlineResultHandler
|
||||
|
||||
...
|
||||
|
||||
@router.chosen_inline_result()
|
||||
class MyHandler(ChosenInlineResultHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `self.chat` is alias for `self.event.chat`
|
||||
- `self.from_user` is alias for `self.event.from_user`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [ChosenInlineResult](../../api/types/chosen_inline_result.md)
|
||||
- [Router.chosen_inline_result](../router.md#chosen-inline-query)
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
=========================
|
||||
ChosenInlineResultHandler
|
||||
=========================
|
||||
|
||||
There is base class for chosen inline result handlers.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import ChosenInlineResultHandler
|
||||
|
||||
...
|
||||
|
||||
@router.chosen_inline_result()
|
||||
class MyHandler(ChosenInlineResultHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of :ref:`BaseHandler <cbh-base-handler>` with some extensions:
|
||||
|
||||
- :code:`self.chat` is alias for :code:`self.event.chat`
|
||||
- :code:`self.from_user` is alias for :code:`self.event.from_user`
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
# ErrorHandler
|
||||
|
||||
There is base class for error handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import ErrorHandler
|
||||
|
||||
...
|
||||
|
||||
@router.errors()
|
||||
class MyHandler(ErrorHandler):
|
||||
async def handle(self) -> Any:
|
||||
log.exception(
|
||||
"Cause unexpected exception %s: %s",
|
||||
self.exception_name,
|
||||
self.exception_message
|
||||
)
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `#!python3 self.exception_name` is alias for `#!python3 self.event.__class__.__name__`
|
||||
- `#!python3 self.exception_message` is alias for `#!python3 str(self.event)`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [Router.errors](../router.md#errors)
|
||||
- [Filters](../filters/exception.md)
|
||||
32
docs/dispatcher/class_based_handlers/error.rst
Normal file
32
docs/dispatcher/class_based_handlers/error.rst
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
============
|
||||
ErrorHandler
|
||||
============
|
||||
|
||||
There is base class for error handlers.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import ErrorHandler
|
||||
|
||||
...
|
||||
|
||||
@router.errors()
|
||||
class MyHandler(ErrorHandler):
|
||||
async def handle(self) -> Any:
|
||||
log.exception(
|
||||
"Cause unexpected exception %s: %s",
|
||||
self.exception_name,
|
||||
self.exception_message
|
||||
)
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of :ref:`BaseHandler <cbh-base-handler>` with some extensions:
|
||||
|
||||
- :code:`self.exception_name` is alias for :code:`self.event.__class__.__name__`
|
||||
- :code:`self.exception_message` is alias for :code:`str(self.event)`
|
||||
23
docs/dispatcher/class_based_handlers/index.rst
Normal file
23
docs/dispatcher/class_based_handlers/index.rst
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
====================
|
||||
Class based handlers
|
||||
====================
|
||||
|
||||
A handler is a async callable which takes a event with contextual data and returns a response.
|
||||
|
||||
In **aiogram** it can be more than just an async function, these allow you to use classes
|
||||
which can be used as Telegram event handlers to structure your event handlers and reuse code by harnessing inheritance and mixins.
|
||||
|
||||
There are some base class based handlers what you need to use in your own handlers:
|
||||
|
||||
.. toctree::
|
||||
|
||||
base
|
||||
callback_query
|
||||
chosen_inline_result
|
||||
error
|
||||
inline_query
|
||||
message
|
||||
poll
|
||||
pre_checkout_query
|
||||
shipping_query
|
||||
chat_member
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# InlineQueryHandler
|
||||
There is base class for inline query handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import InlineQueryHandler
|
||||
|
||||
...
|
||||
|
||||
@router.inline_query()
|
||||
class MyHandler(InlineQueryHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `self.chat` is alias for `self.event.chat`
|
||||
- `self.query` is alias for `self.event.query`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [InlineQuery](../../api/types/inline_query.md)
|
||||
- [Router.inline_query_handler](../router.md#inline-query)
|
||||
27
docs/dispatcher/class_based_handlers/inline_query.rst
Normal file
27
docs/dispatcher/class_based_handlers/inline_query.rst
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
==================
|
||||
InlineQueryHandler
|
||||
==================
|
||||
|
||||
There is base class for inline query handlers.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import InlineQueryHandler
|
||||
|
||||
...
|
||||
|
||||
@router.inline_query()
|
||||
class MyHandler(InlineQueryHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of :ref:`BaseHandler <cbh-base-handler>` with some extensions:
|
||||
|
||||
- :code:`self.chat` is alias for :code:`self.event.chat`
|
||||
- :code:`self.query` is alias for :code:`self.event.query`
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
# MessageHandler
|
||||
|
||||
There is base class for message handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import MessageHandler
|
||||
|
||||
...
|
||||
|
||||
@router.message()
|
||||
class MyHandler(MessageHandler):
|
||||
async def handle(self) -> Any:
|
||||
return SendMessage(chat_id=self.chat.id, text="PASS")
|
||||
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `self.chat` is alias for `self.event.chat`
|
||||
- `self.from_user` is alias for `self.event.from_user`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [Message](../../api/types/message.md)
|
||||
- [Router.message](../router.md#message)
|
||||
- [Router.edited_message](../router.md#edited-message)
|
||||
- [Router.channel_post](../router.md#channel-post)
|
||||
- [Router.edited_channel_post](../router.md#edited-channel-post)
|
||||
27
docs/dispatcher/class_based_handlers/message.rst
Normal file
27
docs/dispatcher/class_based_handlers/message.rst
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
==============
|
||||
MessageHandler
|
||||
==============
|
||||
|
||||
There is base class for message handlers.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import MessageHandler
|
||||
|
||||
...
|
||||
|
||||
@router.message()
|
||||
class MyHandler(MessageHandler):
|
||||
async def handle(self) -> Any:
|
||||
return SendMessage(chat_id=self.chat.id, text="PASS")
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- :code:`self.chat` is alias for :code:`self.event.chat`
|
||||
- :code:`self.from_user` is alias for :code:`self.event.from_user`
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# PollHandler
|
||||
|
||||
There is base class for poll handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import PollHandler
|
||||
|
||||
...
|
||||
|
||||
@router.poll()
|
||||
class MyHandler(PollHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `self.question` is alias for `self.event.question`
|
||||
- `self.options` is alias for `self.event.options`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [Poll](../../api/types/poll.md)
|
||||
- [Router.poll](../router.md#poll)
|
||||
26
docs/dispatcher/class_based_handlers/poll.rst
Normal file
26
docs/dispatcher/class_based_handlers/poll.rst
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
===========
|
||||
PollHandler
|
||||
===========
|
||||
|
||||
There is base class for poll handlers.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import PollHandler
|
||||
|
||||
...
|
||||
|
||||
@router.poll()
|
||||
class MyHandler(PollHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of :ref:`BaseHandler <cbh-base-handler>` with some extensions:
|
||||
|
||||
- :code:`self.question` is alias for :code:`self.event.question`
|
||||
- :code:`self.options` is alias for :code:`self.event.options`
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# PreCheckoutQueryHandler
|
||||
|
||||
There is base class for callback query handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import PreCheckoutQueryHandler
|
||||
|
||||
...
|
||||
|
||||
@router.pre_checkout_query()
|
||||
class MyHandler(PreCheckoutQueryHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `self.from_user` is alias for `self.event.from_user`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [PreCheckoutQuery](../../api/types/pre_checkout_query.md)
|
||||
- [Router.pre_checkout_query](../router.md#pre-checkout-query)
|
||||
25
docs/dispatcher/class_based_handlers/pre_checkout_query.rst
Normal file
25
docs/dispatcher/class_based_handlers/pre_checkout_query.rst
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
=======================
|
||||
PreCheckoutQueryHandler
|
||||
=======================
|
||||
|
||||
There is base class for callback query handlers.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import PreCheckoutQueryHandler
|
||||
|
||||
...
|
||||
|
||||
@router.pre_checkout_query()
|
||||
class MyHandler(PreCheckoutQueryHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of :ref:`BaseHandler <cbh-base-handler>` with some extensions:
|
||||
|
||||
- :code:`self.from_user` is alias for :code:`self.event.from_user`
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# ShippingQueryHandler
|
||||
|
||||
There is base class for callback query handlers.
|
||||
|
||||
## Simple usage:
|
||||
```pyhton3
|
||||
from aiogram.handlers import ShippingQueryHandler
|
||||
|
||||
...
|
||||
|
||||
@router.shipping_query()
|
||||
class MyHandler(ShippingQueryHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
```
|
||||
|
||||
## Extension
|
||||
|
||||
This base handler is subclass of [BaseHandler](basics.md#basehandler) with some extensions:
|
||||
|
||||
- `self.from_user` is alias for `self.event.from_user`
|
||||
|
||||
## Related pages
|
||||
|
||||
- [BaseHandler](basics.md#basehandler)
|
||||
- [ShippingQuery](../../api/types/shipping_query.md)
|
||||
- [Router.shipping_query](../router.md#shipping-query)
|
||||
25
docs/dispatcher/class_based_handlers/shipping_query.rst
Normal file
25
docs/dispatcher/class_based_handlers/shipping_query.rst
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
====================
|
||||
ShippingQueryHandler
|
||||
====================
|
||||
|
||||
There is base class for callback query handlers.
|
||||
|
||||
Simple usage
|
||||
============
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.handlers import ShippingQueryHandler
|
||||
|
||||
...
|
||||
|
||||
@router.shipping_query()
|
||||
class MyHandler(ShippingQueryHandler):
|
||||
async def handle(self) -> Any: ...
|
||||
|
||||
Extension
|
||||
=========
|
||||
|
||||
This base handler is subclass of :ref:`BaseHandler <cbh-base-handler>` with some extensions:
|
||||
|
||||
- :code:`self.from_user` is alias for :code:`self.event.from_user`
|
||||
Loading…
Add table
Add a link
Reference in a new issue