Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API Schema to Layer 162 #1336

Closed
wants to merge 13 commits into from
149 changes: 114 additions & 35 deletions compiler/api/source/main_api.tl

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions compiler/errors/source/400_BAD_REQUEST.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CHANNEL_TOO_LARGE The channel is too large
CHAT_ABOUT_NOT_MODIFIED The chat about text was not modified because you tried to edit it using the same content
CHAT_ABOUT_TOO_LONG The chat about text is too long
CHAT_ADMIN_REQUIRED The method requires chat admin privileges
CHAT_DISCUSSION_UNALLOWED The chat discussion is not allowed
CHAT_FORWARDS_RESTRICTED The chat restricts forwarding content
CHAT_ID_EMPTY The provided chat id is empty
CHAT_ID_INVALID The chat id being used is invalid or not known yet. Make sure you see the chat before interacting with it
Expand Down Expand Up @@ -168,9 +169,12 @@ MAX_QTS_INVALID The provided QTS is invalid
MD5_CHECKSUM_INVALID The file's checksum did not match the md5_checksum parameter
MEDIA_CAPTION_TOO_LONG The media caption is too long
MEDIA_EMPTY The media you tried to send is invalid
MEDIA_FILE_INVALID The media file is invalid
MEDIA_INVALID The media is invalid
MEDIA_NEW_INVALID The new media to edit the message with is invalid
MEDIA_PREV_INVALID The previous media cannot be edited with anything else
MEDIA_TTL_INVALID The media ttl is invalid
MEDIA_VIDEO_STORY_MISSING The media does not have a photo or a video
MEGAGROUP_ID_INVALID The supergroup is invalid
MEGAGROUP_PREHISTORY_HIDDEN The action failed because the supergroup has the pre-history hidden
MEGAGROUP_REQUIRED The request can only be used with a supergroup
Expand All @@ -183,6 +187,7 @@ MESSAGE_POLL_CLOSED You can't interact with a closed poll
MESSAGE_TOO_LONG The message text is too long
METHOD_INVALID The API method is invalid and cannot be used
MSG_ID_INVALID The message ID used in the peer was invalid
MSG_VOICE_MISSING The message does not contain a voice message
MSG_WAIT_FAILED A waiting call returned an error
MULTI_MEDIA_TOO_LONG The album/media group contains too many items
NEW_SALT_INVALID The new salt is invalid
Expand Down Expand Up @@ -240,6 +245,7 @@ POLL_OPTION_INVALID A poll option used invalid data (the data may be too long)
POLL_QUESTION_INVALID The poll question is invalid
POLL_UNSUPPORTED This layer does not support polls in the invoked method
POLL_VOTE_REQUIRED Cast a vote in the poll before calling this method
PREMIUM_ACCOUNT_REQUIRED The method requires a premium user account
PRIVACY_KEY_INVALID The privacy key is invalid
PRIVACY_TOO_LONG Your privacy exception list has exceeded the maximum capacity
PRIVACY_VALUE_INVALID The privacy value is invalid
Expand Down Expand Up @@ -302,6 +308,7 @@ STICKER_PNG_NOPNG Stickers must be png files but the provided image was not a pn
STICKER_TGS_NOTGS A tgs sticker file was expected, but something else was provided
STICKER_THUMB_PNG_NOPNG A png sticker thumbnail file was expected, but something else was provided
STICKER_VIDEO_NOWEBM A webm video file was expected, but something else was provided
STORIES_TOO_MUCH Too many stories in the current account
TAKEOUT_INVALID The takeout id is invalid
TAKEOUT_REQUIRED The method must be invoked inside a takeout session
TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty
Expand All @@ -312,6 +319,7 @@ THEME_MIME_INVALID You cannot create this theme because the mime-type is invalid
TMP_PASSWORD_DISABLED The temporary password is disabled
TMP_PASSWORD_INVALID The temporary password is invalid
TOKEN_INVALID The provided token is invalid
TRANSCRIPTION_FAILED Telegram is having internal problems. Please try again later to transcribe the audio.
TTL_DAYS_INVALID The provided TTL days is invalid
TTL_MEDIA_INVALID The media does not support self-destruction
TYPES_EMPTY The types parameter is empty
Expand Down
3 changes: 2 additions & 1 deletion compiler/errors/source/503_SERVICE_UNAVAILABLE.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
id message
ApiCallError Telegram is having internal problems. Please try again later.
Timeout Telegram is having internal problems. Please try again later.
Timeout Telegram is having internal problems. Please try again later.
Timedout Telegram is having internal problems. Please try again later.
12 changes: 9 additions & 3 deletions pyrogram/methods/bots/send_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from typing import Union

import pyrogram
from pyrogram import raw
from pyrogram import types
from pyrogram import raw, utils, types


class SendGame:
Expand All @@ -30,6 +29,7 @@ async def send_game(
game_short_name: str,
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -58,6 +58,9 @@ async def send_game(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.

Expand All @@ -73,6 +76,9 @@ async def send_game(

await app.send_game(chat_id, "gamename")
"""

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
Expand All @@ -84,7 +90,7 @@ async def send_game(
),
message="",
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
reply_to=reply_to,
random_id=self.rnd_id(),
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None
Expand Down
15 changes: 11 additions & 4 deletions pyrogram/methods/bots/send_inline_bot_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from typing import Union

import pyrogram
from pyrogram import raw
from pyrogram import raw, utils


class SendInlineBotResult:
Expand All @@ -29,7 +29,8 @@ async def send_inline_bot_result(
query_id: int,
result_id: str,
disable_notification: bool = None,
reply_to_message_id: int = None
reply_to_message_id: int = None,
message_thread_id: int = None
) -> "raw.base.Updates":
"""Send an inline bot result.
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
Expand All @@ -52,9 +53,12 @@ async def send_inline_bot_result(
Sends the message silently.
Users will receive a notification with no sound.

reply_to_message_id (``bool``, *optional*):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

Returns:
:obj:`~pyrogram.raw.base.Updates`: Currently, on success, a raw result is returned.

Expand All @@ -63,13 +67,16 @@ async def send_inline_bot_result(

await app.send_inline_bot_result(chat_id, query_id, result_id)
"""

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

return await self.invoke(
raw.functions.messages.SendInlineBotResult(
peer=await self.resolve_peer(chat_id),
query_id=query_id,
id=result_id,
random_id=self.rnd_id(),
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id
reply_to=reply_to
)
)
8 changes: 7 additions & 1 deletion pyrogram/methods/messages/copy_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async def copy_media_group(
captions: Union[List[str], str] = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
schedule_date: datetime = None,
) -> List["types.Message"]:
"""Copy a media group by providing one of the message ids.
Expand Down Expand Up @@ -68,6 +69,9 @@ async def copy_media_group(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.

Expand Down Expand Up @@ -114,12 +118,14 @@ async def copy_media_group(
)
)

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

r = await self.invoke(
raw.functions.messages.SendMultiMedia(
peer=await self.resolve_peer(chat_id),
multi_media=multi_media,
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
reply_to=reply_to,
schedule_date=utils.datetime_to_timestamp(schedule_date)
),
sleep_threshold=60
Expand Down
8 changes: 7 additions & 1 deletion pyrogram/methods/messages/send_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async def send_animation(
file_name: str = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
Expand Down Expand Up @@ -118,6 +119,9 @@ async def send_animation(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.

Expand Down Expand Up @@ -223,14 +227,16 @@ async def progress(current, total):
]
)

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

while True:
try:
r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
media=media,
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
reply_to=reply_to,
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
Expand Down
8 changes: 7 additions & 1 deletion pyrogram/methods/messages/send_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async def send_audio(
file_name: str = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
Expand Down Expand Up @@ -111,6 +112,9 @@ async def send_audio(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.

Expand Down Expand Up @@ -210,14 +214,16 @@ async def progress(current, total):
]
)

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

while True:
try:
r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
media=media,
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
reply_to=reply_to,
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
Expand Down
8 changes: 7 additions & 1 deletion pyrogram/methods/messages/send_cached_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def send_cached_media(
caption_entities: List["types.MessageEntity"] = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
Expand Down Expand Up @@ -79,6 +80,9 @@ async def send_cached_media(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.

Expand All @@ -98,12 +102,14 @@ async def send_cached_media(
await app.send_cached_media("me", file_id)
"""

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
media=utils.get_input_media_from_file_id(file_id),
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
reply_to=reply_to,
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
Expand Down
9 changes: 8 additions & 1 deletion pyrogram/methods/messages/send_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def send_contact(
vcard: str = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
Expand Down Expand Up @@ -72,6 +73,9 @@ async def send_contact(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.

Expand All @@ -90,6 +94,9 @@ async def send_contact(

await app.send_contact("me", "+1-123-456-7890", "Name")
"""

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
Expand All @@ -101,7 +108,7 @@ async def send_contact(
),
message="",
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
reply_to=reply_to,
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
Expand Down
8 changes: 7 additions & 1 deletion pyrogram/methods/messages/send_dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async def send_dice(
emoji: str = "🎲",
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
Expand Down Expand Up @@ -64,6 +65,9 @@ async def send_dice(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.

message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.

schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.

Expand All @@ -90,12 +94,14 @@ async def send_dice(
await app.send_dice(chat_id, "🏀")
"""

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
media=raw.types.InputMediaDice(emoticon=emoji),
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
reply_to=reply_to,
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
Expand Down
Loading
Loading