2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-09-03 07:45:14 +00:00

Revamp docs about the main Pyrogram package

This commit is contained in:
Dan
2019-05-09 04:28:46 +02:00
parent ee91e6daa1
commit 1737ba5f49
171 changed files with 1116 additions and 919 deletions

View File

@@ -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 <pyrogram.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])))

View File

@@ -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

View File

@@ -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:

View File

@@ -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 <Handlers.html>`_; they do so by instantiating the correct handler and calling
:meth:`add_handler() <pyrogram.Client.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()

View File

@@ -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

View File

@@ -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 <Decorators.html>`_ instead.
In case you decided to manually create an handler, use :meth:`add_handler() <pyrogram.Client.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:

View File

@@ -0,0 +1,270 @@
Methods
=======
All Pyrogram methods listed here are bound to a :obj:`Client <pyrogram.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()

View File

@@ -1,6 +0,0 @@
ParseMode
=========
.. autoclass:: pyrogram.ParseMode
:members:
:undoc-members:

View File

@@ -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

View File

@@ -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:

View File

@@ -4,17 +4,18 @@ Pyrogram
In this section you can find a detailed description of the Pyrogram package and its API.
:class:`Client <pyrogram.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()

View File

@@ -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 <pyrogram.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 <pyrogram.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 <pyrogram.api.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 <pyrogram.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 <pyrogram.api.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 <pyrogram.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 <pyrogram.api.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 <pyrogram.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 <pyrogram.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)

View File

@@ -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 <Handlers.html>`_ is coming from.
For example, in a :obj:`MessageHandler <pyrogram.MessageHandler>` the update type will be
a :obj:`Message <pyrogram.Message>`; in a :obj:`CallbackQueryHandler <pyrogram.CallbackQueryHandler>` the
update type will be a :obj:`CallbackQuery <pyrogram.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 <pyrogram.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 <Handlers.html>`_ 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 <pyrogram.Audio>` objects."""
"""Filter messages that contain :obj:`Audio` objects."""
document = create("Document", lambda _, m: bool(m.document))
"""Filter messages that contain :obj:`Document <pyrogram.Document>` objects."""
"""Filter messages that contain :obj:`Document` objects."""
photo = create("Photo", lambda _, m: bool(m.photo))
"""Filter messages that contain :obj:`Photo <pyrogram.PhotoSize>` objects."""
"""Filter messages that contain :obj:`Photo` objects."""
sticker = create("Sticker", lambda _, m: bool(m.sticker))
"""Filter messages that contain :obj:`Sticker <pyrogram.Sticker>` objects."""
"""Filter messages that contain :obj:`Sticker` objects."""
animation = create("Animation", lambda _, m: bool(m.animation))
"""Filter messages that contain :obj:`Animation <pyrogram.Animation>` objects."""
"""Filter messages that contain :obj:`Animation` objects."""
game = create("Game", lambda _, m: bool(m.game))
"""Filter messages that contain :obj:`Game <pyrogram.Game>` objects."""
"""Filter messages that contain :obj:`Game` objects."""
video = create("Video", lambda _, m: bool(m.video))
"""Filter messages that contain :obj:`Video <pyrogram.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 <pyrogram.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 <pyrogram.VideoNote>` objects."""
"""Filter messages that contain :obj:`VideoNote` objects."""
contact = create("Contact", lambda _, m: bool(m.contact))
"""Filter messages that contain :obj:`Contact <pyrogram.Contact>` objects."""
"""Filter messages that contain :obj:`Contact` objects."""
location = create("Location", lambda _, m: bool(m.location))
"""Filter messages that contain :obj:`Location <pyrogram.Location>` objects."""
"""Filter messages that contain :obj:`Location` objects."""
venue = create("Venue", lambda _, m: bool(m.venue))
"""Filter messages that contain :obj:`Venue <pyrogram.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 <pyrogram.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 <pyrogram.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 <https://docs.python.org/3/library/re.html#match-objects>`_
are stored in the *matches* field of the :class:`Message <pyrogram.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 <https://docs.python.org/3/library/stdtypes.html#set>`_ 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 <https://docs.python.org/3/library/stdtypes.html#set>`_ 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".

View File

