Add sphinx with converting part of pages

This commit is contained in:
Alex Root Junior 2020-06-15 02:22:24 +03:00
parent 3aa68a93d1
commit f68960ca87
192 changed files with 6123 additions and 350 deletions

1
.gitignore vendored
View file

@ -5,6 +5,7 @@ __pycache__/
env/
build/
_build/
dist/
site/
*.egg-info/

12
.readthedocs.yml Normal file
View file

@ -0,0 +1,12 @@
version: 2
sphinx:
configuration: docs2/source/conf.py
formats: all
python:
version: 3.8
install:
- method: pip
path: .

File diff suppressed because it is too large Load diff

View file

@ -32,35 +32,63 @@ _JsonDumps = Callable[..., str]
class BaseSession(abc.ABC):
default_timeout: ClassVar[float] = 60.0
api: Default[TelegramAPIServer] = Default(PRODUCTION)
"""Telegra Bot API URL patterns"""
json_loads: Default[_JsonLoads] = Default(json.loads)
"""JSON loader"""
json_dumps: Default[_JsonDumps] = Default(json.dumps)
"""JSON dumper"""
default_timeout: ClassVar[float] = 60.0
"""Default timeout"""
timeout: Default[float] = Default(fget=lambda self: float(self.__class__.default_timeout))
"""Session scope request timeout"""
@classmethod
def raise_for_status(cls, response: Response[T]) -> None:
"""
Check response status
:param response: Response instance
"""
if response.ok:
return
raise TelegramAPIError(response.description)
@abc.abstractmethod
async def close(self) -> None: # pragma: no cover
"""
Close client session
"""
pass
@abc.abstractmethod
async def make_request(
self, bot: Bot, method: TelegramMethod[T], timeout: Optional[int] = UNSET
) -> T: # pragma: no cover
"""
Make request to Telegram Bot API
:param bot: Bot instance
:param method: Method instance
:param timeout: Request timeout
:return:
:raise TelegramApiError:
"""
pass
@abc.abstractmethod
async def stream_content(
self, url: str, timeout: int, chunk_size: int
) -> AsyncGenerator[bytes, None]: # pragma: no cover
"""
Stream reader
"""
yield b""
def prepare_value(self, value: Any) -> Union[str, int, bool]:
"""
Prepare value before send
"""
if isinstance(value, str):
return value
if isinstance(value, (list, dict)):
@ -74,6 +102,9 @@ class BaseSession(abc.ABC):
return str(value)
def clean_json(self, value: Any) -> Any:
"""
Clean data before send
"""
if isinstance(value, list):
return [self.clean_json(v) for v in value if v is not None]
elif isinstance(value, dict):

View file

@ -38,6 +38,13 @@ class InputFile(ABC):
class BufferedInputFile(InputFile):
def __init__(self, file: bytes, filename: str, chunk_size: int = DEFAULT_CHUNK_SIZE):
"""
Represents object for uploading files from filesystem
:param file: Bytes
:param filename: Filename to be propagated to telegram.
:param chunk_size: Uploading chunk size
"""
super().__init__(filename=filename, chunk_size=chunk_size)
self.data = file
@ -49,6 +56,15 @@ class BufferedInputFile(InputFile):
filename: Optional[str] = None,
chunk_size: int = DEFAULT_CHUNK_SIZE,
) -> BufferedInputFile:
"""
Create buffer from file
:param path: Path to file
:param filename: Filename to be propagated to telegram.
By default will be parsed from path
:param chunk_size: Uploading chunk size
:return: instance of :obj:`BufferedInputFile`
"""
if filename is None:
filename = os.path.basename(path)
with open(path, "rb") as f:
@ -70,6 +86,14 @@ class FSInputFile(InputFile):
filename: Optional[str] = None,
chunk_size: int = DEFAULT_CHUNK_SIZE,
):
"""
Represents object for uploading files from filesystem
:param path: Path to file
:param filename: Filename to be propagated to telegram.
By default will be parsed from path
:param chunk_size: Uploading chunk size
"""
if filename is None:
filename = os.path.basename(path)
super().__init__(filename=filename, chunk_size=chunk_size)
@ -92,6 +116,13 @@ class URLInputFile(InputFile):
chunk_size: int = DEFAULT_CHUNK_SIZE,
timeout: int = 30,
):
"""
Represents object for streaming files from internet
:param url: URL in internet
:param filename: Filename to be propagated to telegram.
:param chunk_size: Uploading chunk size
"""
super().__init__(filename=filename, chunk_size=chunk_size)
self.url = url

24
docs2/Makefile Normal file
View file

@ -0,0 +1,24 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SPHINXINTL ?= sphinx-intl
SOURCEDIR = source
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
update-intl: gettext
$(SPHINXINTL) update -p $(BUILDDIR)/gettext $(O)
.PHONY: help update-intl Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

35
docs2/make.bat Normal file
View file

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

BIN
docs2/source/_static/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

14
docs2/source/api/bot.rst Normal file
View file

@ -0,0 +1,14 @@
###
Bot
###
Bot instance can be created from :code:`aiogram.Bot` (:code:`from aiogram import Bot`) and
you can't use API methods without instance of bot with configured token.
This class has aliases for all API methods and named in :code:`lower_camel_case`.
For example :code:`sendMessage` named :code:`send_message` and has the same specification with all class-based methods.
.. autoclass:: aiogram.api.client.bot.Bot
:members:
:show-inheritance:

View file

