From 4661fb035b3122e01522b0122ae994d9c5c91691 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 20:17:42 +0200
Subject: [PATCH 001/202] Refactor Poll types and methods to reflect Bot API
4.2 docs
---
pyrogram/client/methods/messages/__init__.py | 4 +-
.../client/methods/messages/retract_vote.py | 13 ++---
pyrogram/client/methods/messages/send_poll.py | 4 +-
.../messages/{close_poll.py => stop_poll.py} | 28 ++++++----
pyrogram/client/methods/messages/vote_poll.py | 14 ++---
.../client/types/messages_and_media/poll.py | 54 ++++++++++---------
.../types/messages_and_media/poll_option.py | 21 ++++----
pyrogram/client/types/pyrogram_type.py | 2 +-
8 files changed, 74 insertions(+), 66 deletions(-)
rename pyrogram/client/methods/messages/{close_poll.py => stop_poll.py} (71%)
diff --git a/pyrogram/client/methods/messages/__init__.py b/pyrogram/client/methods/messages/__init__.py
index dde50b7b..d26c51cc 100644
--- a/pyrogram/client/methods/messages/__init__.py
+++ b/pyrogram/client/methods/messages/__init__.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from .close_poll import ClosePoll
+from .stop_poll import StopPoll
from .delete_messages import DeleteMessages
from .download_media import DownloadMedia
from .edit_message_caption import EditMessageCaption
@@ -72,7 +72,7 @@ class Messages(
SendVoice,
SendPoll,
VotePoll,
- ClosePoll,
+ StopPoll,
RetractVote,
DownloadMedia,
IterHistory,
diff --git a/pyrogram/client/methods/messages/retract_vote.py b/pyrogram/client/methods/messages/retract_vote.py
index 8fa8996c..ce8a0140 100644
--- a/pyrogram/client/methods/messages/retract_vote.py
+++ b/pyrogram/client/methods/messages/retract_vote.py
@@ -18,6 +18,7 @@
from typing import Union
+import pyrogram
from pyrogram.api import functions
from pyrogram.client.ext import BaseClient
@@ -26,8 +27,8 @@ class RetractVote(BaseClient):
def retract_vote(
self,
chat_id: Union[int, str],
- message_id: id
- ) -> bool:
+ message_id: int
+ ) -> "pyrogram.Poll":
"""Use this method to retract your vote in a poll.
Args:
@@ -37,15 +38,15 @@ class RetractVote(BaseClient):
For a contact that exists in your Telegram address book you can use his phone number (str).
message_id (``int``):
- Unique poll message identifier inside this chat.
+ Identifier of the original message with the poll.
Returns:
- On success, True is returned.
+ On success, the :obj:`Poll ` with the retracted vote is returned.
Raises:
:class:`RPCError ` in case of a Telegram RPC error.
"""
- self.send(
+ r = self.send(
functions.messages.SendVote(
peer=self.resolve_peer(chat_id),
msg_id=message_id,
@@ -53,4 +54,4 @@ class RetractVote(BaseClient):
)
)
- return True
+ return pyrogram.Poll._parse(self, r.updates[0])
diff --git a/pyrogram/client/methods/messages/send_poll.py b/pyrogram/client/methods/messages/send_poll.py
index 13e55b08..6b4e227a 100644
--- a/pyrogram/client/methods/messages/send_poll.py
+++ b/pyrogram/client/methods/messages/send_poll.py
@@ -47,10 +47,10 @@ class SendPoll(BaseClient):
For a contact that exists in your Telegram address book you can use his phone number (str).
question (``str``):
- The poll question, as string.
+ Poll question, 1-255 characters.
options (List of ``str``):
- The poll options, as list of strings (2 to 10 options are allowed).
+ List of answer options, 2-10 strings 1-100 characters each.
disable_notification (``bool``, *optional*):
Sends the message silently.
diff --git a/pyrogram/client/methods/messages/close_poll.py b/pyrogram/client/methods/messages/stop_poll.py
similarity index 71%
rename from pyrogram/client/methods/messages/close_poll.py
rename to pyrogram/client/methods/messages/stop_poll.py
index 1b1164c2..a5a4ecc8 100644
--- a/pyrogram/client/methods/messages/close_poll.py
+++ b/pyrogram/client/methods/messages/stop_poll.py
@@ -18,19 +18,21 @@
from typing import Union
+import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import BaseClient
-class ClosePoll(BaseClient):
- def close_poll(
+class StopPoll(BaseClient):
+ def stop_poll(
self,
chat_id: Union[int, str],
- message_id: id
- ) -> bool:
- """Use this method to close (stop) a poll.
+ message_id: int,
+ reply_markup: "pyrogram.InlineKeyboardMarkup" = None
+ ) -> "pyrogram.Poll":
+ """Use this method to stop a poll which was sent by you.
- Closed polls can't be reopened and nobody will be able to vote in it anymore.
+ Stopped polls can't be reopened and nobody will be able to vote in it anymore.
Args:
chat_id (``int`` | ``str``):
@@ -39,17 +41,20 @@ class ClosePoll(BaseClient):
For a contact that exists in your Telegram address book you can use his phone number (str).
message_id (``int``):
- Unique poll message identifier inside this chat.
+ Identifier of the original message with the poll.
+
+ reply_markup (:obj:`InlineKeyboardMarkup`, *optional*):
+ An InlineKeyboardMarkup object.
Returns:
- On success, True is returned.
+ On success, the stopped :obj:`Poll ` with the final results is returned.
Raises:
:class:`RPCError ` in case of a Telegram RPC error.
"""
poll = self.get_messages(chat_id, message_id).poll
- self.send(
+ r = self.send(
functions.messages.EditMessage(
peer=self.resolve_peer(chat_id),
id=message_id,
@@ -60,8 +65,9 @@ class ClosePoll(BaseClient):
question="",
answers=[]
)
- )
+ ),
+ reply_markup=reply_markup.write() if reply_markup else None
)
)
- return True
+ return pyrogram.Poll._parse(self, r.updates[0])
diff --git a/pyrogram/client/methods/messages/vote_poll.py b/pyrogram/client/methods/messages/vote_poll.py
index 2a9de874..58f21a6c 100644
--- a/pyrogram/client/methods/messages/vote_poll.py
+++ b/pyrogram/client/methods/messages/vote_poll.py
@@ -18,6 +18,7 @@
from typing import Union
+import pyrogram
from pyrogram.api import functions
from pyrogram.client.ext import BaseClient
@@ -28,7 +29,7 @@ class VotePoll(BaseClient):
chat_id: Union[int, str],
message_id: id,
option: int
- ) -> bool:
+ ) -> "pyrogram.Poll":
"""Use this method to vote a poll.
Args:
@@ -38,25 +39,26 @@ class VotePoll(BaseClient):
For a contact that exists in your Telegram address book you can use his phone number (str).
message_id (``int``):
- Unique poll message identifier inside this chat.
+ Identifier of the original message with the poll.
option (``int``):
Index of the poll option you want to vote for (0 to 9).
Returns:
- On success, True is returned.
+ On success, the :obj:`Poll ` with the chosen option is returned.
Raises:
:class:`RPCError ` in case of a Telegram RPC error.
"""
+
poll = self.get_messages(chat_id, message_id).poll
- self.send(
+ r = self.send(
functions.messages.SendVote(
peer=self.resolve_peer(chat_id),
msg_id=message_id,
- options=[poll.options[option].data]
+ options=[poll.options[option]._data]
)
)
- return True
+ return pyrogram.Poll._parse(self, r.updates[0])
diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py
index 68667334..dfe7daa9 100644
--- a/pyrogram/client/types/messages_and_media/poll.py
+++ b/pyrogram/client/types/messages_and_media/poll.py
@@ -29,78 +29,80 @@ class Poll(PyrogramType):
Args:
id (``int``):
- The poll id in this chat.
-
- closed (``bool``):
- Whether the poll is closed or not.
+ Unique poll identifier.
question (``str``):
- Poll question.
+ Poll question, 1-255 characters.
options (List of :obj:`PollOption`):
- The available poll options.
+ List of poll options.
+
+ is_closed (``bool``):
+ True, if the poll is closed.
total_voters (``int``):
- Total amount of voters for this poll.
+ Total count of voters for this poll.
- option_chosen (``int``, *optional*):
- The index of your chosen option (in case you voted already), None otherwise.
+ chosen_option (``int``, *optional*):
+ Index of your chosen option (0-9), None in case you haven't voted yet.
"""
- __slots__ = ["id", "closed", "question", "options", "total_voters", "option_chosen"]
+ __slots__ = ["id", "question", "options", "is_closed", "total_voters", "chosen_option"]
def __init__(
self,
*,
client: "pyrogram.client.ext.BaseClient",
id: int,
- closed: bool,
question: str,
options: List[PollOption],
+ is_closed: bool,
total_voters: int,
- option_chosen: int = None
+ chosen_option: int = None
):
super().__init__(client)
self.id = id
- self.closed = closed
self.question = question
self.options = options
+ self.is_closed = is_closed
self.total_voters = total_voters
- self.option_chosen = option_chosen
+ self.chosen_option = chosen_option
@staticmethod
def _parse(client, media_poll: types.MessageMediaPoll) -> "Poll":
poll = media_poll.poll
results = media_poll.results.results
total_voters = media_poll.results.total_voters
- option_chosen = None
+ chosen_option = None
options = []
for i, answer in enumerate(poll.answers):
- voters = 0
+ voter_count = 0
if results:
result = results[i]
- voters = result.voters
+ voter_count = result.voters
if result.chosen:
- option_chosen = i
+ chosen_option = i
- options.append(PollOption(
- text=answer.text,
- voters=voters,
- data=answer.option,
- client=client
- ))
+ options.append(
+ PollOption(
+ text=answer.text,
+ voter_count=voter_count,
+ data=answer.option,
+ client=client
+ )
+ )
return Poll(
id=poll.id,
- closed=poll.closed,
question=poll.question,
options=options,
+ is_closed=poll.closed,
total_voters=total_voters,
- option_chosen=option_chosen,
+ chosen_option=chosen_option,
client=client
)
diff --git a/pyrogram/client/types/messages_and_media/poll_option.py b/pyrogram/client/types/messages_and_media/poll_option.py
index c45c1db2..4b32623a 100644
--- a/pyrogram/client/types/messages_and_media/poll_option.py
+++ b/pyrogram/client/types/messages_and_media/poll_option.py
@@ -21,32 +21,29 @@ from ..pyrogram_type import PyrogramType
class PollOption(PyrogramType):
- """This object represents a Poll Option.
+ """This object contains information about one answer option in a poll.
Args:
text (``str``):
- Text of the poll option.
+ Option text, 1-100 characters.
- voters (``int``):
- The number of users who voted this option.
- It will be 0 until you vote for the poll.
-
- data (``bytes``):
- Unique data that identifies this option among all the other options in a poll.
+ voter_count (``int``):
+ Number of users that voted for this option.
+ Equals to 0 until you vote.
"""
- __slots__ = ["text", "voters", "data"]
+ __slots__ = ["text", "voter_count", "_data"]
def __init__(
self,
*,
client: "pyrogram.client.ext.BaseClient",
text: str,
- voters: int,
+ voter_count: int,
data: bytes
):
super().__init__(client)
self.text = text
- self.voters = voters
- self.data = data
+ self.voter_count = voter_count
+ self._data = data # Hidden
diff --git a/pyrogram/client/types/pyrogram_type.py b/pyrogram/client/types/pyrogram_type.py
index af828926..5f757d43 100644
--- a/pyrogram/client/types/pyrogram_type.py
+++ b/pyrogram/client/types/pyrogram_type.py
@@ -51,7 +51,7 @@ def default(o: PyrogramType):
return remove_none(
OrderedDict(
[("_", "pyrogram." + o.__class__.__name__)]
- + [i for i in content.items()]
+ + [i for i in content.items() if not i[0].startswith("_")]
)
)
except AttributeError:
From 22a7e338ff418f57d12ace8ca4f650a2e02c8f4c Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 20:18:44 +0200
Subject: [PATCH 002/202] Fetch the pinned message in own chat (saved messages)
---
pyrogram/client/types/user_and_chats/chat.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py
index a13f8a2b..1d4369d4 100644
--- a/pyrogram/client/types/user_and_chats/chat.py
+++ b/pyrogram/client/types/user_and_chats/chat.py
@@ -185,6 +185,12 @@ class Chat(PyrogramType):
if isinstance(chat_full, types.UserFull):
parsed_chat = Chat._parse_user_chat(client, chat_full.user)
parsed_chat.description = chat_full.about
+
+ if chat_full.pinned_msg_id:
+ parsed_chat.pinned_message = client.get_messages(
+ parsed_chat.id,
+ message_ids=chat_full.pinned_msg_id
+ )
else:
full_chat = chat_full.full_chat
chat = None
From ebacefb6e039c4a16b0c2993c6cfb9da705328bf Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 20:33:45 +0200
Subject: [PATCH 003/202] Increase media thumbnail size limit
---
pyrogram/client/methods/messages/send_animation.py | 2 +-
pyrogram/client/methods/messages/send_audio.py | 2 +-
pyrogram/client/methods/messages/send_document.py | 2 +-
pyrogram/client/methods/messages/send_video.py | 2 +-
pyrogram/client/methods/messages/send_video_note.py | 2 +-
.../client/types/input_media/input_media_animation.py | 2 +-
pyrogram/client/types/input_media/input_media_audio.py | 2 +-
.../client/types/input_media/input_media_document.py | 2 +-
pyrogram/client/types/input_media/input_media_video.py | 2 +-
pyrogram/client/types/messages_and_media/message.py | 10 +++++-----
10 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py
index 798d236d..c8da7297 100644
--- a/pyrogram/client/methods/messages/send_animation.py
+++ b/pyrogram/client/methods/messages/send_animation.py
@@ -83,7 +83,7 @@ class SendAnimation(BaseClient):
thumb (``str``, *optional*):
Thumbnail of the animation file sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
disable_notification (``bool``, *optional*):
diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py
index d514b737..0ef2aef3 100644
--- a/pyrogram/client/methods/messages/send_audio.py
+++ b/pyrogram/client/methods/messages/send_audio.py
@@ -85,7 +85,7 @@ class SendAudio(BaseClient):
thumb (``str``, *optional*):
Thumbnail of the music file album cover.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
disable_notification (``bool``, *optional*):
diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py
index a36a0fbb..ad47d38c 100644
--- a/pyrogram/client/methods/messages/send_document.py
+++ b/pyrogram/client/methods/messages/send_document.py
@@ -63,7 +63,7 @@ class SendDocument(BaseClient):
thumb (``str``, *optional*):
Thumbnail of the file sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
caption (``str``, *optional*):
diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py
index 08d8b7ab..c9456858 100644
--- a/pyrogram/client/methods/messages/send_video.py
+++ b/pyrogram/client/methods/messages/send_video.py
@@ -84,7 +84,7 @@ class SendVideo(BaseClient):
thumb (``str``, *optional*):
Thumbnail of the video sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
supports_streaming (``bool``, *optional*):
diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py
index 4844dd65..19b35256 100644
--- a/pyrogram/client/methods/messages/send_video_note.py
+++ b/pyrogram/client/methods/messages/send_video_note.py
@@ -69,7 +69,7 @@ class SendVideoNote(BaseClient):
thumb (``str``, *optional*):
Thumbnail of the video sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
disable_notification (``bool``, *optional*):
diff --git a/pyrogram/client/types/input_media/input_media_animation.py b/pyrogram/client/types/input_media/input_media_animation.py
index e77499b5..6c06df7b 100644
--- a/pyrogram/client/types/input_media/input_media_animation.py
+++ b/pyrogram/client/types/input_media/input_media_animation.py
@@ -31,7 +31,7 @@ class InputMediaAnimation(InputMedia):
thumb (``str``, *optional*):
Thumbnail of the animation file sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
caption (``str``, *optional*):
diff --git a/pyrogram/client/types/input_media/input_media_audio.py b/pyrogram/client/types/input_media/input_media_audio.py
index e8f1c257..6b7659fe 100644
--- a/pyrogram/client/types/input_media/input_media_audio.py
+++ b/pyrogram/client/types/input_media/input_media_audio.py
@@ -32,7 +32,7 @@ class InputMediaAudio(InputMedia):
thumb (``str``, *optional*):
Thumbnail of the music file album cover.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
caption (``str``, *optional*):
diff --git a/pyrogram/client/types/input_media/input_media_document.py b/pyrogram/client/types/input_media/input_media_document.py
index 9391e7d8..a5d36261 100644
--- a/pyrogram/client/types/input_media/input_media_document.py
+++ b/pyrogram/client/types/input_media/input_media_document.py
@@ -31,7 +31,7 @@ class InputMediaDocument(InputMedia):
thumb (``str``):
Thumbnail of the file sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
caption (``str``, *optional*):
diff --git a/pyrogram/client/types/input_media/input_media_video.py b/pyrogram/client/types/input_media/input_media_video.py
index 5c918f13..27d166bd 100644
--- a/pyrogram/client/types/input_media/input_media_video.py
+++ b/pyrogram/client/types/input_media/input_media_video.py
@@ -33,7 +33,7 @@ class InputMediaVideo(InputMedia):
thumb (``str``):
Thumbnail of the video sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
caption (``str``, *optional*):
diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py
index fc2cb8fb..1ad00a7f 100644
--- a/pyrogram/client/types/messages_and_media/message.py
+++ b/pyrogram/client/types/messages_and_media/message.py
@@ -795,7 +795,7 @@ class Message(PyrogramType, Update):
thumb (``str``, *optional*):
Thumbnail of the animation file sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
disable_notification (``bool``, *optional*):
@@ -930,7 +930,7 @@ class Message(PyrogramType, Update):
thumb (``str``, *optional*):
Thumbnail of the music file album cover.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
disable_notification (``bool``, *optional*):
@@ -1257,7 +1257,7 @@ class Message(PyrogramType, Update):
thumb (``str``, *optional*):
Thumbnail of the file sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
caption (``str``, *optional*):
@@ -2064,7 +2064,7 @@ class Message(PyrogramType, Update):
thumb (``str``, *optional*):
Thumbnail of the video sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
supports_streaming (``bool``, *optional*):
@@ -2189,7 +2189,7 @@ class Message(PyrogramType, Update):
thumb (``str``, *optional*):
Thumbnail of the video sent.
The thumbnail should be in JPEG format and less than 200 KB in size.
- A thumbnail's width and height should not exceed 90 pixels.
+ A thumbnail's width and height should not exceed 320 pixels.
Thumbnails can't be reused and can be only uploaded as a new file.
disable_notification (``bool``, *optional*):
From cbc938931dbe222e3b46e1289b298b36f02e1e3e Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 20:34:46 +0200
Subject: [PATCH 004/202] Rename forward_from_name to forward_sender_name
---
.../client/types/messages_and_media/message.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py
index 1ad00a7f..de2f51b1 100644
--- a/pyrogram/client/types/messages_and_media/message.py
+++ b/pyrogram/client/types/messages_and_media/message.py
@@ -79,7 +79,7 @@ class Message(PyrogramType, Update):
forward_from (:obj:`User `, *optional*):
For forwarded messages, sender of the original message.
- forward_from_name (``str``, *optional*):
+ forward_sender_name (``str``, *optional*):
For messages forwarded from users who have hidden their accounts, name of the user.
forward_from_chat (:obj:`Chat `, *optional*):
@@ -267,7 +267,7 @@ class Message(PyrogramType, Update):
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
__slots__ = [
- "message_id", "date", "chat", "from_user", "forward_from", "forward_from_name", "forward_from_chat",
+ "message_id", "date", "chat", "from_user", "forward_from", "forward_sender_name", "forward_from_chat",
"forward_from_message_id", "forward_signature", "forward_date", "reply_to_message", "mentioned", "empty",
"service", "media", "edit_date", "media_group_id", "author_signature", "text", "entities", "caption_entities",
"audio", "document", "photo", "sticker", "animation", "game", "video", "voice", "video_note", "caption",
@@ -286,7 +286,7 @@ class Message(PyrogramType, Update):
chat: Chat = None,
from_user: User = None,
forward_from: User = None,
- forward_from_name: str = None,
+ forward_sender_name: str = None,
forward_from_chat: Chat = None,
forward_from_message_id: int = None,
forward_signature: str = None,
@@ -348,7 +348,7 @@ class Message(PyrogramType, Update):
self.chat = chat
self.from_user = from_user
self.forward_from = forward_from
- self.forward_from_name = forward_from_name
+ self.forward_sender_name = forward_sender_name
self.forward_from_chat = forward_from_chat
self.forward_from_message_id = forward_from_message_id
self.forward_signature = forward_signature
@@ -487,7 +487,7 @@ class Message(PyrogramType, Update):
entities = list(filter(lambda x: x is not None, entities))
forward_from = None
- forward_from_name = None
+ forward_sender_name = None
forward_from_chat = None
forward_from_message_id = None
forward_signature = None
@@ -501,7 +501,7 @@ class Message(PyrogramType, Update):
if forward_header.from_id:
forward_from = User._parse(client, users[forward_header.from_id])
elif forward_header.from_name:
- forward_from_name = forward_header.from_name
+ forward_sender_name = forward_header.from_name
else:
forward_from_chat = Chat._parse_channel_chat(client, chats[forward_header.channel_id])
forward_from_message_id = forward_header.channel_post
@@ -607,7 +607,7 @@ class Message(PyrogramType, Update):
caption_entities=entities or None if media is not None else None,
author_signature=message.post_author,
forward_from=forward_from,
- forward_from_name=forward_from_name,
+ forward_sender_name=forward_sender_name,
forward_from_chat=forward_from_chat,
forward_from_message_id=forward_from_message_id,
forward_signature=forward_signature,
From 5c638e707e0fe70e3b449ffdbdafd5be3ba8b36a Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 20:48:25 +0200
Subject: [PATCH 005/202] Poll ids are now strings and not integers
---
pyrogram/client/types/messages_and_media/poll.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py
index dfe7daa9..e0461bba 100644
--- a/pyrogram/client/types/messages_and_media/poll.py
+++ b/pyrogram/client/types/messages_and_media/poll.py
@@ -28,7 +28,7 @@ class Poll(PyrogramType):
"""This object represents a Poll.
Args:
- id (``int``):
+ id (``str``):
Unique poll identifier.
question (``str``):
@@ -53,7 +53,7 @@ class Poll(PyrogramType):
self,
*,
client: "pyrogram.client.ext.BaseClient",
- id: int,
+ id: str,
question: str,
options: List[PollOption],
is_closed: bool,
@@ -98,7 +98,7 @@ class Poll(PyrogramType):
)
return Poll(
- id=poll.id,
+ id=str(poll.id),
question=poll.question,
options=options,
is_closed=poll.closed,
From 5905f761fa214a459aa66f63630c72b2cd408273 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 20:50:13 +0200
Subject: [PATCH 006/202] Add PollHandler type and on_poll decorator for
handling Poll updates
---
pyrogram/client/ext/dispatcher.py | 7 ++-
pyrogram/client/handlers/__init__.py | 3 +-
pyrogram/client/handlers/poll_handler.py | 48 +++++++++++++++
.../client/methods/decorators/__init__.py | 4 +-
pyrogram/client/methods/decorators/on_poll.py | 59 +++++++++++++++++++
.../client/types/messages_and_media/poll.py | 3 +-
6 files changed, 119 insertions(+), 5 deletions(-)
create mode 100644 pyrogram/client/handlers/poll_handler.py
create mode 100644 pyrogram/client/methods/decorators/on_poll.py
diff --git a/pyrogram/client/ext/dispatcher.py b/pyrogram/client/ext/dispatcher.py
index 7552b034..46be47f7 100644
--- a/pyrogram/client/ext/dispatcher.py
+++ b/pyrogram/client/ext/dispatcher.py
@@ -26,7 +26,7 @@ import pyrogram
from pyrogram.api import types
from ..handlers import (
CallbackQueryHandler, MessageHandler, DeletedMessagesHandler,
- UserStatusHandler, RawUpdateHandler, InlineQueryHandler
+ UserStatusHandler, RawUpdateHandler, InlineQueryHandler, PollHandler
)
log = logging.getLogger(__name__)
@@ -79,7 +79,10 @@ class Dispatcher:
),
(types.UpdateBotInlineQuery,):
- lambda upd, usr, cht: (pyrogram.InlineQuery._parse(self.client, upd, usr), InlineQueryHandler)
+ lambda upd, usr, cht: (pyrogram.InlineQuery._parse(self.client, upd, usr), InlineQueryHandler),
+
+ (types.UpdateMessagePoll,):
+ lambda upd, usr, cht: (pyrogram.Poll._parse(self.client, upd), PollHandler)
}
self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple}
diff --git a/pyrogram/client/handlers/__init__.py b/pyrogram/client/handlers/__init__.py
index 5e392949..c88c12fe 100644
--- a/pyrogram/client/handlers/__init__.py
+++ b/pyrogram/client/handlers/__init__.py
@@ -21,10 +21,11 @@ from .deleted_messages_handler import DeletedMessagesHandler
from .disconnect_handler import DisconnectHandler
from .inline_query_handler import InlineQueryHandler
from .message_handler import MessageHandler
+from .poll_handler import PollHandler
from .raw_update_handler import RawUpdateHandler
from .user_status_handler import UserStatusHandler
__all__ = [
"MessageHandler", "DeletedMessagesHandler", "CallbackQueryHandler", "RawUpdateHandler", "DisconnectHandler",
- "UserStatusHandler", "InlineQueryHandler"
+ "UserStatusHandler", "InlineQueryHandler", "PollHandler"
]
diff --git a/pyrogram/client/handlers/poll_handler.py b/pyrogram/client/handlers/poll_handler.py
new file mode 100644
index 00000000..567fcec0
--- /dev/null
+++ b/pyrogram/client/handlers/poll_handler.py
@@ -0,0 +1,48 @@
+# Pyrogram - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-2019 Dan Tès
+#
+# This file is part of Pyrogram.
+#
+# Pyrogram is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrogram is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrogram. If not, see .
+
+from .handler import Handler
+
+
+class PollHandler(Handler):
+ """The Poll handler class. Used to handle polls updates.
+
+ It is intended to be used with :meth:`add_handler() `
+
+ For a nicer way to register this handler, have a look at the
+ :meth:`on_poll() ` decorator.
+
+ Args:
+ callback (``callable``):
+ Pass a function that will be called when a new poll update arrives. It takes *(client, poll)*
+ as positional arguments (look at the section below for a detailed description).
+
+ filters (:obj:`Filters `):
+ Pass one or more filters to allow only a subset of polls to be passed
+ in your callback function.
+
+ Other parameters:
+ client (:obj:`Client `):
+ The Client itself, useful when you want to call other API methods inside the poll handler.
+
+ poll (:obj:`Poll `):
+ The received poll.
+ """
+
+ def __init__(self, callback: callable, filters=None):
+ super().__init__(callback, filters)
diff --git a/pyrogram/client/methods/decorators/__init__.py b/pyrogram/client/methods/decorators/__init__.py
index 33f55a3d..2a2861ae 100644
--- a/pyrogram/client/methods/decorators/__init__.py
+++ b/pyrogram/client/methods/decorators/__init__.py
@@ -21,6 +21,7 @@ from .on_deleted_messages import OnDeletedMessages
from .on_disconnect import OnDisconnect
from .on_inline_query import OnInlineQuery
from .on_message import OnMessage
+from .on_poll import OnPoll
from .on_raw_update import OnRawUpdate
from .on_user_status import OnUserStatus
@@ -32,6 +33,7 @@ class Decorators(
OnRawUpdate,
OnDisconnect,
OnUserStatus,
- OnInlineQuery
+ OnInlineQuery,
+ OnPoll
):
pass
diff --git a/pyrogram/client/methods/decorators/on_poll.py b/pyrogram/client/methods/decorators/on_poll.py
new file mode 100644
index 00000000..56dcd757
--- /dev/null
+++ b/pyrogram/client/methods/decorators/on_poll.py
@@ -0,0 +1,59 @@
+# Pyrogram - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-2019 Dan Tès
+#
+# This file is part of Pyrogram.
+#
+# Pyrogram is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrogram is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrogram. If not, see .
+
+from typing import Tuple
+
+import pyrogram
+from pyrogram.client.filters.filter import Filter
+from pyrogram.client.handlers.handler import Handler
+from ...ext import BaseClient
+
+
+class OnPoll(BaseClient):
+ def on_poll(
+ self=None,
+ filters=None,
+ group: int = 0
+ ) -> callable:
+ """Use this decorator to automatically register a function for handling poll updates.
+ This does the same thing as :meth:`add_handler` using the :class:`PollHandler`.
+
+ Args:
+ filters (:obj:`Filters `):
+ Pass one or more filters to allow only a subset of polls to be passed
+ in your function.
+
+ group (``int``, *optional*):
+ The group identifier, defaults to 0.
+ """
+
+ def decorator(func: callable) -> Tuple[Handler, int]:
+ if isinstance(func, tuple):
+ func = func[0].callback
+
+ handler = pyrogram.PollHandler(func, filters)
+
+ if isinstance(self, Filter):
+ return pyrogram.PollHandler(func, self), group if filters is None else filters
+
+ if self is not None:
+ self.add_handler(handler, group)
+
+ return handler, group
+
+ return decorator
diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py
index e0461bba..acaf8697 100644
--- a/pyrogram/client/types/messages_and_media/poll.py
+++ b/pyrogram/client/types/messages_and_media/poll.py
@@ -22,9 +22,10 @@ import pyrogram
from pyrogram.api import types
from .poll_option import PollOption
from ..pyrogram_type import PyrogramType
+from ..update import Update
-class Poll(PyrogramType):
+class Poll(PyrogramType, Update):
"""This object represents a Poll.
Args:
From d6d2923e34381a90e62a3779e82532fc7923ef21 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 20:52:00 +0200
Subject: [PATCH 007/202] Add missing Poll docstrings in Message
---
pyrogram/client/types/messages_and_media/message.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py
index de2f51b1..8dc05661 100644
--- a/pyrogram/client/types/messages_and_media/message.py
+++ b/pyrogram/client/types/messages_and_media/message.py
@@ -186,6 +186,9 @@ class Message(PyrogramType, Update):
web page preview. In future versions this property could turn into a full web page object that contains
more details.
+ poll (:obj:`Poll `, *optional*):
+ Message is a native poll, information about the poll.
+
new_chat_members (List of :obj:`User `, *optional*):
New members that were added to the group or supergroup and information about them
(the bot itself may be one of these members).
From bcef74c574d799aa07d75f39ece5d271b21c6477 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 21:00:19 +0200
Subject: [PATCH 008/202] Update .gitignore to ignore the generated RPC error
classes The "errors" package has been moved to make it simpler to import
---
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index bfc2fb83..0b1a0699 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,7 @@
config.ini
# Pyrogram generated code
-pyrogram/api/errors/exceptions/
+pyrogram/errors/exceptions/
pyrogram/api/functions/
pyrogram/api/types/
pyrogram/api/all.py
From b056aa8d7f1f484aaffffc966a52b48094f8cfbe Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 21:04:34 +0200
Subject: [PATCH 009/202] Add the field is_member to the ChatMember type This
can be used to find whether a restricted user is a member of the chat at the
moment of the request.
---
.../types/user_and_chats/chat_member.py | 20 +++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/pyrogram/client/types/user_and_chats/chat_member.py b/pyrogram/client/types/user_and_chats/chat_member.py
index 35911210..9ccf9314 100644
--- a/pyrogram/client/types/user_and_chats/chat_member.py
+++ b/pyrogram/client/types/user_and_chats/chat_member.py
@@ -36,6 +36,9 @@ class ChatMember(PyrogramType):
date (``int``, *optional*):
Date when the user joined, unix time. Not available for creator.
+ is_member (``bool``, *optional*):
+ Restricted only. True, if the user is a member of the chat at the moment of the request.
+
invited_by (:obj:`User `, *optional*):
Administrators and self member only. Information about the user who invited this member.
In case the user joined by himself this will be the same as "user".
@@ -51,7 +54,7 @@ class ChatMember(PyrogramType):
Information about the member permissions.
"""
- __slots__ = ["user", "status", "date", "invited_by", "promoted_by", "restricted_by", "permissions"]
+ __slots__ = ["user", "status", "date", "is_member", "invited_by", "promoted_by", "restricted_by", "permissions"]
def __init__(
self,
@@ -60,6 +63,7 @@ class ChatMember(PyrogramType):
user: "pyrogram.User",
status: str,
date: int = None,
+ is_member: bool = None,
invited_by: "pyrogram.User" = None,
promoted_by: "pyrogram.User" = None,
restricted_by: "pyrogram.User" = None,
@@ -70,6 +74,7 @@ class ChatMember(PyrogramType):
self.user = user
self.status = status
self.date = date
+ self.is_member = is_member
self.invited_by = invited_by
self.promoted_by = promoted_by
self.restricted_by = restricted_by
@@ -121,14 +126,17 @@ class ChatMember(PyrogramType):
)
if isinstance(member, types.ChannelParticipantBanned):
+ status = (
+ "kicked" if member.banned_rights.view_messages
+ else "left" if member.left
+ else "restricted"
+ )
+
return ChatMember(
user=user,
- status=(
- "kicked" if member.banned_rights.view_messages
- else "left" if member.left
- else "restricted"
- ),
+ status=status,
date=member.date,
+ is_member=not member.left if status == "restricted" else None,
restricted_by=pyrogram.User._parse(client, users[member.kicked_by]),
permissions=pyrogram.ChatPermissions._parse(member),
client=client
From 57be97566d9a182e10e39f4e55c99f7c1e2c67a3 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 14 Apr 2019 22:34:05 +0200
Subject: [PATCH 010/202] Make delete_messages return False when it fails to
delete This is because there will be no exception raised, because Telegram is
not sending any RPCError when you try to delete a message you don't have
rights on to.
---
pyrogram/client/methods/messages/delete_messages.py | 10 ++++++----
pyrogram/client/types/messages_and_media/message.py | 6 ++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/pyrogram/client/methods/messages/delete_messages.py b/pyrogram/client/methods/messages/delete_messages.py
index bbd838ee..4076be22 100644
--- a/pyrogram/client/methods/messages/delete_messages.py
+++ b/pyrogram/client/methods/messages/delete_messages.py
@@ -48,7 +48,7 @@ class DeleteMessages(BaseClient):
Defaults to True.
Returns:
- True on success.
+ True on success, False otherwise.
Raises:
:class:`RPCError ` in case of a Telegram RPC error.
@@ -57,18 +57,20 @@ class DeleteMessages(BaseClient):
message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids]
if isinstance(peer, types.InputPeerChannel):
- self.send(
+ r = self.send(
functions.channels.DeleteMessages(
channel=peer,
id=message_ids
)
)
else:
- self.send(
+ r = self.send(
functions.messages.DeleteMessages(
id=message_ids,
revoke=revoke or None
)
)
- return True
+ # Deleting messages you don't have right onto, won't raise any error.
+ # Check for pts_count, which is 0 in case deletes fail.
+ return bool(r.pts_count)
diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py
index fc2cb8fb..727b6330 100644
--- a/pyrogram/client/types/messages_and_media/message.py
+++ b/pyrogram/client/types/messages_and_media/message.py
@@ -2729,19 +2729,17 @@ class Message(PyrogramType, Update):
Defaults to True.
Returns:
- True on success.
+ True on success, False otherwise.
Raises:
:class:`RPCError `
"""
- self._client.delete_messages(
+ return self._client.delete_messages(
chat_id=self.chat.id,
message_ids=self.message_id,
revoke=revoke
)
- return True
-
def click(self, x: int or str, y: int = None, quote: bool = None):
"""Bound method *click* of :obj:`Message `.
From 63d76a7f13bd28e5cfda7b0db684b09c64886991 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sat, 20 Apr 2019 17:59:42 +0200
Subject: [PATCH 011/202] Bring back automatic mime type detection for new
uploads (fixes #239)
- Add mime.types file to contain a good database of type -> ext mappings
from svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
- Load mime.type at BaseClient creation and add two convenience methods
for guessing mime types from filenames and extensions from mime types,
guess_mime_type and guess_extension
- Make all send_* method as well as download_media use the new mime type
database via guess_mime_type and guess_extension methods
---
pyrogram/client/client.py | 34 +-
pyrogram/client/ext/base_client.py | 21 +
pyrogram/client/ext/mime.types | 1855 +++++++++++++++++
.../methods/messages/edit_message_media.py | 8 +-
.../client/methods/messages/send_animation.py | 2 +-
.../client/methods/messages/send_audio.py | 2 +-
.../client/methods/messages/send_document.py | 2 +-
.../methods/messages/send_media_group.py | 2 +-
.../client/methods/messages/send_sticker.py | 2 +-
.../client/methods/messages/send_video.py | 2 +-
.../methods/messages/send_video_note.py | 2 +-
.../client/methods/messages/send_voice.py | 2 +-
12 files changed, 1911 insertions(+), 23 deletions(-)
create mode 100644 pyrogram/client/ext/mime.types
diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py
index 44aef5df..ec47c448 100644
--- a/pyrogram/client/client.py
+++ b/pyrogram/client/client.py
@@ -861,18 +861,20 @@ class Client(Methods, BaseClient):
file_name = file_name or getattr(media, "file_name", None)
if not file_name:
- if media_type == 3:
- extension = ".ogg"
- elif media_type in (4, 10, 13):
- extension = mimetypes.guess_extension(media.mime_type) or ".mp4"
- elif media_type == 5:
- extension = mimetypes.guess_extension(media.mime_type) or ".unknown"
- elif media_type == 8:
- extension = ".webp"
- elif media_type == 9:
- extension = mimetypes.guess_extension(media.mime_type) or ".mp3"
- elif media_type in (0, 1, 2):
+ guessed_extension = self.guess_extension(media.mime_type)
+
+ if media_type in (0, 1, 2):
extension = ".jpg"
+ elif media_type == 3:
+ extension = guessed_extension or ".ogg"
+ elif media_type in (4, 10, 13):
+ extension = guessed_extension or ".mp4"
+ elif media_type == 5:
+ extension = guessed_extension or ".zip"
+ elif media_type == 8:
+ extension = guessed_extension or ".webp"
+ elif media_type == 9:
+ extension = guessed_extension or ".mp3"
else:
continue
@@ -1708,3 +1710,13 @@ class Client(Methods, BaseClient):
return ""
else:
return file_name
+
+ def guess_mime_type(self, filename: str):
+ extension = os.path.splitext(filename)[1]
+ return self.extensions_to_mime_types.get(extension)
+
+ def guess_extension(self, mime_type: str):
+ extensions = self.mime_types_to_extensions.get(mime_type)
+
+ if extensions:
+ return extensions.split(" ")[0]
diff --git a/pyrogram/client/ext/base_client.py b/pyrogram/client/ext/base_client.py
index fcd746ce..b4bfbd6b 100644
--- a/pyrogram/client/ext/base_client.py
+++ b/pyrogram/client/ext/base_client.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+import os
import platform
import re
from queue import Queue
@@ -67,6 +68,20 @@ class BaseClient:
13: "video_note"
}
+ mime_types_to_extensions = {}
+ extensions_to_mime_types = {}
+
+ with open("{}/mime.types".format(os.path.dirname(__file__)), "r", encoding="UTF-8") as f:
+ for match in re.finditer(r"^([^#\s]+)\s+(.+)$", f.read(), flags=re.M):
+ mime_type, extensions = match.groups()
+
+ extensions = [".{}".format(ext) for ext in extensions.split(" ")]
+
+ for ext in extensions:
+ extensions_to_mime_types[ext] = mime_type
+
+ mime_types_to_extensions[mime_type] = " ".join(extensions)
+
def __init__(self):
self.is_bot = None
self.dc_id = None
@@ -132,3 +147,9 @@ class BaseClient:
def answer_inline_query(self, *args, **kwargs):
pass
+
+ def guess_mime_type(self, *args, **kwargs):
+ pass
+
+ def guess_extension(self, *args, **kwargs):
+ pass
diff --git a/pyrogram/client/ext/mime.types b/pyrogram/client/ext/mime.types
new file mode 100644
index 00000000..4db43cae
--- /dev/null
+++ b/pyrogram/client/ext/mime.types
@@ -0,0 +1,1855 @@
+# This file maps Internet media types to unique file extension(s).
+# Although created for httpd, this file is used by many software systems
+# and has been placed in the public domain for unlimited redisribution.
+#
+# The table below contains both registered and (common) unregistered types.
+# A type that has no unique extension can be ignored -- they are listed
+# here to guide configurations toward known types and to make it easier to
+# identify "new" types. File extensions are also commonly used to indicate
+# content languages and encodings, so choose them carefully.
+#
+# Internet media types should be registered as described in RFC 4288.
+# The registry is at .
+#
+# MIME type (lowercased) Extensions
+# ============================================ ==========
+# application/1d-interleaved-parityfec
+# application/3gpdash-qoe-report+xml
+# application/3gpp-ims+xml
+# application/a2l
+# application/activemessage
+# application/alto-costmap+json
+# application/alto-costmapfilter+json
+# application/alto-directory+json
+# application/alto-endpointcost+json
+# application/alto-endpointcostparams+json
+# application/alto-endpointprop+json
+# application/alto-endpointpropparams+json
+# application/alto-error+json
+# application/alto-networkmap+json
+# application/alto-networkmapfilter+json
+# application/aml
+application/andrew-inset ez
+# application/applefile
+application/applixware aw
+# application/atf
+# application/atfx
+application/atom+xml atom
+application/atomcat+xml atomcat
+# application/atomdeleted+xml
+# application/atomicmail
+application/atomsvc+xml atomsvc
+# application/atxml
+# application/auth-policy+xml
+# application/bacnet-xdd+zip
+# application/batch-smtp
+# application/beep+xml
+# application/calendar+json
+# application/calendar+xml
+# application/call-completion
+# application/cals-1840
+# application/cbor
+# application/ccmp+xml
+application/ccxml+xml ccxml
+# application/cdfx+xml
+application/cdmi-capability cdmia
+application/cdmi-container cdmic
+application/cdmi-domain cdmid
+application/cdmi-object cdmio
+application/cdmi-queue cdmiq
+# application/cdni
+# application/cea
+# application/cea-2018+xml
+# application/cellml+xml
+# application/cfw
+# application/cms
+# application/cnrp+xml
+# application/coap-group+json
+# application/commonground
+# application/conference-info+xml
+# application/cpl+xml
+# application/csrattrs
+# application/csta+xml
+# application/cstadata+xml
+# application/csvm+json
+application/cu-seeme cu
+# application/cybercash
+# application/dash+xml
+# application/dashdelta
+application/davmount+xml davmount
+# application/dca-rft
+# application/dcd
+# application/dec-dx
+# application/dialog-info+xml
+# application/dicom
+# application/dii
+# application/dit
+# application/dns
+application/docbook+xml dbk
+# application/dskpp+xml
+application/dssc+der dssc
+application/dssc+xml xdssc
+# application/dvcs
+application/ecmascript ecma
+# application/edi-consent
+# application/edi-x12
+# application/edifact
+# application/efi
+# application/emergencycalldata.comment+xml
+# application/emergencycalldata.deviceinfo+xml
+# application/emergencycalldata.providerinfo+xml
+# application/emergencycalldata.serviceinfo+xml
+# application/emergencycalldata.subscriberinfo+xml
+application/emma+xml emma
+# application/emotionml+xml
+# application/encaprtp
+# application/epp+xml
+application/epub+zip epub
+# application/eshop
+# application/example
+application/exi exi
+# application/fastinfoset
+# application/fastsoap
+# application/fdt+xml
+# application/fits
+application/font-tdpfr pfr
+# application/framework-attributes+xml
+# application/geo+json
+application/gml+xml gml
+application/gpx+xml gpx
+application/gxf gxf
+# application/gzip
+# application/h224
+# application/held+xml
+# application/http
+application/hyperstudio stk
+# application/ibe-key-request+xml
+# application/ibe-pkg-reply+xml
+# application/ibe-pp-data
+# application/iges
+# application/im-iscomposing+xml
+# application/index
+# application/index.cmd
+# application/index.obj
+# application/index.response
+# application/index.vnd
+application/inkml+xml ink inkml
+# application/iotp
+application/ipfix ipfix
+# application/ipp
+# application/isup
+# application/its+xml
+application/java-archive jar
+application/java-serialized-object ser
+application/java-vm class
+application/javascript js
+# application/jose
+# application/jose+json
+# application/jrd+json
+application/json json
+# application/json-patch+json
+# application/json-seq
+application/jsonml+json jsonml
+# application/jwk+json
+# application/jwk-set+json
+# application/jwt
+# application/kpml-request+xml
+# application/kpml-response+xml
+# application/ld+json
+# application/lgr+xml
+# application/link-format
+# application/load-control+xml
+application/lost+xml lostxml
+# application/lostsync+xml
+# application/lxf
+application/mac-binhex40 hqx
+application/mac-compactpro cpt
+# application/macwriteii
+application/mads+xml mads
+application/marc mrc
+application/marcxml+xml mrcx
+application/mathematica ma nb mb
+application/mathml+xml mathml
+# application/mathml-content+xml
+# application/mathml-presentation+xml
+# application/mbms-associated-procedure-description+xml
+# application/mbms-deregister+xml
+# application/mbms-envelope+xml
+# application/mbms-msk+xml
+# application/mbms-msk-response+xml
+# application/mbms-protection-description+xml
+# application/mbms-reception-report+xml
+# application/mbms-register+xml
+# application/mbms-register-response+xml
+# application/mbms-schedule+xml
+# application/mbms-user-service-description+xml
+application/mbox mbox
+# application/media-policy-dataset+xml
+# application/media_control+xml
+application/mediaservercontrol+xml mscml
+# application/merge-patch+json
+application/metalink+xml metalink
+application/metalink4+xml meta4
+application/mets+xml mets
+# application/mf4
+# application/mikey
+application/mods+xml mods
+# application/moss-keys
+# application/moss-signature
+# application/mosskey-data
+# application/mosskey-request
+application/mp21 m21 mp21
+application/mp4 mp4s
+# application/mpeg4-generic
+# application/mpeg4-iod
+# application/mpeg4-iod-xmt
+# application/mrb-consumer+xml
+# application/mrb-publish+xml
+# application/msc-ivr+xml
+# application/msc-mixer+xml
+application/msword doc dot
+application/mxf mxf
+# application/nasdata
+# application/news-checkgroups
+# application/news-groupinfo
+# application/news-transmission
+# application/nlsml+xml
+# application/nss
+# application/ocsp-request
+# application/ocsp-response
+application/octet-stream bin dms lrf mar so dist distz pkg bpk dump elc deploy
+application/oda oda
+# application/odx
+application/oebps-package+xml opf
+application/ogg ogx
+application/omdoc+xml omdoc
+application/onenote onetoc onetoc2 onetmp onepkg
+application/oxps oxps
+# application/p2p-overlay+xml
+# application/parityfec
+application/patch-ops-error+xml xer
+application/pdf pdf
+# application/pdx
+application/pgp-encrypted pgp
+# application/pgp-keys
+application/pgp-signature asc sig
+application/pics-rules prf
+# application/pidf+xml
+# application/pidf-diff+xml
+application/pkcs10 p10
+# application/pkcs12
+application/pkcs7-mime p7m p7c
+application/pkcs7-signature p7s
+application/pkcs8 p8
+application/pkix-attr-cert ac
+application/pkix-cert cer
+application/pkix-crl crl
+application/pkix-pkipath pkipath
+application/pkixcmp pki
+application/pls+xml pls
+# application/poc-settings+xml
+application/postscript ai eps ps
+# application/ppsp-tracker+json
+# application/problem+json
+# application/problem+xml
+# application/provenance+xml
+# application/prs.alvestrand.titrax-sheet
+application/prs.cww cww
+# application/prs.hpub+zip
+# application/prs.nprend
+# application/prs.plucker
+# application/prs.rdf-xml-crypt
+# application/prs.xsf+xml
+application/pskc+xml pskcxml
+# application/qsig
+# application/raptorfec
+# application/rdap+json
+application/rdf+xml rdf
+application/reginfo+xml rif
+application/relax-ng-compact-syntax rnc
+# application/remote-printing
+# application/reputon+json
+application/resource-lists+xml rl
+application/resource-lists-diff+xml rld
+# application/rfc+xml
+# application/riscos
+# application/rlmi+xml
+application/rls-services+xml rs
+application/rpki-ghostbusters gbr
+application/rpki-manifest mft
+application/rpki-roa roa
+# application/rpki-updown
+application/rsd+xml rsd
+application/rss+xml rss
+application/rtf rtf
+# application/rtploopback
+# application/rtx
+# application/samlassertion+xml
+# application/samlmetadata+xml
+application/sbml+xml sbml
+# application/scaip+xml
+# application/scim+json
+application/scvp-cv-request scq
+application/scvp-cv-response scs
+application/scvp-vp-request spq
+application/scvp-vp-response spp
+application/sdp sdp
+# application/sep+xml
+# application/sep-exi
+# application/session-info
+# application/set-payment
+application/set-payment-initiation setpay
+# application/set-registration
+application/set-registration-initiation setreg
+# application/sgml
+# application/sgml-open-catalog
+application/shf+xml shf
+# application/sieve
+# application/simple-filter+xml
+# application/simple-message-summary
+# application/simplesymbolcontainer
+# application/slate
+# application/smil
+application/smil+xml smi smil
+# application/smpte336m
+# application/soap+fastinfoset
+# application/soap+xml
+application/sparql-query rq
+application/sparql-results+xml srx
+# application/spirits-event+xml
+# application/sql
+application/srgs gram
+application/srgs+xml grxml
+application/sru+xml sru
+application/ssdl+xml ssdl
+application/ssml+xml ssml
+# application/tamp-apex-update
+# application/tamp-apex-update-confirm
+# application/tamp-community-update
+# application/tamp-community-update-confirm
+# application/tamp-error
+# application/tamp-sequence-adjust
+# application/tamp-sequence-adjust-confirm
+# application/tamp-status-query
+# application/tamp-status-response
+# application/tamp-update
+# application/tamp-update-confirm
+application/tei+xml tei teicorpus
+application/thraud+xml tfi
+# application/timestamp-query
+# application/timestamp-reply
+application/timestamped-data tsd
+# application/ttml+xml
+# application/tve-trigger
+# application/ulpfec
+# application/urc-grpsheet+xml
+# application/urc-ressheet+xml
+# application/urc-targetdesc+xml
+# application/urc-uisocketdesc+xml
+# application/vcard+json
+# application/vcard+xml
+# application/vemmi
+# application/vividence.scriptfile
+# application/vnd.3gpp-prose+xml
+# application/vnd.3gpp-prose-pc3ch+xml
+# application/vnd.3gpp.access-transfer-events+xml
+# application/vnd.3gpp.bsf+xml
+# application/vnd.3gpp.mid-call+xml
+application/vnd.3gpp.pic-bw-large plb
+application/vnd.3gpp.pic-bw-small psb
+application/vnd.3gpp.pic-bw-var pvb
+# application/vnd.3gpp.sms
+# application/vnd.3gpp.sms+xml
+# application/vnd.3gpp.srvcc-ext+xml
+# application/vnd.3gpp.srvcc-info+xml
+# application/vnd.3gpp.state-and-event-info+xml
+# application/vnd.3gpp.ussd+xml
+# application/vnd.3gpp2.bcmcsinfo+xml
+# application/vnd.3gpp2.sms
+application/vnd.3gpp2.tcap tcap
+# application/vnd.3lightssoftware.imagescal
+application/vnd.3m.post-it-notes pwn
+application/vnd.accpac.simply.aso aso
+application/vnd.accpac.simply.imp imp
+application/vnd.acucobol acu
+application/vnd.acucorp atc acutc
+application/vnd.adobe.air-application-installer-package+zip air
+# application/vnd.adobe.flash.movie
+application/vnd.adobe.formscentral.fcdt fcdt
+application/vnd.adobe.fxp fxp fxpl
+# application/vnd.adobe.partial-upload
+application/vnd.adobe.xdp+xml xdp
+application/vnd.adobe.xfdf xfdf
+# application/vnd.aether.imp
+# application/vnd.ah-barcode
+application/vnd.ahead.space ahead
+application/vnd.airzip.filesecure.azf azf
+application/vnd.airzip.filesecure.azs azs
+application/vnd.amazon.ebook azw
+# application/vnd.amazon.mobi8-ebook
+application/vnd.americandynamics.acc acc
+application/vnd.amiga.ami ami
+# application/vnd.amundsen.maze+xml
+application/vnd.android.package-archive apk
+# application/vnd.anki
+application/vnd.anser-web-certificate-issue-initiation cii
+application/vnd.anser-web-funds-transfer-initiation fti
+application/vnd.antix.game-component atx
+# application/vnd.apache.thrift.binary
+# application/vnd.apache.thrift.compact
+# application/vnd.apache.thrift.json
+# application/vnd.api+json
+application/vnd.apple.installer+xml mpkg
+application/vnd.apple.mpegurl m3u8
+# application/vnd.arastra.swi
+application/vnd.aristanetworks.swi swi
+# application/vnd.artsquare
+application/vnd.astraea-software.iota iota
+application/vnd.audiograph aep
+# application/vnd.autopackage
+# application/vnd.avistar+xml
+# application/vnd.balsamiq.bmml+xml
+# application/vnd.balsamiq.bmpr
+# application/vnd.bekitzur-stech+json
+# application/vnd.biopax.rdf+xml
+application/vnd.blueice.multipass mpm
+# application/vnd.bluetooth.ep.oob
+# application/vnd.bluetooth.le.oob
+application/vnd.bmi bmi
+application/vnd.businessobjects rep
+# application/vnd.cab-jscript
+# application/vnd.canon-cpdl
+# application/vnd.canon-lips
+# application/vnd.cendio.thinlinc.clientconf
+# application/vnd.century-systems.tcp_stream
+application/vnd.chemdraw+xml cdxml
+# application/vnd.chess-pgn
+application/vnd.chipnuts.karaoke-mmd mmd
+application/vnd.cinderella cdy
+# application/vnd.cirpack.isdn-ext
+# application/vnd.citationstyles.style+xml
+application/vnd.claymore cla
+application/vnd.cloanto.rp9 rp9
+application/vnd.clonk.c4group c4g c4d c4f c4p c4u
+application/vnd.cluetrust.cartomobile-config c11amc
+application/vnd.cluetrust.cartomobile-config-pkg c11amz
+# application/vnd.coffeescript
+# application/vnd.collection+json
+# application/vnd.collection.doc+json
+# application/vnd.collection.next+json
+# application/vnd.comicbook+zip
+# application/vnd.commerce-battelle
+application/vnd.commonspace csp
+application/vnd.contact.cmsg cdbcmsg
+# application/vnd.coreos.ignition+json
+application/vnd.cosmocaller cmc
+application/vnd.crick.clicker clkx
+application/vnd.crick.clicker.keyboard clkk
+application/vnd.crick.clicker.palette clkp
+application/vnd.crick.clicker.template clkt
+application/vnd.crick.clicker.wordbank clkw
+application/vnd.criticaltools.wbs+xml wbs
+application/vnd.ctc-posml pml
+# application/vnd.ctct.ws+xml
+# application/vnd.cups-pdf
+# application/vnd.cups-postscript
+application/vnd.cups-ppd ppd
+# application/vnd.cups-raster
+# application/vnd.cups-raw
+# application/vnd.curl
+application/vnd.curl.car car
+application/vnd.curl.pcurl pcurl
+# application/vnd.cyan.dean.root+xml
+# application/vnd.cybank
+application/vnd.dart dart
+application/vnd.data-vision.rdz rdz
+# application/vnd.debian.binary-package
+application/vnd.dece.data uvf uvvf uvd uvvd
+application/vnd.dece.ttml+xml uvt uvvt
+application/vnd.dece.unspecified uvx uvvx
+application/vnd.dece.zip uvz uvvz
+application/vnd.denovo.fcselayout-link fe_launch
+# application/vnd.desmume.movie
+# application/vnd.dir-bi.plate-dl-nosuffix
+# application/vnd.dm.delegation+xml
+application/vnd.dna dna
+# application/vnd.document+json
+application/vnd.dolby.mlp mlp
+# application/vnd.dolby.mobile.1
+# application/vnd.dolby.mobile.2
+# application/vnd.doremir.scorecloud-binary-document
+application/vnd.dpgraph dpg
+application/vnd.dreamfactory dfac
+# application/vnd.drive+json
+application/vnd.ds-keypoint kpxx
+# application/vnd.dtg.local
+# application/vnd.dtg.local.flash
+# application/vnd.dtg.local.html
+application/vnd.dvb.ait ait
+# application/vnd.dvb.dvbj
+# application/vnd.dvb.esgcontainer
+# application/vnd.dvb.ipdcdftnotifaccess
+# application/vnd.dvb.ipdcesgaccess
+# application/vnd.dvb.ipdcesgaccess2
+# application/vnd.dvb.ipdcesgpdd
+# application/vnd.dvb.ipdcroaming
+# application/vnd.dvb.iptv.alfec-base
+# application/vnd.dvb.iptv.alfec-enhancement
+# application/vnd.dvb.notif-aggregate-root+xml
+# application/vnd.dvb.notif-container+xml
+# application/vnd.dvb.notif-generic+xml
+# application/vnd.dvb.notif-ia-msglist+xml
+# application/vnd.dvb.notif-ia-registration-request+xml
+# application/vnd.dvb.notif-ia-registration-response+xml
+# application/vnd.dvb.notif-init+xml
+# application/vnd.dvb.pfr
+application/vnd.dvb.service svc
+# application/vnd.dxr
+application/vnd.dynageo geo
+# application/vnd.dzr
+# application/vnd.easykaraoke.cdgdownload
+# application/vnd.ecdis-update
+application/vnd.ecowin.chart mag
+# application/vnd.ecowin.filerequest
+# application/vnd.ecowin.fileupdate
+# application/vnd.ecowin.series
+# application/vnd.ecowin.seriesrequest
+# application/vnd.ecowin.seriesupdate
+# application/vnd.emclient.accessrequest+xml
+application/vnd.enliven nml
+# application/vnd.enphase.envoy
+# application/vnd.eprints.data+xml
+application/vnd.epson.esf esf
+application/vnd.epson.msf msf
+application/vnd.epson.quickanime qam
+application/vnd.epson.salt slt
+application/vnd.epson.ssf ssf
+# application/vnd.ericsson.quickcall
+application/vnd.eszigno3+xml es3 et3
+# application/vnd.etsi.aoc+xml
+# application/vnd.etsi.asic-e+zip
+# application/vnd.etsi.asic-s+zip
+# application/vnd.etsi.cug+xml
+# application/vnd.etsi.iptvcommand+xml
+# application/vnd.etsi.iptvdiscovery+xml
+# application/vnd.etsi.iptvprofile+xml
+# application/vnd.etsi.iptvsad-bc+xml
+# application/vnd.etsi.iptvsad-cod+xml
+# application/vnd.etsi.iptvsad-npvr+xml
+# application/vnd.etsi.iptvservice+xml
+# application/vnd.etsi.iptvsync+xml
+# application/vnd.etsi.iptvueprofile+xml
+# application/vnd.etsi.mcid+xml
+# application/vnd.etsi.mheg5
+# application/vnd.etsi.overload-control-policy-dataset+xml
+# application/vnd.etsi.pstn+xml
+# application/vnd.etsi.sci+xml
+# application/vnd.etsi.simservs+xml
+# application/vnd.etsi.timestamp-token
+# application/vnd.etsi.tsl+xml
+# application/vnd.etsi.tsl.der
+# application/vnd.eudora.data
+application/vnd.ezpix-album ez2
+application/vnd.ezpix-package ez3
+# application/vnd.f-secure.mobile
+# application/vnd.fastcopy-disk-image
+application/vnd.fdf fdf
+application/vnd.fdsn.mseed mseed
+application/vnd.fdsn.seed seed dataless
+# application/vnd.ffsns
+# application/vnd.filmit.zfc
+# application/vnd.fints
+# application/vnd.firemonkeys.cloudcell
+application/vnd.flographit gph
+application/vnd.fluxtime.clip ftc
+# application/vnd.font-fontforge-sfd
+application/vnd.framemaker fm frame maker book
+application/vnd.frogans.fnc fnc
+application/vnd.frogans.ltf ltf
+application/vnd.fsc.weblaunch fsc
+application/vnd.fujitsu.oasys oas
+application/vnd.fujitsu.oasys2 oa2
+application/vnd.fujitsu.oasys3 oa3
+application/vnd.fujitsu.oasysgp fg5
+application/vnd.fujitsu.oasysprs bh2
+# application/vnd.fujixerox.art-ex
+# application/vnd.fujixerox.art4
+application/vnd.fujixerox.ddd ddd
+application/vnd.fujixerox.docuworks xdw
+application/vnd.fujixerox.docuworks.binder xbd
+# application/vnd.fujixerox.docuworks.container
+# application/vnd.fujixerox.hbpl
+# application/vnd.fut-misnet
+application/vnd.fuzzysheet fzs
+application/vnd.genomatix.tuxedo txd
+# application/vnd.geo+json
+# application/vnd.geocube+xml
+application/vnd.geogebra.file ggb
+application/vnd.geogebra.tool ggt
+application/vnd.geometry-explorer gex gre
+application/vnd.geonext gxt
+application/vnd.geoplan g2w
+application/vnd.geospace g3w
+# application/vnd.gerber
+# application/vnd.globalplatform.card-content-mgt
+# application/vnd.globalplatform.card-content-mgt-response
+application/vnd.gmx gmx
+application/vnd.google-earth.kml+xml kml
+application/vnd.google-earth.kmz kmz
+# application/vnd.gov.sk.e-form+xml
+# application/vnd.gov.sk.e-form+zip
+# application/vnd.gov.sk.xmldatacontainer+xml
+application/vnd.grafeq gqf gqs
+# application/vnd.gridmp
+application/vnd.groove-account gac
+application/vnd.groove-help ghf
+application/vnd.groove-identity-message gim
+application/vnd.groove-injector grv
+application/vnd.groove-tool-message gtm
+application/vnd.groove-tool-template tpl
+application/vnd.groove-vcard vcg
+# application/vnd.hal+json
+application/vnd.hal+xml hal
+application/vnd.handheld-entertainment+xml zmm
+application/vnd.hbci hbci
+# application/vnd.hcl-bireports
+# application/vnd.hdt
+# application/vnd.heroku+json
+application/vnd.hhe.lesson-player les
+application/vnd.hp-hpgl hpgl
+application/vnd.hp-hpid hpid
+application/vnd.hp-hps hps
+application/vnd.hp-jlyt jlt
+application/vnd.hp-pcl pcl
+application/vnd.hp-pclxl pclxl
+# application/vnd.httphone
+application/vnd.hydrostatix.sof-data sfd-hdstx
+# application/vnd.hyperdrive+json
+# application/vnd.hzn-3d-crossword
+# application/vnd.ibm.afplinedata
+# application/vnd.ibm.electronic-media
+application/vnd.ibm.minipay mpy
+application/vnd.ibm.modcap afp listafp list3820
+application/vnd.ibm.rights-management irm
+application/vnd.ibm.secure-container sc
+application/vnd.iccprofile icc icm
+# application/vnd.ieee.1905
+application/vnd.igloader igl
+application/vnd.immervision-ivp ivp
+application/vnd.immervision-ivu ivu
+# application/vnd.ims.imsccv1p1
+# application/vnd.ims.imsccv1p2
+# application/vnd.ims.imsccv1p3
+# application/vnd.ims.lis.v2.result+json
+# application/vnd.ims.lti.v2.toolconsumerprofile+json
+# application/vnd.ims.lti.v2.toolproxy+json
+# application/vnd.ims.lti.v2.toolproxy.id+json
+# application/vnd.ims.lti.v2.toolsettings+json
+# application/vnd.ims.lti.v2.toolsettings.simple+json
+# application/vnd.informedcontrol.rms+xml
+# application/vnd.informix-visionary
+# application/vnd.infotech.project
+# application/vnd.infotech.project+xml
+# application/vnd.innopath.wamp.notification
+application/vnd.insors.igm igm
+application/vnd.intercon.formnet xpw xpx
+application/vnd.intergeo i2g
+# application/vnd.intertrust.digibox
+# application/vnd.intertrust.nncp
+application/vnd.intu.qbo qbo
+application/vnd.intu.qfx qfx
+# application/vnd.iptc.g2.catalogitem+xml
+# application/vnd.iptc.g2.conceptitem+xml
+# application/vnd.iptc.g2.knowledgeitem+xml
+# application/vnd.iptc.g2.newsitem+xml
+# application/vnd.iptc.g2.newsmessage+xml
+# application/vnd.iptc.g2.packageitem+xml
+# application/vnd.iptc.g2.planningitem+xml
+application/vnd.ipunplugged.rcprofile rcprofile
+application/vnd.irepository.package+xml irp
+application/vnd.is-xpr xpr
+application/vnd.isac.fcs fcs
+application/vnd.jam jam
+# application/vnd.japannet-directory-service
+# application/vnd.japannet-jpnstore-wakeup
+# application/vnd.japannet-payment-wakeup
+# application/vnd.japannet-registration
+# application/vnd.japannet-registration-wakeup
+# application/vnd.japannet-setstore-wakeup
+# application/vnd.japannet-verification
+# application/vnd.japannet-verification-wakeup
+application/vnd.jcp.javame.midlet-rms rms
+application/vnd.jisp jisp
+application/vnd.joost.joda-archive joda
+# application/vnd.jsk.isdn-ngn
+application/vnd.kahootz ktz ktr
+application/vnd.kde.karbon karbon
+application/vnd.kde.kchart chrt
+application/vnd.kde.kformula kfo
+application/vnd.kde.kivio flw
+application/vnd.kde.kontour kon
+application/vnd.kde.kpresenter kpr kpt
+application/vnd.kde.kspread ksp
+application/vnd.kde.kword kwd kwt
+application/vnd.kenameaapp htke
+application/vnd.kidspiration kia
+application/vnd.kinar kne knp
+application/vnd.koan skp skd skt skm
+application/vnd.kodak-descriptor sse
+application/vnd.las.las+xml lasxml
+# application/vnd.liberty-request+xml
+application/vnd.llamagraphics.life-balance.desktop lbd
+application/vnd.llamagraphics.life-balance.exchange+xml lbe
+application/vnd.lotus-1-2-3 123
+application/vnd.lotus-approach apr
+application/vnd.lotus-freelance pre
+application/vnd.lotus-notes nsf
+application/vnd.lotus-organizer org
+application/vnd.lotus-screencam scm
+application/vnd.lotus-wordpro lwp
+application/vnd.macports.portpkg portpkg
+# application/vnd.mapbox-vector-tile
+# application/vnd.marlin.drm.actiontoken+xml
+# application/vnd.marlin.drm.conftoken+xml
+# application/vnd.marlin.drm.license+xml
+# application/vnd.marlin.drm.mdcf
+# application/vnd.mason+json
+# application/vnd.maxmind.maxmind-db
+application/vnd.mcd mcd
+application/vnd.medcalcdata mc1
+application/vnd.mediastation.cdkey cdkey
+# application/vnd.meridian-slingshot
+application/vnd.mfer mwf
+application/vnd.mfmp mfm
+# application/vnd.micro+json
+application/vnd.micrografx.flo flo
+application/vnd.micrografx.igx igx
+# application/vnd.microsoft.portable-executable
+# application/vnd.miele+json
+application/vnd.mif mif
+# application/vnd.minisoft-hp3000-save
+# application/vnd.mitsubishi.misty-guard.trustweb
+application/vnd.mobius.daf daf
+application/vnd.mobius.dis dis
+application/vnd.mobius.mbk mbk
+application/vnd.mobius.mqy mqy
+application/vnd.mobius.msl msl
+application/vnd.mobius.plc plc
+application/vnd.mobius.txf txf
+application/vnd.mophun.application mpn
+application/vnd.mophun.certificate mpc
+# application/vnd.motorola.flexsuite
+# application/vnd.motorola.flexsuite.adsi
+# application/vnd.motorola.flexsuite.fis
+# application/vnd.motorola.flexsuite.gotap
+# application/vnd.motorola.flexsuite.kmr
+# application/vnd.motorola.flexsuite.ttc
+# application/vnd.motorola.flexsuite.wem
+# application/vnd.motorola.iprm
+application/vnd.mozilla.xul+xml xul
+# application/vnd.ms-3mfdocument
+application/vnd.ms-artgalry cil
+# application/vnd.ms-asf
+application/vnd.ms-cab-compressed cab
+# application/vnd.ms-color.iccprofile
+application/vnd.ms-excel xls xlm xla xlc xlt xlw
+application/vnd.ms-excel.addin.macroenabled.12 xlam
+application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb
+application/vnd.ms-excel.sheet.macroenabled.12 xlsm
+application/vnd.ms-excel.template.macroenabled.12 xltm
+application/vnd.ms-fontobject eot
+application/vnd.ms-htmlhelp chm
+application/vnd.ms-ims ims
+application/vnd.ms-lrm lrm
+# application/vnd.ms-office.activex+xml
+application/vnd.ms-officetheme thmx
+# application/vnd.ms-opentype
+# application/vnd.ms-package.obfuscated-opentype
+application/vnd.ms-pki.seccat cat
+application/vnd.ms-pki.stl stl
+# application/vnd.ms-playready.initiator+xml
+application/vnd.ms-powerpoint ppt pps pot
+application/vnd.ms-powerpoint.addin.macroenabled.12 ppam
+application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm
+application/vnd.ms-powerpoint.slide.macroenabled.12 sldm
+application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm
+application/vnd.ms-powerpoint.template.macroenabled.12 potm
+# application/vnd.ms-printdevicecapabilities+xml
+# application/vnd.ms-printing.printticket+xml
+# application/vnd.ms-printschematicket+xml
+application/vnd.ms-project mpp mpt
+# application/vnd.ms-tnef
+# application/vnd.ms-windows.devicepairing
+# application/vnd.ms-windows.nwprinting.oob
+# application/vnd.ms-windows.printerpairing
+# application/vnd.ms-windows.wsd.oob
+# application/vnd.ms-wmdrm.lic-chlg-req
+# application/vnd.ms-wmdrm.lic-resp
+# application/vnd.ms-wmdrm.meter-chlg-req
+# application/vnd.ms-wmdrm.meter-resp
+application/vnd.ms-word.document.macroenabled.12 docm
+application/vnd.ms-word.template.macroenabled.12 dotm
+application/vnd.ms-works wps wks wcm wdb
+application/vnd.ms-wpl wpl
+application/vnd.ms-xpsdocument xps
+# application/vnd.msa-disk-image
+application/vnd.mseq mseq
+# application/vnd.msign
+# application/vnd.multiad.creator
+# application/vnd.multiad.creator.cif
+# application/vnd.music-niff
+application/vnd.musician mus
+application/vnd.muvee.style msty
+application/vnd.mynfc taglet
+# application/vnd.ncd.control
+# application/vnd.ncd.reference
+# application/vnd.nervana
+# application/vnd.netfpx
+application/vnd.neurolanguage.nlu nlu
+# application/vnd.nintendo.nitro.rom
+# application/vnd.nintendo.snes.rom
+application/vnd.nitf ntf nitf
+application/vnd.noblenet-directory nnd
+application/vnd.noblenet-sealer nns
+application/vnd.noblenet-web nnw
+# application/vnd.nokia.catalogs
+# application/vnd.nokia.conml+wbxml
+# application/vnd.nokia.conml+xml
+# application/vnd.nokia.iptv.config+xml
+# application/vnd.nokia.isds-radio-presets
+# application/vnd.nokia.landmark+wbxml
+# application/vnd.nokia.landmark+xml
+# application/vnd.nokia.landmarkcollection+xml
+# application/vnd.nokia.n-gage.ac+xml
+application/vnd.nokia.n-gage.data ngdat
+application/vnd.nokia.n-gage.symbian.install n-gage
+# application/vnd.nokia.ncd
+# application/vnd.nokia.pcd+wbxml
+# application/vnd.nokia.pcd+xml
+application/vnd.nokia.radio-preset rpst
+application/vnd.nokia.radio-presets rpss
+application/vnd.novadigm.edm edm
+application/vnd.novadigm.edx edx
+application/vnd.novadigm.ext ext
+# application/vnd.ntt-local.content-share
+# application/vnd.ntt-local.file-transfer
+# application/vnd.ntt-local.ogw_remote-access
+# application/vnd.ntt-local.sip-ta_remote
+# application/vnd.ntt-local.sip-ta_tcp_stream
+application/vnd.oasis.opendocument.chart odc
+application/vnd.oasis.opendocument.chart-template otc
+application/vnd.oasis.opendocument.database odb
+application/vnd.oasis.opendocument.formula odf
+application/vnd.oasis.opendocument.formula-template odft
+application/vnd.oasis.opendocument.graphics odg
+application/vnd.oasis.opendocument.graphics-template otg
+application/vnd.oasis.opendocument.image odi
+application/vnd.oasis.opendocument.image-template oti
+application/vnd.oasis.opendocument.presentation odp
+application/vnd.oasis.opendocument.presentation-template otp
+application/vnd.oasis.opendocument.spreadsheet ods
+application/vnd.oasis.opendocument.spreadsheet-template ots
+application/vnd.oasis.opendocument.text odt
+application/vnd.oasis.opendocument.text-master odm
+application/vnd.oasis.opendocument.text-template ott
+application/vnd.oasis.opendocument.text-web oth
+# application/vnd.obn
+# application/vnd.oftn.l10n+json
+# application/vnd.oipf.contentaccessdownload+xml
+# application/vnd.oipf.contentaccessstreaming+xml
+# application/vnd.oipf.cspg-hexbinary
+# application/vnd.oipf.dae.svg+xml
+# application/vnd.oipf.dae.xhtml+xml
+# application/vnd.oipf.mippvcontrolmessage+xml
+# application/vnd.oipf.pae.gem
+# application/vnd.oipf.spdiscovery+xml
+# application/vnd.oipf.spdlist+xml
+# application/vnd.oipf.ueprofile+xml
+# application/vnd.oipf.userprofile+xml
+application/vnd.olpc-sugar xo
+# application/vnd.oma-scws-config
+# application/vnd.oma-scws-http-request
+# application/vnd.oma-scws-http-response
+# application/vnd.oma.bcast.associated-procedure-parameter+xml
+# application/vnd.oma.bcast.drm-trigger+xml
+# application/vnd.oma.bcast.imd+xml
+# application/vnd.oma.bcast.ltkm
+# application/vnd.oma.bcast.notification+xml
+# application/vnd.oma.bcast.provisioningtrigger
+# application/vnd.oma.bcast.sgboot
+# application/vnd.oma.bcast.sgdd+xml
+# application/vnd.oma.bcast.sgdu
+# application/vnd.oma.bcast.simple-symbol-container
+# application/vnd.oma.bcast.smartcard-trigger+xml
+# application/vnd.oma.bcast.sprov+xml
+# application/vnd.oma.bcast.stkm
+# application/vnd.oma.cab-address-book+xml
+# application/vnd.oma.cab-feature-handler+xml
+# application/vnd.oma.cab-pcc+xml
+# application/vnd.oma.cab-subs-invite+xml
+# application/vnd.oma.cab-user-prefs+xml
+# application/vnd.oma.dcd
+# application/vnd.oma.dcdc
+application/vnd.oma.dd2+xml dd2
+# application/vnd.oma.drm.risd+xml
+# application/vnd.oma.group-usage-list+xml
+# application/vnd.oma.lwm2m+json
+# application/vnd.oma.lwm2m+tlv
+# application/vnd.oma.pal+xml
+# application/vnd.oma.poc.detailed-progress-report+xml
+# application/vnd.oma.poc.final-report+xml
+# application/vnd.oma.poc.groups+xml
+# application/vnd.oma.poc.invocation-descriptor+xml
+# application/vnd.oma.poc.optimized-progress-report+xml
+# application/vnd.oma.push
+# application/vnd.oma.scidm.messages+xml
+# application/vnd.oma.xcap-directory+xml
+# application/vnd.omads-email+xml
+# application/vnd.omads-file+xml
+# application/vnd.omads-folder+xml
+# application/vnd.omaloc-supl-init
+# application/vnd.onepager
+# application/vnd.openblox.game+xml
+# application/vnd.openblox.game-binary
+# application/vnd.openeye.oeb
+application/vnd.openofficeorg.extension oxt
+# application/vnd.openxmlformats-officedocument.custom-properties+xml
+# application/vnd.openxmlformats-officedocument.customxmlproperties+xml
+# application/vnd.openxmlformats-officedocument.drawing+xml
+# application/vnd.openxmlformats-officedocument.drawingml.chart+xml
+# application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml
+# application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml
+# application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml
+# application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml
+# application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml
+# application/vnd.openxmlformats-officedocument.extended-properties+xml
+# application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml
+# application/vnd.openxmlformats-officedocument.presentationml.comments+xml
+# application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml
+# application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml
+# application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml
+application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
+# application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml
+# application/vnd.openxmlformats-officedocument.presentationml.presprops+xml
+application/vnd.openxmlformats-officedocument.presentationml.slide sldx
+# application/vnd.openxmlformats-officedocument.presentationml.slide+xml
+# application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml
+# application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml
+application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
+# application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml
+# application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml
+# application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml
+# application/vnd.openxmlformats-officedocument.presentationml.tags+xml
+application/vnd.openxmlformats-officedocument.presentationml.template potx
+# application/vnd.openxmlformats-officedocument.presentationml.template.main+xml
+# application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
+# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
+# application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml
+# application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml
+# application/vnd.openxmlformats-officedocument.theme+xml
+# application/vnd.openxmlformats-officedocument.themeoverride+xml
+# application/vnd.openxmlformats-officedocument.vmldrawing
+# application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
+# application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
+# application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml
+# application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml
+# application/vnd.openxmlformats-package.core-properties+xml
+# application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml
+# application/vnd.openxmlformats-package.relationships+xml
+# application/vnd.oracle.resource+json
+# application/vnd.orange.indata
+# application/vnd.osa.netdeploy
+application/vnd.osgeo.mapguide.package mgp
+# application/vnd.osgi.bundle
+application/vnd.osgi.dp dp
+application/vnd.osgi.subsystem esa
+# application/vnd.otps.ct-kip+xml
+# application/vnd.oxli.countgraph
+# application/vnd.pagerduty+json
+application/vnd.palm pdb pqa oprc
+# application/vnd.panoply
+# application/vnd.paos.xml
+application/vnd.pawaafile paw
+# application/vnd.pcos
+application/vnd.pg.format str
+application/vnd.pg.osasli ei6
+# application/vnd.piaccess.application-licence
+application/vnd.picsel efif
+application/vnd.pmi.widget wg
+# application/vnd.poc.group-advertisement+xml
+application/vnd.pocketlearn plf
+application/vnd.powerbuilder6 pbd
+# application/vnd.powerbuilder6-s
+# application/vnd.powerbuilder7
+# application/vnd.powerbuilder7-s
+# application/vnd.powerbuilder75
+# application/vnd.powerbuilder75-s
+# application/vnd.preminet
+application/vnd.previewsystems.box box
+application/vnd.proteus.magazine mgz
+application/vnd.publishare-delta-tree qps
+application/vnd.pvi.ptid1 ptid
+# application/vnd.pwg-multiplexed
+# application/vnd.pwg-xhtml-print+xml
+# application/vnd.qualcomm.brew-app-res
+# application/vnd.quarantainenet
+application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb
+# application/vnd.quobject-quoxdocument
+# application/vnd.radisys.moml+xml
+# application/vnd.radisys.msml+xml
+# application/vnd.radisys.msml-audit+xml
+# application/vnd.radisys.msml-audit-conf+xml
+# application/vnd.radisys.msml-audit-conn+xml
+# application/vnd.radisys.msml-audit-dialog+xml
+# application/vnd.radisys.msml-audit-stream+xml
+# application/vnd.radisys.msml-conf+xml
+# application/vnd.radisys.msml-dialog+xml
+# application/vnd.radisys.msml-dialog-base+xml
+# application/vnd.radisys.msml-dialog-fax-detect+xml
+# application/vnd.radisys.msml-dialog-fax-sendrecv+xml
+# application/vnd.radisys.msml-dialog-group+xml
+# application/vnd.radisys.msml-dialog-speech+xml
+# application/vnd.radisys.msml-dialog-transform+xml
+# application/vnd.rainstor.data
+# application/vnd.rapid
+# application/vnd.rar
+application/vnd.realvnc.bed bed
+application/vnd.recordare.musicxml mxl
+application/vnd.recordare.musicxml+xml musicxml
+# application/vnd.renlearn.rlprint
+application/vnd.rig.cryptonote cryptonote
+application/vnd.rim.cod cod
+application/vnd.rn-realmedia rm
+application/vnd.rn-realmedia-vbr rmvb
+application/vnd.route66.link66+xml link66
+# application/vnd.rs-274x
+# application/vnd.ruckus.download
+# application/vnd.s3sms
+application/vnd.sailingtracker.track st
+# application/vnd.sbm.cid
+# application/vnd.sbm.mid2
+# application/vnd.scribus
+# application/vnd.sealed.3df
+# application/vnd.sealed.csf
+# application/vnd.sealed.doc
+# application/vnd.sealed.eml
+# application/vnd.sealed.mht
+# application/vnd.sealed.net
+# application/vnd.sealed.ppt
+# application/vnd.sealed.tiff
+# application/vnd.sealed.xls
+# application/vnd.sealedmedia.softseal.html
+# application/vnd.sealedmedia.softseal.pdf
+application/vnd.seemail see
+application/vnd.sema sema
+application/vnd.semd semd
+application/vnd.semf semf
+application/vnd.shana.informed.formdata ifm
+application/vnd.shana.informed.formtemplate itp
+application/vnd.shana.informed.interchange iif
+application/vnd.shana.informed.package ipk
+application/vnd.simtech-mindmapper twd twds
+# application/vnd.siren+json
+application/vnd.smaf mmf
+# application/vnd.smart.notebook
+application/vnd.smart.teacher teacher
+# application/vnd.software602.filler.form+xml
+# application/vnd.software602.filler.form-xml-zip
+application/vnd.solent.sdkm+xml sdkm sdkd
+application/vnd.spotfire.dxp dxp
+application/vnd.spotfire.sfs sfs
+# application/vnd.sss-cod
+# application/vnd.sss-dtf
+# application/vnd.sss-ntf
+application/vnd.stardivision.calc sdc
+application/vnd.stardivision.draw sda
+application/vnd.stardivision.impress sdd
+application/vnd.stardivision.math smf
+application/vnd.stardivision.writer sdw vor
+application/vnd.stardivision.writer-global sgl
+application/vnd.stepmania.package smzip
+application/vnd.stepmania.stepchart sm
+# application/vnd.street-stream
+# application/vnd.sun.wadl+xml
+application/vnd.sun.xml.calc sxc
+application/vnd.sun.xml.calc.template stc
+application/vnd.sun.xml.draw sxd
+application/vnd.sun.xml.draw.template std
+application/vnd.sun.xml.impress sxi
+application/vnd.sun.xml.impress.template sti
+application/vnd.sun.xml.math sxm
+application/vnd.sun.xml.writer sxw
+application/vnd.sun.xml.writer.global sxg
+application/vnd.sun.xml.writer.template stw
+application/vnd.sus-calendar sus susp
+application/vnd.svd svd
+# application/vnd.swiftview-ics
+application/vnd.symbian.install sis sisx
+application/vnd.syncml+xml xsm
+application/vnd.syncml.dm+wbxml bdm
+application/vnd.syncml.dm+xml xdm
+# application/vnd.syncml.dm.notification
+# application/vnd.syncml.dmddf+wbxml
+# application/vnd.syncml.dmddf+xml
+# application/vnd.syncml.dmtnds+wbxml
+# application/vnd.syncml.dmtnds+xml
+# application/vnd.syncml.ds.notification
+application/vnd.tao.intent-module-archive tao
+application/vnd.tcpdump.pcap pcap cap dmp
+# application/vnd.tmd.mediaflex.api+xml
+# application/vnd.tml
+application/vnd.tmobile-livetv tmo
+application/vnd.trid.tpt tpt
+application/vnd.triscape.mxs mxs
+application/vnd.trueapp tra
+# application/vnd.truedoc
+# application/vnd.ubisoft.webplayer
+application/vnd.ufdl ufd ufdl
+application/vnd.uiq.theme utz
+application/vnd.umajin umj
+application/vnd.unity unityweb
+application/vnd.uoml+xml uoml
+# application/vnd.uplanet.alert
+# application/vnd.uplanet.alert-wbxml
+# application/vnd.uplanet.bearer-choice
+# application/vnd.uplanet.bearer-choice-wbxml
+# application/vnd.uplanet.cacheop
+# application/vnd.uplanet.cacheop-wbxml
+# application/vnd.uplanet.channel
+# application/vnd.uplanet.channel-wbxml
+# application/vnd.uplanet.list
+# application/vnd.uplanet.list-wbxml
+# application/vnd.uplanet.listcmd
+# application/vnd.uplanet.listcmd-wbxml
+# application/vnd.uplanet.signal
+# application/vnd.uri-map
+# application/vnd.valve.source.material
+application/vnd.vcx vcx
+# application/vnd.vd-study
+# application/vnd.vectorworks
+# application/vnd.vel+json
+# application/vnd.verimatrix.vcas
+# application/vnd.vidsoft.vidconference
+application/vnd.visio vsd vst vss vsw
+application/vnd.visionary vis
+# application/vnd.vividence.scriptfile
+application/vnd.vsf vsf
+# application/vnd.wap.sic
+# application/vnd.wap.slc
+application/vnd.wap.wbxml wbxml
+application/vnd.wap.wmlc wmlc
+application/vnd.wap.wmlscriptc wmlsc
+application/vnd.webturbo wtb
+# application/vnd.wfa.p2p
+# application/vnd.wfa.wsc
+# application/vnd.windows.devicepairing
+# application/vnd.wmc
+# application/vnd.wmf.bootstrap
+# application/vnd.wolfram.mathematica
+# application/vnd.wolfram.mathematica.package
+application/vnd.wolfram.player nbp
+application/vnd.wordperfect wpd
+application/vnd.wqd wqd
+# application/vnd.wrq-hp3000-labelled
+application/vnd.wt.stf stf
+# application/vnd.wv.csp+wbxml
+# application/vnd.wv.csp+xml
+# application/vnd.wv.ssp+xml
+# application/vnd.xacml+json
+application/vnd.xara xar
+application/vnd.xfdl xfdl
+# application/vnd.xfdl.webform
+# application/vnd.xmi+xml
+# application/vnd.xmpie.cpkg
+# application/vnd.xmpie.dpkg
+# application/vnd.xmpie.plan
+# application/vnd.xmpie.ppkg
+# application/vnd.xmpie.xlim
+application/vnd.yamaha.hv-dic hvd
+application/vnd.yamaha.hv-script hvs
+application/vnd.yamaha.hv-voice hvp
+application/vnd.yamaha.openscoreformat osf
+application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg
+# application/vnd.yamaha.remote-setup
+application/vnd.yamaha.smaf-audio saf
+application/vnd.yamaha.smaf-phrase spf
+# application/vnd.yamaha.through-ngn
+# application/vnd.yamaha.tunnel-udpencap
+# application/vnd.yaoweme
+application/vnd.yellowriver-custom-menu cmp
+application/vnd.zul zir zirz
+application/vnd.zzazz.deck+xml zaz
+application/voicexml+xml vxml
+# application/vq-rtcpxr
+# application/watcherinfo+xml
+# application/whoispp-query
+# application/whoispp-response
+application/widget wgt
+application/winhlp hlp
+# application/wita
+# application/wordperfect5.1
+application/wsdl+xml wsdl
+application/wspolicy+xml wspolicy
+application/x-7z-compressed 7z
+application/x-abiword abw
+application/x-ace-compressed ace
+# application/x-amf
+application/x-apple-diskimage dmg
+application/x-authorware-bin aab x32 u32 vox
+application/x-authorware-map aam
+application/x-authorware-seg aas
+application/x-bcpio bcpio
+application/x-bittorrent torrent
+application/x-blorb blb blorb
+application/x-bzip bz
+application/x-bzip2 bz2 boz
+application/x-cbr cbr cba cbt cbz cb7
+application/x-cdlink vcd
+application/x-cfs-compressed cfs
+application/x-chat chat
+application/x-chess-pgn pgn
+# application/x-compress
+application/x-conference nsc
+application/x-cpio cpio
+application/x-csh csh
+application/x-debian-package deb udeb
+application/x-dgc-compressed dgc
+application/x-director dir dcr dxr cst cct cxt w3d fgd swa
+application/x-doom wad
+application/x-dtbncx+xml ncx
+application/x-dtbook+xml dtb
+application/x-dtbresource+xml res
+application/x-dvi dvi
+application/x-envoy evy
+application/x-eva eva
+application/x-font-bdf bdf
+# application/x-font-dos
+# application/x-font-framemaker
+application/x-font-ghostscript gsf
+# application/x-font-libgrx
+application/x-font-linux-psf psf
+application/x-font-pcf pcf
+application/x-font-snf snf
+# application/x-font-speedo
+# application/x-font-sunos-news
+application/x-font-type1 pfa pfb pfm afm
+# application/x-font-vfont
+application/x-freearc arc
+application/x-futuresplash spl
+application/x-gca-compressed gca
+application/x-glulx ulx
+application/x-gnumeric gnumeric
+application/x-gramps-xml gramps
+application/x-gtar gtar
+# application/x-gzip
+application/x-hdf hdf
+application/x-install-instructions install
+application/x-iso9660-image iso
+application/x-java-jnlp-file jnlp
+application/x-latex latex
+application/x-lzh-compressed lzh lha
+application/x-mie mie
+application/x-mobipocket-ebook prc mobi
+application/x-ms-application application
+application/x-ms-shortcut lnk
+application/x-ms-wmd wmd
+application/x-ms-wmz wmz
+application/x-ms-xbap xbap
+application/x-msaccess mdb
+application/x-msbinder obd
+application/x-mscardfile crd
+application/x-msclip clp
+application/x-msdownload exe dll com bat msi
+application/x-msmediaview mvb m13 m14
+application/x-msmetafile wmf wmz emf emz
+application/x-msmoney mny
+application/x-mspublisher pub
+application/x-msschedule scd
+application/x-msterminal trm
+application/x-mswrite wri
+application/x-netcdf nc cdf
+application/x-nzb nzb
+application/x-pkcs12 p12 pfx
+application/x-pkcs7-certificates p7b spc
+application/x-pkcs7-certreqresp p7r
+application/x-rar-compressed rar
+application/x-research-info-systems ris
+application/x-sh sh
+application/x-shar shar
+application/x-shockwave-flash swf
+application/x-silverlight-app xap
+application/x-sql sql
+application/x-stuffit sit
+application/x-stuffitx sitx
+application/x-subrip srt
+application/x-sv4cpio sv4cpio
+application/x-sv4crc sv4crc
+application/x-t3vm-image t3
+application/x-tads gam
+application/x-tar tar
+application/x-tcl tcl
+application/x-tex tex
+application/x-tex-tfm tfm
+application/x-texinfo texinfo texi
+application/x-tgif obj
+application/x-ustar ustar
+application/x-wais-source src
+# application/x-www-form-urlencoded
+application/x-x509-ca-cert der crt
+application/x-xfig fig
+application/x-xliff+xml xlf
+application/x-xpinstall xpi
+application/x-xz xz
+application/x-zmachine z1 z2 z3 z4 z5 z6 z7 z8
+# application/x400-bp
+# application/xacml+xml
+application/xaml+xml xaml
+# application/xcap-att+xml
+# application/xcap-caps+xml
+application/xcap-diff+xml xdf
+# application/xcap-el+xml
+# application/xcap-error+xml
+# application/xcap-ns+xml
+# application/xcon-conference-info+xml
+# application/xcon-conference-info-diff+xml
+application/xenc+xml xenc
+application/xhtml+xml xhtml xht
+# application/xhtml-voice+xml
+application/xml xml xsl
+application/xml-dtd dtd
+# application/xml-external-parsed-entity
+# application/xml-patch+xml
+# application/xmpp+xml
+application/xop+xml xop
+application/xproc+xml xpl
+application/xslt+xml xslt
+application/xspf+xml xspf
+application/xv+xml mxml xhvml xvml xvm
+application/yang yang
+application/yin+xml yin
+application/zip zip
+# application/zlib
+# audio/1d-interleaved-parityfec
+# audio/32kadpcm
+# audio/3gpp
+# audio/3gpp2
+# audio/ac3
+audio/adpcm adp
+# audio/amr
+# audio/amr-wb
+# audio/amr-wb+
+# audio/aptx
+# audio/asc
+# audio/atrac-advanced-lossless
+# audio/atrac-x
+# audio/atrac3
+audio/basic au snd
+# audio/bv16
+# audio/bv32
+# audio/clearmode
+# audio/cn
+# audio/dat12
+# audio/dls
+# audio/dsr-es201108
+# audio/dsr-es202050
+# audio/dsr-es202211
+# audio/dsr-es202212
+# audio/dv
+# audio/dvi4
+# audio/eac3
+# audio/encaprtp
+# audio/evrc
+# audio/evrc-qcp
+# audio/evrc0
+# audio/evrc1
+# audio/evrcb
+# audio/evrcb0
+# audio/evrcb1
+# audio/evrcnw
+# audio/evrcnw0
+# audio/evrcnw1
+# audio/evrcwb
+# audio/evrcwb0
+# audio/evrcwb1
+# audio/evs
+# audio/example
+# audio/fwdred
+# audio/g711-0
+# audio/g719
+# audio/g722
+# audio/g7221
+# audio/g723
+# audio/g726-16
+# audio/g726-24
+# audio/g726-32
+# audio/g726-40
+# audio/g728
+# audio/g729
+# audio/g7291
+# audio/g729d
+# audio/g729e
+# audio/gsm
+# audio/gsm-efr
+# audio/gsm-hr-08
+# audio/ilbc
+# audio/ip-mr_v2.5
+# audio/isac
+# audio/l16
+# audio/l20
+# audio/l24
+# audio/l8
+# audio/lpc
+audio/midi mid midi kar rmi
+# audio/mobile-xmf
+audio/mp4 m4a mp4a
+# audio/mp4a-latm
+# audio/mpa
+# audio/mpa-robust
+audio/mpeg mp3 mpga mp2 mp2a m2a m3a
+# audio/mpeg4-generic
+# audio/musepack
+audio/ogg ogg oga spx
+# audio/opus
+# audio/parityfec
+# audio/pcma
+# audio/pcma-wb
+# audio/pcmu
+# audio/pcmu-wb
+# audio/prs.sid
+# audio/qcelp
+# audio/raptorfec
+# audio/red
+# audio/rtp-enc-aescm128
+# audio/rtp-midi
+# audio/rtploopback
+# audio/rtx
+audio/s3m s3m
+audio/silk sil
+# audio/smv
+# audio/smv-qcp
+# audio/smv0
+# audio/sp-midi
+# audio/speex
+# audio/t140c
+# audio/t38
+# audio/telephone-event
+# audio/tone
+# audio/uemclip
+# audio/ulpfec
+# audio/vdvi
+# audio/vmr-wb
+# audio/vnd.3gpp.iufp
+# audio/vnd.4sb
+# audio/vnd.audiokoz
+# audio/vnd.celp
+# audio/vnd.cisco.nse
+# audio/vnd.cmles.radio-events
+# audio/vnd.cns.anp1
+# audio/vnd.cns.inf1
+audio/vnd.dece.audio uva uvva
+audio/vnd.digital-winds eol
+# audio/vnd.dlna.adts
+# audio/vnd.dolby.heaac.1
+# audio/vnd.dolby.heaac.2
+# audio/vnd.dolby.mlp
+# audio/vnd.dolby.mps
+# audio/vnd.dolby.pl2
+# audio/vnd.dolby.pl2x
+# audio/vnd.dolby.pl2z
+# audio/vnd.dolby.pulse.1
+audio/vnd.dra dra
+audio/vnd.dts dts
+audio/vnd.dts.hd dtshd
+# audio/vnd.dvb.file
+# audio/vnd.everad.plj
+# audio/vnd.hns.audio
+audio/vnd.lucent.voice lvp
+audio/vnd.ms-playready.media.pya pya
+# audio/vnd.nokia.mobile-xmf
+# audio/vnd.nortel.vbk
+audio/vnd.nuera.ecelp4800 ecelp4800
+audio/vnd.nuera.ecelp7470 ecelp7470
+audio/vnd.nuera.ecelp9600 ecelp9600
+# audio/vnd.octel.sbc
+# audio/vnd.qcelp
+# audio/vnd.rhetorex.32kadpcm
+audio/vnd.rip rip
+# audio/vnd.sealedmedia.softseal.mpeg
+# audio/vnd.vmx.cvsd
+# audio/vorbis
+# audio/vorbis-config
+audio/webm weba
+audio/x-aac aac
+audio/x-aiff aif aiff aifc
+audio/x-caf caf
+audio/x-flac flac
+audio/x-matroska mka
+audio/x-mpegurl m3u
+audio/x-ms-wax wax
+audio/x-ms-wma wma
+audio/x-pn-realaudio ram ra
+audio/x-pn-realaudio-plugin rmp
+# audio/x-tta
+audio/x-wav wav
+audio/xm xm
+chemical/x-cdx cdx
+chemical/x-cif cif
+chemical/x-cmdf cmdf
+chemical/x-cml cml
+chemical/x-csml csml
+# chemical/x-pdb
+chemical/x-xyz xyz
+font/collection ttc
+font/otf otf
+# font/sfnt
+font/ttf ttf
+font/woff woff
+font/woff2 woff2
+image/bmp bmp
+image/cgm cgm
+# image/dicom-rle
+# image/emf
+# image/example
+# image/fits
+image/g3fax g3
+image/gif gif
+image/ief ief
+# image/jls
+# image/jp2
+image/jpeg jpg jpeg jpe
+# image/jpm
+# image/jpx
+image/ktx ktx
+# image/naplps
+image/png png
+image/prs.btif btif
+# image/prs.pti
+# image/pwg-raster
+image/sgi sgi
+image/svg+xml svg svgz
+# image/t38
+image/tiff tiff tif
+# image/tiff-fx
+image/vnd.adobe.photoshop psd
+# image/vnd.airzip.accelerator.azv
+# image/vnd.cns.inf2
+image/vnd.dece.graphic uvi uvvi uvg uvvg
+image/vnd.djvu djvu djv
+image/vnd.dvb.subtitle sub
+image/vnd.dwg dwg
+image/vnd.dxf dxf
+image/vnd.fastbidsheet fbs
+image/vnd.fpx fpx
+image/vnd.fst fst
+image/vnd.fujixerox.edmics-mmr mmr
+image/vnd.fujixerox.edmics-rlc rlc
+# image/vnd.globalgraphics.pgb
+# image/vnd.microsoft.icon
+# image/vnd.mix
+# image/vnd.mozilla.apng
+image/vnd.ms-modi mdi
+image/vnd.ms-photo wdp
+image/vnd.net-fpx npx
+# image/vnd.radiance
+# image/vnd.sealed.png
+# image/vnd.sealedmedia.softseal.gif
+# image/vnd.sealedmedia.softseal.jpg
+# image/vnd.svf
+# image/vnd.tencent.tap
+# image/vnd.valve.source.texture
+image/vnd.wap.wbmp wbmp
+image/vnd.xiff xif
+# image/vnd.zbrush.pcx
+image/webp webp
+# image/wmf
+image/x-3ds 3ds
+image/x-cmu-raster ras
+image/x-cmx cmx
+image/x-freehand fh fhc fh4 fh5 fh7
+image/x-icon ico
+image/x-mrsid-image sid
+image/x-pcx pcx
+image/x-pict pic pct
+image/x-portable-anymap pnm
+image/x-portable-bitmap pbm
+image/x-portable-graymap pgm
+image/x-portable-pixmap ppm
+image/x-rgb rgb
+image/x-tga tga
+image/x-xbitmap xbm
+image/x-xpixmap xpm
+image/x-xwindowdump xwd
+# message/cpim
+# message/delivery-status
+# message/disposition-notification
+# message/example
+# message/external-body
+# message/feedback-report
+# message/global
+# message/global-delivery-status
+# message/global-disposition-notification
+# message/global-headers
+# message/http
+# message/imdn+xml
+# message/news
+# message/partial
+message/rfc822 eml mime
+# message/s-http
+# message/sip
+# message/sipfrag
+# message/tracking-status
+# message/vnd.si.simp
+# message/vnd.wfa.wsc
+# model/example
+# model/gltf+json
+model/iges igs iges
+model/mesh msh mesh silo
+model/vnd.collada+xml dae
+model/vnd.dwf dwf
+# model/vnd.flatland.3dml
+model/vnd.gdl gdl
+# model/vnd.gs-gdl
+# model/vnd.gs.gdl
+model/vnd.gtw gtw
+# model/vnd.moml+xml
+model/vnd.mts mts
+# model/vnd.opengex
+# model/vnd.parasolid.transmit.binary
+# model/vnd.parasolid.transmit.text
+# model/vnd.rosette.annotated-data-model
+# model/vnd.valve.source.compiled-map
+model/vnd.vtu vtu
+model/vrml wrl vrml
+model/x3d+binary x3db x3dbz
+# model/x3d+fastinfoset
+model/x3d+vrml x3dv x3dvz
+model/x3d+xml x3d x3dz
+# model/x3d-vrml
+# multipart/alternative
+# multipart/appledouble
+# multipart/byteranges
+# multipart/digest
+# multipart/encrypted
+# multipart/example
+# multipart/form-data
+# multipart/header-set
+# multipart/mixed
+# multipart/parallel
+# multipart/related
+# multipart/report
+# multipart/signed
+# multipart/voice-message
+# multipart/x-mixed-replace
+# text/1d-interleaved-parityfec
+text/cache-manifest appcache
+text/calendar ics ifb
+text/css css
+text/csv csv
+# text/csv-schema
+# text/directory
+# text/dns
+# text/ecmascript
+# text/encaprtp
+# text/enriched
+# text/example
+# text/fwdred
+# text/grammar-ref-list
+text/html html htm
+# text/javascript
+# text/jcr-cnd
+# text/markdown
+# text/mizar
+text/n3 n3
+# text/parameters
+# text/parityfec
+text/plain txt text conf def list log in
+# text/provenance-notation
+# text/prs.fallenstein.rst
+text/prs.lines.tag dsc
+# text/prs.prop.logic
+# text/raptorfec
+# text/red
+# text/rfc822-headers
+text/richtext rtx
+# text/rtf
+# text/rtp-enc-aescm128
+# text/rtploopback
+# text/rtx
+text/sgml sgml sgm
+# text/t140
+text/tab-separated-values tsv
+text/troff t tr roff man me ms
+text/turtle ttl
+# text/ulpfec
+text/uri-list uri uris urls
+text/vcard vcard
+# text/vnd.a
+# text/vnd.abc
+text/vnd.curl curl
+text/vnd.curl.dcurl dcurl
+text/vnd.curl.mcurl mcurl
+text/vnd.curl.scurl scurl
+# text/vnd.debian.copyright
+# text/vnd.dmclientscript
+text/vnd.dvb.subtitle sub
+# text/vnd.esmertec.theme-descriptor
+text/vnd.fly fly
+text/vnd.fmi.flexstor flx
+text/vnd.graphviz gv
+text/vnd.in3d.3dml 3dml
+text/vnd.in3d.spot spot
+# text/vnd.iptc.newsml
+# text/vnd.iptc.nitf
+# text/vnd.latex-z
+# text/vnd.motorola.reflex
+# text/vnd.ms-mediapackage
+# text/vnd.net2phone.commcenter.command
+# text/vnd.radisys.msml-basic-layout
+# text/vnd.si.uricatalogue
+text/vnd.sun.j2me.app-descriptor jad
+# text/vnd.trolltech.linguist
+# text/vnd.wap.si
+# text/vnd.wap.sl
+text/vnd.wap.wml wml
+text/vnd.wap.wmlscript wmls
+text/x-asm s asm
+text/x-c c cc cxx cpp h hh dic
+text/x-fortran f for f77 f90
+text/x-java-source java
+text/x-nfo nfo
+text/x-opml opml
+text/x-pascal p pas
+text/x-setext etx
+text/x-sfv sfv
+text/x-uuencode uu
+text/x-vcalendar vcs
+text/x-vcard vcf
+# text/xml
+# text/xml-external-parsed-entity
+# video/1d-interleaved-parityfec
+video/3gpp 3gp
+# video/3gpp-tt
+video/3gpp2 3g2
+# video/bmpeg
+# video/bt656
+# video/celb
+# video/dv
+# video/encaprtp
+# video/example
+video/h261 h261
+video/h263 h263
+# video/h263-1998
+# video/h263-2000
+video/h264 h264
+# video/h264-rcdo
+# video/h264-svc
+# video/h265
+# video/iso.segment
+video/jpeg jpgv
+# video/jpeg2000
+video/jpm jpm jpgm
+video/mj2 mj2 mjp2
+# video/mp1s
+# video/mp2p
+# video/mp2t
+video/mp4 mp4 mp4v mpg4
+# video/mp4v-es
+video/mpeg mpeg mpg mpe m1v m2v
+# video/mpeg4-generic
+# video/mpv
+# video/nv
+video/ogg ogv
+# video/parityfec
+# video/pointer
+video/quicktime qt mov
+# video/raptorfec
+# video/raw
+# video/rtp-enc-aescm128
+# video/rtploopback
+# video/rtx
+# video/smpte292m
+# video/ulpfec
+# video/vc1
+# video/vnd.cctv
+video/vnd.dece.hd uvh uvvh
+video/vnd.dece.mobile uvm uvvm
+# video/vnd.dece.mp4
+video/vnd.dece.pd uvp uvvp
+video/vnd.dece.sd uvs uvvs
+video/vnd.dece.video uvv uvvv
+# video/vnd.directv.mpeg
+# video/vnd.directv.mpeg-tts
+# video/vnd.dlna.mpeg-tts
+video/vnd.dvb.file dvb
+video/vnd.fvt fvt
+# video/vnd.hns.video
+# video/vnd.iptvforum.1dparityfec-1010
+# video/vnd.iptvforum.1dparityfec-2005
+# video/vnd.iptvforum.2dparityfec-1010
+# video/vnd.iptvforum.2dparityfec-2005
+# video/vnd.iptvforum.ttsavc
+# video/vnd.iptvforum.ttsmpeg2
+# video/vnd.motorola.video
+# video/vnd.motorola.videop
+video/vnd.mpegurl mxu m4u
+video/vnd.ms-playready.media.pyv pyv
+# video/vnd.nokia.interleaved-multimedia
+# video/vnd.nokia.videovoip
+# video/vnd.objectvideo
+# video/vnd.radgamettools.bink
+# video/vnd.radgamettools.smacker
+# video/vnd.sealed.mpeg1
+# video/vnd.sealed.mpeg4
+# video/vnd.sealed.swf
+# video/vnd.sealedmedia.softseal.mov
+video/vnd.uvvu.mp4 uvu uvvu
+video/vnd.vivo viv
+# video/vp8
+video/webm webm
+video/x-f4v f4v
+video/x-fli fli
+video/x-flv flv
+video/x-m4v m4v
+video/x-matroska mkv mk3d mks
+video/x-mng mng
+video/x-ms-asf asf asx
+video/x-ms-vob vob
+video/x-ms-wm wm
+video/x-ms-wmv wmv
+video/x-ms-wmx wmx
+video/x-ms-wvx wvx
+video/x-msvideo avi
+video/x-sgi-movie movie
+video/x-smv smv
+x-conference/x-cooltalk ice
\ No newline at end of file
diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py
index ea5870fc..69693384 100644
--- a/pyrogram/client/methods/messages/edit_message_media.py
+++ b/pyrogram/client/methods/messages/edit_message_media.py
@@ -123,7 +123,7 @@ class EditMessageMedia(BaseClient):
functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument(
- mime_type="video/mp4",
+ mime_type=self.guess_mime_type(media.media) or "video/mp4",
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media),
attributes=[
@@ -182,7 +182,7 @@ class EditMessageMedia(BaseClient):
functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument(
- mime_type="audio/mpeg",
+ mime_type=self.guess_mime_type(media.media) or "audio/mpeg",
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media),
attributes=[
@@ -240,7 +240,7 @@ class EditMessageMedia(BaseClient):
functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument(
- mime_type="video/mp4",
+ mime_type=self.guess_mime_type(media.media) or "video/mp4",
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media),
attributes=[
@@ -300,7 +300,7 @@ class EditMessageMedia(BaseClient):
functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument(
- mime_type="application/zip",
+ mime_type=self.guess_mime_type(media.media) or "application/zip",
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media),
attributes=[
diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py
index 798d236d..2ef67a4e 100644
--- a/pyrogram/client/methods/messages/send_animation.py
+++ b/pyrogram/client/methods/messages/send_animation.py
@@ -135,7 +135,7 @@ class SendAnimation(BaseClient):
thumb = None if thumb is None else self.save_file(thumb)
file = self.save_file(animation, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
- mime_type="video/mp4",
+ mime_type=self.guess_mime_type(animation) or "video/mp4",
file=file,
thumb=thumb,
attributes=[
diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py
index d514b737..ee9cd305 100644
--- a/pyrogram/client/methods/messages/send_audio.py
+++ b/pyrogram/client/methods/messages/send_audio.py
@@ -137,7 +137,7 @@ class SendAudio(BaseClient):
thumb = None if thumb is None else self.save_file(thumb)
file = self.save_file(audio, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
- mime_type="audio/mpeg",
+ mime_type=self.guess_mime_type(audio) or "audio/mpeg",
file=file,
thumb=thumb,
attributes=[
diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py
index a36a0fbb..a71c79e6 100644
--- a/pyrogram/client/methods/messages/send_document.py
+++ b/pyrogram/client/methods/messages/send_document.py
@@ -123,7 +123,7 @@ class SendDocument(BaseClient):
thumb = None if thumb is None else self.save_file(thumb)
file = self.save_file(document, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
- mime_type="application/zip",
+ mime_type=self.guess_mime_type(document) or "application/zip",
file=file,
thumb=thumb,
attributes=[
diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py
index 4fdc1132..f40401b0 100644
--- a/pyrogram/client/methods/messages/send_media_group.py
+++ b/pyrogram/client/methods/messages/send_media_group.py
@@ -129,7 +129,7 @@ class SendMediaGroup(BaseClient):
media=types.InputMediaUploadedDocument(
file=self.save_file(i.media),
thumb=None if i.thumb is None else self.save_file(i.thumb),
- mime_type="video/mp4",
+ mime_type=self.guess_mime_type(i.media) or "video/mp4",
attributes=[
types.DocumentAttributeVideo(
supports_streaming=i.supports_streaming or None,
diff --git a/pyrogram/client/methods/messages/send_sticker.py b/pyrogram/client/methods/messages/send_sticker.py
index e556aae3..a10f3b74 100644
--- a/pyrogram/client/methods/messages/send_sticker.py
+++ b/pyrogram/client/methods/messages/send_sticker.py
@@ -104,7 +104,7 @@ class SendSticker(BaseClient):
if os.path.exists(sticker):
file = self.save_file(sticker, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
- mime_type="image/webp",
+ mime_type=self.guess_mime_type(sticker) or "image/webp",
file=file,
attributes=[
types.DocumentAttributeFilename(file_name=os.path.basename(sticker))
diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py
index 08d8b7ab..0faf8e38 100644
--- a/pyrogram/client/methods/messages/send_video.py
+++ b/pyrogram/client/methods/messages/send_video.py
@@ -139,7 +139,7 @@ class SendVideo(BaseClient):
thumb = None if thumb is None else self.save_file(thumb)
file = self.save_file(video, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
- mime_type="video/mp4",
+ mime_type=self.guess_mime_type(video) or "video/mp4",
file=file,
thumb=thumb,
attributes=[
diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py
index 4844dd65..b2547d04 100644
--- a/pyrogram/client/methods/messages/send_video_note.py
+++ b/pyrogram/client/methods/messages/send_video_note.py
@@ -120,7 +120,7 @@ class SendVideoNote(BaseClient):
thumb = None if thumb is None else self.save_file(thumb)
file = self.save_file(video_note, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
- mime_type="video/mp4",
+ mime_type=self.guess_mime_type(video_note) or "video/mp4",
file=file,
thumb=thumb,
attributes=[
diff --git a/pyrogram/client/methods/messages/send_voice.py b/pyrogram/client/methods/messages/send_voice.py
index 110b0704..44e998b6 100644
--- a/pyrogram/client/methods/messages/send_voice.py
+++ b/pyrogram/client/methods/messages/send_voice.py
@@ -119,7 +119,7 @@ class SendVoice(BaseClient):
if os.path.exists(voice):
file = self.save_file(voice, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
- mime_type="audio/mpeg",
+ mime_type=self.guess_mime_type(voice) or "audio/mpeg",
file=file,
attributes=[
types.DocumentAttributeAudio(
From cec43bf568c97c520a966e1510f7b4bc8273f2d1 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sat, 20 Apr 2019 18:57:07 +0200
Subject: [PATCH 012/202] Update develop version
---
pyrogram/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py
index 44dbe231..bf688797 100644
--- a/pyrogram/__init__.py
+++ b/pyrogram/__init__.py
@@ -24,7 +24,7 @@ if sys.version_info[:3] in [(3, 5, 0), (3, 5, 1), (3, 5, 2)]:
# Monkey patch the standard "typing" module because Python versions from 3.5.0 to 3.5.2 have a broken one.
sys.modules["typing"] = typing
-__version__ = "0.12.0"
+__version__ = "0.13.0.develop"
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
__copyright__ = "Copyright (C) 2017-2019 Dan Tès ".replace(
"\xe8", "e" if sys.getfilesystemencoding() != "utf-8" else "\xe8"
From e7258a341ba905cfa86264c22040654db732ec1c Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sat, 20 Apr 2019 22:51:54 +0200
Subject: [PATCH 013/202] Add mime.types in MANIFEST.in
---
MANIFEST.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/MANIFEST.in b/MANIFEST.in
index f818e13a..80c061ff 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,6 +1,7 @@
## Include
include COPYING COPYING.lesser NOTICE requirements.txt
recursive-include compiler *.py *.tl *.tsv *.txt
+recursive-include pyrogram mime.types
## Exclude
prune pyrogram/api/errors/exceptions
From 94574efe2c6c5001ec444e4a219337cc72f7c833 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 30 Apr 2019 10:33:11 +0200
Subject: [PATCH 014/202] Remove unneeded method
---
pyrogram/client/handlers/inline_query_handler.py | 7 -------
1 file changed, 7 deletions(-)
diff --git a/pyrogram/client/handlers/inline_query_handler.py b/pyrogram/client/handlers/inline_query_handler.py
index e59514c0..c64d49c8 100644
--- a/pyrogram/client/handlers/inline_query_handler.py
+++ b/pyrogram/client/handlers/inline_query_handler.py
@@ -45,10 +45,3 @@ class InlineQueryHandler(Handler):
def __init__(self, callback: callable, filters=None):
super().__init__(callback, filters)
-
- def check(self, callback_query):
- return (
- self.filters(callback_query)
- if callable(self.filters)
- else True
- )
From 16d3b2d56e751570358edf60ae90d143dd7f0534 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 30 Apr 2019 10:45:27 +0200
Subject: [PATCH 015/202] Make sure mime.types actually gets installed
---
setup.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/setup.py b/setup.py
index cba41b78..ef02c428 100644
--- a/setup.py
+++ b/setup.py
@@ -171,6 +171,9 @@ setup(
},
python_requires="~=3.4",
packages=find_packages(exclude=["compiler*"]),
+ package_data={
+ "pyrogram.client.ext": ["mime.types"]
+ },
zip_safe=False,
install_requires=read("requirements.txt"),
extras_require={
From 2aad59856d27aa36bfe5ebd25a4408580b03929f Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 30 Apr 2019 11:04:37 +0200
Subject: [PATCH 016/202] Fix export_chat_invite_link broken because of Layer
update Fixes #244
---
.../client/methods/chats/export_chat_invite_link.py | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py
index b84b1d3c..c9c7ca41 100644
--- a/pyrogram/client/methods/chats/export_chat_invite_link.py
+++ b/pyrogram/client/methods/chats/export_chat_invite_link.py
@@ -44,15 +44,11 @@ class ExportChatInviteLink(BaseClient):
"""
peer = self.resolve_peer(chat_id)
- if isinstance(peer, types.InputPeerChat):
+ if isinstance(peer, (types.InputPeerChat, types.InputPeerChannel)):
return self.send(
functions.messages.ExportChatInvite(
- peer=peer.chat_id
- )
- ).link
- elif isinstance(peer, types.InputPeerChannel):
- return self.send(
- functions.channels.ExportInvite(
- channel=peer
+ peer=peer
)
).link
+ else:
+ raise ValueError("The chat_id \"{}\" belongs to a user".format(chat_id))
From d83a2a951d72b8b9cfbc67a166ac953851774a88 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 30 Apr 2019 11:22:23 +0200
Subject: [PATCH 017/202] Revert "Fix export_chat_invite_link broken because of
Layer update Fixes #244"
This reverts commit 2aad5985
---
.../client/methods/chats/export_chat_invite_link.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py
index c9c7ca41..b84b1d3c 100644
--- a/pyrogram/client/methods/chats/export_chat_invite_link.py
+++ b/pyrogram/client/methods/chats/export_chat_invite_link.py
@@ -44,11 +44,15 @@ class ExportChatInviteLink(BaseClient):
"""
peer = self.resolve_peer(chat_id)
- if isinstance(peer, (types.InputPeerChat, types.InputPeerChannel)):
+ if isinstance(peer, types.InputPeerChat):
return self.send(
functions.messages.ExportChatInvite(
- peer=peer
+ peer=peer.chat_id
+ )
+ ).link
+ elif isinstance(peer, types.InputPeerChannel):
+ return self.send(
+ functions.channels.ExportInvite(
+ channel=peer
)
).link
- else:
- raise ValueError("The chat_id \"{}\" belongs to a user".format(chat_id))
From 881f3e479aaf310f927fe4504bdaddd7306580b4 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 30 Apr 2019 11:23:31 +0200
Subject: [PATCH 018/202] Bring the old, but working, channels.exportInvite
method back We keep this until the server decides to enable the new methods
for bots
---
compiler/api/source/main_api.tl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/compiler/api/source/main_api.tl b/compiler/api/source/main_api.tl
index 581427b5..61c9faf6 100644
--- a/compiler/api/source/main_api.tl
+++ b/compiler/api/source/main_api.tl
@@ -1313,3 +1313,6 @@ langpack.getLanguages#42c6978f lang_pack:string = Vector;
langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage;
// LAYER 97
+
+// Ports
+channels.exportInvite#c7560885 channel:InputChannel = ExportedChatInvite;
\ No newline at end of file
From cc9bc56391cbe4add6915846d1669c045e100a8a Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 30 Apr 2019 11:29:54 +0200
Subject: [PATCH 019/202] Add important note to export_chat_invite_link
---
pyrogram/client/methods/chats/export_chat_invite_link.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py
index b84b1d3c..16f5bc01 100644
--- a/pyrogram/client/methods/chats/export_chat_invite_link.py
+++ b/pyrogram/client/methods/chats/export_chat_invite_link.py
@@ -31,6 +31,13 @@ class ExportChatInviteLink(BaseClient):
You must be an administrator in the chat for this to work and have the appropriate admin rights.
+ .. note ::
+
+ Each administrator in a chat generates their own invite links. Bots can't use invite links generated by
+ other administrators. If you want your bot to work with invite links, it will need to generate its own link
+ using this method – after this the link will become available to the bot via the :meth:`get_chat` method.
+ If your bot needs to generate a new invite link replacing its previous one, use this method again.
+
Args:
chat_id (``int`` | ``str``):
Unique identifier for the target chat or username of the target channel/supergroup
From d30cad1a2dccfca1fc2b8386732b35711a937a7a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joscha=20G=C3=B6tzer?=
Date: Tue, 30 Apr 2019 11:49:18 +0200
Subject: [PATCH 020/202] Use str or bytes for callback_data and
CallbackQuery.data (#241)
---
pyrogram/client/types/bots/callback_query.py | 2 +-
pyrogram/client/types/bots/inline_keyboard_button.py | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/pyrogram/client/types/bots/callback_query.py b/pyrogram/client/types/bots/callback_query.py
index 4497747e..ac58338a 100644
--- a/pyrogram/client/types/bots/callback_query.py
+++ b/pyrogram/client/types/bots/callback_query.py
@@ -79,7 +79,7 @@ class CallbackQuery(PyrogramType, Update):
self.chat_instance = chat_instance
self.message = message
self.inline_message_id = inline_message_id
- self.data = data
+ self.data = str(data, "utf-8")
self.game_short_name = game_short_name
@staticmethod
diff --git a/pyrogram/client/types/bots/inline_keyboard_button.py b/pyrogram/client/types/bots/inline_keyboard_button.py
index c0c3eb8c..a26d6ca6 100644
--- a/pyrogram/client/types/bots/inline_keyboard_button.py
+++ b/pyrogram/client/types/bots/inline_keyboard_button.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from typing import Union
+
from pyrogram.api.types import (
KeyboardButtonUrl, KeyboardButtonCallback,
KeyboardButtonSwitchInline, KeyboardButtonGame
@@ -61,7 +63,7 @@ class InlineKeyboardButton(PyrogramType):
def __init__(
self,
text: str,
- callback_data: bytes = None,
+ callback_data: Union[str, bytes] = None,
url: str = None,
switch_inline_query: str = None,
switch_inline_query_current_chat: str = None,
@@ -71,7 +73,7 @@ class InlineKeyboardButton(PyrogramType):
self.text = str(text)
self.url = url
- self.callback_data = callback_data
+ self.callback_data = bytes(callback_data, "utf-8") if isinstance(callback_data, str) else 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
From 80081a29b48e24d3bf9dd261bc3594b931f513e6 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 30 Apr 2019 14:43:57 +0200
Subject: [PATCH 021/202] Add supports_streaming attribute to the Video type
---
.../client/types/messages_and_media/video.py | 25 +++++++++++++------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/pyrogram/client/types/messages_and_media/video.py b/pyrogram/client/types/messages_and_media/video.py
index caf34ce9..a45a8f8d 100644
--- a/pyrogram/client/types/messages_and_media/video.py
+++ b/pyrogram/client/types/messages_and_media/video.py
@@ -50,6 +50,9 @@ class Video(PyrogramType):
mime_type (``str``, *optional*):
Mime type of a file as defined by sender.
+ supports_streaming (``bool``, *optional*):
+ True, if the video was uploaded with streaming support.
+
file_size (``int``, *optional*):
File size.
@@ -57,7 +60,10 @@ class Video(PyrogramType):
Date the video was sent in Unix time.
"""
- __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "duration"]
+ __slots__ = [
+ "file_id", "width", "height", "duration", "thumb", "file_name", "mime_type", "supports_streaming", "file_size",
+ "date"
+ ]
def __init__(
self,
@@ -70,20 +76,22 @@ class Video(PyrogramType):
thumb: PhotoSize = None,
file_name: str = None,
mime_type: str = None,
+ supports_streaming: bool = None,
file_size: int = None,
date: int = None
):
super().__init__(client)
self.file_id = file_id
- self.thumb = thumb
- self.file_name = file_name
- self.mime_type = mime_type
- self.file_size = file_size
- self.date = date
self.width = width
self.height = height
self.duration = duration
+ self.thumb = thumb
+ self.file_name = file_name
+ self.mime_type = mime_type
+ self.supports_streaming = supports_streaming
+ self.file_size = file_size
+ self.date = date
@staticmethod
def _parse(client, video: types.Document, video_attributes: types.DocumentAttributeVideo,
@@ -102,9 +110,10 @@ class Video(PyrogramType):
height=video_attributes.h,
duration=video_attributes.duration,
thumb=PhotoSize._parse(client, video.thumbs),
- mime_type=video.mime_type,
- file_size=video.size,
file_name=file_name,
+ mime_type=video.mime_type,
+ supports_streaming=video_attributes.supports_streaming,
+ file_size=video.size,
date=video.date,
client=client
)
From 58482919ba826b36d5e7b60e8e9203c4f715093a Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 5 May 2019 12:21:20 +0200
Subject: [PATCH 022/202] Make is_member field actually working
---
pyrogram/client/types/user_and_chats/chat_member.py | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/pyrogram/client/types/user_and_chats/chat_member.py b/pyrogram/client/types/user_and_chats/chat_member.py
index 9ccf9314..046d2ebc 100644
--- a/pyrogram/client/types/user_and_chats/chat_member.py
+++ b/pyrogram/client/types/user_and_chats/chat_member.py
@@ -126,17 +126,11 @@ class ChatMember(PyrogramType):
)
if isinstance(member, types.ChannelParticipantBanned):
- status = (
- "kicked" if member.banned_rights.view_messages
- else "left" if member.left
- else "restricted"
- )
-
return ChatMember(
user=user,
- status=status,
+ status="kicked" if member.banned_rights.view_messages else "restricted",
date=member.date,
- is_member=not member.left if status == "restricted" else None,
+ is_member=not member.left,
restricted_by=pyrogram.User._parse(client, users[member.kicked_by]),
permissions=pyrogram.ChatPermissions._parse(member),
client=client
From bfda5852b6ba587709b24c9b0423ec77cb498db3 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 5 May 2019 15:44:28 +0200
Subject: [PATCH 023/202] Hint the return type of get_history
---
pyrogram/client/methods/messages/get_history.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyrogram/client/methods/messages/get_history.py b/pyrogram/client/methods/messages/get_history.py
index fda8f11f..1953fabc 100644
--- a/pyrogram/client/methods/messages/get_history.py
+++ b/pyrogram/client/methods/messages/get_history.py
@@ -37,7 +37,7 @@ class GetHistory(BaseClient):
offset_id: int = 0,
offset_date: int = 0,
reverse: bool = False
- ):
+ ) -> "pyrogram.Messages":
"""Use this method to retrieve a chunk of the history of a chat.
You can get up to 100 messages at once.
From 6f2c625cd1c3c769b5db2b2af519e7515a8fd930 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 5 May 2019 15:44:53 +0200
Subject: [PATCH 024/202] Handle minified poll updates
---
pyrogram/client/ext/dispatcher.py | 2 +-
.../client/types/messages_and_media/poll.py | 37 +++++++++++++++++--
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/pyrogram/client/ext/dispatcher.py b/pyrogram/client/ext/dispatcher.py
index 46be47f7..1004095b 100644
--- a/pyrogram/client/ext/dispatcher.py
+++ b/pyrogram/client/ext/dispatcher.py
@@ -82,7 +82,7 @@ class Dispatcher:
lambda upd, usr, cht: (pyrogram.InlineQuery._parse(self.client, upd, usr), InlineQueryHandler),
(types.UpdateMessagePoll,):
- lambda upd, usr, cht: (pyrogram.Poll._parse(self.client, upd), PollHandler)
+ lambda upd, usr, cht: (pyrogram.Poll._parse_update(self.client, upd), PollHandler)
}
self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple}
diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py
index acaf8697..fa68f669 100644
--- a/pyrogram/client/types/messages_and_media/poll.py
+++ b/pyrogram/client/types/messages_and_media/poll.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from typing import List
+from typing import List, Union
import pyrogram
from pyrogram.api import types
@@ -71,12 +71,11 @@ class Poll(PyrogramType, Update):
self.chosen_option = chosen_option
@staticmethod
- def _parse(client, media_poll: types.MessageMediaPoll) -> "Poll":
+ def _parse(client, media_poll: Union[types.MessageMediaPoll, types.UpdateMessagePoll]) -> "Poll":
poll = media_poll.poll
results = media_poll.results.results
total_voters = media_poll.results.total_voters
chosen_option = None
-
options = []
for i, answer in enumerate(poll.answers):
@@ -107,3 +106,35 @@ class Poll(PyrogramType, Update):
chosen_option=chosen_option,
client=client
)
+
+ @staticmethod
+ def _parse_update(client, update: types.UpdateMessagePoll):
+ if update.poll is not None:
+ return Poll._parse(client, update)
+
+ results = update.results.results
+ chosen_option = None
+ options = []
+
+ for i, result in enumerate(results):
+ if result.chosen:
+ chosen_option = i
+
+ options.append(
+ PollOption(
+ text="",
+ voter_count=result.voters,
+ data=result.option,
+ client=client
+ )
+ )
+
+ return Poll(
+ id=str(update.poll_id),
+ question="",
+ options=options,
+ is_closed=False,
+ total_voters=update.results.total_voters,
+ chosen_option=chosen_option,
+ client=client
+ )
From 01f0af6bb033fa8468bc495d5afb4b3009288037 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 16:36:57 +0200
Subject: [PATCH 025/202] Increase OFFLINE_SLEEP to 15 minutes This avoid
frequent dialogs fetch while debugging with user accounts
---
pyrogram/client/ext/base_client.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyrogram/client/ext/base_client.py b/pyrogram/client/ext/base_client.py
index b4bfbd6b..ee7b2c24 100644
--- a/pyrogram/client/ext/base_client.py
+++ b/pyrogram/client/ext/base_client.py
@@ -50,7 +50,7 @@ class BaseClient:
DIALOGS_AT_ONCE = 100
UPDATES_WORKERS = 1
DOWNLOAD_WORKERS = 1
- OFFLINE_SLEEP = 300
+ OFFLINE_SLEEP = 900
WORKERS = 4
WORKDIR = "."
CONFIG_FILE = "./config.ini"
From 95ef9a64deb01ea4ca523a42f9d674079387b96c Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 16:40:07 +0200
Subject: [PATCH 026/202] Fix small typos
---
docs/source/pyrogram/Client.rst | 2 +-
pyrogram/client/types/user_and_chats/dialog.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst
index dcf8bb79..3a7c231f 100644
--- a/docs/source/pyrogram/Client.rst
+++ b/docs/source/pyrogram/Client.rst
@@ -69,7 +69,7 @@ Messages
iter_history
send_poll
vote_poll
- close_poll
+ stop_poll
retract_vote
download_media
diff --git a/pyrogram/client/types/user_and_chats/dialog.py b/pyrogram/client/types/user_and_chats/dialog.py
index 1bbd3b4b..d406d783 100644
--- a/pyrogram/client/types/user_and_chats/dialog.py
+++ b/pyrogram/client/types/user_and_chats/dialog.py
@@ -34,7 +34,7 @@ class Dialog(PyrogramType):
The last message sent in the dialog at this time.
unread_messages_count (``int``):
- Amount of unread messages in this dialogs.
+ Amount of unread messages in this dialog.
unread_mentions_count (``int``):
Amount of unread messages containing a mention in this dialog.
From e80eebc23494ecd558a4067fd0b6e3176cbc0261 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 16:44:50 +0200
Subject: [PATCH 027/202] Add get_history_count method
---
docs/source/pyrogram/Client.rst | 1 +
pyrogram/client/methods/messages/__init__.py | 6 +-
.../methods/messages/get_history_count.py | 84 +++++++++++++++++++
3 files changed, 89 insertions(+), 2 deletions(-)
create mode 100644 pyrogram/client/methods/messages/get_history_count.py
diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst
index 3a7c231f..59293273 100644
--- a/docs/source/pyrogram/Client.rst
+++ b/docs/source/pyrogram/Client.rst
@@ -66,6 +66,7 @@ Messages
delete_messages
get_messages
get_history
+ get_history_count
iter_history
send_poll
vote_poll
diff --git a/pyrogram/client/methods/messages/__init__.py b/pyrogram/client/methods/messages/__init__.py
index d26c51cc..e843aa7c 100644
--- a/pyrogram/client/methods/messages/__init__.py
+++ b/pyrogram/client/methods/messages/__init__.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from .stop_poll import StopPoll
from .delete_messages import DeleteMessages
from .download_media import DownloadMedia
from .edit_message_caption import EditMessageCaption
@@ -25,6 +24,7 @@ from .edit_message_reply_markup import EditMessageReplyMarkup
from .edit_message_text import EditMessageText
from .forward_messages import ForwardMessages
from .get_history import GetHistory
+from .get_history_count import GetHistoryCount
from .get_messages import GetMessages
from .iter_history import IterHistory
from .retract_vote import RetractVote
@@ -44,6 +44,7 @@ from .send_venue import SendVenue
from .send_video import SendVideo
from .send_video_note import SendVideoNote
from .send_voice import SendVoice
+from .stop_poll import StopPoll
from .vote_poll import VotePoll
@@ -76,6 +77,7 @@ class Messages(
RetractVote,
DownloadMedia,
IterHistory,
- SendCachedMedia
+ SendCachedMedia,
+ GetHistoryCount
):
pass
diff --git a/pyrogram/client/methods/messages/get_history_count.py b/pyrogram/client/methods/messages/get_history_count.py
new file mode 100644
index 00000000..046ec095
--- /dev/null
+++ b/pyrogram/client/methods/messages/get_history_count.py
@@ -0,0 +1,84 @@
+# Pyrogram - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-2019 Dan Tès
+#
+# This file is part of Pyrogram.
+#
+# Pyrogram is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrogram is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrogram. If not, see .
+
+import logging
+import time
+from typing import Union
+
+from pyrogram.api import types, functions
+from pyrogram.client.ext import BaseClient
+from pyrogram.errors import FloodWait
+
+log = logging.getLogger(__name__)
+
+
+class GetHistoryCount(BaseClient):
+ def get_history_count(
+ self,
+ chat_id: Union[int, str]
+ ) -> int:
+ """Use this method to get the total count of messages in a chat.
+
+ .. note::
+
+ Due to Telegram latest internal changes, the server can't reliably find anymore the total count of messages
+ a **private** or a **basic group** chat has with a single method call. To overcome this limitation, Pyrogram
+ has to iterate over all the messages. Channels and supergroups are not affected by this limitation.
+
+ Args:
+ chat_id (``int`` | ``str``):
+ Unique identifier (int) or username (str) of the target chat.
+
+ Returns:
+ On success, an integer is returned.
+
+ Raises:
+ :class:`RPCError ` in case of a Telegram RPC error.
+ """
+
+ peer = self.resolve_peer(chat_id)
+
+ if not isinstance(peer, types.InputPeerChannel):
+ offset = 0
+ limit = 100
+
+ while True:
+ try:
+ r = self.send(
+ functions.messages.GetHistory(
+ peer=peer,
+ offset_id=1,
+ offset_date=0,
+ add_offset=-offset - limit,
+ limit=limit,
+ max_id=0,
+ min_id=0,
+ hash=0
+ )
+ )
+ except FloodWait as e:
+ log.warning("Sleeping for {}s".format(e.x))
+ time.sleep(e.x)
+ continue
+
+ if not r.messages:
+ return offset
+
+ offset += len(r.messages)
+
+ return self.get_history(chat_id=chat_id, limit=1).total_count
From 4e77ead18171d6c692d57737c88dbf2f00ea007b Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 16:54:50 +0200
Subject: [PATCH 028/202] Add get_dialogs_count method
---
docs/source/pyrogram/Client.rst | 1 +
pyrogram/client/methods/chats/__init__.py | 4 +-
.../client/methods/chats/get_dialogs_count.py | 51 +++++++++++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
create mode 100644 pyrogram/client/methods/chats/get_dialogs_count.py
diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst
index 59293273..e704cc1e 100644
--- a/docs/source/pyrogram/Client.rst
+++ b/docs/source/pyrogram/Client.rst
@@ -101,6 +101,7 @@ Chats
iter_chat_members
get_dialogs
iter_dialogs
+ get_dialogs_count
restrict_chat
update_chat_username
diff --git a/pyrogram/client/methods/chats/__init__.py b/pyrogram/client/methods/chats/__init__.py
index c708453f..8db44abe 100644
--- a/pyrogram/client/methods/chats/__init__.py
+++ b/pyrogram/client/methods/chats/__init__.py
@@ -39,6 +39,7 @@ from .set_chat_title import SetChatTitle
from .unban_chat_member import UnbanChatMember
from .unpin_chat_message import UnpinChatMessage
from .update_chat_username import UpdateChatUsername
+from .get_dialogs_count import GetDialogsCount
class Chats(
@@ -64,6 +65,7 @@ class Chats(
IterDialogs,
IterChatMembers,
UpdateChatUsername,
- RestrictChat
+ RestrictChat,
+ GetDialogsCount
):
pass
diff --git a/pyrogram/client/methods/chats/get_dialogs_count.py b/pyrogram/client/methods/chats/get_dialogs_count.py
new file mode 100644
index 00000000..1ba6895f
--- /dev/null
+++ b/pyrogram/client/methods/chats/get_dialogs_count.py
@@ -0,0 +1,51 @@
+# Pyrogram - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-2019 Dan Tès
+#
+# This file is part of Pyrogram.
+#
+# Pyrogram is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrogram is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrogram. If not, see .
+
+from pyrogram.api import functions, types
+from ...ext import BaseClient
+
+
+class GetDialogsCount(BaseClient):
+ def get_dialogs_count(self, pinned_only: bool = False) -> int:
+ """Use this method to get the total count of your dialogs.
+
+ pinned_only (``bool``, *optional*):
+ Pass True if you want to count only pinned dialogs.
+ Defaults to False.
+
+ Returns:
+ On success, an integer is returned.
+
+ Raises:
+ :class:`RPCError ` in case of a Telegram RPC error.
+ """
+
+ if pinned_only:
+ return len(self.send(functions.messages.GetPinnedDialogs()).dialogs)
+ else:
+ r = self.send(
+ functions.messages.GetDialogs(
+ offset_date=0,
+ offset_id=0,
+ offset_peer=types.InputPeerEmpty(),
+ limit=1,
+ hash=0
+ )
+ )
+
+ return r.count
From e8e0c16daf1b4f30370b02969d6620d1e6a60317 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 17:00:09 +0200
Subject: [PATCH 029/202] Add get_contacts_count method
---
docs/source/pyrogram/Client.rst | 1 +
pyrogram/client/methods/contacts/__init__.py | 4 ++-
.../methods/contacts/get_contacts_count.py | 34 +++++++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
create mode 100644 pyrogram/client/methods/contacts/get_contacts_count.py
diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst
index e704cc1e..e3ef2d69 100644
--- a/docs/source/pyrogram/Client.rst
+++ b/docs/source/pyrogram/Client.rst
@@ -126,6 +126,7 @@ Contacts
add_contacts
get_contacts
+ get_contacts_count
delete_contacts
Password
diff --git a/pyrogram/client/methods/contacts/__init__.py b/pyrogram/client/methods/contacts/__init__.py
index ab9ae6ef..a966d10a 100644
--- a/pyrogram/client/methods/contacts/__init__.py
+++ b/pyrogram/client/methods/contacts/__init__.py
@@ -19,11 +19,13 @@
from .add_contacts import AddContacts
from .delete_contacts import DeleteContacts
from .get_contacts import GetContacts
+from .get_contacts_count import GetContactsCount
class Contacts(
GetContacts,
DeleteContacts,
- AddContacts
+ AddContacts,
+ GetContactsCount
):
pass
diff --git a/pyrogram/client/methods/contacts/get_contacts_count.py b/pyrogram/client/methods/contacts/get_contacts_count.py
new file mode 100644
index 00000000..b41b27b8
--- /dev/null
+++ b/pyrogram/client/methods/contacts/get_contacts_count.py
@@ -0,0 +1,34 @@
+# Pyrogram - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-2019 Dan Tès
+#
+# This file is part of Pyrogram.
+#
+# Pyrogram is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrogram is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrogram. If not, see .
+
+from pyrogram.api import functions
+from ...ext import BaseClient
+
+
+class GetContactsCount(BaseClient):
+ def get_contacts_count(self) -> int:
+ """Use this method to get the total count of contacts from your Telegram address book.
+
+ Returns:
+ On success, an integer is returned.
+
+ Raises:
+ :class:`RPCError ` in case of a Telegram RPC error.
+ """
+
+ return len(self.send(functions.contacts.GetContacts(hash=0)).contacts)
From 08554633ce90a01b29931156c555760bd3567a9b Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 17:07:41 +0200
Subject: [PATCH 030/202] Add get_user_profile_photos_count method
---
docs/source/pyrogram/Client.rst | 1 +
pyrogram/client/methods/users/__init__.py | 4 +-
.../users/get_user_profile_photos_count.py | 54 +++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 pyrogram/client/methods/users/get_user_profile_photos_count.py
diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst
index e3ef2d69..5adf4956 100644
--- a/docs/source/pyrogram/Client.rst
+++ b/docs/source/pyrogram/Client.rst
@@ -114,6 +114,7 @@ Users
get_me
get_users
get_user_profile_photos
+ get_user_profile_photos_count
set_user_profile_photo
delete_user_profile_photos
update_username
diff --git a/pyrogram/client/methods/users/__init__.py b/pyrogram/client/methods/users/__init__.py
index f8c39650..d67a18bd 100644
--- a/pyrogram/client/methods/users/__init__.py
+++ b/pyrogram/client/methods/users/__init__.py
@@ -19,6 +19,7 @@
from .delete_user_profile_photos import DeleteUserProfilePhotos
from .get_me import GetMe
from .get_user_profile_photos import GetUserProfilePhotos
+from .get_user_profile_photos_count import GetUserProfilePhotosCount
from .get_users import GetUsers
from .set_user_profile_photo import SetUserProfilePhoto
from .update_username import UpdateUsername
@@ -30,6 +31,7 @@ class Users(
DeleteUserProfilePhotos,
GetUsers,
GetMe,
- UpdateUsername
+ UpdateUsername,
+ GetUserProfilePhotosCount
):
pass
diff --git a/pyrogram/client/methods/users/get_user_profile_photos_count.py b/pyrogram/client/methods/users/get_user_profile_photos_count.py
new file mode 100644
index 00000000..fdb81790
--- /dev/null
+++ b/pyrogram/client/methods/users/get_user_profile_photos_count.py
@@ -0,0 +1,54 @@
+# Pyrogram - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-2019 Dan Tès
+#
+# This file is part of Pyrogram.
+#
+# Pyrogram is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrogram is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrogram. If not, see .
+
+from typing import Union
+
+from pyrogram.api import functions, types
+from ...ext import BaseClient
+
+
+class GetUserProfilePhotosCount(BaseClient):
+ def get_user_profile_photos_count(self, user_id: Union[int, str]) -> int:
+ """Use this method to get the total count of profile pictures for a user.
+
+ Args:
+ user_id (``int`` | ``str``):
+ Unique identifier (int) or username (str) of the target chat.
+ For your personal cloud (Saved Messages) you can simply use "me" or "self".
+ For a contact that exists in your Telegram address book you can use his phone number (str).
+
+ Returns:
+ On success, an integer is returned.
+
+ Raises:
+ :class:`RPCError ` in case of a Telegram RPC error.
+ """
+
+ r = self.send(
+ functions.photos.GetUserPhotos(
+ user_id=self.resolve_peer(user_id),
+ offset=0,
+ max_id=0,
+ limit=1
+ )
+ )
+
+ if isinstance(r, types.photos.Photos):
+ return len(r.photos)
+ else:
+ return r.count
From 692073c856837e1e5e71f174cd4b866d12dd0f90 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 17:09:44 +0200
Subject: [PATCH 031/202] Fix get_dialogs_count breaking in case of less than
200 dialogs
---
pyrogram/client/methods/chats/get_dialogs_count.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/pyrogram/client/methods/chats/get_dialogs_count.py b/pyrogram/client/methods/chats/get_dialogs_count.py
index 1ba6895f..bf1754ee 100644
--- a/pyrogram/client/methods/chats/get_dialogs_count.py
+++ b/pyrogram/client/methods/chats/get_dialogs_count.py
@@ -48,4 +48,7 @@ class GetDialogsCount(BaseClient):
)
)
- return r.count
+ if isinstance(r, types.messages.Dialogs):
+ return len(r.dialogs)
+ else:
+ return r.count
From 591499121f5a68baefb12743d8af2c79b7c103c8 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Mon, 6 May 2019 17:39:57 +0200
Subject: [PATCH 032/202] Add an hint about which client is loading the plugins
---
pyrogram/client/client.py | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py
index ec47c448..8d706084 100644
--- a/pyrogram/client/client.py
+++ b/pyrogram/client/client.py
@@ -1176,8 +1176,8 @@ class Client(Methods, BaseClient):
if isinstance(handler, Handler) and isinstance(group, int):
self.add_handler(handler, group)
- log.info('[LOAD] {}("{}") in group {} from "{}"'.format(
- type(handler).__name__, name, group, module_path))
+ log.info('[{}] [LOAD] {}("{}") in group {} from "{}"'.format(
+ self.session_name, type(handler).__name__, name, group, module_path))
count += 1
except Exception:
@@ -1190,11 +1190,13 @@ class Client(Methods, BaseClient):
try:
module = import_module(module_path)
except ImportError:
- log.warning('[LOAD] Ignoring non-existent module "{}"'.format(module_path))
+ log.warning('[{}] [LOAD] Ignoring non-existent module "{}"'.format(
+ self.session_name, module_path))
continue
if "__path__" in dir(module):
- log.warning('[LOAD] Ignoring namespace "{}"'.format(module_path))
+ log.warning('[{}] [LOAD] Ignoring namespace "{}"'.format(
+ self.session_name, module_path))
continue
if handlers is None:
@@ -1209,14 +1211,14 @@ class Client(Methods, BaseClient):
if isinstance(handler, Handler) and isinstance(group, int):
self.add_handler(handler, group)
- log.info('[LOAD] {}("{}") in group {} from "{}"'.format(
- type(handler).__name__, name, group, module_path))
+ log.info('[{}] [LOAD] {}("{}") in group {} from "{}"'.format(
+ self.session_name, type(handler).__name__, name, group, module_path))
count += 1
except Exception:
if warn_non_existent_functions:
- log.warning('[LOAD] Ignoring non-existent function "{}" from "{}"'.format(
- name, module_path))
+ log.warning('[{}] [LOAD] Ignoring non-existent function "{}" from "{}"'.format(
+ self.session_name, name, module_path))
if exclude is not None:
for path, handlers in exclude:
@@ -1226,11 +1228,13 @@ class Client(Methods, BaseClient):
try:
module = import_module(module_path)
except ImportError:
- log.warning('[UNLOAD] Ignoring non-existent module "{}"'.format(module_path))
+ log.warning('[{}] [UNLOAD] Ignoring non-existent module "{}"'.format(
+ self.session_name, module_path))
continue
if "__path__" in dir(module):
- log.warning('[UNLOAD] Ignoring namespace "{}"'.format(module_path))
+ log.warning('[{}] [UNLOAD] Ignoring namespace "{}"'.format(
+ self.session_name, module_path))
continue
if handlers is None:
@@ -1245,19 +1249,21 @@ class Client(Methods, BaseClient):
if isinstance(handler, Handler) and isinstance(group, int):
self.remove_handler(handler, group)
- log.info('[UNLOAD] {}("{}") from group {} in "{}"'.format(
- type(handler).__name__, name, group, module_path))
+ log.info('[{}] [UNLOAD] {}("{}") from group {} in "{}"'.format(
+ self.session_name, type(handler).__name__, name, group, module_path))
count -= 1
except Exception:
if warn_non_existent_functions:
- log.warning('[UNLOAD] Ignoring non-existent function "{}" from "{}"'.format(
- name, module_path))
+ log.warning('[{}] [UNLOAD] Ignoring non-existent function "{}" from "{}"'.format(
+ self.session_name, name, module_path))
if count > 0:
- log.warning('Successfully loaded {} plugin{} from "{}"'.format(count, "s" if count > 1 else "", root))
+ log.warning('[{}] Successfully loaded {} plugin{} from "{}"'.format(
+ self.session_name, count, "s" if count > 1 else "", root))
else:
- log.warning('No plugin loaded from "{}"'.format(root))
+ log.warning('[{}] No plugin loaded from "{}"'.format(
+ self.session_name, root))
def save_session(self):
auth_key = base64.b64encode(self.auth_key).decode()
From bd9bb83df5eee03a3708bfbeaa6a56188c6256c3 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 7 May 2019 18:26:27 +0200
Subject: [PATCH 033/202] Reword some methods' docstring
---
pyrogram/client/client.py | 98 +++++++++++++++++++++++++--------------
1 file changed, 62 insertions(+), 36 deletions(-)
diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py
index 8d706084..610a0d0c 100644
--- a/pyrogram/client/client.py
+++ b/pyrogram/client/client.py
@@ -261,8 +261,7 @@ class Client(Methods, BaseClient):
self._proxy.update(value)
def start(self):
- """Use this method to start the Client after creating it.
- Requires no parameters.
+ """Use this method to start the Client.
Raises:
:class:`RPCError ` in case of a Telegram RPC error.
@@ -355,8 +354,7 @@ class Client(Methods, BaseClient):
return self
def stop(self):
- """Use this method to manually stop the Client.
- Requires no parameters.
+ """Use this method to stop the Client.
Raises:
``ConnectionError`` in case you try to stop an already stopped Client.
@@ -399,7 +397,6 @@ class Client(Methods, BaseClient):
def restart(self):
"""Use this method to restart the Client.
- Requires no parameters.
Raises:
``ConnectionError`` in case you try to restart a stopped Client.
@@ -408,8 +405,16 @@ class Client(Methods, BaseClient):
self.start()
def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)):
- """Blocks the program execution until one of the signals are received,
- then gently stop the Client by closing the underlying connection.
+ """Use this method to block the main script execution until a signal (e.g.: from CTRL+C) is received.
+ Once the signal is received, the client will automatically stop and the main script will continue its execution.
+
+ This is used after starting one or more clients and is useful for event-driven applications only, that are,
+ applications which react upon incoming Telegram updates through handlers, rather than executing a set of methods
+ sequentially.
+
+ The way Pyrogram works, will keep your handlers in a pool of workers, which are executed concurrently outside
+ the main script; calling idle() will ensure the client(s) will be kept alive by not letting the main script to
+ end, until you decide to quit.
Args:
stop_signals (``tuple``, *optional*):
@@ -417,6 +422,8 @@ class Client(Methods, BaseClient):
Defaults to (SIGINT, SIGTERM, SIGABRT).
"""
+ # TODO: Maybe make this method static and don't automatically stop
+
def signal_handler(*args):
self.is_idle = False
@@ -431,8 +438,11 @@ class Client(Methods, BaseClient):
self.stop()
def run(self):
- """Use this method to automatically start and idle a Client.
- Requires no parameters.
+ """Use this method as a convenience shortcut to automatically start the Client and idle the main script.
+
+ This is a convenience method that literally just calls :meth:`start` and :meth:`idle`. It makes running a client
+ less verbose, but is not suitable in case you want to run more than one client in a single main script,
+ since :meth:`idle` will block.
Raises:
:class:`RPCError ` in case of a Telegram RPC error.
@@ -465,7 +475,7 @@ class Client(Methods, BaseClient):
return handler, group
def remove_handler(self, handler: Handler, group: int = 0):
- """Removes a previously-added update handler.
+ """Use this method to remove a previously-registered update handler.
Make sure to provide the right group that the handler was added in. You can use
the return value of the :meth:`add_handler` method, a tuple of (handler, group), and
@@ -752,9 +762,16 @@ class Client(Methods, BaseClient):
print("Logged in successfully as {}".format(r.user.first_name))
- def fetch_peers(self, entities: List[Union[types.User,
- types.Chat, types.ChatForbidden,
- types.Channel, types.ChannelForbidden]]):
+ def fetch_peers(
+ self,
+ entities: List[
+ Union[
+ types.User,
+ types.Chat, types.ChatForbidden,
+ types.Channel, types.ChannelForbidden
+ ]
+ ]
+ ):
for entity in entities:
if isinstance(entity, types.User):
user_id = entity.id
@@ -1018,16 +1035,19 @@ class Client(Methods, BaseClient):
log.debug("{} stopped".format(name))
- def send(self,
- data: Object,
- retries: int = Session.MAX_RETRIES,
- timeout: float = Session.WAIT_TIMEOUT):
- """Use this method to send Raw Function queries.
+ def send(self, data: Object, retries: int = Session.MAX_RETRIES, timeout: float = Session.WAIT_TIMEOUT):
+ """Use this method to send raw Telegram queries.
- This method makes possible to manually call every single Telegram API method in a low-level manner.
+ This method makes it possible to manually call every single Telegram API method in a low-level manner.
Available functions are listed in the :obj:`functions ` package and may accept compound
data types from :obj:`types ` as well as bare types such as ``int``, ``str``, etc...
+ .. note::
+
+ This is a utility method intended to be used **only** when working with raw
+ :obj:`functions ` (i.e: a Telegram API method you wish to use which is not
+ available yet in the Client class as an easy-to-use method).
+
Args:
data (``Object``):
The API Schema function filled with proper arguments.
@@ -1285,8 +1305,7 @@ class Client(Methods, BaseClient):
indent=4
)
- def get_initial_dialogs_chunk(self,
- offset_date: int = 0):
+ def get_initial_dialogs_chunk(self, offset_date: int = 0):
while True:
try:
r = self.send(
@@ -1318,13 +1337,15 @@ class Client(Methods, BaseClient):
self.get_initial_dialogs_chunk()
- def resolve_peer(self,
- peer_id: Union[int, str]):
- """Use this method to get the InputPeer of a known peer_id.
+ def resolve_peer(self, peer_id: Union[int, str]):
+ """Use this method to get the InputPeer of a known peer id.
+ Useful whenever an InputPeer type is required.
- This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
- method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
- InputPeer type is required.
+ .. note::
+
+ This is a utility method intended to be used **only** when working with raw
+ :obj:`functions ` (i.e: a Telegram API method you wish to use which is not
+ available yet in the Client class as an easy-to-use method).
Args:
peer_id (``int`` | ``str``):
@@ -1391,17 +1412,22 @@ class Client(Methods, BaseClient):
except KeyError:
raise PeerIdInvalid
- def save_file(self,
- path: str,
- file_id: int = None,
- file_part: int = 0,
- progress: callable = None,
- progress_args: tuple = ()):
+ def save_file(
+ self,
+ path: str,
+ file_id: int = None,
+ file_part: int = 0,
+ progress: callable = None,
+ progress_args: tuple = ()
+ ):
"""Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
+ Useful whenever an InputFile type is required.
- This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
- method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
- InputFile type is required.
+ .. note::
+
+ This is a utility method intended to be used **only** when working with raw
+ :obj:`functions ` (i.e: a Telegram API method you wish to use which is not
+ available yet in the Client class as an easy-to-use method).
Args:
path (``str``):
From 692befe038e924354aad74a0706b8e0890e7ce3d Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Wed, 8 May 2019 15:40:36 +0200
Subject: [PATCH 034/202] Allow getting more than one reply via get_messages
and replies param Just for fun (and for consistency with the code logic,
since this part is implemented recursively), not really useful and might lead
to frequent flood waits
---
pyrogram/client/types/messages_and_media/messages.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyrogram/client/types/messages_and_media/messages.py b/pyrogram/client/types/messages_and_media/messages.py
index da1a2676..4f78277c 100644
--- a/pyrogram/client/types/messages_and_media/messages.py
+++ b/pyrogram/client/types/messages_and_media/messages.py
@@ -75,7 +75,7 @@ class Messages(PyrogramType, Update):
reply_messages = client.get_messages(
parsed_messages[0].chat.id,
reply_to_message_ids=reply_message_ids,
- replies=0
+ replies=replies - 1
).messages
for message in parsed_messages:
From 920f8ff911d47a8d1a403305bdc4d97892927e34 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Wed, 8 May 2019 16:01:03 +0200
Subject: [PATCH 035/202] Allow unlimited replies to be fetched with
get_messages
---
pyrogram/client/methods/messages/get_messages.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py
index c018a9eb..f03cac93 100644
--- a/pyrogram/client/methods/messages/get_messages.py
+++ b/pyrogram/client/methods/messages/get_messages.py
@@ -55,7 +55,9 @@ class GetMessages(BaseClient):
If *message_ids* is set, this argument will be ignored.
replies (``int``, *optional*):
- The number of subsequent replies to get for each message. Defaults to 1.
+ The number of subsequent replies to get for each message.
+ Pass 0 for no reply at all or -1 for unlimited replies.
+ Defaults to 1.
Returns:
On success and in case *message_ids* or *reply_to_message_ids* was an iterable, the returned value will be a
@@ -80,6 +82,9 @@ class GetMessages(BaseClient):
ids = list(ids) if is_iterable else [ids]
ids = [ids_type(id=i) for i in ids]
+ if replies < 0:
+ replies = (1 << 31) - 1
+
if isinstance(peer, types.InputPeerChannel):
rpc = functions.channels.GetMessages(channel=peer, id=ids)
else:
From ee91e6daa1e051cc6fd6cf9e676e19465fd39f46 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Wed, 8 May 2019 19:52:21 +0200
Subject: [PATCH 036/202] Rename bots folder to keyboards
---
pyrogram/client/filters/filters.py | 2 +-
pyrogram/client/types/__init__.py | 2 +-
pyrogram/client/types/{bots => keyboards}/__init__.py | 0
pyrogram/client/types/{bots => keyboards}/callback_game.py | 0
pyrogram/client/types/{bots => keyboards}/callback_query.py | 0
pyrogram/client/types/{bots => keyboards}/force_reply.py | 0
pyrogram/client/types/{bots => keyboards}/game_high_score.py | 0
pyrogram/client/types/{bots => keyboards}/game_high_scores.py | 0
.../client/types/{bots => keyboards}/inline_keyboard_button.py | 0
.../client/types/{bots => keyboards}/inline_keyboard_markup.py | 0
pyrogram/client/types/{bots => keyboards}/keyboard_button.py | 0
.../client/types/{bots => keyboards}/reply_keyboard_markup.py | 0
.../client/types/{bots => keyboards}/reply_keyboard_remove.py | 0
13 files changed, 2 insertions(+), 2 deletions(-)
rename pyrogram/client/types/{bots => keyboards}/__init__.py (100%)
rename pyrogram/client/types/{bots => keyboards}/callback_game.py (100%)
rename pyrogram/client/types/{bots => keyboards}/callback_query.py (100%)
rename pyrogram/client/types/{bots => keyboards}/force_reply.py (100%)
rename pyrogram/client/types/{bots => keyboards}/game_high_score.py (100%)
rename pyrogram/client/types/{bots => keyboards}/game_high_scores.py (100%)
rename pyrogram/client/types/{bots => keyboards}/inline_keyboard_button.py (100%)
rename pyrogram/client/types/{bots => keyboards}/inline_keyboard_markup.py (100%)
rename pyrogram/client/types/{bots => keyboards}/keyboard_button.py (100%)
rename pyrogram/client/types/{bots => keyboards}/reply_keyboard_markup.py (100%)
rename pyrogram/client/types/{bots => keyboards}/reply_keyboard_remove.py (100%)
diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py
index 4c6f0ce3..8f5b9164 100644
--- a/pyrogram/client/filters/filters.py
+++ b/pyrogram/client/filters/filters.py
@@ -19,7 +19,7 @@
import re
from .filter import Filter
-from ..types.bots import InlineKeyboardMarkup, ReplyKeyboardMarkup
+from ..types.keyboards import InlineKeyboardMarkup, ReplyKeyboardMarkup
def create(name: str, func: callable, **kwargs) -> type:
diff --git a/pyrogram/client/types/__init__.py b/pyrogram/client/types/__init__.py
index 120c7ff5..3d430c44 100644
--- a/pyrogram/client/types/__init__.py
+++ b/pyrogram/client/types/__init__.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from .bots import *
+from .keyboards import *
from .inline_mode import *
from .input_media import *
from .input_message_content import *
diff --git a/pyrogram/client/types/bots/__init__.py b/pyrogram/client/types/keyboards/__init__.py
similarity index 100%
rename from pyrogram/client/types/bots/__init__.py
rename to pyrogram/client/types/keyboards/__init__.py
diff --git a/pyrogram/client/types/bots/callback_game.py b/pyrogram/client/types/keyboards/callback_game.py
similarity index 100%
rename from pyrogram/client/types/bots/callback_game.py
rename to pyrogram/client/types/keyboards/callback_game.py
diff --git a/pyrogram/client/types/bots/callback_query.py b/pyrogram/client/types/keyboards/callback_query.py
similarity index 100%
rename from pyrogram/client/types/bots/callback_query.py
rename to pyrogram/client/types/keyboards/callback_query.py
diff --git a/pyrogram/client/types/bots/force_reply.py b/pyrogram/client/types/keyboards/force_reply.py
similarity index 100%
rename from pyrogram/client/types/bots/force_reply.py
rename to pyrogram/client/types/keyboards/force_reply.py
diff --git a/pyrogram/client/types/bots/game_high_score.py b/pyrogram/client/types/keyboards/game_high_score.py
similarity index 100%
rename from pyrogram/client/types/bots/game_high_score.py
rename to pyrogram/client/types/keyboards/game_high_score.py
diff --git a/pyrogram/client/types/bots/game_high_scores.py b/pyrogram/client/types/keyboards/game_high_scores.py
similarity index 100%
rename from pyrogram/client/types/bots/game_high_scores.py
rename to pyrogram/client/types/keyboards/game_high_scores.py
diff --git a/pyrogram/client/types/bots/inline_keyboard_button.py b/pyrogram/client/types/keyboards/inline_keyboard_button.py
similarity index 100%
rename from pyrogram/client/types/bots/inline_keyboard_button.py
rename to pyrogram/client/types/keyboards/inline_keyboard_button.py
diff --git a/pyrogram/client/types/bots/inline_keyboard_markup.py b/pyrogram/client/types/keyboards/inline_keyboard_markup.py
similarity index 100%
rename from pyrogram/client/types/bots/inline_keyboard_markup.py
rename to pyrogram/client/types/keyboards/inline_keyboard_markup.py
diff --git a/pyrogram/client/types/bots/keyboard_button.py b/pyrogram/client/types/keyboards/keyboard_button.py
similarity index 100%
rename from pyrogram/client/types/bots/keyboard_button.py
rename to pyrogram/client/types/keyboards/keyboard_button.py
diff --git a/pyrogram/client/types/bots/reply_keyboard_markup.py b/pyrogram/client/types/keyboards/reply_keyboard_markup.py
similarity index 100%
rename from pyrogram/client/types/bots/reply_keyboard_markup.py
rename to pyrogram/client/types/keyboards/reply_keyboard_markup.py
diff --git a/pyrogram/client/types/bots/reply_keyboard_remove.py b/pyrogram/client/types/keyboards/reply_keyboard_remove.py
similarity index 100%
rename from pyrogram/client/types/bots/reply_keyboard_remove.py
rename to pyrogram/client/types/keyboards/reply_keyboard_remove.py
From 1737ba5f49b1c53945edb82c5b8f0624e03a7a87 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Thu, 9 May 2019 04:28:46 +0200
Subject: [PATCH 037/202] Revamp docs about the main Pyrogram package
---
compiler/api/compiler.py | 5 +-
docs/source/conf.py | 4 +-
docs/source/pyrogram/Client.rst | 162 ---------
docs/source/pyrogram/Decorators.rst | 47 +++
docs/source/pyrogram/Errors.rst | 28 ++
docs/source/pyrogram/Handlers.rst | 37 +-
docs/source/pyrogram/Methods.rst | 270 +++++++++++++++
docs/source/pyrogram/ParseMode.rst | 6 -
docs/source/pyrogram/RPCError.rst | 15 -
docs/source/pyrogram/Types.rst | 127 +++----
docs/source/pyrogram/index.rst | 11 +-
pyrogram/client/client.py | 45 +--
pyrogram/client/filters/filters.py | 48 +--
.../client/handlers/callback_query_handler.py | 6 +-
.../handlers/deleted_messages_handler.py | 8 +-
.../client/handlers/disconnect_handler.py | 4 +-
.../client/handlers/inline_query_handler.py | 8 +-
pyrogram/client/handlers/message_handler.py | 8 +-
pyrogram/client/handlers/poll_handler.py | 2 +-
.../client/handlers/raw_update_handler.py | 4 +-
.../client/handlers/user_status_handler.py | 8 +-
.../methods/bots/answer_callback_query.py | 6 +-
.../methods/bots/answer_inline_query.py | 7 +-
.../methods/bots/get_game_high_scores.py | 8 +-
.../methods/bots/get_inline_bot_results.py | 8 +-
.../methods/bots/request_callback_answer.py | 6 +-
pyrogram/client/methods/bots/send_game.py | 6 +-
.../methods/bots/send_inline_bot_result.py | 4 +-
.../client/methods/bots/set_game_score.py | 7 +-
.../client/methods/chats/delete_chat_photo.py | 6 +-
.../methods/chats/export_chat_invite_link.py | 6 +-
pyrogram/client/methods/chats/get_chat.py | 8 +-
.../client/methods/chats/get_chat_member.py | 6 +-
.../client/methods/chats/get_chat_members.py | 8 +-
.../methods/chats/get_chat_members_count.py | 6 +-
.../client/methods/chats/get_chat_preview.py | 10 +-
pyrogram/client/methods/chats/get_dialogs.py | 6 +-
.../client/methods/chats/get_dialogs_count.py | 4 +-
.../client/methods/chats/iter_chat_members.py | 6 +-
pyrogram/client/methods/chats/iter_dialogs.py | 6 +-
pyrogram/client/methods/chats/join_chat.py | 6 +-
.../client/methods/chats/kick_chat_member.py | 8 +-
pyrogram/client/methods/chats/leave_chat.py | 4 +-
.../client/methods/chats/pin_chat_message.py | 6 +-
.../methods/chats/promote_chat_member.py | 6 +-
.../client/methods/chats/restrict_chat.py | 6 +-
.../methods/chats/restrict_chat_member.py | 6 +-
.../methods/chats/set_chat_description.py | 6 +-
.../client/methods/chats/set_chat_photo.py | 6 +-
.../client/methods/chats/set_chat_title.py | 8 +-
.../client/methods/chats/unban_chat_member.py | 6 +-
.../methods/chats/unpin_chat_message.py | 6 +-
.../methods/chats/update_chat_username.py | 8 +-
.../client/methods/contacts/add_contacts.py | 9 +-
.../methods/contacts/delete_contacts.py | 6 +-
.../client/methods/contacts/get_contacts.py | 7 +-
.../methods/contacts/get_contacts_count.py | 4 +-
.../methods/decorators/on_callback_query.py | 4 +-
.../methods/decorators/on_deleted_messages.py | 4 +-
.../methods/decorators/on_inline_query.py | 2 +-
.../client/methods/decorators/on_message.py | 4 +-
pyrogram/client/methods/decorators/on_poll.py | 2 +-
.../methods/decorators/on_raw_update.py | 2 +-
.../methods/decorators/on_user_status.py | 4 +-
.../methods/messages/delete_messages.py | 6 +-
.../client/methods/messages/download_media.py | 13 +-
.../methods/messages/edit_message_caption.py | 11 +-
.../methods/messages/edit_message_media.py | 6 +-
.../messages/edit_message_reply_markup.py | 9 +-
.../methods/messages/edit_message_text.py | 11 +-
.../methods/messages/forward_messages.py | 13 +-
.../client/methods/messages/get_history.py | 6 +-
.../methods/messages/get_history_count.py | 6 +-
.../client/methods/messages/get_messages.py | 12 +-
.../client/methods/messages/iter_history.py | 6 +-
.../client/methods/messages/retract_vote.py | 6 +-
.../client/methods/messages/send_animation.py | 16 +-
.../client/methods/messages/send_audio.py | 16 +-
.../methods/messages/send_cached_media.py | 11 +-
.../methods/messages/send_chat_action.py | 12 +-
.../client/methods/messages/send_contact.py | 6 +-
.../client/methods/messages/send_document.py | 16 +-
.../client/methods/messages/send_location.py | 6 +-
.../methods/messages/send_media_group.py | 7 +-
.../client/methods/messages/send_message.py | 11 +-
.../client/methods/messages/send_photo.py | 16 +-
pyrogram/client/methods/messages/send_poll.py | 6 +-
.../client/methods/messages/send_sticker.py | 11 +-
.../client/methods/messages/send_venue.py | 6 +-
.../client/methods/messages/send_video.py | 16 +-
.../methods/messages/send_video_note.py | 11 +-
.../client/methods/messages/send_voice.py | 16 +-
pyrogram/client/methods/messages/stop_poll.py | 6 +-
pyrogram/client/methods/messages/vote_poll.py | 6 +-
.../methods/password/change_cloud_password.py | 8 +-
.../methods/password/enable_cloud_password.py | 8 +-
.../methods/password/remove_cloud_password.py | 8 +-
.../users/delete_user_profile_photos.py | 8 +-
pyrogram/client/methods/users/get_me.py | 4 +-
.../methods/users/get_user_profile_photos.py | 6 +-
.../users/get_user_profile_photos_count.py | 6 +-
pyrogram/client/methods/users/get_users.py | 10 +-
.../methods/users/set_user_profile_photo.py | 6 +-
.../client/methods/users/update_username.py | 8 +-
.../client/types/inline_mode/inline_query.py | 8 +-
.../inline_query_result_article.py | 2 +-
.../todo/inline_query_result_audio.py | 2 +-
.../todo/inline_query_result_cached_audio.py | 2 +-
.../inline_query_result_cached_document.py | 2 +-
.../todo/inline_query_result_cached_gif.py | 2 +-
.../inline_query_result_cached_mpeg4_gif.py | 4 +-
.../todo/inline_query_result_cached_photo.py | 2 +-
.../inline_query_result_cached_sticker.py | 2 +-
.../todo/inline_query_result_cached_video.py | 2 +-
.../todo/inline_query_result_cached_voice.py | 2 +-
.../todo/inline_query_result_contact.py | 2 +-
.../todo/inline_query_result_document.py | 2 +-
.../todo/inline_query_result_game.py | 2 +-
.../todo/inline_query_result_gif.py | 2 +-
.../todo/inline_query_result_location.py | 2 +-
.../todo/inline_query_result_mpeg4_gif.py | 2 +-
.../todo/inline_query_result_photo.py | 2 +-
.../todo/inline_query_result_venue.py | 2 +-
.../todo/inline_query_result_video.py | 2 +-
.../todo/inline_query_result_voice.py | 2 +-
.../client/types/input_media/input_media.py | 10 +-
.../input_media/input_media_animation.py | 7 +-
.../types/input_media/input_media_audio.py | 7 +-
.../types/input_media/input_media_document.py | 7 +-
.../types/input_media/input_media_photo.py | 7 +-
.../types/input_media/input_media_video.py | 7 +-
.../types/input_media/input_phone_contact.py | 2 +-
.../input_text_message_content.py | 7 +-
.../client/types/keyboards/callback_query.py | 10 +-
.../client/types/keyboards/force_reply.py | 2 +-
.../client/types/keyboards/game_high_score.py | 2 +-
.../types/keyboards/game_high_scores.py | 4 +-
.../types/keyboards/inline_keyboard_button.py | 2 +-
.../types/keyboards/inline_keyboard_markup.py | 4 +-
.../client/types/keyboards/keyboard_button.py | 2 +-
.../types/keyboards/reply_keyboard_markup.py | 4 +-
.../types/keyboards/reply_keyboard_remove.py | 2 +-
.../types/messages_and_media/animation.py | 2 +-
.../client/types/messages_and_media/audio.py | 4 +-
.../types/messages_and_media/contact.py | 2 +-
.../types/messages_and_media/document.py | 4 +-
.../client/types/messages_and_media/game.py | 6 +-
.../types/messages_and_media/location.py | 2 +-
.../types/messages_and_media/message.py | 316 +++++++++---------
.../messages_and_media/message_entity.py | 4 +-
.../types/messages_and_media/messages.py | 12 +-
.../client/types/messages_and_media/photo.py | 4 +-
.../types/messages_and_media/photo_size.py | 2 +-
.../client/types/messages_and_media/poll.py | 2 +-
.../types/messages_and_media/poll_option.py | 2 +-
.../types/messages_and_media/sticker.py | 4 +-
.../messages_and_media/user_profile_photos.py | 4 +-
.../client/types/messages_and_media/venue.py | 4 +-
.../client/types/messages_and_media/video.py | 4 +-
.../types/messages_and_media/video_note.py | 4 +-
.../client/types/messages_and_media/voice.py | 2 +-
pyrogram/client/types/user_and_chats/chat.py | 4 +-
.../types/user_and_chats/chat_member.py | 12 +-
.../types/user_and_chats/chat_members.py | 2 +-
.../types/user_and_chats/chat_permissions.py | 2 +-
.../client/types/user_and_chats/chat_photo.py | 2 +-
.../types/user_and_chats/chat_preview.py | 2 +-
.../client/types/user_and_chats/dialog.py | 4 +-
.../client/types/user_and_chats/dialogs.py | 4 +-
pyrogram/client/types/user_and_chats/user.py | 2 +-
.../types/user_and_chats/user_status.py | 2 +-
171 files changed, 1116 insertions(+), 919 deletions(-)
delete mode 100644 docs/source/pyrogram/Client.rst
create mode 100644 docs/source/pyrogram/Decorators.rst
create mode 100644 docs/source/pyrogram/Errors.rst
create mode 100644 docs/source/pyrogram/Methods.rst
delete mode 100644 docs/source/pyrogram/ParseMode.rst
delete mode 100644 docs/source/pyrogram/RPCError.rst
diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py
index 6be16ba5..992548fd 100644
--- a/compiler/api/compiler.py
+++ b/compiler/api/compiler.py
@@ -328,15 +328,16 @@ def start():
)
if docstring_args:
- docstring_args = "Args:\n " + "\n ".join(docstring_args)
+ docstring_args = "Parameters:\n " + "\n ".join(docstring_args)
else:
docstring_args = "No parameters required."
docstring_args = "Attributes:\n ID: ``{}``\n\n ".format(c.id) + docstring_args
if c.section == "functions":
- docstring_args += "\n\n Raises:\n :obj:`RPCError `"
docstring_args += "\n\n Returns:\n " + get_docstring_arg_type(c.return_type)
+ docstring_args += "\n\n Raises:\n RPCError: In case of a Telegram RPC error."
+
else:
references = get_references(".".join(filter(None, [c.namespace, c.name])))
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 8acfde42..e08298ef 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -44,6 +44,8 @@ extensions = [
'sphinx.ext.autosummary'
]
+napoleon_use_rtype = False
+
# Don't show source files on docs
html_show_sourcelink = True
@@ -112,7 +114,7 @@ html_theme = 'sphinx_rtd_theme'
#
html_theme_options = {
'canonical_url': "https://docs.pyrogram.ml/",
- 'collapse_navigation': False,
+ 'collapse_navigation': True,
'sticky_navigation': False,
'logo_only': True,
'display_version': True
diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst
deleted file mode 100644
index 5adf4956..00000000
--- a/docs/source/pyrogram/Client.rst
+++ /dev/null
@@ -1,162 +0,0 @@
-Client
-======
-
-.. currentmodule:: pyrogram.Client
-
-.. autoclass:: pyrogram.Client
-
-Utilities
----------
-
-.. autosummary::
- :nosignatures:
-
- start
- stop
- restart
- idle
- run
- add_handler
- remove_handler
- send
- resolve_peer
- save_file
- stop_transmission
-
-Decorators
-----------
-
-.. autosummary::
- :nosignatures:
-
- on_message
- on_callback_query
- on_inline_query
- on_deleted_messages
- on_user_status
- on_disconnect
- on_raw_update
-
-Messages
---------
-
-.. autosummary::
- :nosignatures:
-
- send_message
- forward_messages
- send_photo
- send_audio
- send_document
- send_sticker
- send_video
- send_animation
- send_voice
- send_video_note
- send_media_group
- send_location
- send_venue
- send_contact
- send_cached_media
- send_chat_action
- edit_message_text
- edit_message_caption
- edit_message_reply_markup
- edit_message_media
- delete_messages
- get_messages
- get_history
- get_history_count
- iter_history
- send_poll
- vote_poll
- stop_poll
- retract_vote
- download_media
-
-Chats
------
-
-.. autosummary::
- :nosignatures:
-
- join_chat
- leave_chat
- kick_chat_member
- unban_chat_member
- restrict_chat_member
- promote_chat_member
- export_chat_invite_link
- set_chat_photo
- delete_chat_photo
- set_chat_title
- set_chat_description
- pin_chat_message
- unpin_chat_message
- get_chat
- get_chat_preview
- get_chat_member
- get_chat_members
- get_chat_members_count
- iter_chat_members
- get_dialogs
- iter_dialogs
- get_dialogs_count
- restrict_chat
- update_chat_username
-
-Users
------
-
-.. autosummary::
- :nosignatures:
-
- get_me
- get_users
- get_user_profile_photos
- get_user_profile_photos_count
- set_user_profile_photo
- delete_user_profile_photos
- update_username
-
-Contacts
---------
-
-.. autosummary::
- :nosignatures:
-
- add_contacts
- get_contacts
- get_contacts_count
- delete_contacts
-
-Password
---------
-
-.. autosummary::
- :nosignatures:
-
- enable_cloud_password
- change_cloud_password
- remove_cloud_password
-
-Bots
-----
-
-.. autosummary::
- :nosignatures:
-
- get_inline_bot_results
- send_inline_bot_result
- answer_callback_query
- answer_inline_query
- request_callback_answer
- send_game
- set_game_score
- get_game_high_scores
- answer_inline_query
-
-
-.. autoclass:: pyrogram.Client
- :inherited-members:
- :members:
diff --git a/docs/source/pyrogram/Decorators.rst b/docs/source/pyrogram/Decorators.rst
new file mode 100644
index 00000000..a9cd70c7
--- /dev/null
+++ b/docs/source/pyrogram/Decorators.rst
@@ -0,0 +1,47 @@
+Decorators
+==========
+
+While still being methods bound to the :obj:`Client` class, decorators are of a special kind and thus deserve a
+dedicated page.
+
+Decorators are able to register callback functions for handling updates in a much easier and cleaner way compared to
+`Handlers `_; they do so by instantiating the correct handler and calling
+:meth:`add_handler() `, automatically. All you need to do is adding the decorators on top
+of your functions.
+
+**Example:**
+
+.. code-block:: python
+
+ from pyrogram import Client
+
+ app = Client(...)
+
+
+ @app.on_message()
+ def log(client, message):
+ print(message)
+
+
+ app.run()
+
+.. currentmodule:: pyrogram.Client
+
+.. autosummary::
+ :nosignatures:
+
+ on_message
+ on_callback_query
+ on_inline_query
+ on_deleted_messages
+ on_user_status
+ on_disconnect
+ on_raw_update
+
+.. automethod:: pyrogram.Client.on_message()
+.. automethod:: pyrogram.Client.on_callback_query()
+.. automethod:: pyrogram.Client.on_inline_query()
+.. automethod:: pyrogram.Client.on_deleted_messages()
+.. automethod:: pyrogram.Client.on_user_status()
+.. automethod:: pyrogram.Client.on_disconnect()
+.. automethod:: pyrogram.Client.on_raw_update()
\ No newline at end of file
diff --git a/docs/source/pyrogram/Errors.rst b/docs/source/pyrogram/Errors.rst
new file mode 100644
index 00000000..6c816a72
--- /dev/null
+++ b/docs/source/pyrogram/Errors.rst
@@ -0,0 +1,28 @@
+Errors
+======
+
+All the Pyrogram errors listed here live inside the ``errors`` sub-package.
+
+**Example:**
+
+.. code-block:: python
+
+ from pyrogram.errors import RPCError
+
+ try:
+ ...
+ except RPCError:
+ ...
+
+.. autoexception:: pyrogram.RPCError()
+ :members:
+
+.. toctree::
+ ../errors/SeeOther
+ ../errors/BadRequest
+ ../errors/Unauthorized
+ ../errors/Forbidden
+ ../errors/NotAcceptable
+ ../errors/Flood
+ ../errors/InternalServerError
+ ../errors/UnknownError
diff --git a/docs/source/pyrogram/Handlers.rst b/docs/source/pyrogram/Handlers.rst
index 1bb16ece..7140897b 100644
--- a/docs/source/pyrogram/Handlers.rst
+++ b/docs/source/pyrogram/Handlers.rst
@@ -1,6 +1,29 @@
Handlers
========
+Handlers are used to instruct Pyrogram about which kind of updates you'd like to handle with your callback functions.
+
+For a much more convenient way of registering callback functions have a look at `Decorators `_ instead.
+In case you decided to manually create an handler, use :meth:`add_handler() ` to register
+it.
+
+**Example:**
+
+.. code-block:: python
+
+ from pyrogram import Client, MessageHandler
+
+ app = Client(...)
+
+
+ def dump(client, message):
+ print(message)
+
+
+ app.add_handler(MessageHandler(dump))
+
+ app.run()
+
.. currentmodule:: pyrogram
.. autosummary::
@@ -14,24 +37,24 @@ Handlers
DisconnectHandler
RawUpdateHandler
-.. autoclass:: MessageHandler
+.. autoclass:: MessageHandler()
:members:
-.. autoclass:: DeletedMessagesHandler
+.. autoclass:: DeletedMessagesHandler()
:members:
-.. autoclass:: CallbackQueryHandler
+.. autoclass:: CallbackQueryHandler()
:members:
-.. autoclass:: InlineQueryHandler
+.. autoclass:: InlineQueryHandler()
:members:
-.. autoclass:: UserStatusHandler
+.. autoclass:: UserStatusHandler()
:members:
-.. autoclass:: DisconnectHandler
+.. autoclass:: DisconnectHandler()
:members:
-.. autoclass:: RawUpdateHandler
+.. autoclass:: RawUpdateHandler()
:members:
diff --git a/docs/source/pyrogram/Methods.rst b/docs/source/pyrogram/Methods.rst
new file mode 100644
index 00000000..d0387790
--- /dev/null
+++ b/docs/source/pyrogram/Methods.rst
@@ -0,0 +1,270 @@
+Methods
+=======
+
+All Pyrogram methods listed here are bound to a :obj:`Client ` instance.
+
+**Example:**
+
+.. code-block:: python
+
+ from pyrogram import Client
+
+ app = Client(...)
+
+ with app:
+ app.send_message("haskell", "hi")
+
+.. currentmodule:: pyrogram.Client
+
+Utilities
+---------
+
+.. autosummary::
+ :nosignatures:
+
+ start
+ stop
+ restart
+ idle
+ run
+ add_handler
+ remove_handler
+ send
+ resolve_peer
+ save_file
+ stop_transmission
+
+Messages
+--------
+
+.. autosummary::
+ :nosignatures:
+
+ send_message
+ forward_messages
+ send_photo
+ send_audio
+ send_document
+ send_sticker
+ send_video
+ send_animation
+ send_voice
+ send_video_note
+ send_media_group
+ send_location
+ send_venue
+ send_contact
+ send_cached_media
+ send_chat_action
+ edit_message_text
+ edit_message_caption
+ edit_message_reply_markup
+ edit_message_media
+ delete_messages
+ get_messages
+ get_history
+ get_history_count
+ iter_history
+ send_poll
+ vote_poll
+ stop_poll
+ retract_vote
+ download_media
+
+Chats
+-----
+
+.. autosummary::
+ :nosignatures:
+
+ join_chat
+ leave_chat
+ kick_chat_member
+ unban_chat_member
+ restrict_chat_member
+ promote_chat_member
+ export_chat_invite_link
+ set_chat_photo
+ delete_chat_photo
+ set_chat_title
+ set_chat_description
+ pin_chat_message
+ unpin_chat_message
+ get_chat
+ get_chat_preview
+ get_chat_member
+ get_chat_members
+ get_chat_members_count
+ iter_chat_members
+ get_dialogs
+ iter_dialogs
+ get_dialogs_count
+ restrict_chat
+ update_chat_username
+
+Users
+-----
+
+.. autosummary::
+ :nosignatures:
+
+ get_me
+ get_users
+ get_user_profile_photos
+ get_user_profile_photos_count
+ set_user_profile_photo
+ delete_user_profile_photos
+ update_username
+
+Contacts
+--------
+
+.. autosummary::
+ :nosignatures:
+
+ add_contacts
+ get_contacts
+ get_contacts_count
+ delete_contacts
+
+Password
+--------
+
+.. autosummary::
+ :nosignatures:
+
+ enable_cloud_password
+ change_cloud_password
+ remove_cloud_password
+
+Bots
+----
+
+.. autosummary::
+ :nosignatures:
+
+ get_inline_bot_results
+ send_inline_bot_result
+ answer_callback_query
+ answer_inline_query
+ request_callback_answer
+ send_game
+ set_game_score
+ get_game_high_scores
+ answer_inline_query
+
+.. Utilities
+ ---------
+
+.. automethod:: pyrogram.Client.start()
+.. automethod:: pyrogram.Client.stop()
+.. automethod:: pyrogram.Client.restart()
+.. automethod:: pyrogram.Client.idle()
+.. automethod:: pyrogram.Client.run()
+.. automethod:: pyrogram.Client.add_handler()
+.. automethod:: pyrogram.Client.remove_handler()
+.. automethod:: pyrogram.Client.send()
+.. automethod:: pyrogram.Client.resolve_peer()
+.. automethod:: pyrogram.Client.save_file()
+.. automethod:: pyrogram.Client.stop_transmission()
+
+.. Messages
+ --------
+
+.. automethod:: pyrogram.Client.send_message()
+.. automethod:: pyrogram.Client.forward_messages()
+.. automethod:: pyrogram.Client.send_photo()
+.. automethod:: pyrogram.Client.send_audio()
+.. automethod:: pyrogram.Client.send_document()
+.. automethod:: pyrogram.Client.send_sticker()
+.. automethod:: pyrogram.Client.send_video()
+.. automethod:: pyrogram.Client.send_animation()
+.. automethod:: pyrogram.Client.send_voice()
+.. automethod:: pyrogram.Client.send_video_note()
+.. automethod:: pyrogram.Client.send_media_group()
+.. automethod:: pyrogram.Client.send_location()
+.. automethod:: pyrogram.Client.send_venue()
+.. automethod:: pyrogram.Client.send_contact()
+.. automethod:: pyrogram.Client.send_cached_media()
+.. automethod:: pyrogram.Client.send_chat_action()
+.. automethod:: pyrogram.Client.edit_message_text()
+.. automethod:: pyrogram.Client.edit_message_caption()
+.. automethod:: pyrogram.Client.edit_message_reply_markup()
+.. automethod:: pyrogram.Client.edit_message_media()
+.. automethod:: pyrogram.Client.delete_messages()
+.. automethod:: pyrogram.Client.get_messages()
+.. automethod:: pyrogram.Client.get_history()
+.. automethod:: pyrogram.Client.get_history_count()
+.. automethod:: pyrogram.Client.iter_history()
+.. automethod:: pyrogram.Client.send_poll()
+.. automethod:: pyrogram.Client.vote_poll()
+.. automethod:: pyrogram.Client.stop_poll()
+.. automethod:: pyrogram.Client.retract_vote()
+.. automethod:: pyrogram.Client.download_media()
+
+.. Chats
+ -----
+
+.. automethod:: pyrogram.Client.join_chat()
+.. automethod:: pyrogram.Client.leave_chat()
+.. automethod:: pyrogram.Client.kick_chat_member()
+.. automethod:: pyrogram.Client.unban_chat_member()
+.. automethod:: pyrogram.Client.restrict_chat_member()
+.. automethod:: pyrogram.Client.promote_chat_member()
+.. automethod:: pyrogram.Client.export_chat_invite_link()
+.. automethod:: pyrogram.Client.set_chat_photo()
+.. automethod:: pyrogram.Client.delete_chat_photo()
+.. automethod:: pyrogram.Client.set_chat_title()
+.. automethod:: pyrogram.Client.set_chat_description()
+.. automethod:: pyrogram.Client.pin_chat_message()
+.. automethod:: pyrogram.Client.unpin_chat_message()
+.. automethod:: pyrogram.Client.get_chat()
+.. automethod:: pyrogram.Client.get_chat_preview()
+.. automethod:: pyrogram.Client.get_chat_member()
+.. automethod:: pyrogram.Client.get_chat_members()
+.. automethod:: pyrogram.Client.get_chat_members_count()
+.. automethod:: pyrogram.Client.iter_chat_members()
+.. automethod:: pyrogram.Client.get_dialogs()
+.. automethod:: pyrogram.Client.iter_dialogs()
+.. automethod:: pyrogram.Client.get_dialogs_count()
+.. automethod:: pyrogram.Client.restrict_chat()
+.. automethod:: pyrogram.Client.update_chat_username()
+
+.. Users
+ -----
+
+.. automethod:: pyrogram.Client.get_me()
+.. automethod:: pyrogram.Client.get_users()
+.. automethod:: pyrogram.Client.get_user_profile_photos()
+.. automethod:: pyrogram.Client.get_user_profile_photos_count()
+.. automethod:: pyrogram.Client.set_user_profile_photo()
+.. automethod:: pyrogram.Client.delete_user_profile_photos()
+.. automethod:: pyrogram.Client.update_username()
+
+.. Contacts
+ --------
+
+.. automethod:: pyrogram.Client.add_contacts()
+.. automethod:: pyrogram.Client.get_contacts()
+.. automethod:: pyrogram.Client.get_contacts_count()
+.. automethod:: pyrogram.Client.delete_contacts()
+
+.. Password
+ --------
+
+.. automethod:: pyrogram.Client.enable_cloud_password()
+.. automethod:: pyrogram.Client.change_cloud_password()
+.. automethod:: pyrogram.Client.remove_cloud_password()
+
+.. Bots
+ ----
+
+.. automethod:: pyrogram.Client.get_inline_bot_results()
+.. automethod:: pyrogram.Client.send_inline_bot_result()
+.. automethod:: pyrogram.Client.answer_callback_query()
+.. automethod:: pyrogram.Client.answer_inline_query()
+.. automethod:: pyrogram.Client.request_callback_answer()
+.. automethod:: pyrogram.Client.send_game()
+.. automethod:: pyrogram.Client.set_game_score()
+.. automethod:: pyrogram.Client.get_game_high_scores()
+.. automethod:: pyrogram.Client.answer_inline_query()
\ No newline at end of file
diff --git a/docs/source/pyrogram/ParseMode.rst b/docs/source/pyrogram/ParseMode.rst
deleted file mode 100644
index 6a4e0bbb..00000000
--- a/docs/source/pyrogram/ParseMode.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-ParseMode
-=========
-
-.. autoclass:: pyrogram.ParseMode
- :members:
- :undoc-members:
diff --git a/docs/source/pyrogram/RPCError.rst b/docs/source/pyrogram/RPCError.rst
deleted file mode 100644
index a47c9b9c..00000000
--- a/docs/source/pyrogram/RPCError.rst
+++ /dev/null
@@ -1,15 +0,0 @@
-RPCError
-========
-
-.. autoexception:: pyrogram.RPCError
- :members:
-
-.. toctree::
- ../errors/SeeOther
- ../errors/BadRequest
- ../errors/Unauthorized
- ../errors/Forbidden
- ../errors/NotAcceptable
- ../errors/Flood
- ../errors/InternalServerError
- ../errors/UnknownError
diff --git a/docs/source/pyrogram/Types.rst b/docs/source/pyrogram/Types.rst
index 5deb58b2..52e97107 100644
--- a/docs/source/pyrogram/Types.rst
+++ b/docs/source/pyrogram/Types.rst
@@ -1,6 +1,19 @@
Types
=====
+All Pyrogram types listed here are accessible through the main package directly.
+
+**Example:**
+
+.. code-block:: python
+
+ from pyrogram import User, Message, ...
+
+.. note::
+
+ **Optional** fields may not exist when irrelevant -- i.e.: they will contain the value of ``None`` and aren't shown
+ when, for example, using ``print()``.
+
.. currentmodule:: pyrogram
Users & Chats
@@ -42,11 +55,12 @@ Messages & Media
Location
Venue
Sticker
+ Game
Poll
PollOption
-Bots
-----
+Keyboards
+---------
.. autosummary::
:nosignatures:
@@ -58,7 +72,8 @@ Bots
InlineKeyboardButton
ForceReply
CallbackQuery
- Game
+ GameHighScore
+ CallbackGame
Input Media
-----------
@@ -96,168 +111,168 @@ InputMessageContent
.. User & Chats
------------
-.. autoclass:: User
+.. autoclass:: User()
:members:
-.. autoclass:: UserStatus
+.. autoclass:: UserStatus()
:members:
-.. autoclass:: Chat
+.. autoclass:: Chat()
:members:
-.. autoclass:: ChatPreview
+.. autoclass:: ChatPreview()
:members:
-.. autoclass:: ChatPhoto
+.. autoclass:: ChatPhoto()
:members:
-.. autoclass:: ChatMember
+.. autoclass:: ChatMember()
:members:
-.. autoclass:: ChatMembers
+.. autoclass:: ChatMembers()
:members:
-.. autoclass:: ChatPermissions
+.. autoclass:: ChatPermissions()
:members:
-.. autoclass:: Dialog
+.. autoclass:: Dialog()
:members:
-.. autoclass:: Dialogs
+.. autoclass:: Dialogs()
:members:
.. Messages & Media
----------------
-.. autoclass:: Message
+.. autoclass:: Message()
:members:
-.. autoclass:: Messages
+.. autoclass:: Messages()
:members:
-.. autoclass:: MessageEntity
+.. autoclass:: MessageEntity()
:members:
-.. autoclass:: Photo
+.. autoclass:: Photo()
:members:
-.. autoclass:: PhotoSize
+.. autoclass:: PhotoSize()
:members:
-.. autoclass:: UserProfilePhotos
+.. autoclass:: UserProfilePhotos()
:members:
-.. autoclass:: Audio
+.. autoclass:: Audio()
:members:
-.. autoclass:: Document
+.. autoclass:: Document()
:members:
-.. autoclass:: Animation
+.. autoclass:: Animation()
:members:
-.. autoclass:: Video
+.. autoclass:: Video()
:members:
-.. autoclass:: Voice
+.. autoclass:: Voice()
:members:
-.. autoclass:: VideoNote
+.. autoclass:: VideoNote()
:members:
-.. autoclass:: Contact
+.. autoclass:: Contact()
:members:
-.. autoclass:: Location
+.. autoclass:: Location()
:members:
-.. autoclass:: Venue
+.. autoclass:: Venue()
:members:
-.. autoclass:: Sticker
+.. autoclass:: Sticker()
:members:
-.. autoclass:: Poll
+.. autoclass:: Game()
:members:
-.. autoclass:: PollOption
+.. autoclass:: Poll()
:members:
-.. Bots
- ----
-
-.. autoclass:: ReplyKeyboardMarkup
+.. autoclass:: PollOption()
:members:
-.. autoclass:: KeyboardButton
+.. Keyboards
+ ---------
+
+.. autoclass:: ReplyKeyboardMarkup()
:members:
-.. autoclass:: ReplyKeyboardRemove
+.. autoclass:: KeyboardButton()
:members:
-.. autoclass:: InlineKeyboardMarkup
+.. autoclass:: ReplyKeyboardRemove()
:members:
-.. autoclass:: InlineKeyboardButton
+.. autoclass:: InlineKeyboardMarkup()
:members:
-.. autoclass:: ForceReply
+.. autoclass:: InlineKeyboardButton()
:members:
-.. autoclass:: CallbackQuery
+.. autoclass:: ForceReply()
:members:
-.. autoclass:: Game
+.. autoclass:: CallbackQuery()
:members:
-.. autoclass:: GameHighScore
+.. autoclass:: GameHighScore()
:members:
-.. autoclass:: GameHighScores
+.. autoclass:: CallbackGame()
:members:
.. Input Media
-----------
-.. autoclass:: InputMedia
+.. autoclass:: InputMedia()
:members:
-.. autoclass:: InputMediaPhoto
+.. autoclass:: InputMediaPhoto()
:members:
-.. autoclass:: InputMediaVideo
+.. autoclass:: InputMediaVideo()
:members:
-.. autoclass:: InputMediaAudio
+.. autoclass:: InputMediaAudio()
:members:
-.. autoclass:: InputMediaAnimation
+.. autoclass:: InputMediaAnimation()
:members:
-.. autoclass:: InputMediaDocument
+.. autoclass:: InputMediaDocument()
:members:
-.. autoclass:: InputPhoneContact
+.. autoclass:: InputPhoneContact()
:members:
.. Inline Mode
-----------
-.. autoclass:: InlineQuery
+.. autoclass:: InlineQuery()
:members:
-.. autoclass:: InlineQueryResult
+.. autoclass:: InlineQueryResult()
:members:
-.. autoclass:: InlineQueryResultArticle
+.. autoclass:: InlineQueryResultArticle()
:members:
.. InputMessageContent
-------------------
-.. autoclass:: InputMessageContent
+.. autoclass:: InputMessageContent()
:members:
-.. autoclass:: InputTextMessageContent
+.. autoclass:: InputTextMessageContent()
:members:
diff --git a/docs/source/pyrogram/index.rst b/docs/source/pyrogram/index.rst
index 286b5db1..84471e89 100644
--- a/docs/source/pyrogram/index.rst
+++ b/docs/source/pyrogram/index.rst
@@ -4,17 +4,18 @@ Pyrogram
In this section you can find a detailed description of the Pyrogram package and its API.
:class:`Client ` is the main class. It exposes easy-to-use methods that are named
-after the well established `Telegram Bot API`_ methods, thus offering a familiar look to Bot developers.
+after the well established Telegram Bot API methods, thus offering a familiar look to Bot developers.
.. toctree::
:maxdepth: 1
- Client
Types
+ Methods
Handlers
+ Decorators
Filters
ChatAction
- ParseMode
- RPCError
+ Errors
-.. _Telegram Bot API: https://core.telegram.org/bots/api#available-methods
+
+.. autoclass:: pyrogram.Client()
diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py
index 610a0d0c..823faf27 100644
--- a/pyrogram/client/client.py
+++ b/pyrogram/client/client.py
@@ -64,7 +64,7 @@ class Client(Methods, BaseClient):
It exposes bot-like methods for an easy access to the API as well as a simple way to
invoke every single Telegram API method available.
- Args:
+ Parameters:
session_name (``str``):
Name to uniquely identify a session of either a User or a Bot, e.g.: "my_account". This name will be used
to save a file to disk that stores details needed for reconnecting without asking again for credentials.
@@ -264,8 +264,8 @@ class Client(Methods, BaseClient):
"""Use this method to start the Client.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ConnectionError`` in case you try to start an already started Client.
+ RPCError: 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")
@@ -357,7 +357,7 @@ class Client(Methods, BaseClient):
"""Use this method to stop the Client.
Raises:
- ``ConnectionError`` in case you try to stop an already stopped Client.
+ ConnectionError: In case you try to stop an already stopped Client.
"""
if not self.is_started:
raise ConnectionError("Client is already stopped")
@@ -399,7 +399,7 @@ class Client(Methods, BaseClient):
"""Use this method to restart the Client.
Raises:
- ``ConnectionError`` in case you try to restart a stopped Client.
+ ConnectionError: In case you try to restart a stopped Client.
"""
self.stop()
self.start()
@@ -416,7 +416,7 @@ class Client(Methods, BaseClient):
the main script; calling idle() will ensure the client(s) will be kept alive by not letting the main script to
end, until you decide to quit.
- Args:
+ Parameters:
stop_signals (``tuple``, *optional*):
Iterable containing signals the signal handler will listen to.
Defaults to (SIGINT, SIGTERM, SIGABRT).
@@ -445,7 +445,7 @@ class Client(Methods, BaseClient):
since :meth:`idle` will block.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
self.start()
self.idle()
@@ -457,7 +457,7 @@ class Client(Methods, BaseClient):
will be used for a single update. To handle the same update more than once, register
your handler using a different group id (lower group id == higher priority).
- Args:
+ Parameters:
handler (``Handler``):
The handler to be registered.
@@ -465,7 +465,7 @@ class Client(Methods, BaseClient):
The group identifier, defaults to 0.
Returns:
- A tuple of (handler, group)
+ ``tuple``: A tuple consisting of (handler, group).
"""
if isinstance(handler, DisconnectHandler):
self.disconnect_handler = handler.callback
@@ -481,7 +481,7 @@ class Client(Methods, BaseClient):
the return value of the :meth:`add_handler` method, a tuple of (handler, group), and
pass it directly.
- Args:
+ Parameters:
handler (``Handler``):
The handler to be removed.
@@ -1048,8 +1048,8 @@ class Client(Methods, BaseClient):
:obj:`functions ` (i.e: a Telegram API method you wish to use which is not
available yet in the Client class as an easy-to-use method).
- Args:
- data (``Object``):
+ Parameters:
+ data (``RawFunction``):
The API Schema function filled with proper arguments.
retries (``int``):
@@ -1058,8 +1058,11 @@ class Client(Methods, BaseClient):
timeout (``float``):
Timeout in seconds.
+ Returns:
+ ``RawType``: The raw type response generated by the query.
+
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
if not self.is_started:
raise ConnectionError("Client has not been started")
@@ -1347,17 +1350,17 @@ class Client(Methods, BaseClient):
:obj:`functions ` (i.e: a Telegram API method you wish to use which is not
available yet in the Client class as an easy-to-use method).
- Args:
+ Parameters:
peer_id (``int`` | ``str``):
The peer id you want to extract the InputPeer from.
Can be a direct id (int), a username (str) or a phone number (str).
Returns:
- On success, the resolved peer id is returned in form of an InputPeer object.
+ ``InputPeer``: On success, the resolved peer id is returned in form of an InputPeer object.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``KeyError`` in case the peer doesn't exist in the internal database.
+ RPCError: In case of a Telegram RPC error.
+ KeyError: In case the peer doesn't exist in the internal database.
"""
try:
return self.peers_by_id[peer_id]
@@ -1429,7 +1432,7 @@ class Client(Methods, BaseClient):
:obj:`functions ` (i.e: a Telegram API method you wish to use which is not
available yet in the Client class as an easy-to-use method).
- Args:
+ Parameters:
path (``str``):
The path of the file you want to upload that exists on your local machine.
@@ -1449,7 +1452,7 @@ class Client(Methods, BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -1463,10 +1466,10 @@ class Client(Methods, BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the uploaded file is returned in form of an InputFile object.
+ ``InputFile``: On success, the uploaded file is returned in form of an InputFile object.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
part_size = 512 * 1024
file_size = os.path.getsize(path)
diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py
index 8f5b9164..5070bd52 100644
--- a/pyrogram/client/filters/filters.py
+++ b/pyrogram/client/filters/filters.py
@@ -27,7 +27,7 @@ def create(name: str, func: callable, **kwargs) -> type:
Custom filters give you extra control over which updates are allowed or not to be processed by your handlers.
- Args:
+ Parameters:
name (``str``):
Your filter's name. Can be anything you like.
@@ -35,9 +35,9 @@ def create(name: str, func: callable, **kwargs) -> type:
A function that accepts two arguments *(filter, update)* and returns a Boolean: True if the update should be
handled, False otherwise.
The "update" argument type will vary depending on which `Handler `_ is coming from.
- For example, in a :obj:`MessageHandler ` the update type will be
- a :obj:`Message `; in a :obj:`CallbackQueryHandler ` the
- update type will be a :obj:`CallbackQuery `. Your function body can then access the
+ For example, in a :obj:`MessageHandler` the update type will be
+ a :obj:`Message`; in a :obj:`CallbackQueryHandler` the
+ update type will be a :obj:`CallbackQuery`. Your function body can then access the
incoming update and decide whether to allow it or not.
**kwargs (``any``, *optional*):
@@ -54,7 +54,7 @@ def create(name: str, func: callable, **kwargs) -> type:
class Filters:
"""This class provides access to all library-defined Filters available in Pyrogram.
- The Filters listed here are intended to be used with the :obj:`MessageHandler ` only.
+ The Filters listed here are intended to be used with the :obj:`MessageHandler` only.
At the moment, if you want to filter updates coming from different `Handlers `_ you have to create
your own filters with :meth:`Filters.create` and use them in the same way.
"""
@@ -89,49 +89,49 @@ class Filters:
"""Filter edited messages."""
audio = create("Audio", lambda _, m: bool(m.audio))
- """Filter messages that contain :obj:`Audio ` objects."""
+ """Filter messages that contain :obj:`Audio` objects."""
document = create("Document", lambda _, m: bool(m.document))
- """Filter messages that contain :obj:`Document ` objects."""
+ """Filter messages that contain :obj:`Document` objects."""
photo = create("Photo", lambda _, m: bool(m.photo))
- """Filter messages that contain :obj:`Photo ` objects."""
+ """Filter messages that contain :obj:`Photo` objects."""
sticker = create("Sticker", lambda _, m: bool(m.sticker))
- """Filter messages that contain :obj:`Sticker ` objects."""
+ """Filter messages that contain :obj:`Sticker` objects."""
animation = create("Animation", lambda _, m: bool(m.animation))
- """Filter messages that contain :obj:`Animation ` objects."""
+ """Filter messages that contain :obj:`Animation` objects."""
game = create("Game", lambda _, m: bool(m.game))
- """Filter messages that contain :obj:`Game ` objects."""
+ """Filter messages that contain :obj:`Game` objects."""
video = create("Video", lambda _, m: bool(m.video))
- """Filter messages that contain :obj:`Video ` objects."""
+ """Filter messages that contain :obj:`Video` objects."""
media_group = create("MediaGroup", lambda _, m: bool(m.media_group_id))
"""Filter messages containing photos or videos being part of an album."""
voice = create("Voice", lambda _, m: bool(m.voice))
- """Filter messages that contain :obj:`Voice ` note objects."""
+ """Filter messages that contain :obj:`Voice` note objects."""
video_note = create("VideoNote", lambda _, m: bool(m.video_note))
- """Filter messages that contain :obj:`VideoNote ` objects."""
+ """Filter messages that contain :obj:`VideoNote` objects."""
contact = create("Contact", lambda _, m: bool(m.contact))
- """Filter messages that contain :obj:`Contact ` objects."""
+ """Filter messages that contain :obj:`Contact` objects."""
location = create("Location", lambda _, m: bool(m.location))
- """Filter messages that contain :obj:`Location ` objects."""
+ """Filter messages that contain :obj:`Location` objects."""
venue = create("Venue", lambda _, m: bool(m.venue))
- """Filter messages that contain :obj:`Venue ` objects."""
+ """Filter messages that contain :obj:`Venue` objects."""
web_page = create("WebPage", lambda _, m: m.web_page)
"""Filter messages sent with a webpage preview."""
poll = create("Poll", lambda _, m: m.poll)
- """Filter messages that contain :obj:`Poll ` objects."""
+ """Filter messages that contain :obj:`Poll` objects."""
private = create("Private", lambda _, m: bool(m.chat and m.chat.type == "private"))
"""Filter messages sent in private chats."""
@@ -230,12 +230,12 @@ class Filters:
):
"""Filter commands, i.e.: text messages starting with "/" or any other custom prefix.
- Args:
+ Parameters:
commands (``str`` | ``list``):
The command or list of commands as string the filter should look for.
Examples: "start", ["start", "help", "settings"]. When a message text containing
a command arrives, the command itself and its arguments will be stored in the *command*
- field of the :class:`Message `.
+ field of the :class:`Message`.
prefix (``str`` | ``list``, *optional*):
A prefix or a list of prefixes as string the filter should look for.
@@ -275,11 +275,11 @@ class Filters:
def regex(pattern, flags: int = 0):
"""Filter messages that match a given RegEx pattern.
- Args:
+ Parameters:
pattern (``str``):
The RegEx pattern as string, it will be applied to the text of a message. When a pattern matches,
all the `Match Objects `_
- are stored in the *matches* field of the :class:`Message ` itself.
+ are stored in the *matches* field of the :class:`Message` itself.
flags (``int``, *optional*):
RegEx flags.
@@ -298,7 +298,7 @@ class Filters:
You can use `set bound methods `_ to manipulate the
users container.
- Args:
+ Parameters:
users (``int`` | ``str`` | ``list``):
Pass one or more user ids/usernames to filter users.
For you yourself, "me" or "self" can be used as well.
@@ -329,7 +329,7 @@ class Filters:
You can use `set bound methods `_ to manipulate the
chats container.
- Args:
+ Parameters:
chats (``int`` | ``str`` | ``list``):
Pass one or more chat ids/usernames to filter chats.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
diff --git a/pyrogram/client/handlers/callback_query_handler.py b/pyrogram/client/handlers/callback_query_handler.py
index 88ddd5a0..feb46cb0 100644
--- a/pyrogram/client/handlers/callback_query_handler.py
+++ b/pyrogram/client/handlers/callback_query_handler.py
@@ -26,17 +26,17 @@ class CallbackQueryHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_callback_query() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
Pass a function that will be called when a new CallbackQuery arrives. It takes *(client, callback_query)*
as positional arguments (look at the section below for a detailed description).
- filters (:obj:`Filters `):
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of callback queries to be passed
in your callback function.
Other parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the message handler.
callback_query (:obj:`CallbackQuery `):
diff --git a/pyrogram/client/handlers/deleted_messages_handler.py b/pyrogram/client/handlers/deleted_messages_handler.py
index 52177dcc..f37caaed 100644
--- a/pyrogram/client/handlers/deleted_messages_handler.py
+++ b/pyrogram/client/handlers/deleted_messages_handler.py
@@ -27,20 +27,20 @@ class DeletedMessagesHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_deleted_messages() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
Pass a function that will be called when one or more Messages have been deleted.
It takes *(client, messages)* as positional arguments (look at the section below for a detailed description).
- filters (:obj:`Filters `):
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of messages to be passed
in your callback function.
Other parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the message handler.
- messages (:obj:`Messages `):
+ messages (:obj:`Messages`):
The deleted messages.
"""
diff --git a/pyrogram/client/handlers/disconnect_handler.py b/pyrogram/client/handlers/disconnect_handler.py
index 1e88a7ee..b9e6350a 100644
--- a/pyrogram/client/handlers/disconnect_handler.py
+++ b/pyrogram/client/handlers/disconnect_handler.py
@@ -26,13 +26,13 @@ class DisconnectHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_disconnect() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
Pass a function that will be called when a disconnection occurs. It takes *(client)*
as positional argument (look at the section below for a detailed description).
Other parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself. Useful, for example, when you want to change the proxy before a new connection
is established.
"""
diff --git a/pyrogram/client/handlers/inline_query_handler.py b/pyrogram/client/handlers/inline_query_handler.py
index c64d49c8..98a25652 100644
--- a/pyrogram/client/handlers/inline_query_handler.py
+++ b/pyrogram/client/handlers/inline_query_handler.py
@@ -26,20 +26,20 @@ class InlineQueryHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_inline_query() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
Pass a function that will be called when a new InlineQuery arrives. It takes *(client, inline_query)*
as positional arguments (look at the section below for a detailed description).
- filters (:obj:`Filters `):
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of inline queries to be passed
in your callback function.
Other parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the inline query handler.
- inline_query (:obj:`InlineQuery `):
+ inline_query (:obj:`InlineQuery`):
The received inline query.
"""
diff --git a/pyrogram/client/handlers/message_handler.py b/pyrogram/client/handlers/message_handler.py
index 67b4587e..10fff479 100644
--- a/pyrogram/client/handlers/message_handler.py
+++ b/pyrogram/client/handlers/message_handler.py
@@ -27,20 +27,20 @@ class MessageHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_message() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
Pass a function that will be called when a new Message arrives. It takes *(client, message)*
as positional arguments (look at the section below for a detailed description).
- filters (:obj:`Filters `):
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of messages to be passed
in your callback function.
Other parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the message handler.
- message (:obj:`Message `):
+ message (:obj:`Message`):
The received message.
"""
diff --git a/pyrogram/client/handlers/poll_handler.py b/pyrogram/client/handlers/poll_handler.py
index 567fcec0..9e97f2ac 100644
--- a/pyrogram/client/handlers/poll_handler.py
+++ b/pyrogram/client/handlers/poll_handler.py
@@ -27,7 +27,7 @@ class PollHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_poll() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
Pass a function that will be called when a new poll update arrives. It takes *(client, poll)*
as positional arguments (look at the section below for a detailed description).
diff --git a/pyrogram/client/handlers/raw_update_handler.py b/pyrogram/client/handlers/raw_update_handler.py
index 3a5dea50..f54d59b6 100644
--- a/pyrogram/client/handlers/raw_update_handler.py
+++ b/pyrogram/client/handlers/raw_update_handler.py
@@ -26,14 +26,14 @@ class RawUpdateHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_raw_update() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
A function that will be called when a new update is received from the server. It takes
*(client, update, users, chats)* as positional arguments (look at the section below for
a detailed description).
Other Parameters:
- client (:class:`Client `):
+ client (:class:`Client`):
The Client itself, useful when you want to call other API methods inside the update handler.
update (``Update``):
diff --git a/pyrogram/client/handlers/user_status_handler.py b/pyrogram/client/handlers/user_status_handler.py
index 856ef81d..1250cb19 100644
--- a/pyrogram/client/handlers/user_status_handler.py
+++ b/pyrogram/client/handlers/user_status_handler.py
@@ -26,20 +26,20 @@ class UserStatusHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_user_status() ` decorator.
- Args:
+ Parameters:
callback (``callable``):
Pass a function that will be called when a new UserStatus update arrives. It takes *(client, user_status)*
as positional arguments (look at the section below for a detailed description).
- filters (:obj:`Filters `):
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of messages to be passed
in your callback function.
Other parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the user status handler.
- user_status (:obj:`UserStatus `):
+ user_status (:obj:`UserStatus`):
The received UserStatus update.
"""
diff --git a/pyrogram/client/methods/bots/answer_callback_query.py b/pyrogram/client/methods/bots/answer_callback_query.py
index 33458db9..12effe47 100644
--- a/pyrogram/client/methods/bots/answer_callback_query.py
+++ b/pyrogram/client/methods/bots/answer_callback_query.py
@@ -32,7 +32,7 @@ class AnswerCallbackQuery(BaseClient):
"""Use this method to send answers to callback queries sent from inline keyboards.
The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
- Args:
+ Parameters:
callback_query_id (``str``):
Unique identifier for the query to be answered.
@@ -54,10 +54,10 @@ class AnswerCallbackQuery(BaseClient):
Telegram apps will support caching starting in version 3.14. Defaults to 0.
Returns:
- True, on success.
+ ``bool``: True, on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
return self.send(
functions.messages.SetBotCallbackAnswer(
diff --git a/pyrogram/client/methods/bots/answer_inline_query.py b/pyrogram/client/methods/bots/answer_inline_query.py
index 7b3524b2..7a1b14c8 100644
--- a/pyrogram/client/methods/bots/answer_inline_query.py
+++ b/pyrogram/client/methods/bots/answer_inline_query.py
@@ -37,7 +37,7 @@ class AnswerInlineQuery(BaseClient):
"""Use this method to send answers to an inline query.
No more than 50 results per query are allowed.
- Args:
+ Parameters:
inline_query_id (``str``):
Unique identifier for the answered query.
@@ -73,7 +73,10 @@ class AnswerInlineQuery(BaseClient):
where they wanted to use the bot's inline capabilities.
Returns:
- On success, True is returned.
+ ``bool``: On success, True is returned.
+
+ Raises:
+ RPCError: In case of a Telegram RPC error.
"""
return self.send(
functions.messages.SetInlineBotResults(
diff --git a/pyrogram/client/methods/bots/get_game_high_scores.py b/pyrogram/client/methods/bots/get_game_high_scores.py
index bb2e99db..64901fea 100644
--- a/pyrogram/client/methods/bots/get_game_high_scores.py
+++ b/pyrogram/client/methods/bots/get_game_high_scores.py
@@ -29,10 +29,10 @@ class GetGameHighScores(BaseClient):
user_id: Union[int, str],
chat_id: Union[int, str],
message_id: int = None
- ):
+ ) -> "pyrogram.GameHighScores":
"""Use this method to get data for high score tables.
- Args:
+ Parameters:
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -49,10 +49,10 @@ class GetGameHighScores(BaseClient):
Required if inline_message_id is not specified.
Returns:
- On success, a :obj:`GameHighScores ` object is returned.
+ :obj:`GameHighScores`: On success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
# TODO: inline_message_id
diff --git a/pyrogram/client/methods/bots/get_inline_bot_results.py b/pyrogram/client/methods/bots/get_inline_bot_results.py
index b12c0439..14628b64 100644
--- a/pyrogram/client/methods/bots/get_inline_bot_results.py
+++ b/pyrogram/client/methods/bots/get_inline_bot_results.py
@@ -35,7 +35,7 @@ class GetInlineBotResults(BaseClient):
"""Use this method to get bot results via inline queries.
You can then send a result using :obj:`send_inline_bot_result `
- Args:
+ Parameters:
bot (``int`` | ``str``):
Unique identifier of the inline bot you want to get results from. You can specify
a @username (str) or a bot ID (int).
@@ -55,11 +55,11 @@ class GetInlineBotResults(BaseClient):
Useful for location-based results only.
Returns:
- On Success, :obj:`BotResults ` is returned.
+ :obj:`BotResults `: On Success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``TimeoutError`` if the bot fails to answer within 10 seconds
+ RPCError: In case of a Telegram RPC error.
+ TimeoutError: In case the bot fails to answer within 10 seconds.
"""
# TODO: Don't return the raw type
diff --git a/pyrogram/client/methods/bots/request_callback_answer.py b/pyrogram/client/methods/bots/request_callback_answer.py
index 7b37f51a..b1d8884f 100644
--- a/pyrogram/client/methods/bots/request_callback_answer.py
+++ b/pyrogram/client/methods/bots/request_callback_answer.py
@@ -32,7 +32,7 @@ class RequestCallbackAnswer(BaseClient):
"""Use this method to request a callback answer from bots.
This is the equivalent of clicking an inline button containing callback data.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -49,8 +49,8 @@ class RequestCallbackAnswer(BaseClient):
or as an alert.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``TimeoutError`` if the bot fails to answer within 10 seconds.
+ RPCError: In case of a Telegram RPC error.
+ TimeoutError: In case the bot fails to answer within 10 seconds.
"""
return self.send(
functions.messages.GetBotCallbackAnswer(
diff --git a/pyrogram/client/methods/bots/send_game.py b/pyrogram/client/methods/bots/send_game.py
index a690c960..03593a56 100644
--- a/pyrogram/client/methods/bots/send_game.py
+++ b/pyrogram/client/methods/bots/send_game.py
@@ -39,7 +39,7 @@ class SendGame(BaseClient):
) -> "pyrogram.Message":
"""Use this method to send a game.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -60,10 +60,10 @@ class SendGame(BaseClient):
If not empty, the first button must launch the game.
Returns:
- On success, the sent :obj:`Message` is returned.
+ :obj:`Message`: On success, the sent game message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(
diff --git a/pyrogram/client/methods/bots/send_inline_bot_result.py b/pyrogram/client/methods/bots/send_inline_bot_result.py
index 9b375a0a..49dc11ee 100644
--- a/pyrogram/client/methods/bots/send_inline_bot_result.py
+++ b/pyrogram/client/methods/bots/send_inline_bot_result.py
@@ -35,7 +35,7 @@ class SendInlineBotResult(BaseClient):
"""Use this method to send an inline bot result.
Bot results can be retrieved using :obj:`get_inline_bot_results `
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -61,7 +61,7 @@ class SendInlineBotResult(BaseClient):
On success, the sent Message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
return self.send(
functions.messages.SendInlineBotResult(
diff --git a/pyrogram/client/methods/bots/set_game_score.py b/pyrogram/client/methods/bots/set_game_score.py
index 434720c6..f5658542 100644
--- a/pyrogram/client/methods/bots/set_game_score.py
+++ b/pyrogram/client/methods/bots/set_game_score.py
@@ -36,7 +36,7 @@ class SetGameScore(BaseClient):
# inline_message_id: str = None): TODO Add inline_message_id
"""Use this method to set the score of the specified user in a game.
- Args:
+ Parameters:
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -63,12 +63,11 @@ class SetGameScore(BaseClient):
Required if inline_message_id is not specified.
Returns:
- On success, if the message was sent by the bot, returns the edited :obj:`Message `,
+ On success, if the message was sent by the bot, returns the edited :obj:`Message`,
otherwise returns True.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- :class:`BotScoreNotModified` if the new score is not greater than the user's current score in the chat and force is False.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SetGameScore(
diff --git a/pyrogram/client/methods/chats/delete_chat_photo.py b/pyrogram/client/methods/chats/delete_chat_photo.py
index c11a0d13..f45a7dc2 100644
--- a/pyrogram/client/methods/chats/delete_chat_photo.py
+++ b/pyrogram/client/methods/chats/delete_chat_photo.py
@@ -35,15 +35,15 @@ class DeleteChatPhoto(BaseClient):
In regular groups (non-supergroups), this method will only work if the "All Members Are Admins"
setting is off.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
``ValueError`` if a chat_id belongs to user.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py
index 16f5bc01..e1ca27c2 100644
--- a/pyrogram/client/methods/chats/export_chat_invite_link.py
+++ b/pyrogram/client/methods/chats/export_chat_invite_link.py
@@ -38,16 +38,16 @@ class ExportChatInviteLink(BaseClient):
using this method – after this the link will become available to the bot via the :meth:`get_chat` method.
If your bot needs to generate a new invite link replacing its previous one, use this method again.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier for the target chat or username of the target channel/supergroup
(in the format @username).
Returns:
- On success, the exported invite link as string is returned.
+ ``str``: On success, the exported invite link is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/get_chat.py b/pyrogram/client/methods/chats/get_chat.py
index 38653459..bf4c4cea 100644
--- a/pyrogram/client/methods/chats/get_chat.py
+++ b/pyrogram/client/methods/chats/get_chat.py
@@ -32,18 +32,18 @@ class GetChat(BaseClient):
Information include current name of the user for one-on-one conversations, current username of a user, group or
channel, etc.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Unique identifier for the target chat in form of a *t.me/joinchat/* link, identifier (int) or username
of the target channel/supergroup (in the format @username).
Returns:
- On success, a :obj:`Chat ` object is returned.
+ :obj:`Chat`: On success, a chat object is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` in case the chat invite link refers to a chat you haven't joined yet.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case the chat invite link points to a chat you haven't joined yet.
"""
match = self.INVITE_LINK_RE.match(str(chat_id))
diff --git a/pyrogram/client/methods/chats/get_chat_member.py b/pyrogram/client/methods/chats/get_chat_member.py
index aec4d233..b625e32f 100644
--- a/pyrogram/client/methods/chats/get_chat_member.py
+++ b/pyrogram/client/methods/chats/get_chat_member.py
@@ -32,7 +32,7 @@ class GetChatMember(BaseClient):
) -> "pyrogram.ChatMember":
"""Use this method to get information about one member of a chat.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -42,10 +42,10 @@ class GetChatMember(BaseClient):
For a contact that exists in your Telegram address book you can use his phone number (str).
Returns:
- On success, a :obj:`ChatMember ` object is returned.
+ :obj:`ChatMember`: On success, a chat member is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
chat_id = self.resolve_peer(chat_id)
user_id = self.resolve_peer(user_id)
diff --git a/pyrogram/client/methods/chats/get_chat_members.py b/pyrogram/client/methods/chats/get_chat_members.py
index 726fd14b..79001614 100644
--- a/pyrogram/client/methods/chats/get_chat_members.py
+++ b/pyrogram/client/methods/chats/get_chat_members.py
@@ -53,7 +53,7 @@ class GetChatMembers(BaseClient):
You must be admin to retrieve the members list of a channel (also known as "subscribers").
For a more convenient way of getting chat members see :meth:`iter_chat_members`.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -86,11 +86,11 @@ class GetChatMembers(BaseClient):
.. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only.
Returns:
- On success, a :obj:`ChatMembers` object is returned.
+ :obj:`ChatMembers`: On success, an object containing a list of chat members is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` if you used an invalid filter or a chat_id that belongs to a user.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case you used an invalid filter or a chat id that belongs to a user.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/get_chat_members_count.py b/pyrogram/client/methods/chats/get_chat_members_count.py
index fc13ac39..d40585f5 100644
--- a/pyrogram/client/methods/chats/get_chat_members_count.py
+++ b/pyrogram/client/methods/chats/get_chat_members_count.py
@@ -29,7 +29,7 @@ class GetChatMembersCount(BaseClient):
) -> int:
"""Use this method to get the number of members in a chat.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -37,8 +37,8 @@ class GetChatMembersCount(BaseClient):
On success, an integer is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` if a chat_id belongs to user.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case a chat id belongs to user.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/get_chat_preview.py b/pyrogram/client/methods/chats/get_chat_preview.py
index 9b6c6955..fd00c374 100644
--- a/pyrogram/client/methods/chats/get_chat_preview.py
+++ b/pyrogram/client/methods/chats/get_chat_preview.py
@@ -30,16 +30,18 @@ class GetChatPreview(BaseClient):
This method only returns a chat preview, if you want to join a chat use :meth:`join_chat`
- Args:
+ Parameters:
invite_link (``str``):
Unique identifier for the target chat in form of *t.me/joinchat/* links.
Returns:
- Either :obj:`Chat` or :obj:`ChatPreview`, depending on whether you already joined the chat or not.
+ :obj:`Chat`: In case you already joined the chat.
+
+ :obj:`ChatPreview` -- In case you haven't joined the chat yet.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` in case of an invalid invite_link.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case of an invalid invite link.
"""
match = self.INVITE_LINK_RE.match(invite_link)
diff --git a/pyrogram/client/methods/chats/get_dialogs.py b/pyrogram/client/methods/chats/get_dialogs.py
index 3bcf223f..83732d07 100644
--- a/pyrogram/client/methods/chats/get_dialogs.py
+++ b/pyrogram/client/methods/chats/get_dialogs.py
@@ -39,7 +39,7 @@ class GetDialogs(BaseClient):
You can get up to 100 dialogs at once.
For a more convenient way of getting a user's dialogs see :meth:`iter_dialogs`.
- Args:
+ Parameters:
offset_date (``int``):
The offset date in Unix time taken from the top message of a :obj:`Dialog`.
Defaults to 0. Valid for non-pinned dialogs only.
@@ -53,10 +53,10 @@ class GetDialogs(BaseClient):
Defaults to False.
Returns:
- On success, a :obj:`Dialogs` object is returned.
+ :obj:`Dialogs`: On success, an object containing a list of dialogs is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
while True:
diff --git a/pyrogram/client/methods/chats/get_dialogs_count.py b/pyrogram/client/methods/chats/get_dialogs_count.py
index bf1754ee..eea327da 100644
--- a/pyrogram/client/methods/chats/get_dialogs_count.py
+++ b/pyrogram/client/methods/chats/get_dialogs_count.py
@@ -29,10 +29,10 @@ class GetDialogsCount(BaseClient):
Defaults to False.
Returns:
- On success, an integer is returned.
+ ``int``: On success, an integer is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
if pinned_only:
diff --git a/pyrogram/client/methods/chats/iter_chat_members.py b/pyrogram/client/methods/chats/iter_chat_members.py
index 2f41763e..f735da48 100644
--- a/pyrogram/client/methods/chats/iter_chat_members.py
+++ b/pyrogram/client/methods/chats/iter_chat_members.py
@@ -51,7 +51,7 @@ class IterChatMembers(BaseClient):
from the hassle of setting up boilerplate code. It is useful for getting the whole members list of a chat with
a single call.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -75,10 +75,10 @@ class IterChatMembers(BaseClient):
Defaults to *"all"*.
Returns:
- A generator yielding :obj:`ChatMember ` objects.
+ ``Generator``: A generator yielding :obj:`ChatMember` objects.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
current = 0
yielded = set()
diff --git a/pyrogram/client/methods/chats/iter_dialogs.py b/pyrogram/client/methods/chats/iter_dialogs.py
index 99437cb4..6fc9f81c 100644
--- a/pyrogram/client/methods/chats/iter_dialogs.py
+++ b/pyrogram/client/methods/chats/iter_dialogs.py
@@ -33,7 +33,7 @@ class IterDialogs(BaseClient):
This convenience method does the same as repeatedly calling :meth:`get_dialogs` in a loop, thus saving you from
the hassle of setting up boilerplate code. It is useful for getting the whole dialogs list with a single call.
- Args:
+ Parameters:
offset_date (``int``):
The offset date in Unix time taken from the top message of a :obj:`Dialog`.
Defaults to 0 (most recent dialog).
@@ -43,10 +43,10 @@ class IterDialogs(BaseClient):
By default, no limit is applied and all dialogs are returned.
Returns:
- A generator yielding :obj:`Dialog ` objects.
+ ``Generator``: A generator yielding :obj:`Dialog` objects.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
current = 0
total = limit or (1 << 31) - 1
diff --git a/pyrogram/client/methods/chats/join_chat.py b/pyrogram/client/methods/chats/join_chat.py
index a7933bea..77b2ee50 100644
--- a/pyrogram/client/methods/chats/join_chat.py
+++ b/pyrogram/client/methods/chats/join_chat.py
@@ -28,16 +28,16 @@ class JoinChat(BaseClient):
):
"""Use this method to join a group chat or channel.
- Args:
+ Parameters:
chat_id (``str``):
Unique identifier for the target chat in form of a *t.me/joinchat/* link or username of the target
channel/supergroup (in the format @username).
Returns:
- On success, a :obj:`Chat ` object is returned.
+ :obj:`Chat`: On success, a chat object is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
match = self.INVITE_LINK_RE.match(chat_id)
diff --git a/pyrogram/client/methods/chats/kick_chat_member.py b/pyrogram/client/methods/chats/kick_chat_member.py
index 7b10ddea..dbd095ad 100644
--- a/pyrogram/client/methods/chats/kick_chat_member.py
+++ b/pyrogram/client/methods/chats/kick_chat_member.py
@@ -40,7 +40,7 @@ class KickChatMember(BaseClient):
off in the target group. Otherwise members may only be removed by the group's creator or by the member
that added them.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -54,10 +54,12 @@ class KickChatMember(BaseClient):
considered to be banned forever. Defaults to 0 (ban forever).
Returns:
- On success, either True or a service :obj:`Message ` will be returned (when applicable).
+ :obj:`Message`: On success, a service message will be returned (when applicable).
+
+ ``bool`` -- True, in case a message object couldn't be returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
chat_peer = self.resolve_peer(chat_id)
user_peer = self.resolve_peer(user_id)
diff --git a/pyrogram/client/methods/chats/leave_chat.py b/pyrogram/client/methods/chats/leave_chat.py
index 8ba3a3d1..57cc1090 100644
--- a/pyrogram/client/methods/chats/leave_chat.py
+++ b/pyrogram/client/methods/chats/leave_chat.py
@@ -30,7 +30,7 @@ class LeaveChat(BaseClient):
):
"""Use this method to leave a group chat or channel.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier for the target chat or username of the target channel/supergroup
(in the format @username).
@@ -39,7 +39,7 @@ class LeaveChat(BaseClient):
Deletes the group chat dialog after leaving (for simple group chats, not supergroups).
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/pin_chat_message.py b/pyrogram/client/methods/chats/pin_chat_message.py
index 1d5466ba..2c485dab 100644
--- a/pyrogram/client/methods/chats/pin_chat_message.py
+++ b/pyrogram/client/methods/chats/pin_chat_message.py
@@ -33,7 +33,7 @@ class PinChatMessage(BaseClient):
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in
the supergroup or "can_edit_messages" admin right in the channel.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -45,10 +45,10 @@ class PinChatMessage(BaseClient):
message. Notifications are always disabled in channels.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.messages.UpdatePinnedMessage(
diff --git a/pyrogram/client/methods/chats/promote_chat_member.py b/pyrogram/client/methods/chats/promote_chat_member.py
index 26d49516..0b93576a 100644
--- a/pyrogram/client/methods/chats/promote_chat_member.py
+++ b/pyrogram/client/methods/chats/promote_chat_member.py
@@ -41,7 +41,7 @@ class PromoteChatMember(BaseClient):
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Pass False for all boolean parameters to demote a user.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -76,10 +76,10 @@ class PromoteChatMember(BaseClient):
were appointed by him).
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.channels.EditAdmin(
diff --git a/pyrogram/client/methods/chats/restrict_chat.py b/pyrogram/client/methods/chats/restrict_chat.py
index 40d46d34..9f6d2910 100644
--- a/pyrogram/client/methods/chats/restrict_chat.py
+++ b/pyrogram/client/methods/chats/restrict_chat.py
@@ -39,7 +39,7 @@ class RestrictChat(BaseClient):
"""Use this method to restrict a chat.
Pass True for all boolean parameters to lift restrictions from a chat.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -70,10 +70,10 @@ class RestrictChat(BaseClient):
Pass True, if the user can pin messages.
Returns:
- On success, a :obj:`Chat ` object is returned.
+ :obj:`Chat`: On success, a chat object is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
send_messages = True
send_media = True
diff --git a/pyrogram/client/methods/chats/restrict_chat_member.py b/pyrogram/client/methods/chats/restrict_chat_member.py
index 8688ecca..1f31d8eb 100644
--- a/pyrogram/client/methods/chats/restrict_chat_member.py
+++ b/pyrogram/client/methods/chats/restrict_chat_member.py
@@ -43,7 +43,7 @@ class RestrictChatMember(BaseClient):
The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights.
Pass True for all boolean parameters to lift restrictions from a user.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -83,10 +83,10 @@ class RestrictChatMember(BaseClient):
Pass True, if the user can pin messages.
Returns:
- On success, a :obj:`Chat ` object is returned.
+ :obj:`Chat`: On success, a chat object is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
send_messages = True
send_media = True
diff --git a/pyrogram/client/methods/chats/set_chat_description.py b/pyrogram/client/methods/chats/set_chat_description.py
index 9d4e130b..6cc3bbd3 100644
--- a/pyrogram/client/methods/chats/set_chat_description.py
+++ b/pyrogram/client/methods/chats/set_chat_description.py
@@ -31,7 +31,7 @@ class SetChatDescription(BaseClient):
"""Use this method to change the description of a supergroup or a channel.
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -39,10 +39,10 @@ class SetChatDescription(BaseClient):
New chat description, 0-255 characters.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
``ValueError`` if a chat_id doesn't belong to a supergroup or a channel.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/set_chat_photo.py b/pyrogram/client/methods/chats/set_chat_photo.py
index 87fe1b72..7248a265 100644
--- a/pyrogram/client/methods/chats/set_chat_photo.py
+++ b/pyrogram/client/methods/chats/set_chat_photo.py
@@ -39,7 +39,7 @@ class SetChatPhoto(BaseClient):
In regular groups (non-supergroups), this method will only work if the "All Members Are Admins"
setting is off.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -47,10 +47,10 @@ class SetChatPhoto(BaseClient):
New chat photo. You can pass a :class:`Photo` id or a file path to upload a new photo.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
``ValueError`` if a chat_id belongs to user.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/set_chat_title.py b/pyrogram/client/methods/chats/set_chat_title.py
index e94f16a8..a159d2cc 100644
--- a/pyrogram/client/methods/chats/set_chat_title.py
+++ b/pyrogram/client/methods/chats/set_chat_title.py
@@ -36,7 +36,7 @@ class SetChatTitle(BaseClient):
In regular groups (non-supergroups), this method will only work if the "All Members Are Admins"
setting is off.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -44,11 +44,11 @@ class SetChatTitle(BaseClient):
New chat title, 1-255 characters.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` if a chat_id belongs to user.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case a chat id belongs to user.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/chats/unban_chat_member.py b/pyrogram/client/methods/chats/unban_chat_member.py
index 0576c028..35ea0343 100644
--- a/pyrogram/client/methods/chats/unban_chat_member.py
+++ b/pyrogram/client/methods/chats/unban_chat_member.py
@@ -32,7 +32,7 @@ class UnbanChatMember(BaseClient):
The user will **not** return to the group or channel automatically, but will be able to join via link, etc.
You must be an administrator for this to work.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -41,10 +41,10 @@ class UnbanChatMember(BaseClient):
For a contact that exists in your Telegram address book you can use his phone number (str).
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.channels.EditBanned(
diff --git a/pyrogram/client/methods/chats/unpin_chat_message.py b/pyrogram/client/methods/chats/unpin_chat_message.py
index 9753d656..4e2531fd 100644
--- a/pyrogram/client/methods/chats/unpin_chat_message.py
+++ b/pyrogram/client/methods/chats/unpin_chat_message.py
@@ -31,15 +31,15 @@ class UnpinChatMessage(BaseClient):
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin
right in the supergroup or "can_edit_messages" admin right in the channel.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.messages.UpdatePinnedMessage(
diff --git a/pyrogram/client/methods/chats/update_chat_username.py b/pyrogram/client/methods/chats/update_chat_username.py
index 39cdfaeb..2e8adb05 100644
--- a/pyrogram/client/methods/chats/update_chat_username.py
+++ b/pyrogram/client/methods/chats/update_chat_username.py
@@ -32,18 +32,18 @@ class UpdateChatUsername(BaseClient):
To update your own username (for users only, not bots) you can use :meth:`update_username`.
- Args:
+ Parameters:
chat_id (``int`` | ``str``)
Unique identifier (int) or username (str) of the target chat.
username (``str`` | ``None``):
Username to set. Pass "" (empty string) or None to remove the username.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` if a chat_id belongs to a user or chat.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case a chat id belongs to a user or chat.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/contacts/add_contacts.py b/pyrogram/client/methods/contacts/add_contacts.py
index d1a97c99..aa8e1fd5 100644
--- a/pyrogram/client/methods/contacts/add_contacts.py
+++ b/pyrogram/client/methods/contacts/add_contacts.py
@@ -30,15 +30,12 @@ class AddContacts(BaseClient):
):
"""Use this method to add contacts to your Telegram address book.
- Args:
- contacts (List of :obj:`InputPhoneContact `):
+ Parameters:
+ contacts (List of :obj:`InputPhoneContact`):
The contact list to be added
- Returns:
- On success, the added contacts are returned.
-
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
imported_contacts = self.send(
functions.contacts.ImportContacts(
diff --git a/pyrogram/client/methods/contacts/delete_contacts.py b/pyrogram/client/methods/contacts/delete_contacts.py
index af8f453e..db5b9df1 100644
--- a/pyrogram/client/methods/contacts/delete_contacts.py
+++ b/pyrogram/client/methods/contacts/delete_contacts.py
@@ -30,16 +30,16 @@ class DeleteContacts(BaseClient):
):
"""Use this method to delete contacts from your Telegram address book.
- Args:
+ Parameters:
ids (List of ``int``):
A list of unique identifiers for the target users.
Can be an ID (int), a username (string) or phone number (string).
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
contacts = []
diff --git a/pyrogram/client/methods/contacts/get_contacts.py b/pyrogram/client/methods/contacts/get_contacts.py
index e62847c8..7e607e77 100644
--- a/pyrogram/client/methods/contacts/get_contacts.py
+++ b/pyrogram/client/methods/contacts/get_contacts.py
@@ -18,6 +18,7 @@
import logging
import time
+from typing import List
import pyrogram
from pyrogram.api import functions
@@ -28,14 +29,14 @@ log = logging.getLogger(__name__)
class GetContacts(BaseClient):
- def get_contacts(self):
+ def get_contacts(self) -> List["pyrogram.User"]:
"""Use this method to get contacts from your Telegram address book.
Returns:
- On success, a list of :obj:`User` objects is returned.
+ List of :obj:`User`: On success, a list of users is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
while True:
try:
diff --git a/pyrogram/client/methods/contacts/get_contacts_count.py b/pyrogram/client/methods/contacts/get_contacts_count.py
index b41b27b8..b9e6f6c4 100644
--- a/pyrogram/client/methods/contacts/get_contacts_count.py
+++ b/pyrogram/client/methods/contacts/get_contacts_count.py
@@ -25,10 +25,10 @@ class GetContactsCount(BaseClient):
"""Use this method to get the total count of contacts from your Telegram address book.
Returns:
- On success, an integer is returned.
+ ``int``: On success, an integer is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
return len(self.send(functions.contacts.GetContacts(hash=0)).contacts)
diff --git a/pyrogram/client/methods/decorators/on_callback_query.py b/pyrogram/client/methods/decorators/on_callback_query.py
index 3c747c5f..9ead25b4 100644
--- a/pyrogram/client/methods/decorators/on_callback_query.py
+++ b/pyrogram/client/methods/decorators/on_callback_query.py
@@ -33,8 +33,8 @@ class OnCallbackQuery(BaseClient):
"""Use this decorator to automatically register a function for handling callback queries.
This does the same thing as :meth:`add_handler` using the :class:`CallbackQueryHandler`.
- Args:
- filters (:obj:`Filters `):
+ Parameters:
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of callback queries to be passed
in your function.
diff --git a/pyrogram/client/methods/decorators/on_deleted_messages.py b/pyrogram/client/methods/decorators/on_deleted_messages.py
index cf8f9cf2..eb9dfcd0 100644
--- a/pyrogram/client/methods/decorators/on_deleted_messages.py
+++ b/pyrogram/client/methods/decorators/on_deleted_messages.py
@@ -33,8 +33,8 @@ class OnDeletedMessages(BaseClient):
"""Use this decorator to automatically register a function for handling deleted messages.
This does the same thing as :meth:`add_handler` using the :class:`DeletedMessagesHandler`.
- Args:
- filters (:obj:`Filters `):
+ Parameters:
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of messages to be passed
in your function.
diff --git a/pyrogram/client/methods/decorators/on_inline_query.py b/pyrogram/client/methods/decorators/on_inline_query.py
index 81f0f676..e9758c64 100644
--- a/pyrogram/client/methods/decorators/on_inline_query.py
+++ b/pyrogram/client/methods/decorators/on_inline_query.py
@@ -33,7 +33,7 @@ class OnInlineQuery(BaseClient):
"""Use this decorator to automatically register a function for handling inline queries.
This does the same thing as :meth:`add_handler` using the :class:`InlineQueryHandler`.
- Args:
+ Parameters:
filters (:obj:`Filters `):
Pass one or more filters to allow only a subset of inline queries to be passed
in your function.
diff --git a/pyrogram/client/methods/decorators/on_message.py b/pyrogram/client/methods/decorators/on_message.py
index e6563893..ad95cd45 100644
--- a/pyrogram/client/methods/decorators/on_message.py
+++ b/pyrogram/client/methods/decorators/on_message.py
@@ -33,8 +33,8 @@ class OnMessage(BaseClient):
"""Use this decorator to automatically register a function for handling messages.
This does the same thing as :meth:`add_handler` using the :class:`MessageHandler`.
- Args:
- filters (:obj:`Filters `):
+ Parameters:
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of messages to be passed
in your function.
diff --git a/pyrogram/client/methods/decorators/on_poll.py b/pyrogram/client/methods/decorators/on_poll.py
index 56dcd757..68f3d78e 100644
--- a/pyrogram/client/methods/decorators/on_poll.py
+++ b/pyrogram/client/methods/decorators/on_poll.py
@@ -33,7 +33,7 @@ class OnPoll(BaseClient):
"""Use this decorator to automatically register a function for handling poll updates.
This does the same thing as :meth:`add_handler` using the :class:`PollHandler`.
- Args:
+ Parameters:
filters (:obj:`Filters `):
Pass one or more filters to allow only a subset of polls to be passed
in your function.
diff --git a/pyrogram/client/methods/decorators/on_raw_update.py b/pyrogram/client/methods/decorators/on_raw_update.py
index 1494a319..2ab1f61b 100644
--- a/pyrogram/client/methods/decorators/on_raw_update.py
+++ b/pyrogram/client/methods/decorators/on_raw_update.py
@@ -31,7 +31,7 @@ class OnRawUpdate(BaseClient):
"""Use this decorator to automatically register a function for handling raw updates.
This does the same thing as :meth:`add_handler` using the :class:`RawUpdateHandler`.
- Args:
+ Parameters:
group (``int``, *optional*):
The group identifier, defaults to 0.
"""
diff --git a/pyrogram/client/methods/decorators/on_user_status.py b/pyrogram/client/methods/decorators/on_user_status.py
index 4d8185b1..5b49bb3c 100644
--- a/pyrogram/client/methods/decorators/on_user_status.py
+++ b/pyrogram/client/methods/decorators/on_user_status.py
@@ -33,8 +33,8 @@ class OnUserStatus(BaseClient):
"""Use this decorator to automatically register a function for handling user status updates.
This does the same thing as :meth:`add_handler` using the :class:`UserStatusHandler`.
- Args:
- filters (:obj:`Filters `):
+ Parameters:
+ filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of UserStatus updated to be passed in your function.
group (``int``, *optional*):
diff --git a/pyrogram/client/methods/messages/delete_messages.py b/pyrogram/client/methods/messages/delete_messages.py
index 4076be22..067d2fae 100644
--- a/pyrogram/client/methods/messages/delete_messages.py
+++ b/pyrogram/client/methods/messages/delete_messages.py
@@ -31,7 +31,7 @@ class DeleteMessages(BaseClient):
) -> bool:
"""Use this method to delete messages, including service messages.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -48,10 +48,10 @@ class DeleteMessages(BaseClient):
Defaults to True.
Returns:
- True on success, False otherwise.
+ ``bool``: True on success, False otherwise.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
peer = self.resolve_peer(chat_id)
message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids]
diff --git a/pyrogram/client/methods/messages/download_media.py b/pyrogram/client/methods/messages/download_media.py
index 35959d4a..04a5ec57 100644
--- a/pyrogram/client/methods/messages/download_media.py
+++ b/pyrogram/client/methods/messages/download_media.py
@@ -34,8 +34,8 @@ class DownloadMedia(BaseClient):
) -> Union[str, None]:
"""Use this method to download the media from a message.
- Args:
- message (:obj:`Message ` | ``str``):
+ Parameters:
+ message (:obj:`Message` | ``str``):
Pass a Message containing the media, the media itself (message.audio, message.video, ...) or
the file id as string.
@@ -59,7 +59,7 @@ class DownloadMedia(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -73,11 +73,12 @@ class DownloadMedia(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the absolute path of the downloaded file as string is returned, None otherwise.
- In case the download is deliberately stopped with :meth:`stop_transmission`, None is returned as well.
+ ``str``: On success, the absolute path of the downloaded file is returned.
+
+ ``None`` -- In case the download is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: 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"
diff --git a/pyrogram/client/methods/messages/edit_message_caption.py b/pyrogram/client/methods/messages/edit_message_caption.py
index c7bcbd70..fe19dcc9 100644
--- a/pyrogram/client/methods/messages/edit_message_caption.py
+++ b/pyrogram/client/methods/messages/edit_message_caption.py
@@ -34,7 +34,7 @@ class EditMessageCaption(BaseClient):
) -> "pyrogram.Message":
"""Use this method to edit captions of messages.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -47,18 +47,17 @@ class EditMessageCaption(BaseClient):
New caption of the message.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
reply_markup (:obj:`InlineKeyboardMarkup`, *optional*):
An InlineKeyboardMarkup object.
Returns:
- On success, the edited :obj:`Message ` is returned.
+ :obj:`Message`: On success, the edited message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py
index 69693384..b03fb1e0 100644
--- a/pyrogram/client/methods/messages/edit_message_media.py
+++ b/pyrogram/client/methods/messages/edit_message_media.py
@@ -47,7 +47,7 @@ class EditMessageMedia(BaseClient):
Use previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent
by the bot, the edited Message is returned, otherwise True is returned.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -63,10 +63,10 @@ class EditMessageMedia(BaseClient):
An InlineKeyboardMarkup object.
Returns:
- On success, the edited :obj:`Message ` is returned.
+ :obj:`Message`: On success, the edited message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
style = self.html if media.parse_mode.lower() == "html" else self.markdown
caption = media.caption
diff --git a/pyrogram/client/methods/messages/edit_message_reply_markup.py b/pyrogram/client/methods/messages/edit_message_reply_markup.py
index e3495476..73561451 100644
--- a/pyrogram/client/methods/messages/edit_message_reply_markup.py
+++ b/pyrogram/client/methods/messages/edit_message_reply_markup.py
@@ -32,7 +32,7 @@ class EditMessageReplyMarkup(BaseClient):
) -> "pyrogram.Message":
"""Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -45,11 +45,12 @@ class EditMessageReplyMarkup(BaseClient):
An InlineKeyboardMarkup object.
Returns:
- On success, if edited message is sent by the bot, the edited
- :obj:`Message ` is returned, otherwise True is returned.
+ :obj:`Message`: In case the edited message is sent by the bot.
+
+ ``bool`` -- True, in case the edited message is sent by the user.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
diff --git a/pyrogram/client/methods/messages/edit_message_text.py b/pyrogram/client/methods/messages/edit_message_text.py
index 8e23b1de..30b58b68 100644
--- a/pyrogram/client/methods/messages/edit_message_text.py
+++ b/pyrogram/client/methods/messages/edit_message_text.py
@@ -35,7 +35,7 @@ class EditMessageText(BaseClient):
) -> "pyrogram.Message":
"""Use this method to edit text messages.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -48,9 +48,8 @@ class EditMessageText(BaseClient):
New text of the message.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your message.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your message. Defaults to "markdown".
disable_web_page_preview (``bool``, *optional*):
Disables link previews for links in this message.
@@ -59,10 +58,10 @@ class EditMessageText(BaseClient):
An InlineKeyboardMarkup object.
Returns:
- On success, the edited :obj:`Message ` is returned.
+ :obj:`Message`: On success, the edited message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/forward_messages.py b/pyrogram/client/methods/messages/forward_messages.py
index 5540b38a..08cc48ea 100644
--- a/pyrogram/client/methods/messages/forward_messages.py
+++ b/pyrogram/client/methods/messages/forward_messages.py
@@ -35,7 +35,7 @@ class ForwardMessages(BaseClient):
) -> "pyrogram.Messages":
"""Use this method to forward messages of any kind.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -64,13 +64,14 @@ class ForwardMessages(BaseClient):
Defaults to False.
Returns:
- On success and in case *message_ids* was an iterable, the returned value will be a list of the forwarded
- :obj:`Messages ` even if a list contains just one element, otherwise if
- *message_ids* was an integer, the single forwarded :obj:`Message `
- is returned.
+ :obj:`Message`: In case *message_ids* was an integer, the single forwarded message is
+ returned.
+
+ :obj:`Messages` -- In case *message_ids* was an iterable, the returned value will be an
+ object containing a list of messages, even if such iterable contained just a single element.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
is_iterable = not isinstance(message_ids, int)
diff --git a/pyrogram/client/methods/messages/get_history.py b/pyrogram/client/methods/messages/get_history.py
index 1953fabc..ffd8f9e0 100644
--- a/pyrogram/client/methods/messages/get_history.py
+++ b/pyrogram/client/methods/messages/get_history.py
@@ -43,7 +43,7 @@ class GetHistory(BaseClient):
You can get up to 100 messages at once.
For a more convenient way of getting a chat history see :meth:`iter_history`.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -67,10 +67,10 @@ class GetHistory(BaseClient):
Pass True to retrieve the messages in reversed order (from older to most recent).
Returns:
- On success, a :obj:`Messages ` object is returned.
+ :obj:`Messages` - On success, an object containing a list of the retrieved messages.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
while True:
diff --git a/pyrogram/client/methods/messages/get_history_count.py b/pyrogram/client/methods/messages/get_history_count.py
index 046ec095..b4812d26 100644
--- a/pyrogram/client/methods/messages/get_history_count.py
+++ b/pyrogram/client/methods/messages/get_history_count.py
@@ -40,15 +40,15 @@ class GetHistoryCount(BaseClient):
a **private** or a **basic group** chat has with a single method call. To overcome this limitation, Pyrogram
has to iterate over all the messages. Channels and supergroups are not affected by this limitation.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
- On success, an integer is returned.
+ ``int``: On success, an integer is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
peer = self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py
index f03cac93..391c251c 100644
--- a/pyrogram/client/methods/messages/get_messages.py
+++ b/pyrogram/client/methods/messages/get_messages.py
@@ -39,7 +39,7 @@ class GetMessages(BaseClient):
"""Use this method to get one or more messages that belong to a specific chat.
You can retrieve up to 200 messages at once.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -60,12 +60,14 @@ class GetMessages(BaseClient):
Defaults to 1.
Returns:
- On success and in case *message_ids* or *reply_to_message_ids* was an iterable, the returned value will be a
- :obj:`Messages ` even if a list contains just one element. Otherwise, if *message_ids* or
- *reply_to_message_ids* was an integer, the single requested :obj:`Message ` is returned.
+ :obj:`Message`: In case *message_ids* was an integer, the single forwarded message is
+ returned.
+
+ :obj:`Messages` -- In case *message_ids* was an iterable, the returned value will be an
+ object containing a list of messages, even if such iterable contained just a single element.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
ids, ids_type = (
(message_ids, types.InputMessageID) if message_ids
diff --git a/pyrogram/client/methods/messages/iter_history.py b/pyrogram/client/methods/messages/iter_history.py
index f7a8a74e..b1546318 100644
--- a/pyrogram/client/methods/messages/iter_history.py
+++ b/pyrogram/client/methods/messages/iter_history.py
@@ -37,7 +37,7 @@ class IterHistory(BaseClient):
This convenience method does the same as repeatedly calling :meth:`get_history` in a loop, thus saving you from
the hassle of setting up boilerplate code. It is useful for getting the whole chat history with a single call.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -61,10 +61,10 @@ class IterHistory(BaseClient):
Pass True to retrieve the messages in reversed order (from older to most recent).
Returns:
- A generator yielding :obj:`Message ` objects.
+ ``Generator``: A generator yielding :obj:`Message` objects.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
offset_id = offset_id or (1 if reverse else 0)
current = 0
diff --git a/pyrogram/client/methods/messages/retract_vote.py b/pyrogram/client/methods/messages/retract_vote.py
index ce8a0140..929298df 100644
--- a/pyrogram/client/methods/messages/retract_vote.py
+++ b/pyrogram/client/methods/messages/retract_vote.py
@@ -31,7 +31,7 @@ class RetractVote(BaseClient):
) -> "pyrogram.Poll":
"""Use this method to retract your vote in a poll.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -41,10 +41,10 @@ class RetractVote(BaseClient):
Identifier of the original message with the poll.
Returns:
- On success, the :obj:`Poll ` with the retracted vote is returned.
+ :obj:`Poll`: On success, the poll with the retracted vote is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendVote(
diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py
index e2335f72..4e21e56c 100644
--- a/pyrogram/client/methods/messages/send_animation.py
+++ b/pyrogram/client/methods/messages/send_animation.py
@@ -51,7 +51,7 @@ class SendAnimation(BaseClient):
) -> Union["pyrogram.Message", None]:
"""Use this method to send animation files (animation or H.264/MPEG-4 AVC video without sound).
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -67,9 +67,8 @@ class SendAnimation(BaseClient):
Animation caption, 0-1024 characters.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
duration (``int``, *optional*):
Duration of sent animation in seconds.
@@ -107,7 +106,7 @@ class SendAnimation(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -121,11 +120,12 @@ class SendAnimation(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent animation message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py
index 2f01396f..71458c33 100644
--- a/pyrogram/client/methods/messages/send_audio.py
+++ b/pyrogram/client/methods/messages/send_audio.py
@@ -53,7 +53,7 @@ class SendAudio(BaseClient):
For sending voice messages, use the :obj:`send_voice()` method instead.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -69,9 +69,8 @@ class SendAudio(BaseClient):
Audio caption, 0-1024 characters.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
duration (``int``, *optional*):
Duration of the audio in seconds.
@@ -109,7 +108,7 @@ class SendAudio(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -123,11 +122,12 @@ class SendAudio(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent audio message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/send_cached_media.py b/pyrogram/client/methods/messages/send_cached_media.py
index f0c690d9..b0b3fc4e 100644
--- a/pyrogram/client/methods/messages/send_cached_media.py
+++ b/pyrogram/client/methods/messages/send_cached_media.py
@@ -48,7 +48,7 @@ class SendCachedMedia(BaseClient):
It does the same as calling the relevant method for sending media using a file_id, thus saving you from the
hassle of using the correct method for the media the file_id is pointing to.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -62,9 +62,8 @@ class SendCachedMedia(BaseClient):
Media caption, 0-1024 characters.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
disable_notification (``bool``, *optional*):
Sends the message silently.
@@ -78,10 +77,10 @@ class SendCachedMedia(BaseClient):
instructions to remove reply keyboard or to force a reply from the user.
Returns:
- On success, the sent :obj:`Message ` is returned.
+ :obj:`Message`: On success, the sent media message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/send_chat_action.py b/pyrogram/client/methods/messages/send_chat_action.py
index 04777d42..5c50c2cf 100644
--- a/pyrogram/client/methods/messages/send_chat_action.py
+++ b/pyrogram/client/methods/messages/send_chat_action.py
@@ -31,15 +31,15 @@ class SendChatAction(BaseClient):
):
"""Use this method when you need to tell the other party that something is happening on your side.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
- action (:obj:`ChatAction ` | ``str``):
+ action (:obj:`ChatAction` | ``str``):
Type of action to broadcast.
- Choose one from the :class:`ChatAction ` enumeration,
+ Choose one from the :class:`ChatAction` enumeration,
depending on what the user is about to receive.
You can also provide a string (e.g. "typing", "upload_photo", "record_audio", ...).
@@ -48,11 +48,11 @@ class SendChatAction(BaseClient):
Currently useless because official clients don't seem to be handling this.
Returns:
- On success, True is returned.
+ ``bool``: On success, True is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` if the provided string is not a valid ChatAction.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case the provided string is not a valid ChatAction.
"""
# Resolve Enum type
diff --git a/pyrogram/client/methods/messages/send_contact.py b/pyrogram/client/methods/messages/send_contact.py
index 9143440e..27df6505 100644
--- a/pyrogram/client/methods/messages/send_contact.py
+++ b/pyrogram/client/methods/messages/send_contact.py
@@ -42,7 +42,7 @@ class SendContact(BaseClient):
) -> "pyrogram.Message":
"""Use this method to send phone contacts.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -72,10 +72,10 @@ class SendContact(BaseClient):
instructions to remove reply keyboard or to force a reply from the user.
Returns:
- On success, the sent :obj:`Message ` is returned.
+ :obj:`Message`: On success, the sent contact message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(
diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py
index 596adeb1..e2ac0d23 100644
--- a/pyrogram/client/methods/messages/send_document.py
+++ b/pyrogram/client/methods/messages/send_document.py
@@ -48,7 +48,7 @@ class SendDocument(BaseClient):
) -> Union["pyrogram.Message", None]:
"""Use this method to send general files.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -70,9 +70,8 @@ class SendDocument(BaseClient):
Document caption, 0-1024 characters.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
disable_notification (``bool``, *optional*):
Sends the message silently.
@@ -95,7 +94,7 @@ class SendDocument(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -109,11 +108,12 @@ class SendDocument(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent document message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/send_location.py b/pyrogram/client/methods/messages/send_location.py
index f3ed81df..dce6671b 100644
--- a/pyrogram/client/methods/messages/send_location.py
+++ b/pyrogram/client/methods/messages/send_location.py
@@ -40,7 +40,7 @@ class SendLocation(BaseClient):
) -> "pyrogram.Message":
"""Use this method to send points on the map.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -64,10 +64,10 @@ class SendLocation(BaseClient):
instructions to remove reply keyboard or to force a reply from the user.
Returns:
- On success, the sent :obj:`Message ` is returned.
+ :obj:`Message`: On success, the sent location message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(
diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py
index f40401b0..fe6725f0 100644
--- a/pyrogram/client/methods/messages/send_media_group.py
+++ b/pyrogram/client/methods/messages/send_media_group.py
@@ -43,7 +43,7 @@ class SendMediaGroup(BaseClient):
):
"""Use this method to send a group of photos or videos as an album.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -60,11 +60,10 @@ class SendMediaGroup(BaseClient):
If the message is a reply, ID of the original message.
Returns:
- On success, a :obj:`Messages ` object is returned containing all the
- single messages sent.
+ :obj:`Messages`: On success, an object is returned containing all the single messages sent.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
multi_media = []
diff --git a/pyrogram/client/methods/messages/send_message.py b/pyrogram/client/methods/messages/send_message.py
index b45b7192..15c1487a 100644
--- a/pyrogram/client/methods/messages/send_message.py
+++ b/pyrogram/client/methods/messages/send_message.py
@@ -41,7 +41,7 @@ class SendMessage(BaseClient):
) -> "pyrogram.Message":
"""Use this method to send text messages.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -51,9 +51,8 @@ class SendMessage(BaseClient):
Text of the message to be sent.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your message.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your message. Defaults to "markdown".
disable_web_page_preview (``bool``, *optional*):
Disables link previews for links in this message.
@@ -70,10 +69,10 @@ class SendMessage(BaseClient):
instructions to remove reply keyboard or to force a reply from the user.
Returns:
- On success, the sent :obj:`Message` is returned.
+ :obj:`Message`: On success, the sent text message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
style = self.html if parse_mode.lower() == "html" else self.markdown
message, entities = style.parse(text).values()
diff --git a/pyrogram/client/methods/messages/send_photo.py b/pyrogram/client/methods/messages/send_photo.py
index 7e327cbd..5487761e 100644
--- a/pyrogram/client/methods/messages/send_photo.py
+++ b/pyrogram/client/methods/messages/send_photo.py
@@ -48,7 +48,7 @@ class SendPhoto(BaseClient):
) -> Union["pyrogram.Message", None]:
"""Use this method to send photos.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -64,9 +64,8 @@ class SendPhoto(BaseClient):
Photo caption, 0-1024 characters.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
ttl_seconds (``int``, *optional*):
Self-Destruct Timer.
@@ -94,7 +93,7 @@ class SendPhoto(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -108,11 +107,12 @@ class SendPhoto(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent photo message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/send_poll.py b/pyrogram/client/methods/messages/send_poll.py
index 6b4e227a..ff5c8533 100644
--- a/pyrogram/client/methods/messages/send_poll.py
+++ b/pyrogram/client/methods/messages/send_poll.py
@@ -40,7 +40,7 @@ class SendPoll(BaseClient):
) -> "pyrogram.Message":
"""Use this method to send a new poll.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -64,10 +64,10 @@ class SendPoll(BaseClient):
instructions to remove reply keyboard or to force a reply from the user.
Returns:
- On success, the sent :obj:`Message ` is returned.
+ :obj:`Message`: On success, the sent poll message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(
diff --git a/pyrogram/client/methods/messages/send_sticker.py b/pyrogram/client/methods/messages/send_sticker.py
index a10f3b74..0e314641 100644
--- a/pyrogram/client/methods/messages/send_sticker.py
+++ b/pyrogram/client/methods/messages/send_sticker.py
@@ -45,7 +45,7 @@ class SendSticker(BaseClient):
) -> Union["pyrogram.Message", None]:
"""Use this method to send .webp stickers.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -78,7 +78,7 @@ class SendSticker(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -92,11 +92,12 @@ class SendSticker(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent sticker message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
diff --git a/pyrogram/client/methods/messages/send_venue.py b/pyrogram/client/methods/messages/send_venue.py
index 1c9ca630..1045bdbd 100644
--- a/pyrogram/client/methods/messages/send_venue.py
+++ b/pyrogram/client/methods/messages/send_venue.py
@@ -44,7 +44,7 @@ class SendVenue(BaseClient):
) -> "pyrogram.Message":
"""Use this method to send information about a venue.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -81,10 +81,10 @@ class SendVenue(BaseClient):
instructions to remove reply keyboard or to force a reply from the user.
Returns:
- On success, the sent :obj:`Message ` is returned.
+ :obj:`Message`: On success, the sent venue message is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(
diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py
index 045c1cca..baa91d29 100644
--- a/pyrogram/client/methods/messages/send_video.py
+++ b/pyrogram/client/methods/messages/send_video.py
@@ -52,7 +52,7 @@ class SendVideo(BaseClient):
) -> Union["pyrogram.Message", None]:
"""Use this method to send video files.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -68,9 +68,8 @@ class SendVideo(BaseClient):
Video caption, 0-1024 characters.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
duration (``int``, *optional*):
Duration of sent video in seconds.
@@ -111,7 +110,7 @@ class SendVideo(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -125,11 +124,12 @@ class SendVideo(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent video message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py
index 464f2711..9f934efe 100644
--- a/pyrogram/client/methods/messages/send_video_note.py
+++ b/pyrogram/client/methods/messages/send_video_note.py
@@ -48,7 +48,7 @@ class SendVideoNote(BaseClient):
) -> Union["pyrogram.Message", None]:
"""Use this method to send video messages.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -93,7 +93,7 @@ class SendVideoNote(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -107,11 +107,12 @@ class SendVideoNote(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent video note message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
diff --git a/pyrogram/client/methods/messages/send_voice.py b/pyrogram/client/methods/messages/send_voice.py
index 44e998b6..e7ec2b11 100644
--- a/pyrogram/client/methods/messages/send_voice.py
+++ b/pyrogram/client/methods/messages/send_voice.py
@@ -48,7 +48,7 @@ class SendVoice(BaseClient):
) -> Union["pyrogram.Message", None]:
"""Use this method to send audio files.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -64,9 +64,8 @@ class SendVoice(BaseClient):
Voice message caption, 0-1024 characters.
parse_mode (``str``, *optional*):
- Use :obj:`MARKDOWN ` or :obj:`HTML `
- if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption.
- Defaults to Markdown.
+ Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline
+ URLs in your caption. Defaults to "markdown".
duration (``int``, *optional*):
Duration of the voice message in seconds.
@@ -92,7 +91,7 @@ class SendVoice(BaseClient):
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
- client (:obj:`Client `):
+ client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
@@ -106,11 +105,12 @@ class SendVoice(BaseClient):
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
- On success, the sent :obj:`Message ` is returned.
- In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
+ :obj:`Message`: On success, the sent voice message is returned.
+
+ ``None`` -- In case the upload is deliberately stopped with :meth:`stop_transmission`.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
file = None
style = self.html if parse_mode.lower() == "html" else self.markdown
diff --git a/pyrogram/client/methods/messages/stop_poll.py b/pyrogram/client/methods/messages/stop_poll.py
index a5a4ecc8..4179cce4 100644
--- a/pyrogram/client/methods/messages/stop_poll.py
+++ b/pyrogram/client/methods/messages/stop_poll.py
@@ -34,7 +34,7 @@ class StopPoll(BaseClient):
Stopped polls can't be reopened and nobody will be able to vote in it anymore.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -47,10 +47,10 @@ class StopPoll(BaseClient):
An InlineKeyboardMarkup object.
Returns:
- On success, the stopped :obj:`Poll ` with the final results is returned.
+ :obj:`Poll`: On success, the stopped poll with the final results is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
poll = self.get_messages(chat_id, message_id).poll
diff --git a/pyrogram/client/methods/messages/vote_poll.py b/pyrogram/client/methods/messages/vote_poll.py
index 58f21a6c..5e7b8ce8 100644
--- a/pyrogram/client/methods/messages/vote_poll.py
+++ b/pyrogram/client/methods/messages/vote_poll.py
@@ -32,7 +32,7 @@ class VotePoll(BaseClient):
) -> "pyrogram.Poll":
"""Use this method to vote a poll.
- Args:
+ Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
@@ -45,10 +45,10 @@ class VotePoll(BaseClient):
Index of the poll option you want to vote for (0 to 9).
Returns:
- On success, the :obj:`Poll ` with the chosen option is returned.
+ :obj:`Poll` - On success, the poll with the chosen option is returned.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
+ RPCError: In case of a Telegram RPC error.
"""
poll = self.get_messages(chat_id, message_id).poll
diff --git a/pyrogram/client/methods/password/change_cloud_password.py b/pyrogram/client/methods/password/change_cloud_password.py
index 2f8cfbd6..b9ee37d5 100644
--- a/pyrogram/client/methods/password/change_cloud_password.py
+++ b/pyrogram/client/methods/password/change_cloud_password.py
@@ -32,7 +32,7 @@ class ChangeCloudPassword(BaseClient):
) -> bool:
"""Use this method to change your Two-Step Verification password (Cloud Password) with a new one.
- Args:
+ Parameters:
current_password (``str``):
Your current password.
@@ -43,11 +43,11 @@ class ChangeCloudPassword(BaseClient):
A new password hint.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` in case there is no cloud password to change.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case there is no cloud password to change.
"""
r = self.send(functions.account.GetPassword())
diff --git a/pyrogram/client/methods/password/enable_cloud_password.py b/pyrogram/client/methods/password/enable_cloud_password.py
index b29dcfd3..e2e05633 100644
--- a/pyrogram/client/methods/password/enable_cloud_password.py
+++ b/pyrogram/client/methods/password/enable_cloud_password.py
@@ -34,7 +34,7 @@ class EnableCloudPassword(BaseClient):
This password will be asked when you log-in on a new device in addition to the SMS code.
- Args:
+ Parameters:
password (``str``):
Your password.
@@ -45,11 +45,11 @@ class EnableCloudPassword(BaseClient):
Recovery e-mail.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` in case there is already a cloud password enabled.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case there is already a cloud password enabled.
"""
r = self.send(functions.account.GetPassword())
diff --git a/pyrogram/client/methods/password/remove_cloud_password.py b/pyrogram/client/methods/password/remove_cloud_password.py
index 6e9a0ab4..37160530 100644
--- a/pyrogram/client/methods/password/remove_cloud_password.py
+++ b/pyrogram/client/methods/password/remove_cloud_password.py
@@ -28,16 +28,16 @@ class RemoveCloudPassword(BaseClient):
) -> bool:
"""Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account.
- Args:
+ Parameters:
password (``str``):
Your current password.
Returns:
- True on success.
+ ``bool``: True on success.
Raises:
- :class:`RPCError ` in case of a Telegram RPC error.
- ``ValueError`` in case there is no cloud password to remove.
+ RPCError: In case of a Telegram RPC error.
+ ValueError: In case there is no cloud password to remove.
"""
r = self.send(functions.account.GetPassword())
diff --git a/pyrogram/client/methods/users/delete_user_profile_photos.py b/pyrogram/client/methods/users/delete_user_profile_photos.py
index bd9fc98e..4e962245 100644
--- a/pyrogram/client/methods/users/delete_user_profile_photos.py
+++ b/pyrogram/client/methods/users/delete_user_profile_photos.py
@@ -31,16 +31,16 @@ class DeleteUserProfilePhotos(BaseClient):
) -> bool:
"""Use this method to delete your own profile photos.
- Args:
+ Parameters:
id (``str`` | ``list``):
- A single :obj:`Photo