Add support of Bot API 4.7. Bump version

This commit is contained in:
Alex Root Junior 2020-04-11 20:15:03 +03:00
parent 4cb9697cb4
commit 33003f2026
167 changed files with 996 additions and 504 deletions

View file

@ -26,5 +26,5 @@ __all__ = (
"handler",
)
__version__ = "3.0.0a2"
__api_version__ = "4.6"
__version__ = "3.0.0a3"
__api_version__ = "4.7"

View file

@ -2,19 +2,12 @@ from __future__ import annotations
import datetime
from contextlib import asynccontextmanager
from typing import (
List,
Optional,
Union,
TypeVar,
AsyncIterator,
Any,
)
from typing import Any, AsyncIterator, List, Optional, TypeVar, Union
from async_lru import alru_cache
from .session.aiohttp import AiohttpSession
from .session.base import BaseSession
from ...utils.mixins import ContextInstanceMixin
from ...utils.token import extract_bot_id, validate_token
from ..methods import (
AddStickerToSet,
AnswerCallbackQuery,
@ -41,6 +34,7 @@ from ..methods import (
GetFile,
GetGameHighScores,
GetMe,
GetMyCommands,
GetStickerSet,
GetUpdates,
GetUserProfilePhotos,
@ -54,6 +48,7 @@ from ..methods import (
SendAudio,
SendChatAction,
SendContact,
SendDice,
SendDocument,
SendGame,
SendInvoice,
@ -74,17 +69,20 @@ from ..methods import (
SetChatStickerSet,
SetChatTitle,
SetGameScore,
SetMyCommands,
SetPassportDataErrors,
SetStickerPositionInSet,
SetStickerSetThumb,
SetWebhook,
StopMessageLiveLocation,
StopPoll,
TelegramMethod,
UnbanChatMember,
UnpinChatMessage,
UploadStickerFile,
TelegramMethod,
)
from ..types import (
BotCommand,
Chat,
ChatMember,
ChatPermissions,
@ -111,18 +109,15 @@ from ..types import (
UserProfilePhotos,
WebhookInfo,
)
from ...utils.mixins import ContextInstanceMixin
from ...utils.token import (
validate_token,
extract_bot_id,
)
from .session.aiohttp import AiohttpSession
from .session.base import BaseSession
T = TypeVar("T")
class Bot(ContextInstanceMixin["Bot"]):
"""
Class where located all API methods
Main bot class
"""
def __init__(
@ -146,21 +141,6 @@ class Bot(ContextInstanceMixin["Bot"]):
"""
return extract_bot_id(self.__token)
async def __call__(self, method: TelegramMethod[T]) -> T:
"""
Call API method
:param method:
:return:
"""
return await self.session.make_request(self.__token, method)
async def close(self) -> None:
"""
Close bot session
"""
await self.session.close()
@asynccontextmanager
async def context(self, auto_close: bool = True) -> AsyncIterator[Bot]:
"""
@ -177,6 +157,25 @@ class Bot(ContextInstanceMixin["Bot"]):
await self.close()
self.reset_current(token)
@alru_cache() # type: ignore
async def me(self) -> User:
return await self.get_me()
async def close(self) -> None:
"""
Close bot session
"""
await self.session.close()
async def __call__(self, method: TelegramMethod[T]) -> T:
"""
Call API method
:param method:
:return:
"""
return await self.session.make_request(self.__token, method)
def __hash__(self) -> int:
"""
Get hash for the token
@ -196,10 +195,6 @@ class Bot(ContextInstanceMixin["Bot"]):
return False
return hash(self) == hash(other)
@alru_cache() # type: ignore
async def me(self) -> User:
return await self.get_me()
# =============================================================================================
# Group: Getting updates
# Source: https://core.telegram.org/bots/api#getting-updates
@ -359,7 +354,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param chat_id: Unique identifier for the target chat or username of the target channel
(in the format @channelusername)
:param text: Text of the message to be sent
:param text: Text of the message to be sent, 1-4096 characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in your bot's message.
:param disable_web_page_preview: Disables link previews for links in this message
@ -435,7 +430,7 @@ class Bot(ContextInstanceMixin["Bot"]):
get a photo from the Internet, or upload a new photo using
multipart/form-data.
:param caption: Photo caption (may also be used when resending photos by file_id), 0-1024
characters
characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in the media caption.
:param disable_notification: Sends the message silently. Users will receive a notification
@ -488,7 +483,7 @@ class Bot(ContextInstanceMixin["Bot"]):
exists on the Telegram servers (recommended), pass an HTTP URL as a String
for Telegram to get an audio file from the Internet, or upload a new one
using multipart/form-data.
:param caption: Audio caption, 0-1024 characters
:param caption: Audio caption, 0-1024 characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in the media caption.
:param duration: Duration of the audio in seconds
@ -558,7 +553,7 @@ class Bot(ContextInstanceMixin["Bot"]):
can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>.
:param caption: Document caption (may also be used when resending documents by file_id),
0-1024 characters
0-1024 characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in the media caption.
:param disable_notification: Sends the message silently. Users will receive a notification
@ -622,7 +617,7 @@ class Bot(ContextInstanceMixin["Bot"]):
can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>.
:param caption: Video caption (may also be used when resending videos by file_id), 0-1024
characters
characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in the media caption.
:param supports_streaming: Pass True, if the uploaded video is suitable for streaming
@ -690,7 +685,7 @@ class Bot(ContextInstanceMixin["Bot"]):
can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>.
:param caption: Animation caption (may also be used when resending animation by file_id),
0-1024 characters
0-1024 characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in the media caption.
:param disable_notification: Sends the message silently. Users will receive a notification
@ -731,7 +726,7 @@ class Bot(ContextInstanceMixin["Bot"]):
) -> Message:
"""
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
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.
@ -744,7 +739,7 @@ class Bot(ContextInstanceMixin["Bot"]):
the Telegram servers (recommended), pass an HTTP URL as a String for
Telegram to get a file from the Internet, or upload a new one using
multipart/form-data.
:param caption: Voice message caption, 0-1024 characters
:param caption: Voice message caption, 0-1024 characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in the media caption.
:param duration: Duration of the voice message in seconds
@ -1121,6 +1116,40 @@ class Bot(ContextInstanceMixin["Bot"]):
)
return await self(call)
async def send_dice(
self,
chat_id: Union[int, str],
disable_notification: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
) -> Message:
"""
Use this method to send a dice, which will have a random value from 1 to 6. On success,
the sent Message is returned. (Yes, we're aware of the 'proper' singular of die. But it's
awkward, and we decided to help it change. One dice at a time!)
Source: https://core.telegram.org/bots/api#senddice
:param chat_id: Unique identifier for the target chat or username of the target channel
(in the format @channelusername)
:param disable_notification: Sends the message silently. Users will receive a notification
with no sound.
:param reply_to_message_id: If the message is a reply, ID of the original message
:param reply_markup: Additional interface options. A JSON-serialized object for an inline
keyboard, custom reply keyboard, instructions to remove reply
keyboard or to force a reply from the user.
:return: On success, the sent Message is returned.
"""
call = SendDice(
chat_id=chat_id,
disable_notification=disable_notification,
reply_to_message_id=reply_to_message_id,
reply_markup=reply_markup,
)
return await self(call)
async def send_chat_action(self, chat_id: Union[int, str], action: str,) -> bool:
"""
Use this method when you need to tell the user that something is happening on the bot's
@ -1631,6 +1660,31 @@ class Bot(ContextInstanceMixin["Bot"]):
)
return await self(call)
async def set_my_commands(self, commands: List[BotCommand],) -> bool:
"""
Use this method to change the list of the bot's commands. Returns True on success.
Source: https://core.telegram.org/bots/api#setmycommands
:param commands: A JSON-serialized list of bot commands to be set as the list of the bot's
commands. At most 100 commands can be specified.
:return: Returns True on success.
"""
call = SetMyCommands(commands=commands,)
return await self(call)
async def get_my_commands(self,) -> List[BotCommand]:
"""
Use this method to get the current list of the bot's commands. Requires no parameters.
Returns Array of BotCommand on success.
Source: https://core.telegram.org/bots/api#getmycommands
:return: Returns Array of BotCommand on success.
"""
call = GetMyCommands()
return await self(call)
# =============================================================================================
# Group: Updating messages
# Source: https://core.telegram.org/bots/api#updating-messages
@ -1652,7 +1706,7 @@ class Bot(ContextInstanceMixin["Bot"]):
Source: https://core.telegram.org/bots/api#editmessagetext
:param text: New text of the message
:param text: New text of the message, 1-4096 characters after entities parsing
:param chat_id: Required if inline_message_id is not specified. Unique identifier for the
target chat or username of the target channel (in the format
@channelusername)
@ -1700,7 +1754,7 @@ class Bot(ContextInstanceMixin["Bot"]):
message to edit
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier
of the inline message
:param caption: New caption of the message
:param caption: New caption of the message, 0-1024 characters after entities parsing
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in the media caption.
:param reply_markup: A JSON-serialized object for an inline keyboard.
@ -1814,6 +1868,8 @@ class Bot(ContextInstanceMixin["Bot"]):
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.
@ -1857,7 +1913,7 @@ class Bot(ContextInstanceMixin["Bot"]):
(in the format @channelusername)
:param sticker: Sticker to send. Pass a file_id as String to send a file that exists on
the Telegram servers (recommended), pass an HTTP URL as a String for
Telegram to get a .webp file from the Internet, or upload a new one using
Telegram to get a .WEBP file from the Internet, or upload a new one using
multipart/form-data.
:param disable_notification: Sends the message silently. Users will receive a notification
with no sound.
@ -1890,7 +1946,7 @@ class Bot(ContextInstanceMixin["Bot"]):
async def upload_sticker_file(self, user_id: int, png_sticker: InputFile,) -> File:
"""
Use this method to upload a .png file with a sticker for later use in createNewStickerSet
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.
@ -1910,14 +1966,16 @@ class Bot(ContextInstanceMixin["Bot"]):
user_id: int,
name: str,
title: str,
png_sticker: Union[InputFile, str],
emojis: str,
png_sticker: Optional[Union[InputFile, str]] = None,
tgs_sticker: Optional[InputFile] = None,
contains_masks: Optional[bool] = None,
mask_position: Optional[MaskPosition] = None,
) -> bool:
"""
Use this method to create new sticker set owned by a user. The bot will be able to edit
the created sticker set. Returns True on success.
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.
Source: https://core.telegram.org/bots/api#createnewstickerset
@ -1927,13 +1985,16 @@ class Bot(ContextInstanceMixin["Bot"]):
begin with a letter, can't contain consecutive underscores and must end in
'_by_<bot username>'. <bot_username> is case insensitive. 1-64 characters.
:param title: Sticker set title, 1-64 characters
:param png_sticker: Png image with the sticker, must be up to 512 kilobytes in size,
:param emojis: One or more emoji corresponding to the sticker
:param png_sticker: PNG image with the sticker, must be up to 512 kilobytes in size,
dimensions must not exceed 512px, and either width or height must be
exactly 512px. Pass a file_id as a String to send a file that already
exists on the Telegram servers, pass an HTTP URL as a String for
Telegram to get a file from the Internet, or upload a new one using
multipart/form-data.
:param emojis: One or more emoji corresponding to the sticker
:param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data.
See https://core.telegram.org/animated_stickers#technical-requirements
for technical requirements
:param contains_masks: Pass True, if a set of mask stickers should be created
:param mask_position: A JSON-serialized object for position where the mask should be
placed on faces
@ -1943,8 +2004,9 @@ class Bot(ContextInstanceMixin["Bot"]):
user_id=user_id,
name=name,
title=title,
png_sticker=png_sticker,
emojis=emojis,
png_sticker=png_sticker,
tgs_sticker=tgs_sticker,
contains_masks=contains_masks,
mask_position=mask_position,
)
@ -1956,22 +2018,29 @@ class Bot(ContextInstanceMixin["Bot"]):
name: str,
png_sticker: Union[InputFile, str],
emojis: str,
tgs_sticker: Optional[InputFile] = None,
mask_position: Optional[MaskPosition] = None,
) -> bool:
"""
Use this method to add a new sticker to a set created by the bot. Returns True on success.
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.
Source: https://core.telegram.org/bots/api#addstickertoset
:param user_id: User identifier of sticker set owner
:param name: Sticker set name
:param png_sticker: Png image with the sticker, must be up to 512 kilobytes in size,
:param png_sticker: PNG image with the sticker, must be up to 512 kilobytes in size,
dimensions must not exceed 512px, and either width or height must be
exactly 512px. Pass a file_id as a String to send a file that already
exists on the Telegram servers, pass an HTTP URL as a String for
Telegram to get a file from the Internet, or upload a new one using
multipart/form-data.
:param emojis: One or more emoji corresponding to the sticker
:param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data.
See https://core.telegram.org/animated_stickers#technical-requirements
for technical requirements
:param mask_position: A JSON-serialized object for position where the mask should be
placed on faces
:return: Returns True on success.
@ -1981,13 +2050,14 @@ class Bot(ContextInstanceMixin["Bot"]):
name=name,
png_sticker=png_sticker,
emojis=emojis,
tgs_sticker=tgs_sticker,
mask_position=mask_position,
)
return await self(call)
async def set_sticker_position_in_set(self, sticker: str, position: int,) -> bool:
"""
Use this method to move a sticker in a set created by the bot to a specific position .
Use this method to move a sticker in a set created by the bot to a specific position.
Returns True on success.
Source: https://core.telegram.org/bots/api#setstickerpositioninset
@ -2012,6 +2082,31 @@ class Bot(ContextInstanceMixin["Bot"]):
call = DeleteStickerFromSet(sticker=sticker,)
return await self(call)
async def set_sticker_set_thumb(
self, name: str, user_id: int, thumb: Optional[Union[InputFile, str]] = None,
) -> bool:
"""
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.
Source: https://core.telegram.org/bots/api#setstickersetthumb
:param name: Sticker set name
:param user_id: User identifier of the sticker set owner
:param thumb: A PNG image with the thumbnail, must be up to 128 kilobytes in size and have
width and height exactly 100px, or a TGS animation with the thumbnail up to
32 kilobytes in size; see
https://core.telegram.org/animated_stickers#technical-requirements for
animated sticker technical requirements. Pass a file_id as a String to send
a file that already exists on the Telegram servers, pass an HTTP URL as a
String for Telegram to get a file from the Internet, or upload a new one
using multipart/form-data.. Animated sticker set thumbnail can't be uploaded
via HTTP URL.
:return: Returns True on success.
"""
call = SetStickerSetThumb(name=name, user_id=user_id, thumb=thumb,)
return await self(call)
# =============================================================================================
# Group: Inline mode
# Source: https://core.telegram.org/bots/api#inline-mode

View file

@ -4,15 +4,7 @@ import abc
import datetime
import json
from types import TracebackType
from typing import (
Any,
AsyncGenerator,
Callable,
Optional,
Type,
TypeVar,
Union,
)
from typing import Any, AsyncGenerator, Callable, Optional, Type, TypeVar, Union
from aiogram.utils.exceptions import TelegramAPIError

View file

@ -24,6 +24,7 @@ from .get_chat_members_count import GetChatMembersCount
from .get_file import GetFile
from .get_game_high_scores import GetGameHighScores
from .get_me import GetMe
from .get_my_commands import GetMyCommands
from .get_sticker_set import GetStickerSet
from .get_updates import GetUpdates
from .get_user_profile_photos import GetUserProfilePhotos
@ -37,6 +38,7 @@ from .send_animation import SendAnimation
from .send_audio import SendAudio
from .send_chat_action import SendChatAction
from .send_contact import SendContact
from .send_dice import SendDice
from .send_document import SendDocument
from .send_game import SendGame
from .send_invoice import SendInvoice
@ -57,8 +59,10 @@ from .set_chat_photo import SetChatPhoto
from .set_chat_sticker_set import SetChatStickerSet
from .set_chat_title import SetChatTitle
from .set_game_score import SetGameScore
from .set_my_commands import SetMyCommands
from .set_passport_data_errors import SetPassportDataErrors
from .set_sticker_position_in_set import SetStickerPositionInSet
from .set_sticker_set_thumb import SetStickerSetThumb
from .set_webhook import SetWebhook
from .stop_message_live_location import StopMessageLiveLocation
from .stop_poll import StopPoll
@ -91,6 +95,7 @@ __all__ = (
"SendVenue",
"SendContact",
"SendPoll",
"SendDice",
"SendChatAction",
"GetUserProfilePhotos",
"GetFile",
@ -115,6 +120,8 @@ __all__ = (
"SetChatStickerSet",
"DeleteChatStickerSet",
"AnswerCallbackQuery",
"SetMyCommands",
"GetMyCommands",
"EditMessageText",
"EditMessageCaption",
"EditMessageMedia",
@ -128,6 +135,7 @@ __all__ = (
"AddStickerToSet",
"SetStickerPositionInSet",
"DeleteStickerFromSet",
"SetStickerSetThumb",
"AnswerInlineQuery",
"SendInvoice",
"AnswerShippingQuery",

View file

@ -6,7 +6,10 @@ from .base import Request, TelegramMethod, prepare_file
class AddStickerToSet(TelegramMethod[bool]):
"""
Use this method to add a new sticker to a set created by the bot. Returns True on success.
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.
Source: https://core.telegram.org/bots/api#addstickertoset
"""
@ -18,19 +21,24 @@ class AddStickerToSet(TelegramMethod[bool]):
name: str
"""Sticker set name"""
png_sticker: Union[InputFile, str]
"""Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed
"""PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed
512px, and either width or height must be exactly 512px. Pass a file_id as a String to send
a file that already exists on the Telegram servers, pass an HTTP URL as a String for
Telegram to get a file from the Internet, or upload a new one using multipart/form-data."""
emojis: str
"""One or more emoji corresponding to the sticker"""
tgs_sticker: Optional[InputFile] = None
"""TGS animation with the sticker, uploaded using multipart/form-data. See
https://core.telegram.org/animated_stickers#technical-requirements for technical
requirements"""
mask_position: Optional[MaskPosition] = None
"""A JSON-serialized object for position where the mask should be placed on faces"""
def build_request(self) -> Request:
data: Dict[str, Any] = self.dict(exclude={"png_sticker"})
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"})
files: Dict[str, InputFile] = {}
prepare_file(data=data, files=files, name="png_sticker", value=self.png_sticker)
prepare_file(data=data, files=files, name="tgs_sticker", value=self.tgs_sticker)
return Request(method="addStickerToSet", data=data, files=files)

View file

@ -2,16 +2,7 @@ from __future__ import annotations
import abc
import secrets
from typing import (
Generator,
TYPE_CHECKING,
Any,
Dict,
Generic,
Optional,
TypeVar,
Union,
)
from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeVar, Union
from pydantic import BaseConfig, BaseModel, Extra
from pydantic.generics import GenericModel

View file

@ -6,8 +6,9 @@ from .base import Request, TelegramMethod, prepare_file
class CreateNewStickerSet(TelegramMethod[bool]):
"""
Use this method to create new sticker set owned by a user. The bot will be able to edit the
created sticker set. Returns True on success.
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.
Source: https://core.telegram.org/bots/api#createnewstickerset
"""
@ -23,22 +24,27 @@ class CreateNewStickerSet(TelegramMethod[bool]):
case insensitive. 1-64 characters."""
title: str
"""Sticker set title, 1-64 characters"""
png_sticker: Union[InputFile, str]
"""Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed
emojis: str
"""One or more emoji corresponding to the sticker"""
png_sticker: Optional[Union[InputFile, str]] = None
"""PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed
512px, and either width or height must be exactly 512px. Pass a file_id as a String to send
a file that already exists on the Telegram servers, pass an HTTP URL as a String for
Telegram to get a file from the Internet, or upload a new one using multipart/form-data."""
emojis: str
"""One or more emoji corresponding to the sticker"""
tgs_sticker: Optional[InputFile] = None
"""TGS animation with the sticker, uploaded using multipart/form-data. See
https://core.telegram.org/animated_stickers#technical-requirements for technical
requirements"""
contains_masks: Optional[bool] = None
"""Pass True, if a set of mask stickers should be created"""
mask_position: Optional[MaskPosition] = None
"""A JSON-serialized object for position where the mask should be placed on faces"""
def build_request(self) -> Request:
data: Dict[str, Any] = self.dict(exclude={"png_sticker"})
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"})
files: Dict[str, InputFile] = {}
prepare_file(data=data, files=files, name="png_sticker", value=self.png_sticker)
prepare_file(data=data, files=files, name="tgs_sticker", value=self.tgs_sticker)
return Request(method="createNewStickerSet", data=data, files=files)

View file

@ -8,6 +8,7 @@ class DeleteMessage(TelegramMethod[bool]):
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.

View file

@ -22,7 +22,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
inline_message_id: Optional[str] = None
"""Required if chat_id and message_id are not specified. Identifier of the inline message"""
caption: Optional[str] = None
"""New caption of the message"""
"""New caption of the message, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -15,7 +15,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
__returning__ = Union[Message, bool]
text: str
"""New text of the message"""
"""New text of the message, 1-4096 characters after entities parsing"""
chat_id: Optional[Union[int, str]] = None
"""Required if inline_message_id is not specified. Unique identifier for the target chat or
username of the target channel (in the format @channelusername)"""

View file

@ -0,0 +1,20 @@
from typing import Any, Dict, List
from ..types import BotCommand
from .base import Request, TelegramMethod
class GetMyCommands(TelegramMethod[List[BotCommand]]):
"""
Use this method to get the current list of the bot's commands. Requires no parameters. Returns
Array of BotCommand on success.
Source: https://core.telegram.org/bots/api#getmycommands
"""
__returning__ = List[BotCommand]
def build_request(self) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="getMyCommands", data=data)

View file

@ -43,7 +43,8 @@ class SendAnimation(TelegramMethod[Message]):
file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>."""
caption: Optional[str] = None
"""Animation caption (may also be used when resending animation by file_id), 0-1024 characters"""
"""Animation caption (may also be used when resending animation by file_id), 0-1024 characters
after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -32,7 +32,7 @@ class SendAudio(TelegramMethod[Message]):
Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio
file from the Internet, or upload a new one using multipart/form-data."""
caption: Optional[str] = None
"""Audio caption, 0-1024 characters"""
"""Audio caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -0,0 +1,40 @@
from typing import Any, Dict, Optional, Union
from ..types import (
ForceReply,
InlineKeyboardMarkup,
Message,
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
)
from .base import Request, TelegramMethod
class SendDice(TelegramMethod[Message]):
"""
Use this method to send a dice, which will have a random value from 1 to 6. On success, the
sent Message is returned. (Yes, we're aware of the 'proper' singular of die. But it's awkward,
and we decided to help it change. One dice at a time!)
Source: https://core.telegram.org/bots/api#senddice
"""
__returning__ = Message
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format
@channelusername)"""
disable_notification: Optional[bool] = None
"""Sends the message silently. Users will receive a notification with no sound."""
reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message"""
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None
"""Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user."""
def build_request(self) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="sendDice", data=data)

View file

@ -37,7 +37,8 @@ class SendDocument(TelegramMethod[Message]):
file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>."""
caption: Optional[str] = None
"""Document caption (may also be used when resending documents by file_id), 0-1024 characters"""
"""Document caption (may also be used when resending documents by file_id), 0-1024 characters
after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -23,7 +23,7 @@ class SendMessage(TelegramMethod[Message]):
"""Unique identifier for the target chat or username of the target channel (in the format
@channelusername)"""
text: str
"""Text of the message to be sent"""
"""Text of the message to be sent, 1-4096 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in your bot's message."""

View file

@ -28,7 +28,8 @@ class SendPhoto(TelegramMethod[Message]):
(recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet,
or upload a new photo using multipart/form-data."""
caption: Optional[str] = None
"""Photo caption (may also be used when resending photos by file_id), 0-1024 characters"""
"""Photo caption (may also be used when resending photos by file_id), 0-1024 characters after
entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -25,7 +25,7 @@ class SendPoll(TelegramMethod[Message]):
question: str
"""Poll question, 1-255 characters"""
options: List[str]
"""List of answer options, 2-10 strings 1-100 characters each"""
"""A JSON-serialized list of answer options, 2-10 strings 1-100 characters each"""
is_anonymous: Optional[bool] = None
"""True, if the poll needs to be anonymous, defaults to True"""
type: Optional[str] = None

View file

@ -26,7 +26,7 @@ class SendSticker(TelegramMethod[Message]):
@channelusername)"""
sticker: Union[InputFile, str]
"""Sticker to send. Pass a file_id as String to send a file that exists on the Telegram
servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from
servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from
the Internet, or upload a new one using multipart/form-data."""
disable_notification: Optional[bool] = None
"""Sends the message silently. Users will receive a notification with no sound."""

View file

@ -43,7 +43,8 @@ class SendVideo(TelegramMethod[Message]):
file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>."""
caption: Optional[str] = None
"""Video caption (may also be used when resending videos by file_id), 0-1024 characters"""
"""Video caption (may also be used when resending videos by file_id), 0-1024 characters after
entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -14,7 +14,7 @@ from .base import Request, TelegramMethod, prepare_file
class SendVoice(TelegramMethod[Message]):
"""
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
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.
@ -32,7 +32,7 @@ class SendVoice(TelegramMethod[Message]):
servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the
Internet, or upload a new one using multipart/form-data."""
caption: Optional[str] = None
"""Voice message caption, 0-1024 characters"""
"""Voice message caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -0,0 +1,23 @@
from typing import Any, Dict, List
from ..types import BotCommand
from .base import Request, TelegramMethod
class SetMyCommands(TelegramMethod[bool]):
"""
Use this method to change the list of the bot's commands. Returns True on success.
Source: https://core.telegram.org/bots/api#setmycommands
"""
__returning__ = bool
commands: List[BotCommand]
"""A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most
100 commands can be specified."""
def build_request(self) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="setMyCommands", data=data)

View file

@ -5,7 +5,7 @@ from .base import Request, TelegramMethod
class SetStickerPositionInSet(TelegramMethod[bool]):
"""
Use this method to move a sticker in a set created by the bot to a specific position . Returns
Use this method to move a sticker in a set created by the bot to a specific position. Returns
True on success.
Source: https://core.telegram.org/bots/api#setstickerpositioninset

View file

@ -0,0 +1,36 @@
from typing import Any, Dict, Optional, Union
from ..types import InputFile
from .base import Request, TelegramMethod, prepare_file
class SetStickerSetThumb(TelegramMethod[bool]):
"""
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.
Source: https://core.telegram.org/bots/api#setstickersetthumb
"""
__returning__ = bool
name: str
"""Sticker set name"""
user_id: int
"""User identifier of the sticker set owner"""
thumb: Optional[Union[InputFile, str]] = None
"""A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and
height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see
https://core.telegram.org/animated_stickers#technical-requirements for animated sticker
technical requirements. Pass a file_id as a String to send a file that already exists on
the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the
Internet, or upload a new one using multipart/form-data.. Animated sticker set thumbnail
can't be uploaded via HTTP URL."""
def build_request(self) -> Request:
data: Dict[str, Any] = self.dict(exclude={"thumb"})
files: Dict[str, InputFile] = {}
prepare_file(data=data, files=files, name="thumb", value=self.thumb)
return Request(method="setStickerSetThumb", data=data, files=files)

View file

@ -6,7 +6,7 @@ from .base import Request, TelegramMethod, prepare_file
class UploadStickerFile(TelegramMethod[File]):
"""
Use this method to upload a .png file with a sticker for later use in createNewStickerSet and
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.
Source: https://core.telegram.org/bots/api#uploadstickerfile

View file

@ -1,6 +1,7 @@
from .animation import Animation
from .audio import Audio
from .base import TelegramObject
from .bot_command import BotCommand
from .callback_game import CallbackGame
from .callback_query import CallbackQuery
from .chat import Chat
@ -9,6 +10,7 @@ from .chat_permissions import ChatPermissions
from .chat_photo import ChatPhoto
from .chosen_inline_result import ChosenInlineResult
from .contact import Contact
from .dice import Dice
from .document import Document
from .encrypted_credentials import EncryptedCredentials
from .encrypted_passport_element import EncryptedPassportElement
@ -121,6 +123,7 @@ __all__ = (
"PollOption",
"PollAnswer",
"Poll",
"Dice",
"UserProfilePhotos",
"File",
"ReplyKeyboardMarkup",
@ -135,6 +138,7 @@ __all__ = (
"ChatPhoto",
"ChatMember",
"ChatPermissions",
"BotCommand",
"ResponseParameters",
"InputMedia",
"InputMediaPhoto",

View file

@ -0,0 +1,17 @@
from __future__ import annotations
from .base import MutableTelegramObject
class BotCommand(MutableTelegramObject):
"""
This object represents a bot command.
Source: https://core.telegram.org/bots/api#botcommand
"""
command: str
"""Text of the command, 1-32 characters. Can contain only lowercase English letters, digits
and underscores."""
description: str
"""Description of the command, 3-256 characters."""

15
aiogram/api/types/dice.py Normal file
View file

@ -0,0 +1,15 @@
from __future__ import annotations
from .base import TelegramObject
class Dice(TelegramObject):
"""
This object represents a dice with random value from 1 to 6. (Yes, we're aware of the 'proper'
singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
Source: https://core.telegram.org/bots/api#dice
"""
value: int
"""Value of the dice, 1-6"""

View file

@ -31,7 +31,7 @@ class InlineQueryResultAudio(InlineQueryResult):
title: str
"""Title"""
caption: Optional[str] = None
"""Caption, 0-1024 characters"""
"""Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -29,7 +29,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
audio_file_id: str
"""A valid file identifier for the audio file"""
caption: Optional[str] = None
"""Caption, 0-1024 characters"""
"""Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -33,7 +33,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
description: Optional[str] = None
"""Short description of the result"""
caption: Optional[str] = None
"""Caption of the document to be sent, 0-1024 characters"""
"""Caption of the document to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -29,7 +29,7 @@ class InlineQueryResultCachedGif(InlineQueryResult):
title: Optional[str] = None
"""Title for the result"""
caption: Optional[str] = None
"""Caption of the GIF file to be sent, 0-1024 characters"""
"""Caption of the GIF file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -30,7 +30,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
title: Optional[str] = None
"""Title for the result"""
caption: Optional[str] = None
"""Caption of the MPEG-4 file to be sent, 0-1024 characters"""
"""Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -31,7 +31,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
description: Optional[str] = None
"""Short description of the result"""
caption: Optional[str] = None
"""Caption of the photo to be sent, 0-1024 characters"""
"""Caption of the photo to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -31,7 +31,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
description: Optional[str] = None
"""Short description of the result"""
caption: Optional[str] = None
"""Caption of the video to be sent, 0-1024 characters"""
"""Caption of the video to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -31,7 +31,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
title: str
"""Voice message title"""
caption: Optional[str] = None
"""Caption, 0-1024 characters"""
"""Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -34,7 +34,7 @@ class InlineQueryResultDocument(InlineQueryResult):
mime_type: str
"""Mime type of the content of the file, either 'application/pdf' or 'application/zip'"""
caption: Optional[str] = None
"""Caption of the document to be sent, 0-1024 characters"""
"""Caption of the document to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -37,7 +37,7 @@ class InlineQueryResultGif(InlineQueryResult):
title: Optional[str] = None
"""Title for the result"""
caption: Optional[str] = None
"""Caption of the GIF file to be sent, 0-1024 characters"""
"""Caption of the GIF file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -38,7 +38,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
title: Optional[str] = None
"""Title for the result"""
caption: Optional[str] = None
"""Caption of the MPEG-4 file to be sent, 0-1024 characters"""
"""Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -37,7 +37,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
description: Optional[str] = None
"""Short description of the result"""
caption: Optional[str] = None
"""Caption of the photo to be sent, 0-1024 characters"""
"""Caption of the photo to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -35,7 +35,7 @@ class InlineQueryResultVideo(InlineQueryResult):
title: str
"""Title for the result"""
caption: Optional[str] = None
"""Caption of the video to be sent, 0-1024 characters"""
"""Caption of the video to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -13,7 +13,7 @@ if TYPE_CHECKING: # pragma: no cover
class InlineQueryResultVoice(InlineQueryResult):
"""
Represents a link to a voice recording in an .ogg container encoded with OPUS. By default,
Represents a link to a voice recording in an .OGG container encoded with OPUS. By default,
this voice recording will be sent by the user. Alternatively, you can use
input_message_content to send a message with the specified content instead of the the voice
message.
@ -32,7 +32,7 @@ class InlineQueryResultVoice(InlineQueryResult):
title: str
"""Recording title"""
caption: Optional[str] = None
"""Caption, 0-1024 characters"""
"""Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -4,13 +4,7 @@ import io
import os
from abc import ABC, abstractmethod
from pathlib import Path
from typing import (
AsyncGenerator,
AsyncIterator,
Iterator,
Optional,
Union,
)
from typing import AsyncGenerator, AsyncIterator, Iterator, Optional, Union
import aiofiles as aiofiles

View file

@ -32,7 +32,7 @@ class InputMediaAnimation(InputMedia):
file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>."""
caption: Optional[str] = None
"""Caption of the animation to be sent, 0-1024 characters"""
"""Caption of the animation to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -32,7 +32,7 @@ class InputMediaAudio(InputMedia):
file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>."""
caption: Optional[str] = None
"""Caption of the audio to be sent, 0-1024 characters"""
"""Caption of the audio to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -32,7 +32,7 @@ class InputMediaDocument(InputMedia):
file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>."""
caption: Optional[str] = None
"""Caption of the document to be sent, 0-1024 characters"""
"""Caption of the document to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -25,7 +25,7 @@ class InputMediaPhoto(InputMedia):
'attach://<file_attach_name>' to upload a new one using multipart/form-data under
<file_attach_name> name."""
caption: Optional[str] = None
"""Caption of the photo to be sent, 0-1024 characters"""
"""Caption of the photo to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -32,7 +32,7 @@ class InputMediaVideo(InputMedia):
file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
multipart/form-data under <file_attach_name>."""
caption: Optional[str] = None
"""Caption of the video to be sent, 0-1024 characters"""
"""Caption of the video to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
inline URLs in the media caption."""

View file

@ -13,6 +13,7 @@ if TYPE_CHECKING: # pragma: no cover
from .audio import Audio
from .chat import Chat
from .contact import Contact
from .dice import Dice
from .document import Document
from .force_reply import ForceReply
from .game import Game
@ -95,7 +96,7 @@ class Message(TelegramObject):
author_signature: Optional[str] = None
"""Signature of the post author for messages in channels"""
text: Optional[str] = None
"""For text messages, the actual UTF-8 text of the message, 0-4096 characters."""
"""For text messages, the actual UTF-8 text of the message, 0-4096 characters"""
entities: Optional[List[MessageEntity]] = None
"""For text messages, special entities like usernames, URLs, bot commands, etc. that appear in
the text"""
@ -131,6 +132,8 @@ class Message(TelegramObject):
"""Message is a venue, information about the venue"""
poll: Optional[Poll] = None
"""Message is a native poll, information about the poll"""
dice: Optional[Dice] = None
"""Message is a dice with random value from 1 to 6"""
new_chat_members: Optional[List[User]] = None
"""New members that were added to the group or supergroup and information about them (the bot
itself may be one of these members)"""
@ -1479,7 +1482,8 @@ class ContentType(helper.Helper):
DELETE_CHAT_PHOTO = helper.Item() # delete_chat_photo
GROUP_CHAT_CREATED = helper.Item() # group_chat_created
PASSPORT_DATA = helper.Item() # passport_data
POLL = helper.Item()
POLL = helper.Item() # poll
DICE = helper.Item() # dice
UNKNOWN = helper.Item() # unknown
ANY = helper.Item() # any

View file

@ -28,7 +28,7 @@ class Sticker(TelegramObject):
is_animated: bool
"""True, if the sticker is animated"""
thumb: Optional[PhotoSize] = None
"""Sticker thumbnail in the .webp or .jpg format"""
"""Sticker thumbnail in the .WEBP or .JPG format"""
emoji: Optional[str] = None
"""Emoji associated with the sticker"""
set_name: Optional[str] = None

View file

@ -1,10 +1,11 @@
from __future__ import annotations
from typing import TYPE_CHECKING, List
from typing import TYPE_CHECKING, List, Optional
from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
from .photo_size import PhotoSize
from .sticker import Sticker
@ -25,3 +26,5 @@ class StickerSet(TelegramObject):
"""True, if the sticker set contains masks"""
stickers: List[Sticker]
"""List of all set stickers"""
thumb: Optional[PhotoSize] = None
"""Sticker set thumbnail in the .WEBP or .TGS format"""

View file

@ -1,17 +1,7 @@
import inspect
from dataclasses import dataclass, field
from functools import partial
from typing import (
Any,
Awaitable,
Callable,
Dict,
List,
Optional,
Tuple,
Union,
Type,
)
from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Type, Union
from aiogram.dispatcher.filters.base import BaseFilter
from aiogram.dispatcher.handler.base import BaseHandler

View file

@ -1,8 +1,4 @@
from typing import (
Dict,
Tuple,
Type,
)
from typing import Dict, Tuple, Type
from .base import BaseFilter
from .command import Command, CommandObject

View file

@ -1,12 +1,5 @@
from abc import ABC, abstractmethod
from typing import (
TYPE_CHECKING,
Any,
Dict,
Union,
Callable,
Awaitable,
)
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, Union
from pydantic import BaseModel

View file

@ -1,12 +1,5 @@
from abc import ABC, abstractmethod
from typing import (
TYPE_CHECKING,
Any,
Dict,
Generic,
TypeVar,
cast,
)
from typing import TYPE_CHECKING, Any, Dict, Generic, TypeVar, cast
from aiogram import Bot
from aiogram.api.types import Update

View file

@ -1,8 +1,5 @@
from abc import ABC
from typing import (
Optional,
cast,
)
from typing import Optional, cast
from aiogram.api.types import Chat, Message, User
from aiogram.dispatcher.filters import CommandObject

View file

@ -3,12 +3,7 @@ from __future__ import annotations
import warnings
from typing import Any, Dict, List, Optional, Union
from ..api.types import (
Chat,
TelegramObject,
Update,
User,
)
from ..api.types import Chat, TelegramObject, Update, User
from ..utils.imports import import_module
from ..utils.warnings import CodeHasNoEffect
from .event.observer import EventObserver, SkipHandler, TelegramEventObserver

View file

@ -14,15 +14,7 @@ Example:
<<< ['barItem', 'bazItem', 'fooItem', 'lorem']
"""
import inspect
from typing import (
Any,
Callable,
Iterable,
List,
Optional,
Union,
cast,
)
from typing import Any, Callable, Iterable, List, Optional, Union, cast
PROPS_KEYS_ATTR_NAME = "_props_keys"

View file

@ -1,20 +1,12 @@
from __future__ import annotations
import contextvars
from typing import (
Any,
ClassVar,
Generic,
Optional,
TypeVar,
cast,
overload,
Dict,
)
__all__ = ("ContextInstanceMixin", "DataMixin")
import contextvars
from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar, cast, overload
from typing_extensions import Literal
__all__ = ("ContextInstanceMixin", "DataMixin")
class DataMixin:
@property
@ -56,18 +48,24 @@ class ContextInstanceMixin(Generic[ContextInstance]):
def get_current(cls) -> Optional[ContextInstance]: # pragma: no cover
...
@overload # noqa: F811, it's overload, not redefinition
@overload
@classmethod
def get_current(cls, no_error: Literal[True]) -> Optional[ContextInstance]: # pragma: no cover # noqa: F811
def get_current( # noqa: F811
cls, no_error: Literal[True]
) -> Optional[ContextInstance]: # pragma: no cover
...
@overload # noqa: F811, it's overload, not redefinition
@overload
@classmethod
def get_current(cls, no_error: Literal[False]) -> ContextInstance: # pragma: no cover # noqa: F811
def get_current( # noqa: F811
cls, no_error: Literal[False]
) -> ContextInstance: # pragma: no cover
...
@classmethod # noqa: F811, it's overload, not redefinition
def get_current(cls, no_error: bool = True) -> Optional[ContextInstance]: # pragma: no cover # noqa: F811
@classmethod
def get_current( # noqa: F811
cls, no_error: bool = True
) -> Optional[ContextInstance]: # pragma: no cover
# on mypy 0.770 I catch that contextvars.ContextVar always contextvars.ContextVar[Any]
cls.__context_instance = cast(
contextvars.ContextVar[ContextInstance], cls.__context_instance

View file

@ -1 +1 @@
4.6
4.7

View file

@ -2,7 +2,7 @@
## Description
Use this method to add a new sticker to a set created by the bot. Returns True on success.
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.
## Arguments
@ -11,8 +11,9 @@ Use this method to add a new sticker to a set created by the bot. Returns True o
| - | - | - |
| `user_id` | `#!python3 int` | User identifier of sticker set owner |
| `name` | `#!python3 str` | Sticker set name |
| `png_sticker` | `#!python3 Union[InputFile, str]` | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. |
| `png_sticker` | `#!python3 Union[InputFile, str]` | PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. |
| `emojis` | `#!python3 str` | One or more emoji corresponding to the sticker |
| `tgs_sticker` | `#!python3 Optional[InputFile]` | Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements |
| `mask_position` | `#!python3 Optional[MaskPosition]` | Optional. A JSON-serialized object for position where the mask should be placed on faces |
@ -26,8 +27,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.add_sticker_to_set(...)
@ -56,7 +56,6 @@ return AddStickerToSet(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#addstickertoset)

View file

@ -28,8 +28,7 @@ Description: On success, True is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.answer_callback_query(...)
@ -58,7 +57,6 @@ return AnswerCallbackQuery(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#answercallbackquery)

View file

@ -30,8 +30,7 @@ Description: On success, True is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.answer_inline_query(...)
@ -60,7 +59,6 @@ return AnswerInlineQuery(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#answerinlinequery)

View file

@ -24,8 +24,7 @@ Description: On success, True is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.answer_pre_checkout_query(...)
@ -54,7 +53,6 @@ return AnswerPreCheckoutQuery(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#answerprecheckoutquery)

View file

@ -25,8 +25,7 @@ Description: On success, True is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.answer_shipping_query(...)
@ -55,7 +54,6 @@ return AnswerShippingQuery(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#answershippingquery)

View file

@ -2,7 +2,7 @@
## Description
Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
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.
## Arguments
@ -12,8 +12,9 @@ Use this method to create new sticker set owned by a user. The bot will be able
| `user_id` | `#!python3 int` | User identifier of created sticker set owner |
| `name` | `#!python3 str` | Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in '_by_<bot username>'. <bot_username> is case insensitive. 1-64 characters. |
| `title` | `#!python3 str` | Sticker set title, 1-64 characters |
| `png_sticker` | `#!python3 Union[InputFile, str]` | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. |
| `emojis` | `#!python3 str` | One or more emoji corresponding to the sticker |
| `png_sticker` | `#!python3 Optional[Union[InputFile, str]]` | Optional. PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. |
| `tgs_sticker` | `#!python3 Optional[InputFile]` | Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements |
| `contains_masks` | `#!python3 Optional[bool]` | Optional. Pass True, if a set of mask stickers should be created |
| `mask_position` | `#!python3 Optional[MaskPosition]` | Optional. A JSON-serialized object for position where the mask should be placed on faces |
@ -28,8 +29,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.create_new_sticker_set(...)
@ -58,7 +58,6 @@ return CreateNewStickerSet(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#createnewstickerset)

View file

@ -22,8 +22,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.delete_chat_photo(...)
@ -52,7 +51,6 @@ return DeleteChatPhoto(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#deletechatphoto)

View file

@ -22,8 +22,7 @@ Description: Use the field can_set_sticker_set optionally returned in getChat re
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.delete_chat_sticker_set(...)
@ -52,7 +51,6 @@ return DeleteChatStickerSet(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#deletechatstickerset)

View file

@ -6,6 +6,8 @@ Use this method to delete a message, including service messages, with the follow
- 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.
@ -37,8 +39,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.delete_message(...)
@ -67,7 +68,6 @@ return DeleteMessage(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#deletemessage)

View file

@ -22,8 +22,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.delete_sticker_from_set(...)
@ -52,7 +51,6 @@ return DeleteStickerFromSet(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#deletestickerfromset)

View file

@ -16,8 +16,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.delete_webhook(...)
@ -46,7 +45,6 @@ return DeleteWebhook(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#deletewebhook)

View file

@ -12,7 +12,7 @@ Use this method to edit captions of messages. On success, if edited message is s
| `chat_id` | `#!python3 Optional[Union[int, str]]` | Optional. Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
| `message_id` | `#!python3 Optional[int]` | Optional. Required if inline_message_id is not specified. Identifier of the message to edit |
| `inline_message_id` | `#!python3 Optional[str]` | Optional. Required if chat_id and message_id are not specified. Identifier of the inline message |
| `caption` | `#!python3 Optional[str]` | Optional. New caption of the message |
| `caption` | `#!python3 Optional[str]` | Optional. New caption of the message, 0-1024 characters after entities parsing |
| `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. |
| `reply_markup` | `#!python3 Optional[InlineKeyboardMarkup]` | Optional. A JSON-serialized object for an inline keyboard. |
@ -27,8 +27,7 @@ Description: On success, if edited message is sent by the bot, the edited Messag
## Usage
### As bot method bot
### As bot method
```python3
result: Union[Message, bool] = await bot.edit_message_caption(...)
@ -57,7 +56,6 @@ return EditMessageCaption(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#editmessagecaption)

View file

@ -27,8 +27,7 @@ Description: On success, if the edited message was sent by the bot, the edited M
## Usage
### As bot method bot
### As bot method
```python3
result: Union[Message, bool] = await bot.edit_message_live_location(...)
@ -57,7 +56,6 @@ return EditMessageLiveLocation(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#editmessagelivelocation)

View file

@ -26,8 +26,7 @@ Description: On success, if the edited message was sent by the bot, the edited M
## Usage
### As bot method bot
### As bot method
```python3
result: Union[Message, bool] = await bot.edit_message_media(...)
@ -56,7 +55,6 @@ return EditMessageMedia(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#editmessagemedia)

View file

@ -25,8 +25,7 @@ Description: On success, if edited message is sent by the bot, the edited Messag
## Usage
### As bot method bot
### As bot method
```python3
result: Union[Message, bool] = await bot.edit_message_reply_markup(...)
@ -55,7 +54,6 @@ return EditMessageReplyMarkup(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#editmessagereplymarkup)

View file

@ -9,7 +9,7 @@ Use this method to edit text and game messages. On success, if edited message is
| Name | Type | Description |
| - | - | - |
| `text` | `#!python3 str` | New text of the message |
| `text` | `#!python3 str` | New text of the message, 1-4096 characters after entities parsing |
| `chat_id` | `#!python3 Optional[Union[int, str]]` | Optional. Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
| `message_id` | `#!python3 Optional[int]` | Optional. Required if inline_message_id is not specified. Identifier of the message to edit |
| `inline_message_id` | `#!python3 Optional[str]` | Optional. Required if chat_id and message_id are not specified. Identifier of the inline message |
@ -28,8 +28,7 @@ Description: On success, if edited message is sent by the bot, the edited Messag
## Usage
### As bot method bot
### As bot method
```python3
result: Union[Message, bool] = await bot.edit_message_text(...)
@ -58,7 +57,6 @@ return EditMessageText(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#editmessagetext)

View file

@ -24,8 +24,7 @@ Description: Returns the new invite link as String on success.
## Usage
### As bot method bot
### As bot method
```python3
result: str = await bot.export_chat_invite_link(...)
@ -54,7 +53,6 @@ return ExportChatInviteLink(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#exportchatinvitelink)

View file

@ -25,8 +25,7 @@ Description: On success, the sent Message is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: Message = await bot.forward_message(...)
@ -55,7 +54,6 @@ return ForwardMessage(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#forwardmessage)

View file

@ -22,8 +22,7 @@ Description: Returns a Chat object on success.
## Usage
### As bot method bot
### As bot method
```python3
result: Chat = await bot.get_chat(...)

View file

@ -22,8 +22,7 @@ Description: On success, returns an Array of ChatMember objects that contains in
## Usage
### As bot method bot
### As bot method
```python3
result: List[ChatMember] = await bot.get_chat_administrators(...)

View file

@ -23,8 +23,7 @@ Description: Returns a ChatMember object on success.
## Usage
### As bot method bot
### As bot method
```python3
result: ChatMember = await bot.get_chat_member(...)

View file

@ -22,8 +22,7 @@ Description: Returns Int on success.
## Usage
### As bot method bot
### As bot method
```python3
result: int = await bot.get_chat_members_count(...)

View file

@ -24,8 +24,7 @@ Description: On success, a File object is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: File = await bot.get_file(...)

View file

@ -27,8 +27,7 @@ Description: Will return the score of the specified user and several of his neig
## Usage
### As bot method bot
### As bot method
```python3
result: List[GameHighScore] = await bot.get_game_high_scores(...)

View file

@ -16,8 +16,7 @@ Description: Returns basic information about the bot in form of a User object.
## Usage
### As bot method bot
### As bot method
```python3
result: User = await bot.get_me(...)

View file

@ -0,0 +1,48 @@
# getMyCommands
## Description
Use this method to get the current list of the bot's commands. Requires no parameters. Returns Array of BotCommand on success.
## Response
Type: `#!python3 List[BotCommand]`
Description: Returns Array of BotCommand on success.
## Usage
### As bot method
```python3
result: List[BotCommand] = await bot.get_my_commands(...)
```
### Method as object
Imports:
- `from aiogram.methods import GetMyCommands`
- `from aiogram.api.methods import GetMyCommands`
- `from aiogram.api.methods.get_my_commands import GetMyCommands`
#### In handlers with current bot
```python3
result: List[BotCommand] = await GetMyCommands(...)
```
#### With specific bot
```python3
result: List[BotCommand] = await bot(GetMyCommands(...))
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#getmycommands)
- [aiogram.types.BotCommand](../types/bot_command.md)

View file

@ -22,8 +22,7 @@ Description: On success, a StickerSet object is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: StickerSet = await bot.get_sticker_set(...)

View file

@ -31,8 +31,7 @@ Description: An Array of Update objects is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: List[Update] = await bot.get_updates(...)

View file

@ -24,8 +24,7 @@ Description: Returns a UserProfilePhotos object.
## Usage
### As bot method bot
### As bot method
```python3
result: UserProfilePhotos = await bot.get_user_profile_photos(...)

View file

@ -16,8 +16,7 @@ Description: On success, returns a WebhookInfo object. If the bot is using getUp
## Usage
### As bot method bot
### As bot method
```python3
result: WebhookInfo = await bot.get_webhook_info(...)

View file

@ -2,7 +2,6 @@
Here is list of all available API methods:
- Getting updates
- [getUpdates](get_updates.md)
- [setWebhook](set_webhook.md)
@ -26,6 +25,7 @@ Here is list of all available API methods:
- [sendVenue](send_venue.md)
- [sendContact](send_contact.md)
- [sendPoll](send_poll.md)
- [sendDice](send_dice.md)
- [sendChatAction](send_chat_action.md)
- [getUserProfilePhotos](get_user_profile_photos.md)
- [getFile](get_file.md)
@ -50,6 +50,8 @@ Here is list of all available API methods:
- [setChatStickerSet](set_chat_sticker_set.md)
- [deleteChatStickerSet](delete_chat_sticker_set.md)
- [answerCallbackQuery](answer_callback_query.md)
- [setMyCommands](set_my_commands.md)
- [getMyCommands](get_my_commands.md)
- Updating messages
- [editMessageText](edit_message_text.md)
- [editMessageCaption](edit_message_caption.md)
@ -65,6 +67,7 @@ Here is list of all available API methods:
- [addStickerToSet](add_sticker_to_set.md)
- [setStickerPositionInSet](set_sticker_position_in_set.md)
- [deleteStickerFromSet](delete_sticker_from_set.md)
- [setStickerSetThumb](set_sticker_set_thumb.md)
- Inline mode
- [answerInlineQuery](answer_inline_query.md)
- Payments

View file

@ -24,8 +24,7 @@ Description: In the case of supergroups and channels, the user will not be able
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.kick_chat_member(...)
@ -54,7 +53,6 @@ return KickChatMember(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#kickchatmember)

View file

@ -22,8 +22,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.leave_chat(...)
@ -52,7 +51,6 @@ return LeaveChat(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#leavechat)

View file

@ -24,8 +24,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.pin_chat_message(...)
@ -54,7 +53,6 @@ return PinChatMessage(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#pinchatmessage)

View file

@ -31,8 +31,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.promote_chat_member(...)
@ -61,7 +60,6 @@ return PromoteChatMember(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#promotechatmember)

View file

@ -25,8 +25,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.restrict_chat_member(...)
@ -55,7 +54,6 @@ return RestrictChatMember(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#restrictchatmember)

View file

@ -15,7 +15,7 @@ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without s
| `width` | `#!python3 Optional[int]` | Optional. Animation width |
| `height` | `#!python3 Optional[int]` | Optional. Animation height |
| `thumb` | `#!python3 Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnails width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails cant be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
| `caption` | `#!python3 Optional[str]` | Optional. Animation caption (may also be used when resending animation by file_id), 0-1024 characters |
| `caption` | `#!python3 Optional[str]` | Optional. Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing |
| `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. |
| `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. |
| `reply_to_message_id` | `#!python3 Optional[int]` | Optional. If the message is a reply, ID of the original message |
@ -32,8 +32,7 @@ Description: On success, the sent Message is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: Message = await bot.send_animation(...)
@ -62,7 +61,6 @@ return SendAnimation(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#sendanimation)

View file

@ -13,7 +13,7 @@ For sending voice messages, use the sendVoice method instead.
| - | - | - |
| `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
| `audio` | `#!python3 Union[InputFile, str]` | Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. |
| `caption` | `#!python3 Optional[str]` | Optional. Audio caption, 0-1024 characters |
| `caption` | `#!python3 Optional[str]` | Optional. Audio caption, 0-1024 characters after entities parsing |
| `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. |
| `duration` | `#!python3 Optional[int]` | Optional. Duration of the audio in seconds |
| `performer` | `#!python3 Optional[str]` | Optional. Performer |
@ -34,8 +34,7 @@ Description: On success, the sent Message is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: Message = await bot.send_audio(...)
@ -64,7 +63,6 @@ return SendAudio(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#sendaudio)

View file

@ -27,8 +27,7 @@ Description: Returns True on success.
## Usage
### As bot method bot
### As bot method
```python3
result: bool = await bot.send_chat_action(...)
@ -57,7 +56,6 @@ return SendChatAction(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#sendchataction)

View file

@ -29,8 +29,7 @@ Description: On success, the sent Message is returned.
## Usage
### As bot method bot
### As bot method
```python3
result: Message = await bot.send_contact(...)
@ -59,7 +58,6 @@ return SendContact(...)
```
## Related pages:
- [Official documentation](https://core.telegram.org/bots/api#sendcontact)

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