@@ -26,17 +26,17 @@ class CallbackQueryHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_callback_query() <pyrogram.Client.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 <pyrogram.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 <pyrogram.Client>`):
client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the message handler.
callback_query (:obj:`CallbackQuery <pyrogram.CallbackQuery>`):

View File

@@ -27,20 +27,20 @@ class DeletedMessagesHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_deleted_messages() <pyrogram.Client.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 <pyrogram.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 <pyrogram.Client>`):
client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the message handler.
messages (:obj:`Messages <pyrogram.Messages>`):
messages (:obj:`Messages`):
The deleted messages.
"""

View File

@@ -26,13 +26,13 @@ class DisconnectHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_disconnect() <pyrogram.Client.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 <pyrogram.Client>`):
client (:obj:`Client`):
The Client itself. Useful, for example, when you want to change the proxy before a new connection
is established.
"""

View File

@@ -26,20 +26,20 @@ class InlineQueryHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_inline_query() <pyrogram.Client.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 <pyrogram.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 <pyrogram.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 <pyrogram.InlineQuery>`):
inline_query (:obj:`InlineQuery`):
The received inline query.
"""

View File

@@ -27,20 +27,20 @@ class MessageHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_message() <pyrogram.Client.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 <pyrogram.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 <pyrogram.Client>`):
client (:obj:`Client`):
The Client itself, useful when you want to call other API methods inside the message handler.
message (:obj:`Message <pyrogram.Message>`):
message (:obj:`Message`):
The received message.
"""

View File

@@ -27,7 +27,7 @@ class PollHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_poll() <pyrogram.Client.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).

View File

@@ -26,14 +26,14 @@ class RawUpdateHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_raw_update() <pyrogram.Client.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 <pyrogram.Client>`):
client (:class:`Client`):
The Client itself, useful when you want to call other API methods inside the update handler.
update (``Update``):

View File

@@ -26,20 +26,20 @@ class UserStatusHandler(Handler):
For a nicer way to register this handler, have a look at the
:meth:`on_user_status() <pyrogram.Client.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 <pyrogram.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 <pyrogram.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 <pyrogram.UserStatus>`):
user_status (:obj:`UserStatus`):
The received UserStatus update.
"""

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
return self.send(
functions.messages.SetBotCallbackAnswer(

View File

@@ -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(

View File

@@ -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 <pyrogram.GameHighScores>` object is returned.
:obj:`GameHighScores`: On success.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
# TODO: inline_message_id

View File

@@ -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 <pyrogram.Client.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 <pyrogram.api.types.messages.BotResults>` is returned.
:obj:`BotResults <pyrogram.api.types.messages.BotResults>`: On Success.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.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(

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(

View File

@@ -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 <pyrogram.Client.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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
return self.send(
functions.messages.SendInlineBotResult(

View File

@@ -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 <pyrogram.Message>`,
On success, if the message was sent by the bot, returns the edited :obj:`Message`,
otherwise returns True.
Raises:
:class:`RPCError <pyrogram.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(

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
peer = self.resolve_peer(chat_id)

View File

@@ -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 <pyrogram.Chat>` object is returned.
:obj:`Chat`: On success, a chat object is returned.
Raises:
:class:`RPCError <pyrogram.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))

View File

@@ -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 <pyrogram.ChatMember>` object is returned.
:obj:`ChatMember`: On success, a chat member is returned.
Raises:
:class:`RPCError <pyrogram.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)

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
while True:

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
if pinned_only:

View File

@@ -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 <pyrogram.ChatMember>` objects.
``Generator``: A generator yielding :obj:`ChatMember` objects.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
current = 0
yielded = set()

View File

@@ -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 <pyrogram.Dialog>` objects.
``Generator``: A generator yielding :obj:`Dialog` objects.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
current = 0
total = limit or (1 << 31) - 1

View File

@@ -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 <pyrogram.Chat>` object is returned.
:obj:`Chat`: On success, a chat object is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
match = self.INVITE_LINK_RE.match(chat_id)

View File

@@ -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 <pyrogram.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 <pyrogram.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)

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
peer = self.resolve_peer(chat_id)

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.messages.UpdatePinnedMessage(

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.channels.EditAdmin(

View File

@@ -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 <pyrogram.Chat>` object is returned.
:obj:`Chat`: On success, a chat object is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
send_messages = True
send_media = True

View File

@@ -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 <pyrogram.Chat>` object is returned.
:obj:`Chat`: On success, a chat object is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
send_messages = True
send_media = True

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.channels.EditBanned(

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
self.send(
functions.messages.UpdatePinnedMessage(

View File

@@ -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 <pyrogram.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)

View File

@@ -30,15 +30,12 @@ class AddContacts(BaseClient):
):
"""Use this method to add contacts to your Telegram address book.
Args:
contacts (List of :obj:`InputPhoneContact <pyrogram.InputPhoneContact>`):
Parameters:
contacts (List of :obj:`InputPhoneContact`):
The contact list to be added
Returns:
On success, the added contacts are returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
imported_contacts = self.send(
functions.contacts.ImportContacts(

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
contacts = []

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
while True:
try:

View File

@@ -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 <pyrogram.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)

View File

@@ -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 <pyrogram.Filters>`):
Parameters:
filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of callback queries to be passed
in your function.

View File

@@ -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 <pyrogram.Filters>`):
Parameters:
filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of messages to be passed
in your function.

View File

@@ -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 <pyrogram.Filters>`):
Pass one or more filters to allow only a subset of inline queries to be passed
in your function.

View File

@@ -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 <pyrogram.Filters>`):
Parameters:
filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of messages to be passed
in your function.

View File

@@ -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 <pyrogram.Filters>`):
Pass one or more filters to allow only a subset of polls to be passed
in your function.

View File

@@ -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.
"""

View File

@@ -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 <pyrogram.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*):

View File

@@ -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 <pyrogram.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]

View File

@@ -34,8 +34,8 @@ class DownloadMedia(BaseClient):
) -> Union[str, None]:
"""Use this method to download the media from a message.
Args:
message (:obj:`Message <pyrogram.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 <pyrogram.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 <pyrogram.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"

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the edited message is returned.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the edited message is returned.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
r = self.send(

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the edited message is returned.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.Message>` even if a list contains just one element, otherwise if
*message_ids* was an integer, the single forwarded :obj:`Message <pyrogram.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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
is_iterable = not isinstance(message_ids, int)

View File

@@ -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 <pyrogram.Messages>` object is returned.
:obj:`Messages` - On success, an object containing a list of the retrieved messages.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
while True:

View File

@@ -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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
peer = self.resolve_peer(chat_id)

View File

@@ -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 <pyrogram.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 <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.Message>` objects.
``Generator``: A generator yielding :obj:`Message` objects.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.Poll>` with the retracted vote is returned.
:obj:`Poll`: On success, the poll with the retracted vote is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendVote(

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.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 <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.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 <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the sent media message is returned.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.ChatAction>` | ``str``):
action (:obj:`ChatAction` | ``str``):
Type of action to broadcast.
Choose one from the :class:`ChatAction <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the sent contact message is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.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 <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the sent location message is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(

View File

@@ -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 <pyrogram.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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
multi_media = []

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.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()

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.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 <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the sent poll message is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(

View File

@@ -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 <pyrogram.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 <pyrogram.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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
file = None

View File

@@ -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 <pyrogram.Message>` is returned.
:obj:`Message`: On success, the sent venue message is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
r = self.send(
functions.messages.SendMedia(

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.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 <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.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 <pyrogram.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 <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
file = None

View File

@@ -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 <pyrogram.ParseMode.MARKDOWN>` or :obj:`HTML <pyrogram.ParseMode.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 <pyrogram.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 <pyrogram.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 <pyrogram.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

View File

@@ -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 <pyrogram.Poll>` with the final results is returned.
:obj:`Poll`: On success, the stopped poll with the final results is returned.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.Poll>` with the chosen option is returned.
:obj:`Poll` - On success, the poll with the chosen option is returned.
Raises:
:class:`RPCError <pyrogram.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

View File

@@ -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 <pyrogram.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())

View File

@@ -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 <pyrogram.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())

View File

@@ -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 <pyrogram.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())

View File

@@ -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 <pyrogram.Photo>` id as string or multiple ids as list of strings for deleting
A single :obj:`Photo` id as string or multiple ids as list of strings for deleting
more than one photos at once.
Returns:
True on success.
``bool``: True on success.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
id = id if isinstance(id, list) else [id]
input_photos = []

View File

@@ -26,10 +26,10 @@ class GetMe(BaseClient):
"""A simple method for testing your authorization. Requires no parameters.
Returns:
Basic information about the user or bot in form of a :obj:`User` object
:obj:`User`: Basic information about the user or bot.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
return pyrogram.User._parse(
self,

View File

@@ -32,7 +32,7 @@ class GetUserProfilePhotos(BaseClient):
) -> "pyrogram.UserProfilePhotos":
"""Use this method to get a list of profile pictures for a user.
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".
@@ -47,10 +47,10 @@ class GetUserProfilePhotos(BaseClient):
Values between 1—100 are accepted. Defaults to 100.
Returns:
On success, a :obj:`UserProfilePhotos` object is returned.
:obj:`UserProfilePhotos`: On success, an object containing a list of the profile photos is returned.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
RPCError: In case of a Telegram RPC error.
"""
return pyrogram.UserProfilePhotos._parse(
self,

Some files were not shown because too many files have changed in this diff Show More