@ -0,0 +1,97 @@
#####################
How to download file?
#####################
Download file manually
======================
First, you must get the `file_id` of the file you want to download.
Information about files sent to the bot is contained in `Message <types/message.html>`__.
For example, download the document that came to the bot.
.. code-block::
file_id = message.document.file_id
Then use the `getFile <methods/get_file.html>`__ method to get `file_path`.
.. code-block::
file = await bot.get_file(file_id)
file_path = file.file_path
After that, use the `download_file <#download-file>`__ method from the bot object.
download_file(...)
------------------
Download file by `file_path` to destination.
If you want to automatically create destination (:obj:`io.BytesIO`) use default
value of destination and handle result of this method.
.. autoclass:: aiogram.api.client.bot.Bot
:members: download_file
:exclude-members: __init__
There are two options where you can download the file: to **disk** or to **binary I/O object**.
Download file to disk
---------------------
To download file to disk, you must specify the file name or path where to download the file.
In this case, the function will return nothing.
.. code-block::
await bot.download_file(file_path, "text.txt")
Download file to binary I/O object
----------------------------------
To download file to binary I/O object, you must specify an object with the
:obj:`typing.BinaryIO` type or use the default (:obj:`None`) value.
In the first case, the function will return your object:
.. code-block::
my_object = MyBinaryIO()
result: MyBinaryIO = await bot.download_file(file_path, my_object)
# print(result is my_object) # True
If you leave the default value, an :obj:`io.BytesIO` object will be created and returned.
.. code-block::
result: io.BytesIO = await bot.download_file(file_path)
Download file in short way
==========================
Getting `file_path` manually every time is boring, so you should use the `download <#download>`__ method.
download(...)
-------------
Download file by `file_id` or `Downloadable` object to destination.
If you want to automatically create destination (:obj:`io.BytesIO`) use default
value of destination and handle result of this method.
.. autoclass:: aiogram.api.client.bot.Bot
:members: download
:exclude-members: __init__
It differs from `download_file <#download-file>`__ **only** in that it accepts `file_id`
or an `Downloadable` object (object that contains the `file_id` attribute) instead of `file_path`.
You can download a file to `disk <#download-file-to-disk>`__ or to a `binary I/O <#download-file-to-binary-io-object>`__ object in the same way.
Example:
.. code-block::
document = message.document
await bot.download(document)

View file

@ -0,0 +1,15 @@
#######
Bot API
#######
**aiogram** now is fully support of `Telegram Bot API <https://core.telegram.org/bots/api>`_
All API methods and types is fully autogenerated from Telegram Bot API docs by parser with code-generator.
.. toctree::
bot
session/index
types/index
methods/index
download_file
upload_file

View file

