mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Bot API 6.6 (#1139)
* Added basic support of Bot API 6.6 * Update descriptions * Added StickerFormat enum * Bump version * Refresh from docs * Fixed CommandStart * Fixed files uploading * Cover new functionality * Added changelog * Update texts
This commit is contained in:
parent
5adaf7a567
commit
6570d0bab1
218 changed files with 7687 additions and 1741 deletions
|
|
@ -23,6 +23,7 @@ from .delete_forum_topic import DeleteForumTopic
|
|||
from .delete_message import DeleteMessage
|
||||
from .delete_my_commands import DeleteMyCommands
|
||||
from .delete_sticker_from_set import DeleteStickerFromSet
|
||||
from .delete_sticker_set import DeleteStickerSet
|
||||
from .delete_webhook import DeleteWebhook
|
||||
from .edit_chat_invite_link import EditChatInviteLink
|
||||
from .edit_forum_topic import EditForumTopic
|
||||
|
|
@ -46,6 +47,8 @@ from .get_game_high_scores import GetGameHighScores
|
|||
from .get_me import GetMe
|
||||
from .get_my_commands import GetMyCommands
|
||||
from .get_my_default_administrator_rights import GetMyDefaultAdministratorRights
|
||||
from .get_my_description import GetMyDescription
|
||||
from .get_my_short_description import GetMyShortDescription
|
||||
from .get_sticker_set import GetStickerSet
|
||||
from .get_updates import GetUpdates
|
||||
from .get_user_profile_photos import GetUserProfilePhotos
|
||||
|
|
@ -84,12 +87,19 @@ from .set_chat_permissions import SetChatPermissions
|
|||
from .set_chat_photo import SetChatPhoto
|
||||
from .set_chat_sticker_set import SetChatStickerSet
|
||||
from .set_chat_title import SetChatTitle
|
||||
from .set_custom_emoji_sticker_set_thumbnail import SetCustomEmojiStickerSetThumbnail
|
||||
from .set_game_score import SetGameScore
|
||||
from .set_my_commands import SetMyCommands
|
||||
from .set_my_default_administrator_rights import SetMyDefaultAdministratorRights
|
||||
from .set_my_description import SetMyDescription
|
||||
from .set_my_short_description import SetMyShortDescription
|
||||
from .set_passport_data_errors import SetPassportDataErrors
|
||||
from .set_sticker_emoji_list import SetStickerEmojiList
|
||||
from .set_sticker_keywords import SetStickerKeywords
|
||||
from .set_sticker_mask_position import SetStickerMaskPosition
|
||||
from .set_sticker_position_in_set import SetStickerPositionInSet
|
||||
from .set_sticker_set_thumb import SetStickerSetThumb
|
||||
from .set_sticker_set_thumbnail import SetStickerSetThumbnail
|
||||
from .set_sticker_set_title import SetStickerSetTitle
|
||||
from .set_webhook import SetWebhook
|
||||
from .stop_message_live_location import StopMessageLiveLocation
|
||||
from .stop_poll import StopPoll
|
||||
|
|
@ -126,6 +136,7 @@ __all__ = (
|
|||
"DeleteMessage",
|
||||
"DeleteMyCommands",
|
||||
"DeleteStickerFromSet",
|
||||
"DeleteStickerSet",
|
||||
"DeleteWebhook",
|
||||
"EditChatInviteLink",
|
||||
"EditForumTopic",
|
||||
|
|
@ -149,6 +160,8 @@ __all__ = (
|
|||
"GetMe",
|
||||
"GetMyCommands",
|
||||
"GetMyDefaultAdministratorRights",
|
||||
"GetMyDescription",
|
||||
"GetMyShortDescription",
|
||||
"GetStickerSet",
|
||||
"GetUpdates",
|
||||
"GetUserProfilePhotos",
|
||||
|
|
@ -189,12 +202,19 @@ __all__ = (
|
|||
"SetChatPhoto",
|
||||
"SetChatStickerSet",
|
||||
"SetChatTitle",
|
||||
"SetCustomEmojiStickerSetThumbnail",
|
||||
"SetGameScore",
|
||||
"SetMyCommands",
|
||||
"SetMyDefaultAdministratorRights",
|
||||
"SetMyDescription",
|
||||
"SetMyShortDescription",
|
||||
"SetPassportDataErrors",
|
||||
"SetStickerEmojiList",
|
||||
"SetStickerKeywords",
|
||||
"SetStickerMaskPosition",
|
||||
"SetStickerPositionInSet",
|
||||
"SetStickerSetThumb",
|
||||
"SetStickerSetThumbnail",
|
||||
"SetStickerSetTitle",
|
||||
"SetWebhook",
|
||||
"StopMessageLiveLocation",
|
||||
"StopPoll",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
|
||||
from ..types import InputFile, MaskPosition
|
||||
from .base import Request, TelegramMethod, prepare_file
|
||||
from ..types import InputFile, InputSticker
|
||||
from .base import Request, TelegramMethod, prepare_input_sticker
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
|
@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class AddStickerToSet(TelegramMethod[bool]):
|
||||
"""
|
||||
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*, *tgs_sticker*, or *webm_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 :code:`True` on success.
|
||||
Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#addstickertoset
|
||||
"""
|
||||
|
|
@ -22,23 +22,13 @@ class AddStickerToSet(TelegramMethod[bool]):
|
|||
"""User identifier of sticker set owner"""
|
||||
name: str
|
||||
"""Sticker set name"""
|
||||
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. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
tgs_sticker: Optional[InputFile] = None
|
||||
"""**TGS** animation with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for technical requirements"""
|
||||
webm_sticker: Optional[InputFile] = None
|
||||
"""**WEBM** video with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for technical requirements"""
|
||||
mask_position: Optional[MaskPosition] = None
|
||||
"""A JSON-serialized object for position where the mask should be placed on faces"""
|
||||
sticker: InputSticker
|
||||
"""A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker", "webm_sticker"})
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
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)
|
||||
prepare_file(data=data, files=files, name="webm_sticker", value=self.webm_sticker)
|
||||
prepare_input_sticker(input_sticker=data["sticker"], files=files)
|
||||
|
||||
return Request(method="addStickerToSet", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -100,10 +100,10 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[TelegramType]):
|
|||
def prepare_file(name: str, value: Any, data: Dict[str, Any], files: Dict[str, Any]) -> None:
|
||||
if not value:
|
||||
return
|
||||
if name == "thumb":
|
||||
if name == "thumbnail":
|
||||
tag = secrets.token_urlsafe(10)
|
||||
files[tag] = value
|
||||
data["thumb"] = f"attach://{tag}"
|
||||
data["thumbnail"] = f"attach://{tag}"
|
||||
elif isinstance(value, InputFile):
|
||||
files[name] = value
|
||||
else:
|
||||
|
|
@ -122,6 +122,22 @@ def prepare_input_media(data: Dict[str, Any], files: Dict[str, InputFile]) -> No
|
|||
input_media["media"] = f"attach://{tag}"
|
||||
|
||||
|
||||
def prepare_input_sticker(input_sticker: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||
if (
|
||||
"sticker" in input_sticker
|
||||
and input_sticker["sticker"]
|
||||
and isinstance(input_sticker["sticker"], InputFile)
|
||||
):
|
||||
tag = secrets.token_urlsafe(10)
|
||||
files[tag] = input_sticker.pop("sticker")
|
||||
input_sticker["sticker"] = f"attach://{tag}"
|
||||
|
||||
|
||||
def prepare_input_stickers(data: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||
for input_sticker in data["stickers"]:
|
||||
prepare_input_sticker(input_sticker, files=files)
|
||||
|
||||
|
||||
def prepare_media_file(data: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||
if (
|
||||
data["media"]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
from ..types import InputFile, MaskPosition
|
||||
from .base import Request, TelegramMethod, prepare_file
|
||||
from ..types import InputFile, InputSticker
|
||||
from .base import Request, TelegramMethod, prepare_input_sticker, prepare_input_stickers
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
|
@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class CreateNewStickerSet(TelegramMethod[bool]):
|
||||
"""
|
||||
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*, *tgs_sticker*, or *webm_sticker*. Returns :code:`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. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#createnewstickerset
|
||||
"""
|
||||
|
|
@ -24,25 +24,19 @@ class CreateNewStickerSet(TelegramMethod[bool]):
|
|||
"""Short name of sticker set, to be used in :code:`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 :code:`"_by_<bot_username>"`. :code:`<bot_username>` is case insensitive. 1-64 characters."""
|
||||
title: str
|
||||
"""Sticker set title, 1-64 characters"""
|
||||
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. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
tgs_sticker: Optional[InputFile] = None
|
||||
"""**TGS** animation with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for technical requirements"""
|
||||
webm_sticker: Optional[InputFile] = None
|
||||
"""**WEBM** video with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for technical requirements"""
|
||||
stickers: List[InputSticker]
|
||||
"""A JSON-serialized list of 1-50 initial stickers to be added to the sticker set"""
|
||||
sticker_format: str
|
||||
"""Format of stickers in the set, must be one of 'static', 'animated', 'video'"""
|
||||
sticker_type: Optional[str] = None
|
||||
"""Type of stickers in the set, pass 'regular' or 'mask'. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created."""
|
||||
mask_position: Optional[MaskPosition] = None
|
||||
"""A JSON-serialized object for position where the mask should be placed on faces"""
|
||||
"""Type of stickers in the set, pass 'regular', 'mask', or 'custom_emoji'. By default, a regular sticker set is created."""
|
||||
needs_repainting: Optional[bool] = None
|
||||
"""Pass :code:`True` if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker", "webm_sticker"})
|
||||
|
||||
data: Dict[str, Any] = self.dict()
|
||||
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)
|
||||
prepare_file(data=data, files=files, name="webm_sticker", value=self.webm_sticker)
|
||||
|
||||
prepare_input_stickers(data=data, files=files)
|
||||
|
||||
return Request(method="createNewStickerSet", data=data, files=files)
|
||||
|
|
|
|||
26
aiogram/methods/delete_sticker_set.py
Normal file
26
aiogram/methods/delete_sticker_set.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class DeleteStickerSet(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to delete a sticker set that was created by the bot. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#deletestickerset
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
name: str
|
||||
"""Sticker set name"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="deleteStickerSet", data=data)
|
||||
27
aiogram/methods/get_my_description.py
Normal file
27
aiogram/methods/get_my_description.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from ..types import BotDescription
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class GetMyDescription(TelegramMethod[BotDescription]):
|
||||
"""
|
||||
Use this method to get the current bot description for the given user language. Returns :class:`aiogram.types.bot_description.BotDescription` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#getmydescription
|
||||
"""
|
||||
|
||||
__returning__ = BotDescription
|
||||
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code or an empty string"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getMyDescription", data=data)
|
||||
27
aiogram/methods/get_my_short_description.py
Normal file
27
aiogram/methods/get_my_short_description.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from ..types import BotShortDescription
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class GetMyShortDescription(TelegramMethod[BotShortDescription]):
|
||||
"""
|
||||
Use this method to get the current bot short description for the given user language. Returns :class:`aiogram.types.bot_short_description.BotShortDescription` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#getmyshortdescription
|
||||
"""
|
||||
|
||||
__returning__ = BotShortDescription
|
||||
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code or an empty string"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="getMyShortDescription", data=data)
|
||||
|
|
@ -39,7 +39,7 @@ class SendAnimation(TelegramMethod[Message]):
|
|||
"""Animation width"""
|
||||
height: Optional[int] = None
|
||||
"""Animation height"""
|
||||
thumb: Optional[Union[InputFile, str]] = None
|
||||
thumbnail: Optional[Union[InputFile, str]] = None
|
||||
"""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 thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't 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>. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
caption: Optional[str] = None
|
||||
"""Animation caption (may also be used when resending animation by *file_id*), 0-1024 characters after entities parsing"""
|
||||
|
|
@ -71,6 +71,6 @@ class SendAnimation(TelegramMethod[Message]):
|
|||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="animation", value=self.animation)
|
||||
prepare_file(data=data, files=files, name="thumb", value=self.thumb)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendAnimation", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class SendAudio(TelegramMethod[Message]):
|
|||
"""Performer"""
|
||||
title: Optional[str] = None
|
||||
"""Track name"""
|
||||
thumb: Optional[Union[InputFile, str]] = None
|
||||
thumbnail: Optional[Union[InputFile, str]] = None
|
||||
"""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 thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't 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>. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
|
||||
|
|
@ -70,6 +70,6 @@ class SendAudio(TelegramMethod[Message]):
|
|||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="audio", value=self.audio)
|
||||
prepare_file(data=data, files=files, name="thumb", value=self.thumb)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendAudio", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class SendDocument(TelegramMethod[Message]):
|
|||
"""File 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 file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
message_thread_id: Optional[int] = None
|
||||
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
|
||||
thumb: Optional[Union[InputFile, str]] = None
|
||||
thumbnail: Optional[Union[InputFile, str]] = None
|
||||
"""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 thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't 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>. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
caption: Optional[str] = None
|
||||
"""Document caption (may also be used when resending documents by *file_id*), 0-1024 characters after entities parsing"""
|
||||
|
|
@ -65,6 +65,6 @@ class SendDocument(TelegramMethod[Message]):
|
|||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="document", value=self.document)
|
||||
prepare_file(data=data, files=files, name="thumb", value=self.thumb)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendDocument", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -28,9 +28,11 @@ class SendSticker(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@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 the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
"""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 sticker from the Internet, or upload a new .WEBP or .TGS sticker using multipart/form-data. :ref:`More information on Sending Files » <sending-files>`. Video stickers can only be sent by a file_id. Animated stickers can't be sent via an HTTP URL."""
|
||||
message_thread_id: Optional[int] = None
|
||||
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
|
||||
emoji: Optional[str] = None
|
||||
"""Emoji associated with the sticker; only for just uploaded stickers"""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
|
||||
protect_content: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class SendVideo(TelegramMethod[Message]):
|
|||
"""Video width"""
|
||||
height: Optional[int] = None
|
||||
"""Video height"""
|
||||
thumb: Optional[Union[InputFile, str]] = None
|
||||
thumbnail: Optional[Union[InputFile, str]] = None
|
||||
"""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 thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't 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>. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
caption: Optional[str] = None
|
||||
"""Video caption (may also be used when resending videos by *file_id*), 0-1024 characters after entities parsing"""
|
||||
|
|
@ -73,6 +73,6 @@ class SendVideo(TelegramMethod[Message]):
|
|||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="video", value=self.video)
|
||||
prepare_file(data=data, files=files, name="thumb", value=self.thumb)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendVideo", data=data, files=files)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class SendVideoNote(TelegramMethod[Message]):
|
|||
"""Duration of sent video in seconds"""
|
||||
length: Optional[int] = None
|
||||
"""Video width and height, i.e. diameter of the video message"""
|
||||
thumb: Optional[Union[InputFile, str]] = None
|
||||
thumbnail: Optional[Union[InputFile, str]] = None
|
||||
"""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 thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't 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>. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
|
||||
|
|
@ -55,6 +55,6 @@ class SendVideoNote(TelegramMethod[Message]):
|
|||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file(data=data, files=files, name="video_note", value=self.video_note)
|
||||
prepare_file(data=data, files=files, name="thumb", value=self.thumb)
|
||||
prepare_file(data=data, files=files, name="thumbnail", value=self.thumbnail)
|
||||
|
||||
return Request(method="sendVideoNote", data=data, files=files)
|
||||
|
|
|
|||
28
aiogram/methods/set_custom_emoji_sticker_set_thumbnail.py
Normal file
28
aiogram/methods/set_custom_emoji_sticker_set_thumbnail.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetCustomEmojiStickerSetThumbnail(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to set the thumbnail of a custom emoji sticker set. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
name: str
|
||||
"""Sticker set name"""
|
||||
custom_emoji_id: Optional[str] = None
|
||||
"""Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setCustomEmojiStickerSetThumbnail", data=data)
|
||||
|
|
@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class SetMyDefaultAdministratorRights(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns :code:`True` on success.
|
||||
Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setmydefaultadministratorrights
|
||||
"""
|
||||
|
|
|
|||
28
aiogram/methods/set_my_description.py
Normal file
28
aiogram/methods/set_my_description.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetMyDescription(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setmydescription
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
description: Optional[str] = None
|
||||
"""New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language."""
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setMyDescription", data=data)
|
||||
28
aiogram/methods/set_my_short_description.py
Normal file
28
aiogram/methods/set_my_short_description.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetMyShortDescription(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setmyshortdescription
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
short_description: Optional[str] = None
|
||||
"""New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language."""
|
||||
language_code: Optional[str] = None
|
||||
"""A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setMyShortDescription", data=data)
|
||||
28
aiogram/methods/set_sticker_emoji_list.py
Normal file
28
aiogram/methods/set_sticker_emoji_list.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetStickerEmojiList(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setstickeremojilist
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
emoji_list: List[str]
|
||||
"""A JSON-serialized list of 1-20 emoji associated with the sticker"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerEmojiList", data=data)
|
||||
28
aiogram/methods/set_sticker_keywords.py
Normal file
28
aiogram/methods/set_sticker_keywords.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetStickerKeywords(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setstickerkeywords
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
keywords: Optional[List[str]] = None
|
||||
"""A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerKeywords", data=data)
|
||||
29
aiogram/methods/set_sticker_mask_position.py
Normal file
29
aiogram/methods/set_sticker_mask_position.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from ..types import MaskPosition
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetStickerMaskPosition(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to change the `mask position <https://core.telegram.org/bots/api#maskposition>`_ of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setstickermaskposition
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
sticker: str
|
||||
"""File identifier of the sticker"""
|
||||
mask_position: Optional[MaskPosition] = None
|
||||
"""A JSON-serialized object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerMaskPosition", data=data)
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
|
||||
from ..types import InputFile
|
||||
from .base import Request, TelegramMethod, prepare_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
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. Video thumbnails can be set only for video sticker sets only. Returns :code:`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/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for animated sticker technical requirements, or a **WEBM** video with the thumbnail up to 32 kilobytes in size; see `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for video 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. :ref:`More information on Sending Files » <sending-files>`. Animated sticker set thumbnails can't be uploaded via HTTP URL."""
|
||||
|
||||
def build_request(self, bot: Bot) -> 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)
|
||||
34
aiogram/methods/set_sticker_set_thumbnail.py
Normal file
34
aiogram/methods/set_sticker_set_thumbnail.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
||||
|
||||
from ..types import InputFile
|
||||
from .base import Request, TelegramMethod, prepare_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetStickerSetThumbnail(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setstickersetthumbnail
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
name: str
|
||||
"""Sticker set name"""
|
||||
user_id: int
|
||||
"""User identifier of the sticker set owner"""
|
||||
thumbnail: Optional[Union[InputFile, str]] = None
|
||||
"""A **.WEBP** or **.PNG** image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a **.TGS** animation with a thumbnail up to 32 kilobytes in size (see `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for animated sticker technical requirements), or a **WEBM** video with the thumbnail up to 32 kilobytes in size; see `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for video 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. :ref:`More information on Sending Files » <sending-files>`. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
files: Dict[str, InputFile] = {}
|
||||
prepare_file("thumbnail", value=self.thumbnail, data=data, files=files)
|
||||
|
||||
return Request(method="setStickerSetThumbnail", data=data)
|
||||
28
aiogram/methods/set_sticker_set_title.py
Normal file
28
aiogram/methods/set_sticker_set_title.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class SetStickerSetTitle(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to set the title of a created sticker set. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setstickersettitle
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
name: str
|
||||
"""Sticker set name"""
|
||||
title: str
|
||||
"""Sticker set title, 1-64 characters"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setStickerSetTitle", data=data)
|
||||
|
|
@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class UploadStickerFile(TelegramMethod[File]):
|
||||
"""
|
||||
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 :class:`aiogram.types.file.File` on success.
|
||||
Use this method to upload a file with a sticker for later use in the :class:`aiogram.methods.create_new_sticker_set.CreateNewStickerSet` and :class:`aiogram.methods.add_sticker_to_set.AddStickerToSet` methods (the file can be used multiple times). Returns the uploaded :class:`aiogram.types.file.File` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#uploadstickerfile
|
||||
"""
|
||||
|
|
@ -20,13 +20,15 @@ class UploadStickerFile(TelegramMethod[File]):
|
|||
|
||||
user_id: int
|
||||
"""User identifier of sticker file owner"""
|
||||
png_sticker: InputFile
|
||||
"""**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. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
sticker: InputFile
|
||||
"""A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See `https://core.telegram.org/stickers <https://core.telegram.org/stickers>`_`https://core.telegram.org/stickers <https://core.telegram.org/stickers>`_ for technical requirements. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
sticker_format: str
|
||||
"""Format of the sticker, must be one of 'static', 'animated', 'video'"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"png_sticker"})
|
||||
data: Dict[str, Any] = self.dict(exclude={"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="sticker", value=self.sticker)
|
||||
|
||||
return Request(method="uploadStickerFile", data=data, files=files)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue