mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
parent
adfc89f125
commit
247ffbef69
150 changed files with 571 additions and 1112 deletions
|
|
@ -11,6 +11,7 @@ from .base import Request, Response, TelegramMethod
|
|||
from .close import Close
|
||||
from .copy_message import CopyMessage
|
||||
from .create_chat_invite_link import CreateChatInviteLink
|
||||
from .create_invoice_link import CreateInvoiceLink
|
||||
from .create_new_sticker_set import CreateNewStickerSet
|
||||
from .decline_chat_join_request import DeclineChatJoinRequest
|
||||
from .delete_chat_photo import DeleteChatPhoto
|
||||
|
|
@ -176,6 +177,7 @@ __all__ = (
|
|||
"AnswerInlineQuery",
|
||||
"AnswerWebAppQuery",
|
||||
"SendInvoice",
|
||||
"CreateInvoiceLink",
|
||||
"AnswerShippingQuery",
|
||||
"AnswerPreCheckoutQuery",
|
||||
"SetPassportDataErrors",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class AddStickerToSet(TelegramMethod[bool]):
|
|||
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 info on Sending Files » <sending-files>`"""
|
||||
"""**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
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class AnswerCallbackQuery(TelegramMethod[bool]):
|
|||
"""
|
||||
Use this method to send answers to callback queries sent from `inline keyboards <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, :code:`True` is returned.
|
||||
|
||||
Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via `@Botfather <https://t.me/botfather>`_ and accept the terms. Otherwise, you may use links like :code:`t.me/your_bot?start=XXXX` that open your bot with a parameter.
|
||||
Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via `@BotFather <https://t.me/botfather>`_ and accept the terms. Otherwise, you may use links like :code:`t.me/your_bot?start=XXXX` that open your bot with a parameter.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#answercallbackquery
|
||||
"""
|
||||
|
|
@ -26,7 +26,7 @@ class AnswerCallbackQuery(TelegramMethod[bool]):
|
|||
show_alert: Optional[bool] = None
|
||||
"""If :code:`True`, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to *false*."""
|
||||
url: Optional[str] = None
|
||||
"""URL that will be opened by the user's client. If you have created a :class:`aiogram.types.game.Game` and accepted the conditions via `@Botfather <https://t.me/botfather>`_, specify the URL that opens your game — note that this will only work if the query comes from a `https://core.telegram.org/bots/api#inlinekeyboardbutton <https://core.telegram.org/bots/api#inlinekeyboardbutton>`_ *callback_game* button."""
|
||||
"""URL that will be opened by the user's client. If you have created a :class:`aiogram.types.game.Game` and accepted the conditions via `@BotFather <https://t.me/botfather>`_, specify the URL that opens your game - note that this will only work if the query comes from a `https://core.telegram.org/bots/api#inlinekeyboardbutton <https://core.telegram.org/bots/api#inlinekeyboardbutton>`_ *callback_game* button."""
|
||||
cache_time: Optional[int] = None
|
||||
"""The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0."""
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ class AnswerWebAppQuery(TelegramMethod[SentWebAppMessage]):
|
|||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
prepare_parse_mode(
|
||||
bot, data["result"], parse_mode_property="parse_mode", entities_property="entities"
|
||||
)
|
||||
|
||||
return Request(method="answerWebAppQuery", data=data)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class CreateChatInviteLink(TelegramMethod[ChatInviteLink]):
|
|||
expire_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
|
||||
"""Point in time (Unix timestamp) when the link will expire"""
|
||||
member_limit: Optional[int] = None
|
||||
"""Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
|
||||
"""The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
|
||||
creates_join_request: Optional[bool] = None
|
||||
""":code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified"""
|
||||
|
||||
|
|
|
|||
65
aiogram/methods/create_invoice_link.py
Normal file
65
aiogram/methods/create_invoice_link.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
from ..types import LabeledPrice
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class CreateInvoiceLink(TelegramMethod[str]):
|
||||
"""
|
||||
Use this method to create a link for an invoice. Returns the created invoice link as *String* on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#createinvoicelink
|
||||
"""
|
||||
|
||||
__returning__ = str
|
||||
|
||||
title: str
|
||||
"""Product name, 1-32 characters"""
|
||||
description: str
|
||||
"""Product description, 1-255 characters"""
|
||||
payload: str
|
||||
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes."""
|
||||
provider_token: str
|
||||
"""Payment provider token, obtained via `BotFather <https://t.me/botfather>`_"""
|
||||
currency: str
|
||||
"""Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_"""
|
||||
prices: List[LabeledPrice]
|
||||
"""Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)"""
|
||||
max_tip_amount: Optional[int] = None
|
||||
"""The maximum accepted amount for tips in the *smallest units* of the currency (integer, **not** float/double). For example, for a maximum tip of :code:`US$ 1.45` pass :code:`max_tip_amount = 145`. See the *exp* parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0"""
|
||||
suggested_tip_amounts: Optional[List[int]] = None
|
||||
"""A JSON-serialized array of suggested amounts of tips in the *smallest units* of the currency (integer, **not** float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed *max_tip_amount*."""
|
||||
provider_data: Optional[str] = None
|
||||
"""JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider."""
|
||||
photo_url: Optional[str] = None
|
||||
"""URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service."""
|
||||
photo_size: Optional[int] = None
|
||||
"""Photo size in bytes"""
|
||||
photo_width: Optional[int] = None
|
||||
"""Photo width"""
|
||||
photo_height: Optional[int] = None
|
||||
"""Photo height"""
|
||||
need_name: Optional[bool] = None
|
||||
"""Pass :code:`True`, if you require the user's full name to complete the order"""
|
||||
need_phone_number: Optional[bool] = None
|
||||
"""Pass :code:`True`, if you require the user's phone number to complete the order"""
|
||||
need_email: Optional[bool] = None
|
||||
"""Pass :code:`True`, if you require the user's email address to complete the order"""
|
||||
need_shipping_address: Optional[bool] = None
|
||||
"""Pass :code:`True`, if you require the user's shipping address to complete the order"""
|
||||
send_phone_number_to_provider: Optional[bool] = None
|
||||
"""Pass :code:`True`, if the user's phone number should be sent to the provider"""
|
||||
send_email_to_provider: Optional[bool] = None
|
||||
"""Pass :code:`True`, if the user's email address should be sent to the provider"""
|
||||
is_flexible: Optional[bool] = None
|
||||
"""Pass :code:`True`, if the final price depends on the shipping method"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="createInvoiceLink", data=data)
|
||||
|
|
@ -21,13 +21,13 @@ class CreateNewStickerSet(TelegramMethod[bool]):
|
|||
user_id: int
|
||||
"""User identifier of created sticker set owner"""
|
||||
name: str
|
||||
"""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."""
|
||||
"""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 info on Sending Files » <sending-files>`"""
|
||||
"""**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
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class EditChatInviteLink(TelegramMethod[ChatInviteLink]):
|
|||
expire_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
|
||||
"""Point in time (Unix timestamp) when the link will expire"""
|
||||
member_limit: Optional[int] = None
|
||||
"""Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
|
||||
"""The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
|
||||
creates_join_request: Optional[bool] = None
|
||||
""":code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified"""
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
|
|||
heading: Optional[int] = None
|
||||
"""Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified."""
|
||||
proximity_alert_radius: Optional[int] = None
|
||||
"""Maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified."""
|
||||
"""The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for a new `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_."""
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class GetFile(TelegramMethod[File]):
|
||||
"""
|
||||
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a :class:`aiogram.types.file.File` object is returned. The file can then be downloaded via the link :code:`https://api.telegram.org/file/bot<token>/<file_path>`, where :code:`<file_path>` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling :class:`aiogram.methods.get_file.GetFile` again.
|
||||
Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a :class:`aiogram.types.file.File` object is returned. The file can then be downloaded via the link :code:`https://api.telegram.org/file/bot<token>/<file_path>`, where :code:`<file_path>` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling :class:`aiogram.methods.get_file.GetFile` again.
|
||||
**Note:** This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#getfile
|
||||
|
|
@ -20,7 +20,7 @@ class GetFile(TelegramMethod[File]):
|
|||
__returning__ = File
|
||||
|
||||
file_id: str
|
||||
"""File identifier to get info about"""
|
||||
"""File identifier to get information about"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
|
|||
"""
|
||||
Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an *Array* of :class:`aiogram.types.game_high_score.GameHighScore` objects.
|
||||
|
||||
This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change.
|
||||
This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#getgamehighscores
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class SendAnimation(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
animation: Union[InputFile, str]
|
||||
"""Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. :ref:`More info on Sending Files » <sending-files>`"""
|
||||
"""Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
duration: Optional[int] = None
|
||||
"""Duration of sent animation in seconds"""
|
||||
width: Optional[int] = None
|
||||
|
|
@ -38,7 +38,7 @@ class SendAnimation(TelegramMethod[Message]):
|
|||
height: Optional[int] = None
|
||||
"""Animation height"""
|
||||
thumb: 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 info on Sending Files » <sending-files>`"""
|
||||
"""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"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class SendAudio(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
audio: 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. :ref:`More info on Sending Files » <sending-files>`"""
|
||||
"""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. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
caption: Optional[str] = None
|
||||
"""Audio caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
|
|
@ -45,7 +45,7 @@ class SendAudio(TelegramMethod[Message]):
|
|||
title: Optional[str] = None
|
||||
"""Track name"""
|
||||
thumb: 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 info on Sending Files » <sending-files>`"""
|
||||
"""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."""
|
||||
protect_content: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ class SendDocument(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
document: Union[InputFile, str]
|
||||
"""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 info on Sending Files » <sending-files>`"""
|
||||
"""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>`"""
|
||||
thumb: 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 info on Sending Files » <sending-files>`"""
|
||||
"""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"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class SendGame(TelegramMethod[Message]):
|
|||
chat_id: int
|
||||
"""Unique identifier for the target chat"""
|
||||
game_short_name: str
|
||||
"""Short name of the game, serves as the unique identifier for the game. Set up your games via `Botfather <https://t.me/botfather>`_."""
|
||||
"""Short name of the game, serves as the unique identifier for the game. Set up your games via `@BotFather <https://t.me/botfather>`_."""
|
||||
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
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class SendInvoice(TelegramMethod[Message]):
|
|||
payload: str
|
||||
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes."""
|
||||
provider_token: str
|
||||
"""Payments provider token, obtained via `Botfather <https://t.me/botfather>`_"""
|
||||
"""Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_"""
|
||||
currency: str
|
||||
"""Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_"""
|
||||
prices: List[LabeledPrice]
|
||||
|
|
@ -39,11 +39,11 @@ class SendInvoice(TelegramMethod[Message]):
|
|||
start_parameter: Optional[str] = None
|
||||
"""Unique deep-linking parameter. If left empty, **forwarded copies** of the sent message will have a *Pay* button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a *URL* button with a deep link to the bot (instead of a *Pay* button), with the value used as the start parameter"""
|
||||
provider_data: Optional[str] = None
|
||||
"""A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider."""
|
||||
"""JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider."""
|
||||
photo_url: Optional[str] = None
|
||||
"""URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for."""
|
||||
photo_size: Optional[int] = None
|
||||
"""Photo size"""
|
||||
"""Photo size in bytes"""
|
||||
photo_width: Optional[int] = None
|
||||
"""Photo width"""
|
||||
photo_height: Optional[int] = None
|
||||
|
|
@ -57,9 +57,9 @@ class SendInvoice(TelegramMethod[Message]):
|
|||
need_shipping_address: Optional[bool] = None
|
||||
"""Pass :code:`True`, if you require the user's shipping address to complete the order"""
|
||||
send_phone_number_to_provider: Optional[bool] = None
|
||||
"""Pass :code:`True`, if user's phone number should be sent to provider"""
|
||||
"""Pass :code:`True`, if the user's phone number should be sent to provider"""
|
||||
send_email_to_provider: Optional[bool] = None
|
||||
"""Pass :code:`True`, if user's email address should be sent to provider"""
|
||||
"""Pass :code:`True`, if the user's email address should be sent to provider"""
|
||||
is_flexible: Optional[bool] = None
|
||||
"""Pass :code:`True`, if the final price depends on the shipping method"""
|
||||
disable_notification: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class SendPhoto(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
photo: Union[InputFile, str]
|
||||
"""Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (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. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. :ref:`More info on Sending Files » <sending-files>`"""
|
||||
"""Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (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. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
caption: Optional[str] = None
|
||||
"""Photo caption (may also be used when resending photos by *file_id*), 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ 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 info 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 file from the Internet, or upload a new one using multipart/form-data. :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."""
|
||||
protect_content: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class SendVideo(TelegramMethod[Message]):
|
||||
"""
|
||||
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as :class:`aiogram.types.document.Document`). On success, the sent :class:`aiogram.types.message.Message` is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
|
||||
Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as :class:`aiogram.types.document.Document`). On success, the sent :class:`aiogram.types.message.Message` is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#sendvideo
|
||||
"""
|
||||
|
|
@ -30,7 +30,7 @@ class SendVideo(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
video: Union[InputFile, str]
|
||||
"""Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. :ref:`More info on Sending Files » <sending-files>`"""
|
||||
"""Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. :ref:`More information on Sending Files » <sending-files>`"""
|
||||
duration: Optional[int] = None
|
||||
"""Duration of sent video in seconds"""
|
||||
width: Optional[int] = None
|
||||
|
|
@ -38,7 +38,7 @@ class SendVideo(TelegramMethod[Message]):
|
|||
height: Optional[int] = None
|
||||
"""Video height"""
|
||||
thumb: 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 info on Sending Files » <sending-files>`"""
|
||||
"""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"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class SendVideoNote(TelegramMethod[Message]):
|
||||
"""
|
||||
As of `v.4.0 <https://telegram.org/blog/video-messages-and-telescope>`_, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent :class:`aiogram.types.message.Message` is returned.
|
||||
As of `v.4.0 <https://telegram.org/blog/video-messages-and-telescope>`_, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent :class:`aiogram.types.message.Message` is returned.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#sendvideonote
|
||||
"""
|
||||
|
|
@ -28,13 +28,13 @@ class SendVideoNote(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
video_note: Union[InputFile, str]
|
||||
"""Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. :ref:`More info on Sending Files » <sending-files>`. Sending video notes by a URL is currently unsupported"""
|
||||
"""Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. :ref:`More information on Sending Files » <sending-files>`. Sending video notes by a URL is currently unsupported"""
|
||||
duration: Optional[int] = None
|
||||
"""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 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 info on Sending Files » <sending-files>`"""
|
||||
"""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."""
|
||||
protect_content: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class SendVoice(TelegramMethod[Message]):
|
|||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
voice: Union[InputFile, str]
|
||||
"""Audio 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 info on Sending Files » <sending-files>`"""
|
||||
"""Audio 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>`"""
|
||||
caption: Optional[str] = None
|
||||
"""Voice message caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class SetChatMenuButton(TelegramMethod[bool]):
|
|||
chat_id: Optional[int] = None
|
||||
"""Unique identifier for the target private chat. If not specified, default bot's menu button will be changed"""
|
||||
menu_button: Optional[MenuButton] = None
|
||||
"""A JSON-serialized object for the new bot's menu button. Defaults to :class:`aiogram.types.menu_button_default.MenuButtonDefault`"""
|
||||
"""A JSON-serialized object for the bot's new menu button. Defaults to :class:`aiogram.types.menu_button_default.MenuButtonDefault`"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class SetStickerSetThumb(TelegramMethod[bool]):
|
|||
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 info on Sending Files » <sending-files>`. Animated sticker set thumbnails can't be uploaded via HTTP URL."""
|
||||
"""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"})
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ if TYPE_CHECKING:
|
|||
|
||||
class SetWebhook(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized :class:`aiogram.types.update.Update`. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns :code:`True` on success.
|
||||
If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. :code:`https://www.example.com/<token>`. Since nobody else knows your bot's token, you can be pretty sure it's us.
|
||||
Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized :class:`aiogram.types.update.Update`. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns :code:`True` on success.
|
||||
If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter *secret_token*. If specified, the request will contain a header 'X-Telegram-Bot-Api-Secret-Token' with the secret token as content.
|
||||
|
||||
**Notes**
|
||||
|
||||
|
|
@ -20,8 +20,8 @@ class SetWebhook(TelegramMethod[bool]):
|
|||
|
||||
**2.** To use a self-signed certificate, you need to upload your `public key certificate <https://core.telegram.org/bots/self-signed>`_ using *certificate* parameter. Please upload as InputFile, sending a String will not work.
|
||||
|
||||
**3.** Ports currently supported *for Webhooks*: **443, 80, 88, 8443**.
|
||||
**NEW!** If you're having any trouble setting up webhooks, please check out this `amazing guide to Webhooks <https://core.telegram.org/bots/webhooks>`_.
|
||||
**3.** Ports currently supported *for webhooks*: **443, 80, 88, 8443**.
|
||||
If you're having any trouble setting up webhooks, please check out this `amazing guide to webhooks <https://core.telegram.org/bots/webhooks>`_.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setwebhook
|
||||
"""
|
||||
|
|
@ -29,17 +29,19 @@ class SetWebhook(TelegramMethod[bool]):
|
|||
__returning__ = bool
|
||||
|
||||
url: str
|
||||
"""HTTPS url to send updates to. Use an empty string to remove webhook integration"""
|
||||
"""HTTPS URL to send updates to. Use an empty string to remove webhook integration"""
|
||||
certificate: Optional[InputFile] = None
|
||||
"""Upload your public key certificate so that the root certificate in use can be checked. See our `self-signed guide <https://core.telegram.org/bots/self-signed>`_ for details."""
|
||||
ip_address: Optional[str] = None
|
||||
"""The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS"""
|
||||
max_connections: Optional[int] = None
|
||||
"""Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to *40*. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput."""
|
||||
"""The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to *40*. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput."""
|
||||
allowed_updates: Optional[List[str]] = None
|
||||
"""A JSON-serialized list of the update types you want your bot to receive. For example, specify ['message', 'edited_channel_post', 'callback_query'] to only receive updates of these types. See :class:`aiogram.types.update.Update` for a complete list of available update types. Specify an empty list to receive all update types except *chat_member* (default). If not specified, the previous setting will be used."""
|
||||
drop_pending_updates: Optional[bool] = None
|
||||
"""Pass :code:`True` to drop all pending updates"""
|
||||
secret_token: Optional[str] = None
|
||||
"""A secret token to be sent in a header 'X-Telegram-Bot-Api-Secret-Token' in every webhook request, 1-256 characters. Only characters :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed. The header is useful to ensure that the request comes from a webhook set by you."""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"certificate"})
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ 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 info on Sending Files » <sending-files>`"""
|
||||
"""**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>`"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict(exclude={"png_sticker"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue