mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 05:30:15 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/__init__.py # pyrogram/client/types/messages_and_media/message.py # pyrogram/connection/transport/tcp/tcp.py
This commit is contained in:
commit
bc4c787599
@ -5,15 +5,22 @@ Pyrogram embeds a **smart** (automatic) and lightweight plugin system that is me
|
||||
of large projects and to provide a way for creating pluggable components that can be **easily shared** across different
|
||||
Pyrogram applications with **minimal boilerplate code**.
|
||||
|
||||
.. tip::
|
||||
|
||||
Smart Plugins are completely optional and disabled by default.
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Prior to the Smart Plugin system, pluggable handlers were already possible. For example, if you wanted to modularize
|
||||
your applications, you had to do something like this...
|
||||
|
||||
.. note:: This is an example application that replies in private chats with two messages: one containing the same
|
||||
text message you sent and the other containing the reversed text message (e.g.: "pyrogram" -> "pyrogram" and
|
||||
"margoryp"):
|
||||
.. note::
|
||||
|
||||
This is an example application that replies in private chats with two messages: one containing the same
|
||||
text message you sent and the other containing the reversed text message.
|
||||
|
||||
Example: *"Pyrogram"* replies with *"Pyrogram"* and *"margoryP"*
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
|
@ -31,7 +31,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance
|
||||
"e" if sys.getfilesystemencoding() != "utf-8" else "\xe8"
|
||||
)
|
||||
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
|
||||
__version__ = "0.8.1async1"
|
||||
__version__ = "0.9.0.async1"
|
||||
|
||||
from .api.errors import Error
|
||||
from .client.types import (
|
||||
|
@ -148,7 +148,7 @@ class Client(Methods, BaseClient):
|
||||
plugins_dir (``str``, *optional*):
|
||||
Define a custom directory for your plugins. The plugins directory is the location in your
|
||||
filesystem where Pyrogram will automatically load your update handlers.
|
||||
Defaults to "./plugins". Set to None to completely disable plugins.
|
||||
Defaults to None (plugins disabled).
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
@ -219,7 +219,8 @@ class Client(Methods, BaseClient):
|
||||
Requires no parameters.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ConnectionError`` in case you try to start an already started Client.
|
||||
"""
|
||||
if self.is_started:
|
||||
raise ConnectionError("Client has already been started")
|
||||
@ -286,6 +287,9 @@ class Client(Methods, BaseClient):
|
||||
async def stop(self):
|
||||
"""Use this method to manually stop the Client.
|
||||
Requires no parameters.
|
||||
|
||||
Raises:
|
||||
``ConnectionError`` in case you try to stop an already stopped Client.
|
||||
"""
|
||||
if not self.is_started:
|
||||
raise ConnectionError("Client is already stopped")
|
||||
@ -348,7 +352,7 @@ class Client(Methods, BaseClient):
|
||||
Pass a coroutine to run it until is complete.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
run = asyncio.get_event_loop().run_until_complete
|
||||
|
||||
@ -886,7 +890,7 @@ class Client(Methods, BaseClient):
|
||||
|
||||
Args:
|
||||
data (``Object``):
|
||||
The API Scheme function filled with proper arguments.
|
||||
The API Schema function filled with proper arguments.
|
||||
|
||||
retries (``int``):
|
||||
Number of retries.
|
||||
@ -895,7 +899,7 @@ class Client(Methods, BaseClient):
|
||||
Timeout in seconds.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
if not self.is_started:
|
||||
raise ConnectionError("Client has not been started")
|
||||
@ -1084,7 +1088,8 @@ class Client(Methods, BaseClient):
|
||||
On success, the resolved peer id is returned in form of an InputPeer object.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``KeyError`` in case the peer doesn't exist in the internal database.
|
||||
"""
|
||||
if type(peer_id) is str:
|
||||
if peer_id in ("self", "me"):
|
||||
|
@ -50,6 +50,12 @@ class AnswerCallbackQuery(BaseClient):
|
||||
cache_time (``int``):
|
||||
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.
|
||||
|
||||
Returns:
|
||||
True, on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
return await self.send(
|
||||
functions.messages.SetBotCallbackAnswer(
|
||||
|
@ -54,8 +54,8 @@ class GetInlineBotResults(BaseClient):
|
||||
On Success, :obj:`BotResults <pyrogram.api.types.messages.BotResults>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``TimeoutError``: If the bot fails to answer within 10 seconds
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``TimeoutError`` if the bot fails to answer within 10 seconds
|
||||
"""
|
||||
# TODO: Don't return the raw type
|
||||
|
||||
|
@ -45,8 +45,8 @@ class RequestCallbackAnswer(BaseClient):
|
||||
or as an alert.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``TimeoutError``: If the bot fails to answer within 10 seconds
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``TimeoutError`` if the bot fails to answer within 10 seconds.
|
||||
"""
|
||||
return await self.send(
|
||||
functions.messages.GetBotCallbackAnswer(
|
||||
|
@ -53,7 +53,7 @@ class SendInlineBotResult(BaseClient):
|
||||
On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
return await self.send(
|
||||
functions.messages.SendInlineBotResult(
|
||||
|
@ -38,8 +38,8 @@ class DeleteChatPhoto(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If a chat_id belongs to user.
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if a chat_id belongs to user.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -35,7 +35,7 @@ class ExportChatInviteLink(BaseClient):
|
||||
On success, the exported invite link as string is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -33,7 +33,7 @@ class GetChat(BaseClient):
|
||||
On success, a :obj:`Chat <pyrogram.Chat>` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -39,7 +39,7 @@ class GetChatMember(BaseClient):
|
||||
On success, a :obj:`ChatMember <pyrogram.ChatMember>` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
chat_id = await self.resolve_peer(chat_id)
|
||||
user_id = await self.resolve_peer(user_id)
|
||||
|
@ -39,7 +39,7 @@ class GetChatMembers(BaseClient):
|
||||
"""Use this method to get the members list of a chat.
|
||||
|
||||
A chat can be either a basic group, a supergroup or a channel.
|
||||
You must be admin to retrieve the members (also known as "subscribers") list of a channel.
|
||||
You must be admin to retrieve the members list of a channel (also known as "subscribers").
|
||||
|
||||
Args:
|
||||
chat_id (``int`` | ``str``):
|
||||
@ -51,7 +51,7 @@ class GetChatMembers(BaseClient):
|
||||
|
||||
limit (``int``, *optional*):
|
||||
Limits the number of members to be retrieved.
|
||||
Defaults to 200, which is also the maximum limit allowed per method call.
|
||||
Defaults to 200, which is also the maximum server limit allowed per method call.
|
||||
|
||||
query (``str``, *optional*):
|
||||
Query string to filter members based on their display names and usernames.
|
||||
@ -68,9 +68,17 @@ class GetChatMembers(BaseClient):
|
||||
*"administrators"* - chat administrators only.
|
||||
Defaults to *"all"*.
|
||||
|
||||
.. [1] On supergroups and channels you can get up to 10,000 members for a single query string.
|
||||
.. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
|
||||
on channels.
|
||||
|
||||
.. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only.
|
||||
|
||||
Returns:
|
||||
On success, a :obj:`ChatMembers` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if you used an invalid filter or a chat_id that belongs to a user.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -32,8 +32,8 @@ class GetChatMembersCount(BaseClient):
|
||||
On success, an integer is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If a chat_id belongs to user.
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if a chat_id belongs to user.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -47,7 +47,7 @@ class GetDialogs(BaseClient):
|
||||
On success, a :obj:`Dialogs` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
|
||||
if pinned_only:
|
||||
|
@ -30,7 +30,7 @@ class JoinChat(BaseClient):
|
||||
channel/supergroup (in the format @username).
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
match = self.INVITE_LINK_RE.match(chat_id)
|
||||
|
||||
|
@ -53,7 +53,7 @@ class KickChatMember(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
chat_peer = await self.resolve_peer(chat_id)
|
||||
user_peer = await self.resolve_peer(user_id)
|
||||
|
@ -33,7 +33,7 @@ class LeaveChat(BaseClient):
|
||||
Deletes the group chat dialog after leaving (for simple group chats, not supergroups).
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -41,8 +41,8 @@ class PinChatMessage(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If a chat_id doesn't belong to a supergroup or a channel.
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if a chat_id doesn't belong to a supergroup or a channel.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -74,7 +74,7 @@ class PromoteChatMember(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
await self.send(
|
||||
functions.channels.EditAdmin(
|
||||
|
@ -64,7 +64,7 @@ class RestrictChatMember(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
send_messages = True
|
||||
send_media = True
|
||||
|
@ -36,8 +36,8 @@ class SetChatDescription(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If a chat_id doesn't belong to a supergroup or a channel.
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if a chat_id doesn't belong to a supergroup or a channel.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -45,8 +45,8 @@ class SetChatPhoto(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If a chat_id belongs to user.
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if a chat_id belongs to user.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -41,8 +41,8 @@ class SetChatTitle(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If a chat_id belongs to user.
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if a chat_id belongs to user.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -40,7 +40,7 @@ class UnbanChatMember(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
await self.send(
|
||||
functions.channels.EditBanned(
|
||||
|
@ -34,8 +34,8 @@ class UnpinChatMessage(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If a chat_id doesn't belong to a supergroup or a channel.
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if a chat_id doesn't belong to a supergroup or a channel.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
|
@ -32,7 +32,7 @@ class AddContacts(BaseClient):
|
||||
On success, the added contacts are returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
imported_contacts = await self.send(
|
||||
functions.contacts.ImportContacts(
|
||||
|
@ -34,7 +34,7 @@ class DeleteContacts(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
contacts = []
|
||||
|
||||
|
@ -36,7 +36,7 @@ class GetContacts(BaseClient):
|
||||
On success, the user's contacts are returned
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
|
@ -53,7 +53,7 @@ class DeleteMessages(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids]
|
||||
|
@ -53,7 +53,7 @@ class EditMessageCaption(BaseClient):
|
||||
On success, the edited :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
||||
|
@ -57,6 +57,12 @@ class EditMessageMedia(BaseClient):
|
||||
|
||||
reply_markup (:obj:`InlineKeyboardMarkup`, *optional*):
|
||||
An InlineKeyboardMarkup object.
|
||||
|
||||
Returns:
|
||||
On success, the edited :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
style = self.html if media.parse_mode.lower() == "html" else self.markdown
|
||||
caption = media.caption
|
||||
|
@ -44,7 +44,7 @@ class EditMessageReplyMarkup(BaseClient):
|
||||
:obj:`Message <pyrogram.Message>` is returned, otherwise True is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
|
||||
r = await self.send(
|
||||
|
@ -57,7 +57,7 @@ class EditMessageText(BaseClient):
|
||||
On success, the edited :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
||||
|
@ -54,7 +54,7 @@ class ForwardMessages(BaseClient):
|
||||
is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
is_iterable = not isinstance(message_ids, int)
|
||||
message_ids = list(message_ids) if is_iterable else [message_ids]
|
||||
|
@ -56,7 +56,7 @@ class GetHistory(BaseClient):
|
||||
On success, a :obj:`Messages <pyrogram.Messages>` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
|
||||
r = await self.send(
|
||||
|
@ -54,7 +54,7 @@ class GetMessages(BaseClient):
|
||||
:obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
ids, ids_type = (
|
||||
(message_ids, types.InputMessageID) if message_ids
|
||||
|
@ -116,7 +116,7 @@ class SendAnimation(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
@ -117,7 +117,7 @@ class SendAudio(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
@ -47,8 +47,8 @@ class SendChatAction(BaseClient):
|
||||
On success, True is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If the provided string is not a valid ChatAction
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if the provided string is not a valid ChatAction.
|
||||
"""
|
||||
|
||||
# Resolve Enum type
|
||||
|
@ -64,7 +64,7 @@ class SendContact(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
r = await self.send(
|
||||
functions.messages.SendMedia(
|
||||
|
@ -103,7 +103,7 @@ class SendDocument(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
@ -57,7 +57,7 @@ class SendLocation(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
r = await self.send(
|
||||
functions.messages.SendMedia(
|
||||
|
@ -64,7 +64,7 @@ class SendMessage(BaseClient):
|
||||
On success, the sent :obj:`Message` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
||||
|
@ -102,7 +102,7 @@ class SendPhoto(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
@ -86,7 +86,7 @@ class SendSticker(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
|
||||
|
@ -73,7 +73,7 @@ class SendVenue(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
r = await self.send(
|
||||
functions.messages.SendMedia(
|
||||
|
@ -120,7 +120,7 @@ class SendVideo(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
@ -101,7 +101,7 @@ class SendVideoNote(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
|
||||
|
@ -101,7 +101,7 @@ class SendVoice(BaseClient):
|
||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
file = None
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
@ -41,7 +41,7 @@ class ChangeCloudPassword(BaseClient):
|
||||
True on success, False otherwise.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
r = await self.send(functions.account.GetPassword())
|
||||
|
||||
|
@ -43,7 +43,7 @@ class EnableCloudPassword(BaseClient):
|
||||
True on success, False otherwise.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
r = await self.send(functions.account.GetPassword())
|
||||
|
||||
|
@ -34,7 +34,7 @@ class RemoveCloudPassword(BaseClient):
|
||||
True on success, False otherwise.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
r = await self.send(functions.account.GetPassword())
|
||||
|
||||
|
@ -36,7 +36,7 @@ class DeleteUserProfilePhotos(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
id = id if isinstance(id, list) else [id]
|
||||
input_photos = []
|
||||
|
@ -28,7 +28,7 @@ class GetMe(BaseClient):
|
||||
Basic information about the user or bot in form of a :obj:`User` object
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
r = await self.send(
|
||||
functions.users.GetFullUser(
|
||||
|
@ -45,7 +45,7 @@ class GetUserProfilePhotos(BaseClient):
|
||||
On success, a :obj:`UserProfilePhotos` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
return utils.parse_profile_photos(
|
||||
await self.send(
|
||||
|
@ -39,7 +39,7 @@ class GetUsers(BaseClient):
|
||||
*user_ids* was an integer, the single requested :obj:`User` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
is_iterable = not isinstance(user_ids, (int, str))
|
||||
user_ids = list(user_ids) if is_iterable else [user_ids]
|
||||
|
@ -36,7 +36,7 @@ class SetUserProfilePhoto(BaseClient):
|
||||
True on success.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
|
||||
return bool(
|
||||
|
@ -73,8 +73,8 @@ class DownloadMedia(BaseClient):
|
||||
On success, the absolute path of the downloaded file as string is returned, None otherwise.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
``ValueError``: If the message doesn't contain any downloadable media
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
``ValueError`` if the message doesn't contain any downloadable media
|
||||
"""
|
||||
error_message = "This message doesn't contain any downloadable media"
|
||||
|
||||
|
@ -73,7 +73,9 @@ class CallbackQuery(Object):
|
||||
self.game_short_name = game_short_name # flags.3?string
|
||||
|
||||
def answer(self, text: str = None, show_alert: bool = None, url: str = None, cache_time: int = 0):
|
||||
"""Use this method as a shortcut for:
|
||||
"""Bound method *answer* of :obj:`CallbackQuery <pyrogram.CallbackQuery>`.
|
||||
|
||||
Use this method as a shortcut for:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -50,16 +50,10 @@ class InlineKeyboardButton(Object):
|
||||
chat's input field. Can be empty, in which case only the bot's username will be inserted.This offers a
|
||||
quick way for the user to open your bot in inline mode in the same chat – good for selecting something
|
||||
from multiple options.
|
||||
|
||||
callback_game (:obj:`CallbackGame <pyrogram.CallbackGame>`, *optional*):
|
||||
Description of the game that will be launched when the user presses the button.NOTE: This type of button
|
||||
must always be the first button in the first row.
|
||||
|
||||
pay (``bool``, *optional*):
|
||||
Specify True, to send a Pay button.NOTE: This type of button must always be the first button in the
|
||||
first row.
|
||||
"""
|
||||
|
||||
# TODO: Add callback_game and pay fields
|
||||
|
||||
ID = 0xb0700019
|
||||
|
||||
def __init__(
|
||||
@ -69,16 +63,16 @@ class InlineKeyboardButton(Object):
|
||||
url: str = None,
|
||||
switch_inline_query: str = None,
|
||||
switch_inline_query_current_chat: str = None,
|
||||
callback_game=None,
|
||||
pay: bool = None
|
||||
# callback_game=None,
|
||||
# pay: bool = None
|
||||
):
|
||||
self.text = text
|
||||
self.url = url
|
||||
self.callback_data = callback_data
|
||||
self.switch_inline_query = switch_inline_query
|
||||
self.switch_inline_query_current_chat = switch_inline_query_current_chat
|
||||
self.callback_game = callback_game
|
||||
self.pay = pay
|
||||
# self.callback_game = callback_game
|
||||
# self.pay = pay
|
||||
|
||||
@staticmethod
|
||||
def read(b, *args):
|
||||
|
@ -27,7 +27,7 @@ class InlineKeyboardMarkup(Object):
|
||||
|
||||
Args:
|
||||
inline_keyboard (List of List of :obj:`InlineKeyboardButton <pyrogram.InlineKeyboardButton>`):
|
||||
Array of button rows, each represented by an Array of InlineKeyboardButton objects.
|
||||
List of button rows, each represented by a List of InlineKeyboardButton objects.
|
||||
"""
|
||||
|
||||
ID = 0xb0700020
|
||||
|
@ -25,11 +25,11 @@ from . import KeyboardButton
|
||||
|
||||
|
||||
class ReplyKeyboardMarkup(Object):
|
||||
"""This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
|
||||
"""This object represents a custom keyboard with reply options.
|
||||
|
||||
Args:
|
||||
keyboard (List of List of :obj:`KeyboardButton <pyrogram.KeyboardButton>`):
|
||||
Array of button rows, each represented by an Array of KeyboardButton objects.
|
||||
List of button rows, each represented by a List of KeyboardButton objects.
|
||||
|
||||
resize_keyboard (``bool``, *optional*):
|
||||
Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if
|
||||
|
@ -48,7 +48,7 @@ class Animation(Object):
|
||||
File size.
|
||||
|
||||
date (``int``, *optional*):
|
||||
Date the Animation was sent in Unix time.
|
||||
Date the animation was sent in Unix time.
|
||||
"""
|
||||
|
||||
ID = 0xb0700025
|
||||
|
@ -36,7 +36,7 @@ class Contact(Object):
|
||||
Contact's user identifier in Telegram.
|
||||
|
||||
vcard (``str``, *optional*):
|
||||
Additional data about the contact in the form of a vCard
|
||||
Additional data about the contact in the form of a vCard.
|
||||
"""
|
||||
|
||||
ID = 0xb0700011
|
||||
|
@ -164,20 +164,11 @@ class Message(Object):
|
||||
Note that the Message object in this field will not contain further reply_to_message fields even if it
|
||||
is itself a reply.
|
||||
|
||||
invoice (:obj:`Invoice <pyrogram.Invoice>`, *optional*):
|
||||
Message is an invoice for a payment, information about the invoice. More about payments.
|
||||
|
||||
successful_payment (:obj:`SuccessfulPayment <pyrogram.SuccessfulPayment>`, *optional*):
|
||||
Message is a service message about a successful payment, information about the payment. More about payments.
|
||||
|
||||
connected_website (``str``, *optional*):
|
||||
The domain name of the website on which the user has logged in. More about Telegram Login.
|
||||
|
||||
views (``int``, *optional*):
|
||||
Channel post views.
|
||||
|
||||
via_bot (:obj:`User <pyrogram.User>`):
|
||||
Via bot.
|
||||
The information of the bot that generated the message from an inline query of a user.
|
||||
|
||||
outgoing (``bool``, *optional*):
|
||||
Whether the message is incoming or outgoing.
|
||||
@ -199,6 +190,7 @@ class Message(Object):
|
||||
instructions to remove reply keyboard or to force a reply from the user.
|
||||
"""
|
||||
|
||||
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
|
||||
ID = 0xb0700003
|
||||
|
||||
def __init__(
|
||||
@ -243,9 +235,6 @@ class Message(Object):
|
||||
migrate_to_chat_id: int = None,
|
||||
migrate_from_chat_id: int = None,
|
||||
pinned_message=None,
|
||||
invoice=None,
|
||||
successful_payment=None,
|
||||
connected_website=None,
|
||||
views: int = None,
|
||||
via_bot=None,
|
||||
outgoing: bool = None,
|
||||
@ -293,9 +282,6 @@ class Message(Object):
|
||||
self.migrate_to_chat_id = migrate_to_chat_id # flags.33?int
|
||||
self.migrate_from_chat_id = migrate_from_chat_id # flags.34?int
|
||||
self.pinned_message = pinned_message # flags.35?Message
|
||||
self.invoice = invoice # flags.36?Invoice
|
||||
self.successful_payment = successful_payment # flags.37?SuccessfulPayment
|
||||
self.connected_website = connected_website # flags.38?string
|
||||
self.views = views # flags.39?int
|
||||
self.via_bot = via_bot # flags.40?User
|
||||
self.outgoing = outgoing
|
||||
@ -311,7 +297,9 @@ class Message(Object):
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
reply_markup=None):
|
||||
"""Use this method as a shortcut for:
|
||||
"""Bound method *reply* of :obj:`Message <pyrogram.Message>`.
|
||||
|
||||
Use as a shortcut for:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@ -379,7 +367,9 @@ class Message(Object):
|
||||
async def forward(self,
|
||||
chat_id: int or str,
|
||||
disable_notification: bool = None):
|
||||
"""Use this method as a shortcut for:
|
||||
"""Bound method *forward* of :obj:`Message <pyrogram.Message>`.
|
||||
|
||||
Use as a shortcut for:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@ -418,7 +408,9 @@ class Message(Object):
|
||||
)
|
||||
|
||||
async def delete(self, revoke: bool = True):
|
||||
"""Use this method as a shortcut for:
|
||||
"""Bound method *delete* of :obj:`Message <pyrogram.Message>`.
|
||||
|
||||
Use as a shortcut for:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@ -454,8 +446,9 @@ class Message(Object):
|
||||
return True
|
||||
|
||||
async def click(self, x: int or str, y: int = None, quote: bool = None):
|
||||
"""Use this method to click a button attached to the message.
|
||||
It's a shortcut for:
|
||||
"""Bound method *click* of :obj:`Message <pyrogram.Message>`.
|
||||
|
||||
Use as a shortcut for clicking a button attached to the message instead of.
|
||||
|
||||
- Clicking inline buttons:
|
||||
|
||||
@ -476,6 +469,7 @@ class Message(Object):
|
||||
text=message.reply_markup[i][j].text
|
||||
)
|
||||
|
||||
Example:
|
||||
This method can be used in three different ways:
|
||||
|
||||
1. Pass one integer argument only (e.g.: ``.click(2)``, to click a button at index 2).
|
||||
@ -567,7 +561,9 @@ class Message(Object):
|
||||
raise ValueError("The message doesn't contain any keyboard")
|
||||
|
||||
async def download(self, file_name: str = "", block: bool = True):
|
||||
"""Use this method as a shortcut for:
|
||||
"""Bound method *download* of :obj:`Message <pyrogram.Message>`.
|
||||
|
||||
Use as a shortcut for:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -20,7 +20,7 @@ from pyrogram.api.core import Object
|
||||
|
||||
|
||||
class Photo(Object):
|
||||
"""This object represents a Photo
|
||||
"""This object represents a Photo.
|
||||
|
||||
Args:
|
||||
id (``str``):
|
||||
|
@ -52,11 +52,9 @@ class Sticker(Object):
|
||||
|
||||
set_name (``str``, *optional*):
|
||||
Name of the sticker set to which the sticker belongs.
|
||||
|
||||
mask_position (:obj:`MaskPosition <pyrogram.MaskPosition>`, *optional*):
|
||||
For mask stickers, the position where the mask should be placed.
|
||||
"""
|
||||
|
||||
# TODO: Add mask position
|
||||
ID = 0xb0700017
|
||||
|
||||
def __init__(
|
||||
|
@ -22,5 +22,5 @@ from .chat_members import ChatMembers
|
||||
from .chat_photo import ChatPhoto
|
||||
from .dialog import Dialog
|
||||
from .dialogs import Dialogs
|
||||
from .user_status import UserStatus
|
||||
from .user import User
|
||||
from .user_status import UserStatus
|
||||
|
@ -20,7 +20,7 @@ from pyrogram.api.core import Object
|
||||
|
||||
|
||||
class Dialog(Object):
|
||||
"""This object represents a dialog
|
||||
"""This object represents a dialog.
|
||||
|
||||
Args:
|
||||
chat (:obj:`Chat <pyrogram.Chat>`):
|
||||
|
@ -20,7 +20,7 @@ from pyrogram.api.core import Object
|
||||
|
||||
|
||||
class UserStatus(Object):
|
||||
"""This object represents a User status (Last Seen privacy)
|
||||
"""This object represents a User status (Last Seen privacy).
|
||||
|
||||
.. note::
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user