@ -0,0 +1,52 @@
###############
addStickerToSet
###############
Use this method to add a new sticker to a set created by the bot. You must use exactly one of the fields png_sticker or tgs_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.add_sticker_to_set
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.add_sticker_to_set(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import AddStickerToSet`
- :code:`from aiogram.api.methods import AddStickerToSet`
- :code:`from aiogram.api.methods.add_sticker_to_set import AddStickerToSet`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await AddStickerToSet(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(AddStickerToSet(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return AddStickerToSet(...)

View file

@ -0,0 +1,54 @@
###################
answerCallbackQuery
###################
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.answer_callback_query
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.answer_callback_query(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import AnswerCallbackQuery`
- :code:`from aiogram.api.methods import AnswerCallbackQuery`
- :code:`from aiogram.api.methods.answer_callback_query import AnswerCallbackQuery`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await AnswerCallbackQuery(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(AnswerCallbackQuery(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return AnswerCallbackQuery(...)

View file

@ -0,0 +1,54 @@
#################
answerInlineQuery
#################
Use this method to send answers to an inline query. On success, True is returned.
No more than 50 results per query are allowed.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.answer_inline_query
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.answer_inline_query(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import AnswerInlineQuery`
- :code:`from aiogram.api.methods import AnswerInlineQuery`
- :code:`from aiogram.api.methods.answer_inline_query import AnswerInlineQuery`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await AnswerInlineQuery(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(AnswerInlineQuery(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return AnswerInlineQuery(...)

View file

@ -0,0 +1,52 @@
######################
answerPreCheckoutQuery
######################
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.answer_pre_checkout_query
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.answer_pre_checkout_query(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import AnswerPreCheckoutQuery`
- :code:`from aiogram.api.methods import AnswerPreCheckoutQuery`
- :code:`from aiogram.api.methods.answer_pre_checkout_query import AnswerPreCheckoutQuery`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await AnswerPreCheckoutQuery(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(AnswerPreCheckoutQuery(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return AnswerPreCheckoutQuery(...)

View file

@ -0,0 +1,52 @@
###################
answerShippingQuery
###################
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.answer_shipping_query
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.answer_shipping_query(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import AnswerShippingQuery`
- :code:`from aiogram.api.methods import AnswerShippingQuery`
- :code:`from aiogram.api.methods.answer_shipping_query import AnswerShippingQuery`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await AnswerShippingQuery(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(AnswerShippingQuery(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return AnswerShippingQuery(...)

View file

@ -0,0 +1,52 @@
###################
createNewStickerSet
###################
Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields png_sticker or tgs_sticker. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.create_new_sticker_set
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.create_new_sticker_set(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import CreateNewStickerSet`
- :code:`from aiogram.api.methods import CreateNewStickerSet`
- :code:`from aiogram.api.methods.create_new_sticker_set import CreateNewStickerSet`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await CreateNewStickerSet(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(CreateNewStickerSet(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return CreateNewStickerSet(...)

View file

@ -0,0 +1,52 @@
###############
deleteChatPhoto
###############
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.delete_chat_photo
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.delete_chat_photo(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import DeleteChatPhoto`
- :code:`from aiogram.api.methods import DeleteChatPhoto`
- :code:`from aiogram.api.methods.delete_chat_photo import DeleteChatPhoto`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await DeleteChatPhoto(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(DeleteChatPhoto(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return DeleteChatPhoto(...)

View file

@ -0,0 +1,52 @@
####################
deleteChatStickerSet
####################
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.delete_chat_sticker_set
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.delete_chat_sticker_set(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import DeleteChatStickerSet`
- :code:`from aiogram.api.methods import DeleteChatStickerSet`
- :code:`from aiogram.api.methods.delete_chat_sticker_set import DeleteChatStickerSet`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await DeleteChatStickerSet(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(DeleteChatStickerSet(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return DeleteChatStickerSet(...)

View file

@ -0,0 +1,68 @@
#############
deleteMessage
#############
Use this method to delete a message, including service messages, with the following limitations:
- A message can only be deleted if it was sent less than 48 hours ago.
- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
- Bots can delete outgoing messages in private chats, groups, and supergroups.
- Bots can delete incoming messages in private chats.
- Bots granted can_post_messages permissions can delete outgoing messages in channels.
- If the bot is an administrator of a group, it can delete any message there.
- If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.delete_message
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.delete_message(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import DeleteMessage`
- :code:`from aiogram.api.methods import DeleteMessage`
- :code:`from aiogram.api.methods.delete_message import DeleteMessage`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await DeleteMessage(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(DeleteMessage(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return DeleteMessage(...)

View file

@ -0,0 +1,52 @@
####################
deleteStickerFromSet
####################
Use this method to delete a sticker from a set created by the bot. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.delete_sticker_from_set
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.delete_sticker_from_set(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import DeleteStickerFromSet`
- :code:`from aiogram.api.methods import DeleteStickerFromSet`
- :code:`from aiogram.api.methods.delete_sticker_from_set import DeleteStickerFromSet`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await DeleteStickerFromSet(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(DeleteStickerFromSet(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return DeleteStickerFromSet(...)

View file

@ -0,0 +1,52 @@
#############
deleteWebhook
#############
Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. Requires no parameters.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.delete_webhook
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.delete_webhook(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import DeleteWebhook`
- :code:`from aiogram.api.methods import DeleteWebhook`
- :code:`from aiogram.api.methods.delete_webhook import DeleteWebhook`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await DeleteWebhook(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(DeleteWebhook(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return DeleteWebhook(...)

View file

@ -0,0 +1,52 @@
##################
editMessageCaption
##################
Use this method to edit captions of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Returns: :obj:`Union[Message, bool]`
.. automodule:: aiogram.api.methods.edit_message_caption
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Union[Message, bool] = await bot.edit_message_caption(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import EditMessageCaption`
- :code:`from aiogram.api.methods import EditMessageCaption`
- :code:`from aiogram.api.methods.edit_message_caption import EditMessageCaption`
In handlers with current bot
----------------------------
.. code-block::
result: Union[Message, bool] = await EditMessageCaption(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Union[Message, bool] = await bot(EditMessageCaption(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return EditMessageCaption(...)

View file

@ -0,0 +1,52 @@
#######################
editMessageLiveLocation
#######################
Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
Returns: :obj:`Union[Message, bool]`
.. automodule:: aiogram.api.methods.edit_message_live_location
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Union[Message, bool] = await bot.edit_message_live_location(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import EditMessageLiveLocation`
- :code:`from aiogram.api.methods import EditMessageLiveLocation`
- :code:`from aiogram.api.methods.edit_message_live_location import EditMessageLiveLocation`
In handlers with current bot
----------------------------
.. code-block::
result: Union[Message, bool] = await EditMessageLiveLocation(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Union[Message, bool] = await bot(EditMessageLiveLocation(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return EditMessageLiveLocation(...)

View file

@ -0,0 +1,52 @@
################
editMessageMedia
################
Use this method to edit animation, audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
Returns: :obj:`Union[Message, bool]`
.. automodule:: aiogram.api.methods.edit_message_media
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Union[Message, bool] = await bot.edit_message_media(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import EditMessageMedia`
- :code:`from aiogram.api.methods import EditMessageMedia`
- :code:`from aiogram.api.methods.edit_message_media import EditMessageMedia`
In handlers with current bot
----------------------------
.. code-block::
result: Union[Message, bool] = await EditMessageMedia(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Union[Message, bool] = await bot(EditMessageMedia(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return EditMessageMedia(...)

View file

@ -0,0 +1,52 @@
######################
editMessageReplyMarkup
######################
Use this method to edit only the reply markup of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Returns: :obj:`Union[Message, bool]`
.. automodule:: aiogram.api.methods.edit_message_reply_markup
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Union[Message, bool] = await bot.edit_message_reply_markup(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import EditMessageReplyMarkup`
- :code:`from aiogram.api.methods import EditMessageReplyMarkup`
- :code:`from aiogram.api.methods.edit_message_reply_markup import EditMessageReplyMarkup`
In handlers with current bot
----------------------------
.. code-block::
result: Union[Message, bool] = await EditMessageReplyMarkup(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Union[Message, bool] = await bot(EditMessageReplyMarkup(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return EditMessageReplyMarkup(...)

View file

@ -0,0 +1,52 @@
###############
editMessageText
###############
Use this method to edit text and game messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Returns: :obj:`Union[Message, bool]`
.. automodule:: aiogram.api.methods.edit_message_text
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Union[Message, bool] = await bot.edit_message_text(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import EditMessageText`
- :code:`from aiogram.api.methods import EditMessageText`
- :code:`from aiogram.api.methods.edit_message_text import EditMessageText`
In handlers with current bot
----------------------------
.. code-block::
result: Union[Message, bool] = await EditMessageText(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Union[Message, bool] = await bot(EditMessageText(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return EditMessageText(...)

View file

@ -0,0 +1,54 @@
####################
exportChatInviteLink
####################
Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as String on success.
Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink — after this the link will become available to the bot via the getChat method. If your bot needs to generate a new invite link replacing its previous one, use exportChatInviteLink again.
Returns: :obj:`str`
.. automodule:: aiogram.api.methods.export_chat_invite_link
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: str = await bot.export_chat_invite_link(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import ExportChatInviteLink`
- :code:`from aiogram.api.methods import ExportChatInviteLink`
- :code:`from aiogram.api.methods.export_chat_invite_link import ExportChatInviteLink`
In handlers with current bot
----------------------------
.. code-block::
result: str = await ExportChatInviteLink(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: str = await bot(ExportChatInviteLink(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return ExportChatInviteLink(...)

View file

@ -0,0 +1,52 @@
##############
forwardMessage
##############
Use this method to forward messages of any kind. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.forward_message
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.forward_message(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import ForwardMessage`
- :code:`from aiogram.api.methods import ForwardMessage`
- :code:`from aiogram.api.methods.forward_message import ForwardMessage`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await ForwardMessage(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(ForwardMessage(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return ForwardMessage(...)

View file

@ -0,0 +1,46 @@
#######
getChat
#######
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
Returns: :obj:`Chat`
.. automodule:: aiogram.api.methods.get_chat
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Chat = await bot.get_chat(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetChat`
- :code:`from aiogram.api.methods import GetChat`
- :code:`from aiogram.api.methods.get_chat import GetChat`
In handlers with current bot
----------------------------
.. code-block::
result: Chat = await GetChat(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Chat = await bot(GetChat(...))

View file

@ -0,0 +1,46 @@
#####################
getChatAdministrators
#####################
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
Returns: :obj:`List[ChatMember]`
.. automodule:: aiogram.api.methods.get_chat_administrators
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: List[ChatMember] = await bot.get_chat_administrators(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetChatAdministrators`
- :code:`from aiogram.api.methods import GetChatAdministrators`
- :code:`from aiogram.api.methods.get_chat_administrators import GetChatAdministrators`
In handlers with current bot
----------------------------
.. code-block::
result: List[ChatMember] = await GetChatAdministrators(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: List[ChatMember] = await bot(GetChatAdministrators(...))

View file

@ -0,0 +1,46 @@
#############
getChatMember
#############
Use this method to get information about a member of a chat. Returns a ChatMember object on success.
Returns: :obj:`ChatMember`
.. automodule:: aiogram.api.methods.get_chat_member
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: ChatMember = await bot.get_chat_member(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetChatMember`
- :code:`from aiogram.api.methods import GetChatMember`
- :code:`from aiogram.api.methods.get_chat_member import GetChatMember`
In handlers with current bot
----------------------------
.. code-block::
result: ChatMember = await GetChatMember(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: ChatMember = await bot(GetChatMember(...))

View file

@ -0,0 +1,46 @@
###################
getChatMembersCount
###################
Use this method to get the number of members in a chat. Returns Int on success.
Returns: :obj:`int`
.. automodule:: aiogram.api.methods.get_chat_members_count
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: int = await bot.get_chat_members_count(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetChatMembersCount`
- :code:`from aiogram.api.methods import GetChatMembersCount`
- :code:`from aiogram.api.methods.get_chat_members_count import GetChatMembersCount`
In handlers with current bot
----------------------------
.. code-block::
result: int = await GetChatMembersCount(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: int = await bot(GetChatMembersCount(...))

View file

@ -0,0 +1,48 @@
#######
getFile
#######
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
Returns: :obj:`File`
.. automodule:: aiogram.api.methods.get_file
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: File = await bot.get_file(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetFile`
- :code:`from aiogram.api.methods import GetFile`
- :code:`from aiogram.api.methods.get_file import GetFile`
In handlers with current bot
----------------------------
.. code-block::
result: File = await GetFile(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: File = await bot(GetFile(...))

View file

@ -0,0 +1,48 @@
#################
getGameHighScores
#################
Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of GameHighScore objects.
This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change.
Returns: :obj:`List[GameHighScore]`
.. automodule:: aiogram.api.methods.get_game_high_scores
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: List[GameHighScore] = await bot.get_game_high_scores(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetGameHighScores`
- :code:`from aiogram.api.methods import GetGameHighScores`
- :code:`from aiogram.api.methods.get_game_high_scores import GetGameHighScores`
In handlers with current bot
----------------------------
.. code-block::
result: List[GameHighScore] = await GetGameHighScores(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: List[GameHighScore] = await bot(GetGameHighScores(...))

View file

@ -0,0 +1,46 @@
#####
getMe
#####
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a User object.
Returns: :obj:`User`
.. automodule:: aiogram.api.methods.get_me
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: User = await bot.get_me(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetMe`
- :code:`from aiogram.api.methods import GetMe`
- :code:`from aiogram.api.methods.get_me import GetMe`
In handlers with current bot
----------------------------
.. code-block::
result: User = await GetMe(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: User = await bot(GetMe(...))

View file

@ -0,0 +1,46 @@
#############
getMyCommands
#############
Use this method to get the current list of the bot's commands. Requires no parameters. Returns Array of BotCommand on success.
Returns: :obj:`List[BotCommand]`
.. automodule:: aiogram.api.methods.get_my_commands
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: List[BotCommand] = await bot.get_my_commands(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetMyCommands`
- :code:`from aiogram.api.methods import GetMyCommands`
- :code:`from aiogram.api.methods.get_my_commands import GetMyCommands`
In handlers with current bot
----------------------------
.. code-block::
result: List[BotCommand] = await GetMyCommands(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: List[BotCommand] = await bot(GetMyCommands(...))

View file

@ -0,0 +1,46 @@
#############
getStickerSet
#############
Use this method to get a sticker set. On success, a StickerSet object is returned.
Returns: :obj:`StickerSet`
.. automodule:: aiogram.api.methods.get_sticker_set
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: StickerSet = await bot.get_sticker_set(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetStickerSet`
- :code:`from aiogram.api.methods import GetStickerSet`
- :code:`from aiogram.api.methods.get_sticker_set import GetStickerSet`
In handlers with current bot
----------------------------
.. code-block::
result: StickerSet = await GetStickerSet(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: StickerSet = await bot(GetStickerSet(...))

View file

@ -0,0 +1,52 @@
##########
getUpdates
##########
Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned.
Notes
1. This method will not work if an outgoing webhook is set up.
2. In order to avoid getting duplicate updates, recalculate offset after each server response.
Returns: :obj:`List[Update]`
.. automodule:: aiogram.api.methods.get_updates
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: List[Update] = await bot.get_updates(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetUpdates`
- :code:`from aiogram.api.methods import GetUpdates`
- :code:`from aiogram.api.methods.get_updates import GetUpdates`
In handlers with current bot
----------------------------
.. code-block::
result: List[Update] = await GetUpdates(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: List[Update] = await bot(GetUpdates(...))

View file

@ -0,0 +1,46 @@
####################
getUserProfilePhotos
####################
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
Returns: :obj:`UserProfilePhotos`
.. automodule:: aiogram.api.methods.get_user_profile_photos
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: UserProfilePhotos = await bot.get_user_profile_photos(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetUserProfilePhotos`
- :code:`from aiogram.api.methods import GetUserProfilePhotos`
- :code:`from aiogram.api.methods.get_user_profile_photos import GetUserProfilePhotos`
In handlers with current bot
----------------------------
.. code-block::
result: UserProfilePhotos = await GetUserProfilePhotos(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: UserProfilePhotos = await bot(GetUserProfilePhotos(...))

View file

@ -0,0 +1,46 @@
##############
getWebhookInfo
##############
Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
Returns: :obj:`WebhookInfo`
.. automodule:: aiogram.api.methods.get_webhook_info
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: WebhookInfo = await bot.get_webhook_info(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import GetWebhookInfo`
- :code:`from aiogram.api.methods import GetWebhookInfo`
- :code:`from aiogram.api.methods.get_webhook_info import GetWebhookInfo`
In handlers with current bot
----------------------------
.. code-block::
result: WebhookInfo = await GetWebhookInfo(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: WebhookInfo = await bot(GetWebhookInfo(...))

View file

@ -0,0 +1,138 @@
#######
Methods
#######
All API methods is wrapped as `pydantic <https://pydantic-docs.helpmanual.io/>`_ models
and placed in :mod:`aiogram.api.methods` package so that's mean all values which you pass
as arguments to the methods will be validated.
Here is all methods is classes and in due to Python standards all classes named in
upper camel case, for example methods :code:`sendMessage` has the name :code:`SendMessage`
Getting updates
===============
.. toctree::
:maxdepth: 1
get_updates
set_webhook
delete_webhook
get_webhook_info
Available methods
=================
.. toctree::
:maxdepth: 1
get_me
send_message
forward_message
send_photo
send_audio
send_document
send_video
send_animation
send_voice
send_video_note
send_media_group
send_location
edit_message_live_location
stop_message_live_location
send_venue
send_contact
send_poll
send_dice
send_chat_action
get_user_profile_photos
get_file
kick_chat_member
unban_chat_member
restrict_chat_member
promote_chat_member
set_chat_administrator_custom_title
set_chat_permissions
export_chat_invite_link
set_chat_photo
delete_chat_photo
set_chat_title
set_chat_description
pin_chat_message
unpin_chat_message
leave_chat
get_chat
get_chat_administrators
get_chat_members_count
get_chat_member
set_chat_sticker_set
delete_chat_sticker_set
answer_callback_query
set_my_commands
get_my_commands
Updating messages
=================
.. toctree::
:maxdepth: 1
edit_message_text
edit_message_caption
edit_message_media
edit_message_reply_markup
stop_poll
delete_message
Stickers
========
.. toctree::
:maxdepth: 1
send_sticker
get_sticker_set
upload_sticker_file
create_new_sticker_set
add_sticker_to_set
set_sticker_position_in_set
delete_sticker_from_set
set_sticker_set_thumb
Inline mode
===========
.. toctree::
:maxdepth: 1
answer_inline_query
Payments
========
.. toctree::
:maxdepth: 1
send_invoice
answer_shipping_query
answer_pre_checkout_query
Telegram Passport
=================
.. toctree::
:maxdepth: 1
set_passport_data_errors
Games
=====
.. toctree::
:maxdepth: 1
send_game
set_game_score
get_game_high_scores

View file

@ -0,0 +1,52 @@
##############
kickChatMember
##############
Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.kick_chat_member
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.kick_chat_member(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import KickChatMember`
- :code:`from aiogram.api.methods import KickChatMember`
- :code:`from aiogram.api.methods.kick_chat_member import KickChatMember`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await KickChatMember(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(KickChatMember(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return KickChatMember(...)

View file

@ -0,0 +1,52 @@
#########
leaveChat
#########
Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.leave_chat
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.leave_chat(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import LeaveChat`
- :code:`from aiogram.api.methods import LeaveChat`
- :code:`from aiogram.api.methods.leave_chat import LeaveChat`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await LeaveChat(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(LeaveChat(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return LeaveChat(...)

View file

@ -0,0 +1,52 @@
##############
pinChatMessage
##############
Use this method to pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.pin_chat_message
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.pin_chat_message(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import PinChatMessage`
- :code:`from aiogram.api.methods import PinChatMessage`
- :code:`from aiogram.api.methods.pin_chat_message import PinChatMessage`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await PinChatMessage(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(PinChatMessage(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return PinChatMessage(...)

View file

@ -0,0 +1,52 @@
#################
promoteChatMember
#################
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.promote_chat_member
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.promote_chat_member(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import PromoteChatMember`
- :code:`from aiogram.api.methods import PromoteChatMember`
- :code:`from aiogram.api.methods.promote_chat_member import PromoteChatMember`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await PromoteChatMember(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(PromoteChatMember(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return PromoteChatMember(...)

View file

@ -0,0 +1,52 @@
##################
restrictChatMember
##################
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.restrict_chat_member
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.restrict_chat_member(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import RestrictChatMember`
- :code:`from aiogram.api.methods import RestrictChatMember`
- :code:`from aiogram.api.methods.restrict_chat_member import RestrictChatMember`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await RestrictChatMember(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(RestrictChatMember(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return RestrictChatMember(...)

View file

@ -0,0 +1,52 @@
#############
sendAnimation
#############
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_animation
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_animation(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendAnimation`
- :code:`from aiogram.api.methods import SendAnimation`
- :code:`from aiogram.api.methods.send_animation import SendAnimation`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendAnimation(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendAnimation(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendAnimation(...)

View file

@ -0,0 +1,54 @@
#########
sendAudio
#########
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
For sending voice messages, use the sendVoice method instead.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_audio
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_audio(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendAudio`
- :code:`from aiogram.api.methods import SendAudio`
- :code:`from aiogram.api.methods.send_audio import SendAudio`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendAudio(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendAudio(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendAudio(...)

View file

@ -0,0 +1,56 @@
##############
sendChatAction
##############
Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of 'Retrieving image, please wait…', the bot may use sendChatAction with action = upload_photo. The user will see a 'sending photo' status for the bot.
We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.send_chat_action
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.send_chat_action(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendChatAction`
- :code:`from aiogram.api.methods import SendChatAction`
- :code:`from aiogram.api.methods.send_chat_action import SendChatAction`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SendChatAction(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SendChatAction(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendChatAction(...)

View file

@ -0,0 +1,52 @@
###########
sendContact
###########
Use this method to send phone contacts. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_contact
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_contact(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendContact`
- :code:`from aiogram.api.methods import SendContact`
- :code:`from aiogram.api.methods.send_contact import SendContact`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendContact(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendContact(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendContact(...)

View file

@ -0,0 +1,52 @@
########
sendDice
########
Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_dice
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_dice(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendDice`
- :code:`from aiogram.api.methods import SendDice`
- :code:`from aiogram.api.methods.send_dice import SendDice`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendDice(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendDice(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendDice(...)

View file

@ -0,0 +1,52 @@
############
sendDocument
############
Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_document
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_document(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendDocument`
- :code:`from aiogram.api.methods import SendDocument`
- :code:`from aiogram.api.methods.send_document import SendDocument`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendDocument(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendDocument(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendDocument(...)

View file

@ -0,0 +1,52 @@
########
sendGame
########
Use this method to send a game. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_game
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_game(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendGame`
- :code:`from aiogram.api.methods import SendGame`
- :code:`from aiogram.api.methods.send_game import SendGame`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendGame(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendGame(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendGame(...)

View file

@ -0,0 +1,52 @@
###########
sendInvoice
###########
Use this method to send invoices. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_invoice
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_invoice(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendInvoice`
- :code:`from aiogram.api.methods import SendInvoice`
- :code:`from aiogram.api.methods.send_invoice import SendInvoice`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendInvoice(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendInvoice(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendInvoice(...)

View file

@ -0,0 +1,52 @@
############
sendLocation
############
Use this method to send point on the map. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_location
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_location(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendLocation`
- :code:`from aiogram.api.methods import SendLocation`
- :code:`from aiogram.api.methods.send_location import SendLocation`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendLocation(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendLocation(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendLocation(...)

View file

@ -0,0 +1,52 @@
##############
sendMediaGroup
##############
Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned.
Returns: :obj:`List[Message]`
.. automodule:: aiogram.api.methods.send_media_group
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: List[Message] = await bot.send_media_group(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendMediaGroup`
- :code:`from aiogram.api.methods import SendMediaGroup`
- :code:`from aiogram.api.methods.send_media_group import SendMediaGroup`
In handlers with current bot
----------------------------
.. code-block::
result: List[Message] = await SendMediaGroup(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: List[Message] = await bot(SendMediaGroup(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendMediaGroup(...)

View file

@ -0,0 +1,52 @@
###########
sendMessage
###########
Use this method to send text messages. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_message
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_message(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendMessage`
- :code:`from aiogram.api.methods import SendMessage`
- :code:`from aiogram.api.methods.send_message import SendMessage`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendMessage(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendMessage(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendMessage(...)

View file

@ -0,0 +1,52 @@
#########
sendPhoto
#########
Use this method to send photos. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_photo
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_photo(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendPhoto`
- :code:`from aiogram.api.methods import SendPhoto`
- :code:`from aiogram.api.methods.send_photo import SendPhoto`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendPhoto(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendPhoto(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendPhoto(...)

View file

@ -0,0 +1,52 @@
########
sendPoll
########
Use this method to send a native poll. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_poll
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_poll(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendPoll`
- :code:`from aiogram.api.methods import SendPoll`
- :code:`from aiogram.api.methods.send_poll import SendPoll`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendPoll(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendPoll(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendPoll(...)

View file

@ -0,0 +1,52 @@
###########
sendSticker
###########
Use this method to send static .WEBP or animated .TGS stickers. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_sticker
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_sticker(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendSticker`
- :code:`from aiogram.api.methods import SendSticker`
- :code:`from aiogram.api.methods.send_sticker import SendSticker`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendSticker(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendSticker(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendSticker(...)

View file

@ -0,0 +1,52 @@
#########
sendVenue
#########
Use this method to send information about a venue. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_venue
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_venue(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendVenue`
- :code:`from aiogram.api.methods import SendVenue`
- :code:`from aiogram.api.methods.send_venue import SendVenue`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendVenue(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendVenue(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendVenue(...)

View file

@ -0,0 +1,52 @@
#########
sendVideo
#########
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_video
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_video(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendVideo`
- :code:`from aiogram.api.methods import SendVideo`
- :code:`from aiogram.api.methods.send_video import SendVideo`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendVideo(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendVideo(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendVideo(...)

View file

@ -0,0 +1,52 @@
#############
sendVideoNote
#############
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_video_note
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_video_note(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendVideoNote`
- :code:`from aiogram.api.methods import SendVideoNote`
- :code:`from aiogram.api.methods.send_video_note import SendVideoNote`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendVideoNote(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendVideoNote(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendVideoNote(...)

View file

@ -0,0 +1,52 @@
#########
sendVoice
#########
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
Returns: :obj:`Message`
.. automodule:: aiogram.api.methods.send_voice
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Message = await bot.send_voice(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SendVoice`
- :code:`from aiogram.api.methods import SendVoice`
- :code:`from aiogram.api.methods.send_voice import SendVoice`
In handlers with current bot
----------------------------
.. code-block::
result: Message = await SendVoice(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Message = await bot(SendVoice(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SendVoice(...)

View file

@ -0,0 +1,52 @@
###############################
setChatAdministratorCustomTitle
###############################
Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_chat_administrator_custom_title
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_chat_administrator_custom_title(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetChatAdministratorCustomTitle`
- :code:`from aiogram.api.methods import SetChatAdministratorCustomTitle`
- :code:`from aiogram.api.methods.set_chat_administrator_custom_title import SetChatAdministratorCustomTitle`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetChatAdministratorCustomTitle(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetChatAdministratorCustomTitle(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetChatAdministratorCustomTitle(...)

View file

@ -0,0 +1,52 @@
##################
setChatDescription
##################
Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_chat_description
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_chat_description(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetChatDescription`
- :code:`from aiogram.api.methods import SetChatDescription`
- :code:`from aiogram.api.methods.set_chat_description import SetChatDescription`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetChatDescription(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetChatDescription(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetChatDescription(...)

View file

@ -0,0 +1,52 @@
##################
setChatPermissions
##################
Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_chat_permissions
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_chat_permissions(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetChatPermissions`
- :code:`from aiogram.api.methods import SetChatPermissions`
- :code:`from aiogram.api.methods.set_chat_permissions import SetChatPermissions`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetChatPermissions(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetChatPermissions(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetChatPermissions(...)

View file

@ -0,0 +1,46 @@
############
setChatPhoto
############
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_chat_photo
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_chat_photo(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetChatPhoto`
- :code:`from aiogram.api.methods import SetChatPhoto`
- :code:`from aiogram.api.methods.set_chat_photo import SetChatPhoto`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetChatPhoto(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetChatPhoto(...))

View file

@ -0,0 +1,52 @@
#################
setChatStickerSet
#################
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_chat_sticker_set
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_chat_sticker_set(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetChatStickerSet`
- :code:`from aiogram.api.methods import SetChatStickerSet`
- :code:`from aiogram.api.methods.set_chat_sticker_set import SetChatStickerSet`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetChatStickerSet(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetChatStickerSet(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetChatStickerSet(...)

View file

@ -0,0 +1,52 @@
############
setChatTitle
############
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_chat_title
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_chat_title(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetChatTitle`
- :code:`from aiogram.api.methods import SetChatTitle`
- :code:`from aiogram.api.methods.set_chat_title import SetChatTitle`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetChatTitle(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetChatTitle(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetChatTitle(...)

View file

@ -0,0 +1,52 @@
############
setGameScore
############
Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
Returns: :obj:`Union[Message, bool]`
.. automodule:: aiogram.api.methods.set_game_score
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Union[Message, bool] = await bot.set_game_score(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetGameScore`
- :code:`from aiogram.api.methods import SetGameScore`
- :code:`from aiogram.api.methods.set_game_score import SetGameScore`
In handlers with current bot
----------------------------
.. code-block::
result: Union[Message, bool] = await SetGameScore(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Union[Message, bool] = await bot(SetGameScore(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetGameScore(...)

View file

@ -0,0 +1,52 @@
#############
setMyCommands
#############
Use this method to change the list of the bot's commands. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_my_commands
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_my_commands(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetMyCommands`
- :code:`from aiogram.api.methods import SetMyCommands`
- :code:`from aiogram.api.methods.set_my_commands import SetMyCommands`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetMyCommands(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetMyCommands(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetMyCommands(...)

View file

@ -0,0 +1,54 @@
#####################
setPassportDataErrors
#####################
Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_passport_data_errors
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_passport_data_errors(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetPassportDataErrors`
- :code:`from aiogram.api.methods import SetPassportDataErrors`
- :code:`from aiogram.api.methods.set_passport_data_errors import SetPassportDataErrors`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetPassportDataErrors(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetPassportDataErrors(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetPassportDataErrors(...)

View file

@ -0,0 +1,52 @@
#######################
setStickerPositionInSet
#######################
Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_sticker_position_in_set
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_sticker_position_in_set(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetStickerPositionInSet`
- :code:`from aiogram.api.methods import SetStickerPositionInSet`
- :code:`from aiogram.api.methods.set_sticker_position_in_set import SetStickerPositionInSet`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetStickerPositionInSet(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetStickerPositionInSet(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetStickerPositionInSet(...)

View file

@ -0,0 +1,52 @@
##################
setStickerSetThumb
##################
Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_sticker_set_thumb
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_sticker_set_thumb(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetStickerSetThumb`
- :code:`from aiogram.api.methods import SetStickerSetThumb`
- :code:`from aiogram.api.methods.set_sticker_set_thumb import SetStickerSetThumb`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetStickerSetThumb(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetStickerSetThumb(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetStickerSetThumb(...)

View file

@ -0,0 +1,64 @@
##########
setWebhook
##########
Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success.
If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token>. Since nobody else knows your bot's token, you can be pretty sure it's us.
Notes
1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.
2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work.
3. Ports currently supported for Webhooks: 443, 80, 88, 8443.
NEW! If you're having any trouble setting up webhooks, please check out this amazing guide to Webhooks.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.set_webhook
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.set_webhook(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import SetWebhook`
- :code:`from aiogram.api.methods import SetWebhook`
- :code:`from aiogram.api.methods.set_webhook import SetWebhook`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await SetWebhook(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(SetWebhook(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return SetWebhook(...)

View file

@ -0,0 +1,52 @@
#######################
stopMessageLiveLocation
#######################
Use this method to stop updating a live location message before live_period expires. On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.
Returns: :obj:`Union[Message, bool]`
.. automodule:: aiogram.api.methods.stop_message_live_location
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Union[Message, bool] = await bot.stop_message_live_location(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import StopMessageLiveLocation`
- :code:`from aiogram.api.methods import StopMessageLiveLocation`
- :code:`from aiogram.api.methods.stop_message_live_location import StopMessageLiveLocation`
In handlers with current bot
----------------------------
.. code-block::
result: Union[Message, bool] = await StopMessageLiveLocation(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Union[Message, bool] = await bot(StopMessageLiveLocation(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return StopMessageLiveLocation(...)

View file

@ -0,0 +1,52 @@
########
stopPoll
########
Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.
Returns: :obj:`Poll`
.. automodule:: aiogram.api.methods.stop_poll
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: Poll = await bot.stop_poll(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import StopPoll`
- :code:`from aiogram.api.methods import StopPoll`
- :code:`from aiogram.api.methods.stop_poll import StopPoll`
In handlers with current bot
----------------------------
.. code-block::
result: Poll = await StopPoll(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: Poll = await bot(StopPoll(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return StopPoll(...)

View file

@ -0,0 +1,52 @@
###############
unbanChatMember
###############
Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.unban_chat_member
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.unban_chat_member(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import UnbanChatMember`
- :code:`from aiogram.api.methods import UnbanChatMember`
- :code:`from aiogram.api.methods.unban_chat_member import UnbanChatMember`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await UnbanChatMember(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(UnbanChatMember(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return UnbanChatMember(...)

View file

@ -0,0 +1,52 @@
################
unpinChatMessage
################
Use this method to unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel. Returns True on success.
Returns: :obj:`bool`
.. automodule:: aiogram.api.methods.unpin_chat_message
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.unpin_chat_message(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import UnpinChatMessage`
- :code:`from aiogram.api.methods import UnpinChatMessage`
- :code:`from aiogram.api.methods.unpin_chat_message import UnpinChatMessage`
In handlers with current bot
----------------------------
.. code-block::
result: bool = await UnpinChatMessage(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: bool = await bot(UnpinChatMessage(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
return UnpinChatMessage(...)

View file

@ -0,0 +1,46 @@
#################
uploadStickerFile
#################
Use this method to upload a .PNG file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
Returns: :obj:`File`
.. automodule:: aiogram.api.methods.upload_sticker_file
:members:
Usage
=====
As bot method
-------------
.. code-block::
result: File = await bot.upload_sticker_file(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods import UploadStickerFile`
- :code:`from aiogram.api.methods import UploadStickerFile`
- :code:`from aiogram.api.methods.upload_sticker_file import UploadStickerFile`
In handlers with current bot
----------------------------
.. code-block::
result: File = await UploadStickerFile(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block::
result: File = await bot(UploadStickerFile(...))

View file

@ -0,0 +1,92 @@
#######
aiohttp
#######
AiohttpSession represents a wrapper-class around `ClientSession` from `aiohttp <https://pypi.org/project/aiohttp/>`_
Currently `AiohttpSession` is a default session used in `aiogram.Bot`
Usage example
=============
.. code-block::
from aiogram import Bot
from aiogram.api.client.session.aiohttp import AiohttpSession
session = AiohttpSession()
Bot('42:token', session=session)
Proxy requests in AiohttpSession
================================
In order to use AiohttpSession with proxy connector you have to install `aiohttp-socks <https://pypi.org/project/aiohttp-socks>`_
Binding session to bot:
.. code-block::
from aiogram import Bot
from aiogram.api.client.session.aiohttp import AiohttpSession
session = AiohttpSession(proxy="protocol://host:port/")
Bot(token="bot token", session=session)
.. note::
Only following protocols are supported: http(tunneling), socks4(a), socks5
as aiohttp_socks `documentation <https://github.com/romis2012/aiohttp-socks/blob/master/README.md>`_ claims.
Authorization
-------------
Proxy authorization credentials can be specified in proxy URL or come as an instance of :obj:`aiohttp.BasicAuth` containing
login and password.
Consider examples:
.. code-block::
from aiohttp import BasicAuth
from aiogram.api.client.session.aiohttp import AiohttpSession
auth = BasicAuth(login="user", password="password")
session = AiohttpSession(proxy=("protocol://host:port", auth))
or simply include your basic auth credential in URL
.. code-block::
session = AiohttpSession(proxy="protocol://user:password@host:port")
.. note::
Aiogram prefers `BasicAuth` over username and password in URL, so
if proxy URL contains login and password and `BasicAuth` object is passed at the same time
aiogram will use login and password from `BasicAuth` instance.
Proxy chains
------------
Since `aiohttp-socks <https://pypi.org/project/aiohttp-socks/>`_ supports proxy chains, you're able to use them in aiogram
Example of chain proxies:
.. code-block::
from aiohttp import BasicAuth
from aiogram.api.client.session.aiohttp import AiohttpSession
auth = BasicAuth(login="user", password="password")
session = AiohttpSession(
proxy={
"protocol0://host0:port0",
"protocol1://user:password@host1:port1",
("protocol2://host2:port2", auth),
} # can be any iterable if not set
)

View file

@ -0,0 +1,8 @@
####
Base
####
Abstract session for all client sessions
.. autoclass:: aiogram.api.client.session.base.BaseSession
:members:

View file

@ -0,0 +1,7 @@
##############
Client session
##############
.. toctree::
base
aiohttp

View file

@ -0,0 +1,8 @@
#########
Animation
#########
This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
.. automodule:: aiogram.api.types.animation
:members:

View file

@ -0,0 +1,8 @@
#####
Audio
#####
This object represents an audio file to be treated as music by the Telegram clients.
.. automodule:: aiogram.api.types.audio
:members:

View file

@ -0,0 +1,8 @@
##########
BotCommand
##########
This object represents a bot command.
.. automodule:: aiogram.api.types.bot_command
:members:

View file

@ -0,0 +1,8 @@
############
CallbackGame
############
A placeholder, currently holds no information. Use BotFather to set up your game.
.. automodule:: aiogram.api.types.callback_game
:members:

View file

@ -0,0 +1,10 @@
#############
CallbackQuery
#############
This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.
NOTE: After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery. It is, therefore, necessary to react by calling answerCallbackQuery even if no notification to the user is needed (e.g., without specifying any of the optional parameters).
.. automodule:: aiogram.api.types.callback_query
:members:

View file

@ -0,0 +1,8 @@
####
Chat
####
This object represents a chat.
.. automodule:: aiogram.api.types.chat
:members:

View file

@ -0,0 +1,8 @@
##########
ChatMember
##########
This object contains information about one member of a chat.
.. automodule:: aiogram.api.types.chat_member
:members:

View file

@ -0,0 +1,8 @@
###############
ChatPermissions
###############
Describes actions that a non-administrator user is allowed to take in a chat.
.. automodule:: aiogram.api.types.chat_permissions
:members:

View file

@ -0,0 +1,8 @@
#########
ChatPhoto
#########
This object represents a chat photo.
.. automodule:: aiogram.api.types.chat_photo
:members:

View file

@ -0,0 +1,10 @@
##################
ChosenInlineResult
##################
Represents a result of an inline query that was chosen by the user and sent to their chat partner.
Note: It is necessary to enable inline feedback via @Botfather in order to receive these objects in updates.
.. automodule:: aiogram.api.types.chosen_inline_result
:members:

View file

@ -0,0 +1,8 @@
#######
Contact
#######
This object represents a phone contact.
.. automodule:: aiogram.api.types.contact
:members:

View file

@ -0,0 +1,8 @@
####
Dice
####
This object represents an animated emoji that displays a random value.
.. automodule:: aiogram.api.types.dice
:members:

View file

@ -0,0 +1,8 @@
########
Document
########
This object represents a general file (as opposed to photos, voice messages and audio files).
.. automodule:: aiogram.api.types.document
:members:

View file

@ -0,0 +1,8 @@
####################
EncryptedCredentials
####################
Contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
.. automodule:: aiogram.api.types.encrypted_credentials
:members:

View file

@ -0,0 +1,8 @@
########################
EncryptedPassportElement
########################
Contains information about documents or other Telegram Passport elements shared with the bot by the user.
.. automodule:: aiogram.api.types.encrypted_passport_element
:members:

Some files were not shown because too many files have changed in this diff Show more