mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 18:01:04 +00:00
Add some doc's
This commit is contained in:
parent
595caaa458
commit
0b8a37b38a
37 changed files with 498 additions and 5 deletions
|
|
@ -4,7 +4,10 @@ from .photo_size import PhotoSize
|
|||
|
||||
class Animation(Deserializable):
|
||||
"""
|
||||
Represent an animation
|
||||
You can provide an animation for your game so that it looks stylish in chats.
|
||||
This object represents an animation file to be displayed in the message containing a game.
|
||||
|
||||
https://core.telegram.org/bots/api#animation
|
||||
"""
|
||||
def __init__(self, file_id, thumb, file_name, mime_type, file_size):
|
||||
self.file_id: str = file_id
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class Audio(Deserializable):
|
||||
"""
|
||||
This object represents an audio file to be treated as music by the Telegram clients.
|
||||
|
||||
https://core.telegram.org/bots/api#audio
|
||||
"""
|
||||
def __init__(self, file_id, duration, performer, title, mime_type, file_size):
|
||||
self.file_id: str = file_id
|
||||
self.duration: int = duration
|
||||
|
|
|
|||
|
|
@ -4,6 +4,19 @@ from .user import User
|
|||
|
||||
|
||||
class CallbackQuery(Deserializable):
|
||||
"""
|
||||
This object represents an incoming callback query from a callback button in an inline keyboard.
|
||||
|
||||
If the button that originated the query was attached to a message sent by the bot,
|
||||
the field message will be present.
|
||||
|
||||
If the button was attached to a message sent via the bot (in inline mode),
|
||||
the field inline_message_id will be present.
|
||||
|
||||
Exactly one of the fields data or game_short_name will be present.
|
||||
|
||||
https://core.telegram.org/bots/api#callbackquery
|
||||
"""
|
||||
def __init__(self, id, from_user, message, inline_message_id, chat_instance, data, game_short_name):
|
||||
self.id: int = id
|
||||
self.from_user: User = from_user
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .user import User
|
|||
|
||||
|
||||
class ChatMember(Deserializable):
|
||||
"""
|
||||
This object contains information about one member of the chat.
|
||||
|
||||
https://core.telegram.org/bots/api#chatmember
|
||||
"""
|
||||
def __init__(self, user, status):
|
||||
self.user: User = user
|
||||
self.status: str = status
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ from .user import User
|
|||
|
||||
|
||||
class ChosenInlineResult(Deserializable):
|
||||
"""
|
||||
Represents a result of an inline query that was chosen by the user and sent to their chat partner.
|
||||
|
||||
https://core.telegram.org/bots/api#choseninlineresult
|
||||
"""
|
||||
def __init__(self, result_id, from_user, location, inline_message_id, query):
|
||||
self.result_id: str = result_id
|
||||
self.from_user: User = from_user
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class Contact(Deserializable):
|
||||
"""
|
||||
This object represents a phone contact.
|
||||
|
||||
https://core.telegram.org/bots/api#contact
|
||||
"""
|
||||
def __init__(self, phone_number, first_name, last_name, user_id):
|
||||
self.phone_number: str = phone_number
|
||||
self.first_name: str = first_name
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .photo_size import PhotoSize
|
|||
|
||||
|
||||
class Document(Deserializable):
|
||||
"""
|
||||
This object represents a general file (as opposed to photos, voice messages and audio files).
|
||||
|
||||
https://core.telegram.org/bots/api#document
|
||||
"""
|
||||
def __init__(self, file_id, thumb, file_name, mime_type, file_size):
|
||||
self.file_id: str = file_id
|
||||
self.thumb: PhotoSize = thumb
|
||||
|
|
|
|||
|
|
@ -2,6 +2,16 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class File(Deserializable):
|
||||
"""
|
||||
This object represents a file ready to be downloaded.
|
||||
|
||||
The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>.
|
||||
|
||||
It is guaranteed that the link will be valid for at least 1 hour. When the link expires,
|
||||
a new one can be requested by calling getFile.
|
||||
|
||||
https://core.telegram.org/bots/api#file
|
||||
"""
|
||||
def __init__(self, file_id, file_size, file_path):
|
||||
self.file_id: str = file_id
|
||||
self.file_size: int = file_size
|
||||
|
|
|
|||
|
|
@ -2,6 +2,16 @@ from .base import Serializable
|
|||
|
||||
|
||||
class ForceReply(Serializable):
|
||||
"""
|
||||
Upon receiving a message with this object,
|
||||
Telegram clients will display a reply interface to the user
|
||||
(act as if the user has selected the bot‘s message and tapped ’Reply').
|
||||
|
||||
This can be extremely useful if you want to create user-friendly step-by-step
|
||||
interfaces without having to sacrifice privacy mode.
|
||||
|
||||
https://core.telegram.org/bots/api#forcereply
|
||||
"""
|
||||
def __init__(self, selective=None):
|
||||
self.selective = selective
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@ from .photo_size import PhotoSize
|
|||
|
||||
|
||||
class Game(Deserializable):
|
||||
"""
|
||||
This object represents a game.
|
||||
|
||||
Use BotFather to create and edit games, their short names will act as unique identifiers.
|
||||
|
||||
https://core.telegram.org/bots/api#game
|
||||
"""
|
||||
def __init__(self, title, description, photo, text, text_entities, animation):
|
||||
self.title = title
|
||||
self.description = description
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .user import User
|
|||
|
||||
|
||||
class GameHighScore(Deserializable):
|
||||
"""
|
||||
This object represents one row of the high scores table for a game.
|
||||
|
||||
https://core.telegram.org/bots/api#gamehighscore
|
||||
"""
|
||||
def __init__(self, position, user, score):
|
||||
self.position: int = position
|
||||
self.user: User = user
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Serializable
|
|||
|
||||
|
||||
class InlineKeyboardMarkup(Serializable):
|
||||
"""
|
||||
This object represents an inline keyboard that appears right next to the message it belongs to.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinekeyboardmarkup
|
||||
"""
|
||||
def __init__(self, row_width=3):
|
||||
self.row_width = row_width
|
||||
|
||||
|
|
@ -31,6 +36,11 @@ class InlineKeyboardMarkup(Serializable):
|
|||
|
||||
|
||||
class InlineKeyboardButton(Serializable):
|
||||
"""
|
||||
This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinekeyboardbutton
|
||||
"""
|
||||
def __init__(self, text, url=None, callback_data=None, switch_inline_query=None,
|
||||
switch_inline_query_current_chat=None, callback_game=None, pay=None):
|
||||
self.text = text
|
||||
|
|
|
|||
|
|
@ -4,6 +4,13 @@ from .user import User
|
|||
|
||||
|
||||
class InlineQuery(Deserializable):
|
||||
"""
|
||||
This object represents an incoming inline query.
|
||||
|
||||
When the user sends an empty query, your bot could return some default or trending results.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequery
|
||||
"""
|
||||
def __init__(self, id, from_user, location, query, offset):
|
||||
self.id: int = id
|
||||
self.from_user: User = from_user
|
||||
|
|
|
|||
|
|
@ -3,16 +3,77 @@ from .inline_keyboard import InlineKeyboardMarkup
|
|||
|
||||
|
||||
class InputMessageContent(Serializable):
|
||||
"""
|
||||
This object represents the content of a message to be sent as a result of an inline query.
|
||||
|
||||
Telegram clients currently support the following 4 types:
|
||||
|
||||
:class:`aiogram.types.InputTextMessageContent`
|
||||
:class:`aiogram.types.InputLocationMessageContent`
|
||||
:class:`aiogram.types.InputVenueMessageContent`
|
||||
:class:`aiogram.types.InputContactMessageContent`
|
||||
"""
|
||||
def to_json(self):
|
||||
return {k: v.to_json() if hasattr(v, 'to_json') else v for k, v in self.__dict__.items() if
|
||||
not k.startswith('_')}
|
||||
|
||||
|
||||
class InlineQueryResult(InputMessageContent):
|
||||
"""
|
||||
This object represents one result of an inline query.
|
||||
|
||||
Telegram clients currently support results of the following 20 types:
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedAudio`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedDocument`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedGif`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedMpeg4Gif`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedPhoto`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedSticker`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedVideo`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultCachedVoice`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultArticle`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultAudio`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultContact`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultGame`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultDocument`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultGif`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultLocation`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultMpeg4Gif`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultPhoto`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultVenue`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultVideo`
|
||||
|
||||
:class:`aiogram.types.InlineQueryResultVoice`
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class InlineQueryResultArticle(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to an article or web page.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultarticle
|
||||
"""
|
||||
def __init__(self, type: str, id: str, title: str, input_message_content: InputMessageContent,
|
||||
reply_markup: InlineKeyboardMarkup = None, url: str = None, hide_url: bool = None,
|
||||
description: str = None, thumb_url: str = None, thumb_width: int = None, thumb_height: int = None):
|
||||
|
|
@ -30,6 +91,14 @@ class InlineQueryResultArticle(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultPhoto(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a photo. By default, this photo will be sent by the user with optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content instead
|
||||
of the photo.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultphoto
|
||||
"""
|
||||
def __init__(self, type: str, id: str, photo_url: str, thumb_url: str, photo_width: int = None,
|
||||
photo_height: int = None, title: str = None, description: str = None, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
|
|
@ -47,6 +116,16 @@ class InlineQueryResultPhoto(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultGif(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to an animated GIF file.
|
||||
|
||||
By default, this animated GIF file will be sent by the user with optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified
|
||||
content instead of the animation.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultgif
|
||||
"""
|
||||
def __init__(self, type: str, id: str, gif_url: str, thumb_url: str, gif_width: int = None, gif_height: int = None,
|
||||
gif_duration: int = None, title: str = None, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
|
|
@ -64,6 +143,16 @@ class InlineQueryResultGif(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a video animation (H.264/MPEG-4 AVC video without sound).
|
||||
|
||||
By default, this animated MPEG-4 file will be sent by the user with optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the animation.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
|
||||
"""
|
||||
def __init__(self, type: str, id: str, mpeg4_url: str, thumb_url: str, mpeg4_width: int = None,
|
||||
mpeg4_height: int = None, mpeg4_duration: int = None, title: str = None, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
|
|
@ -81,6 +170,14 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultVideo(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a page containing an embedded video player or a video file.
|
||||
By default, this video file will be sent by the user with an optional caption.
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the video.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultvideo
|
||||
"""
|
||||
def __init__(self, type: str, id: str, video_url: str, mime_type: str, thumb_url: str, title: str,
|
||||
caption: str = None, video_width: int = None, video_height: int = None, video_duration: int = None,
|
||||
description: str = None, reply_markup: InlineKeyboardMarkup = None,
|
||||
|
|
@ -101,6 +198,12 @@ class InlineQueryResultVideo(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultAudio(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to an mp3 audio file. By default, this audio file will be sent by the user. Alternatively,
|
||||
you can use input_message_content to send a message with the specified content instead of the audio.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultaudio
|
||||
"""
|
||||
def __init__(self, type: str, id: str, audio_url: str, title: str, caption: str = None, performer: str = None,
|
||||
audio_duration: int = None, reply_markup: InlineKeyboardMarkup = None,
|
||||
input_message_content: InputMessageContent = None):
|
||||
|
|
@ -116,6 +219,16 @@ class InlineQueryResultAudio(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultVoice(InlineQueryResult):
|
||||
"""
|
||||
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.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultvoice
|
||||
"""
|
||||
def __init__(self, type: str, id: str, voice_url: str, title: str, caption: str = None, voice_duration: int = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
self.type: str = type
|
||||
|
|
@ -129,6 +242,14 @@ class InlineQueryResultVoice(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultDocument(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a file. By default, this file will be sent by the user with an optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultdocument
|
||||
"""
|
||||
def __init__(self, type: str, id: str, title: str, document_url: str, mime_type: str, caption: str = None,
|
||||
description: str = None, reply_markup: InlineKeyboardMarkup = None,
|
||||
input_message_content: InputMessageContent = None, thumb_url: str = None, thumb_width: int = None,
|
||||
|
|
@ -148,6 +269,13 @@ class InlineQueryResultDocument(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultLocation(InlineQueryResult):
|
||||
"""
|
||||
Represents a location on a map. By default, the location will be sent by the user.
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the location.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultlocation
|
||||
"""
|
||||
def __init__(self, type: str, id: str, latitude: float, longitude: float, title: str,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None,
|
||||
thumb_url: str = None, thumb_width: int = None, thumb_height: int = None):
|
||||
|
|
@ -164,6 +292,13 @@ class InlineQueryResultLocation(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultVenue(InlineQueryResult):
|
||||
"""
|
||||
Represents a venue. By default, the venue will be sent by the user.
|
||||
Alternatively, you can use input_message_content to send a message with the specified
|
||||
content instead of the venue.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultvenue
|
||||
"""
|
||||
def __init__(self, type: str, id: str, latitude: float, longitude: float, title: str, address: str,
|
||||
foursquare_id: str = None, reply_markup: InlineKeyboardMarkup = None,
|
||||
input_message_content: InputMessageContent = None, thumb_url: str = None, thumb_width: int = None,
|
||||
|
|
@ -183,6 +318,16 @@ class InlineQueryResultVenue(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultContact(InlineQueryResult):
|
||||
"""
|
||||
Represents a contact with a phone number.
|
||||
|
||||
By default, this contact will be sent by the user.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content instead
|
||||
of the contact.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcontact
|
||||
"""
|
||||
def __init__(self, type: str, id: str, phone_number: str, first_name: str, last_name: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None,
|
||||
thumb_url: str = None, thumb_width: int = None, thumb_height: int = None):
|
||||
|
|
@ -199,6 +344,11 @@ class InlineQueryResultContact(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultGame(InlineQueryResult):
|
||||
"""
|
||||
Represents a Game.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultgame
|
||||
"""
|
||||
def __init__(self, type: str, id: str, game_short_name: str, reply_markup: InlineKeyboardMarkup = None):
|
||||
self.type: str = type
|
||||
self.id: str = id
|
||||
|
|
@ -207,6 +357,16 @@ class InlineQueryResultGame(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedPhoto(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a photo stored on the Telegram servers.
|
||||
|
||||
By default, this photo will be sent by the user with an optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified
|
||||
content instead of the photo.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcachedphoto
|
||||
"""
|
||||
def __init__(self, type: str, id: str, photo_file_id: str, title: str = None, description: str = None,
|
||||
caption: str = None, reply_markup: InlineKeyboardMarkup = None,
|
||||
input_message_content: InputMessageContent = None):
|
||||
|
|
@ -221,6 +381,16 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedGif(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to an animated GIF file stored on the Telegram servers.
|
||||
|
||||
By default, this animated GIF file will be sent by the user with an optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with specified content
|
||||
instead of the animation.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcachedgif
|
||||
"""
|
||||
def __init__(self, type: str, id: str, gif_file_id: str, title: str = None, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
self.type: str = type
|
||||
|
|
@ -233,6 +403,16 @@ class InlineQueryResultCachedGif(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers.
|
||||
|
||||
By default, this animated MPEG-4 file will be sent by the user with an optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the animation.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif
|
||||
"""
|
||||
def __init__(self, type: str, id: str, mpeg4_file_id: str, title: str = None, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
self.type: str = type
|
||||
|
|
@ -245,6 +425,16 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedSticker(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a sticker stored on the Telegram servers.
|
||||
|
||||
By default, this sticker will be sent by the user.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the sticker.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcachedsticker
|
||||
"""
|
||||
def __init__(self, type: str, id: str, sticker_file_id: str, reply_markup: InlineKeyboardMarkup = None,
|
||||
input_message_content: InputMessageContent = None):
|
||||
self.type: str = type
|
||||
|
|
@ -255,6 +445,16 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedDocument(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a file stored on the Telegram servers.
|
||||
|
||||
By default, this file will be sent by the user with an optional caption.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the file.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcacheddocument
|
||||
"""
|
||||
def __init__(self, type: str, id: str, title: str, document_file_id: str, description: str = None,
|
||||
caption: str = None, reply_markup: InlineKeyboardMarkup = None,
|
||||
input_message_content: InputMessageContent = None):
|
||||
|
|
@ -269,6 +469,14 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedVideo(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a video file stored on the Telegram servers.
|
||||
By default, this video file will be sent by the user with an optional caption.
|
||||
Alternatively, you can use input_message_content to send a message with the specified content instead
|
||||
of the video.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcachedvideo
|
||||
"""
|
||||
def __init__(self, type: str, id: str, video_file_id: str, title: str, description: str = None, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
self.type: str = type
|
||||
|
|
@ -282,6 +490,16 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedVoice(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to a voice message stored on the Telegram servers.
|
||||
|
||||
By default, this voice message will be sent by the user.
|
||||
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the voice message.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcachedvoice
|
||||
"""
|
||||
def __init__(self, type: str, id: str, voice_file_id: str, title: str, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
self.type: str = type
|
||||
|
|
@ -294,6 +512,15 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
|
|||
|
||||
|
||||
class InlineQueryResultCachedAudio(InlineQueryResult):
|
||||
"""
|
||||
Represents a link to an mp3 audio file stored on the Telegram servers.
|
||||
|
||||
By default, this audio file will be sent by the user.
|
||||
Alternatively, you can use input_message_content to send a message with the specified content
|
||||
instead of the audio.
|
||||
|
||||
https://core.telegram.org/bots/api#inlinequeryresultcachedaudio
|
||||
"""
|
||||
def __init__(self, type: str, id: str, audio_file_id: str, caption: str = None,
|
||||
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
|
||||
self.type: str = type
|
||||
|
|
@ -305,6 +532,11 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
|
|||
|
||||
|
||||
class InputTextMessageContent(InputMessageContent):
|
||||
"""
|
||||
Represents the content of a text message to be sent as the result of an inline query.
|
||||
|
||||
https://core.telegram.org/bots/api#inputtextmessagecontent
|
||||
"""
|
||||
def __init__(self, message_text: str, parse_mode: str = None, disable_web_page_preview: bool = None):
|
||||
self.message_text: str = message_text
|
||||
self.parse_mode: str = parse_mode
|
||||
|
|
@ -312,12 +544,22 @@ class InputTextMessageContent(InputMessageContent):
|
|||
|
||||
|
||||
class InputLocationMessageContent(InputMessageContent):
|
||||
"""
|
||||
Represents the content of a location message to be sent as the result of an inline query.
|
||||
|
||||
https://core.telegram.org/bots/api#inputlocationmessagecontent
|
||||
"""
|
||||
def __init__(self, latitude: float, longitude: float):
|
||||
self.latitude: float = latitude
|
||||
self.longitude: float = longitude
|
||||
|
||||
|
||||
class InputVenueMessageContent(InputMessageContent):
|
||||
"""
|
||||
Represents the content of a venue message to be sent as the result of an inline query.
|
||||
|
||||
https://core.telegram.org/bots/api#inputvenuemessagecontent
|
||||
"""
|
||||
def __init__(self, latitude: float, longitude: float, title: str, address: str, foursquare_id: str = None):
|
||||
self.latitude: float = latitude
|
||||
self.longitude: float = longitude
|
||||
|
|
@ -327,6 +569,11 @@ class InputVenueMessageContent(InputMessageContent):
|
|||
|
||||
|
||||
class InputContactMessageContent(InputMessageContent):
|
||||
"""
|
||||
Represents the content of a contact message to be sent as the result of an inline query.
|
||||
|
||||
https://core.telegram.org/bots/api#inputcontactmessagecontent
|
||||
"""
|
||||
def __init__(self, phone_number: str, first_name: str, last_name: str = None):
|
||||
self.phone_number: str = phone_number
|
||||
self.first_name: str = first_name
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class Invoice(Deserializable):
|
||||
"""
|
||||
This object contains basic information about an invoice.
|
||||
|
||||
https://core.telegram.org/bots/api#invoice
|
||||
"""
|
||||
def __init__(self, title, description, start_parameter, currency, total_amount):
|
||||
self.title: str = title
|
||||
self.description: str = description
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Serializable
|
|||
|
||||
|
||||
class LabeledPrice(Serializable):
|
||||
"""
|
||||
This object represents a portion of the price for goods or services.
|
||||
|
||||
https://core.telegram.org/bots/api#labeledprice
|
||||
"""
|
||||
def __init__(self, label, amount):
|
||||
self.label = label
|
||||
self.amount = amount
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class Location(Deserializable):
|
||||
"""
|
||||
This object represents a point on the map.
|
||||
|
||||
https://core.telegram.org/bots/api#location
|
||||
"""
|
||||
def __init__(self, longitude, latitude):
|
||||
self.longitude = longitude
|
||||
self.latitude = latitude
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .shipping_address import ShippingAddress
|
|||
|
||||
|
||||
class OrderInfo(Deserializable):
|
||||
"""
|
||||
his object represents information about an order.
|
||||
|
||||
https://core.telegram.org/bots/api#orderinfo
|
||||
"""
|
||||
def __init__(self, name, phone_number, email, shipping_address):
|
||||
self.name: str = name
|
||||
self.phone_number: str = phone_number
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ from .user import User
|
|||
|
||||
|
||||
class PreCheckoutQuery(Deserializable):
|
||||
"""
|
||||
This object contains information about an incoming pre-checkout query.
|
||||
|
||||
https://core.telegram.org/bots/api#precheckoutquery
|
||||
"""
|
||||
def __init__(self, id, from_user, currency, total_amount, invoice_payload, shipping_option_id, order_info):
|
||||
self.id: str = id
|
||||
self.from_user: User = from_user
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Serializable
|
|||
|
||||
|
||||
class ReplyKeyboardMarkup(Serializable):
|
||||
"""
|
||||
This object represents a custom keyboard with reply options
|
||||
|
||||
https://core.telegram.org/bots/api#replykeyboardmarkup
|
||||
"""
|
||||
def __init__(self, resize_keyboard=None, one_time_keyboard=None, selective=None, row_width=3):
|
||||
self.resize_keyboard = resize_keyboard
|
||||
self.one_time_keyboard = one_time_keyboard
|
||||
|
|
@ -42,6 +47,15 @@ class ReplyKeyboardMarkup(Serializable):
|
|||
|
||||
|
||||
class KeyboardButton(Serializable):
|
||||
"""
|
||||
This object represents one button of the reply keyboard.
|
||||
|
||||
For simple text buttons String can be used instead of this object to specify text of the button.
|
||||
|
||||
Optional fields are mutually exclusive
|
||||
|
||||
https://core.telegram.org/bots/api#keyboardbutton
|
||||
"""
|
||||
def __init__(self, text, request_contact=None, request_location=None):
|
||||
self.text = text
|
||||
self.request_contact = request_contact
|
||||
|
|
@ -52,6 +66,17 @@ class KeyboardButton(Serializable):
|
|||
|
||||
|
||||
class ReplyKeyboardRemove(Serializable):
|
||||
"""
|
||||
Upon receiving a message with this object,
|
||||
Telegram clients will remove the current custom keyboard and display the default letter-keyboard.
|
||||
|
||||
By default, custom keyboards are displayed until a new keyboard
|
||||
is sent by a bot.
|
||||
|
||||
An exception is made for one-time keyboards that are hidden immediately after the user presses a button
|
||||
|
||||
https://core.telegram.org/bots/api#replykeyboardremove
|
||||
"""
|
||||
def __init__(self, selective=None):
|
||||
self.selective = selective
|
||||
|
||||
|
|
|
|||
21
aiogram/types/response_parameters.py
Normal file
21
aiogram/types/response_parameters.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from .base import Deserializable
|
||||
|
||||
|
||||
class ResponseParameters(Deserializable):
|
||||
"""
|
||||
Contains information about why a request was unsuccessfull.
|
||||
|
||||
https://core.telegram.org/bots/api#responseparameters
|
||||
"""
|
||||
def __init__(self, migrate_to_chat_id, retry_after):
|
||||
self.migrate_to_chat_id = migrate_to_chat_id
|
||||
self.retry_after = retry_after
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, raw_data):
|
||||
data = cls.check_json(raw_data)
|
||||
|
||||
migrate_to_chat_id = data.get('migrate_to_chat_id')
|
||||
retry_after = data.get('retry_after')
|
||||
|
||||
return ResponseParameters(migrate_to_chat_id, retry_after)
|
||||
|
|
@ -2,6 +2,11 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class ShippingAddress(Deserializable):
|
||||
"""
|
||||
This object represents a shipping address.
|
||||
|
||||
https://core.telegram.org/bots/api#shippingaddress
|
||||
"""
|
||||
def __init__(self, country_code, state, city, street_line1, street_line2, post_code):
|
||||
self.country_code: str = country_code
|
||||
self.state: str = state
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Serializable
|
|||
|
||||
|
||||
class ShippingOption(Serializable):
|
||||
"""
|
||||
This object represents one shipping option.
|
||||
|
||||
https://core.telegram.org/bots/api#shippingoption
|
||||
"""
|
||||
def __init__(self, id, title, prices):
|
||||
self.id = id
|
||||
self.title = title
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ from .user import User
|
|||
|
||||
|
||||
class ShippingQuery(Deserializable):
|
||||
"""
|
||||
This object contains information about an incoming shipping query.
|
||||
|
||||
https://core.telegram.org/bots/api#shippingquery
|
||||
"""
|
||||
def __init__(self, id, from_user, invoice_payload, shipping_address):
|
||||
self.id: str = id
|
||||
self.from_user: User = from_user
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .photo_size import PhotoSize
|
|||
|
||||
|
||||
class Sticker(Deserializable):
|
||||
"""
|
||||
This object represents a sticker.
|
||||
|
||||
https://core.telegram.org/bots/api#sticker
|
||||
"""
|
||||
def __init__(self, file_id, width, height, thumb, emoji, file_size):
|
||||
self.file_id: str = file_id
|
||||
self.width: int = width
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .order_info import OrderInfo
|
|||
|
||||
|
||||
class SuccessfulPayment(Deserializable):
|
||||
"""
|
||||
This object contains basic information about a successful payment.
|
||||
|
||||
https://core.telegram.org/bots/api#successfulpayment
|
||||
"""
|
||||
def __init__(self, currency, total_amount, invoice_payload, shipping_option_id, order_info,
|
||||
telegram_payment_charge_id, provider_payment_charge_id):
|
||||
self.currency: str = currency
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ from .shipping_query import ShippingQuery
|
|||
|
||||
|
||||
class Update(Deserializable):
|
||||
"""
|
||||
This object represents an incoming update.
|
||||
|
||||
At most one of the optional parameters can be present in any given update.
|
||||
|
||||
https://core.telegram.org/bots/api#update
|
||||
"""
|
||||
def __init__(self, update_id, message, edited_message, channel_post, edited_channel_post, inline_query,
|
||||
chosen_inline_result, callback_query, shipping_query, pre_checkout_query):
|
||||
self.update_id: int = update_id
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .photo_size import PhotoSize
|
|||
|
||||
|
||||
class UserProfilePhotos(Deserializable):
|
||||
"""
|
||||
This object represent a user's profile pictures.
|
||||
|
||||
https://core.telegram.org/bots/api#userprofilephotos
|
||||
"""
|
||||
def __init__(self, total_count, photos):
|
||||
self.total_count: int = total_count
|
||||
self.photos: [PhotoSize] = photos
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .location import Location
|
|||
|
||||
|
||||
class Venue(Deserializable):
|
||||
"""
|
||||
This object represents a venue.
|
||||
|
||||
https://core.telegram.org/bots/api#venue
|
||||
"""
|
||||
def __init__(self, location, title, address, foursquare_id):
|
||||
self.location: Location = location
|
||||
self.title: str = title
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .photo_size import PhotoSize
|
|||
|
||||
|
||||
class Video(Deserializable):
|
||||
"""
|
||||
This object represents a video file.
|
||||
|
||||
https://core.telegram.org/bots/api#video
|
||||
"""
|
||||
def __init__(self, file_id, width, height, duration, thumb, mime_type, file_size):
|
||||
self.file_id: str = file_id
|
||||
self.width: int = width
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from .photo_size import PhotoSize
|
|||
|
||||
|
||||
class VideoNote(Deserializable):
|
||||
"""
|
||||
This object represents a video message.
|
||||
|
||||
https://core.telegram.org/bots/api#videonote
|
||||
"""
|
||||
def __init__(self, file_id, length, duration, thumb, file_size):
|
||||
self.file_id: str = file_id
|
||||
self.length: int = length
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class Voice(Deserializable):
|
||||
"""
|
||||
This object represents a voice note.
|
||||
|
||||
https://core.telegram.org/bots/api#voice
|
||||
"""
|
||||
def __init__(self, file_id, duration, mime_type, file_size):
|
||||
self.file_id: str = file_id
|
||||
self.duration: int = duration
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ from .base import Deserializable
|
|||
|
||||
|
||||
class WebhookInfo(Deserializable):
|
||||
"""
|
||||
Contains information about the current status of a webhook.
|
||||
|
||||
https://core.telegram.org/bots/api#webhookinfo
|
||||
"""
|
||||
def __init__(self, url, has_custom_certificate, pending_update_count, last_error_date, last_error_message,
|
||||
max_connections, allowed_updates):
|
||||
self.url: str = url
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
aiogram.bot.Bot
|
||||
===============
|
||||
Bot object
|
||||
==========
|
||||
|
||||
For detailed information about parameters read the official `Telegram Bot API reference <https://core.telegram.org/bots/api>`_
|
||||
|
||||
BaseBot
|
||||
-------
|
||||
.. automodule:: aiogram.bot.base
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Bot
|
||||
---
|
||||
.. automodule:: aiogram.bot.bot
|
||||
:members:
|
||||
:show-inheritance:
|
||||
8
docs/source/aiogram.dispatcher.rst
Normal file
8
docs/source/aiogram.dispatcher.rst
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Dispatcher
|
||||
==========
|
||||
|
||||
Doc's for this module will be available soon..
|
||||
|
||||
.. automodule:: aiogram.dispatcher
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
|
@ -7,6 +7,6 @@ Submodules
|
|||
|
||||
.. toctree::
|
||||
|
||||
aiogram.bot.BaseBot
|
||||
aiogram.bot.Bot
|
||||
aiogram.bot
|
||||
aiogram.types
|
||||
aiogram.dispatcher
|
||||
|
|
|
|||
|
|
@ -202,6 +202,14 @@ ChatMember
|
|||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
ResponseParameters
|
||||
------------------
|
||||
:class:`aiogram.types.ResponseParameters`
|
||||
|
||||
.. automodule:: aiogram.types.response_parameters
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Inline mode objects
|
||||
-------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue