diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 13e0071e..19d0cd78 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ github: delivrance -custom: https://docs.pyrogram.org/support +liberapay: delivrance +open_collective: pyrogram diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7efd4ca1..e3bc5909 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,6 @@ --- name: Bug Report -about: Create a bug report affecting the library or the documentation +about: Create a bug report affecting the framework or the documentation --- diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 37e0cd33..453151d8 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,7 +2,7 @@ blank_issues_enabled: false contact_links: - name: Ask Pyrogram related questions url: https://stackoverflow.com/questions/tagged/pyrogram - about: This place is for issues about Pyrogram. If you'd like to ask a question, please do so at StackOverflow. - - name: Join the Telegram community + about: This place is only for reporting issues about Pyrogram. You can ask questions at StackOverflow. + - name: Join the Telegram channel url: https://t.me/pyrogram - about: Join the official channel to stay tuned for news and updates. \ No newline at end of file + about: Join the official channel and stay tuned for news, updates and announcements. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 854db44d..bf5e6a21 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -7,7 +7,7 @@ labels: "enhancement" ## Checklist -- [ ] I believe the idea is awesome and would benefit the library. +- [ ] I believe the idea is awesome and would benefit the framework. - [ ] I have searched in the issue tracker for similar requests, including closed ones. ## Description diff --git a/README.md b/README.md index f8c4432e..e51ee0eb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
-
+
Telegram MTProto API Framework for Python
@@ -9,17 +9,19 @@
Documentation
•
-
+
Releases
•
-
- Community
+
+ News
inline fixed-width code
@@ -136,14 +135,13 @@ The following tags are currently supported:
.. code-block:: python
app.send_message(
- "haskell",
+ "me",
(
"bold, "
"italic, "
"underline, "
"code\n\n"
""
@@ -181,7 +179,7 @@ This means you can combine together both syntaxes in the same text:
.. code-block:: python
- app.send_message("haskell", "**bold**, italic")
+ app.send_message("me", "**bold**, italic")
Result:
@@ -192,8 +190,8 @@ If you don't like this behaviour you can always choose to only enable either Mar
.. code-block::
- app.send_message("haskell", "**bold**, italic", parse_mode="markdown")
- app.send_message("haskell", "**bold**, italic", parse_mode="html")
+ app.send_message("me", "**bold**, italic", parse_mode="markdown")
+ app.send_message("me", "**bold**, italic", parse_mode="html")
Result:
@@ -206,7 +204,7 @@ as-is.
.. code-block:: python
- app.send_message("haskell", "**bold**, italic", parse_mode=None)
+ app.send_message("me", "**bold**, italic", parse_mode=None)
Result:
diff --git a/docs/source/topics/tgcrypto.rst b/docs/source/topics/tgcrypto.rst
index e0d9beb6..f6ca211d 100644
--- a/docs/source/topics/tgcrypto.rst
+++ b/docs/source/topics/tgcrypto.rst
@@ -1,11 +1,11 @@
Fast Crypto
===========
-Pyrogram's speed can be *dramatically* boosted up by TgCrypto_, a high-performance, easy-to-install Telegram Crypto
-Library specifically written in C for Pyrogram [1]_ as a Python extension.
+Pyrogram's speed can be boosted up by TgCrypto_, a high-performance, easy-to-install cryptography library specifically
+written in C for Pyrogram as a Python extension.
-TgCrypto is a replacement for the much slower PyAES and implements the crypto algorithms Telegram requires, namely
-**AES-IGE 256 bit** (used in MTProto v2.0) and **AES-CTR 256 bit** (used for CDN encrypted files).
+TgCrypto is a replacement for a slower Python-only alternative and implements the cryptographic algorithms Telegram
+requires, namely: AES-256-IGE, AES-256-CTR and AES-256-CBC.
Installation
------------
@@ -14,10 +14,10 @@ Installation
$ pip3 install -U tgcrypto
-.. note:: Being a C extension for Python, TgCrypto is an optional but *highly recommended* dependency; when TgCrypto is
- not detected in your system, Pyrogram will automatically fall back to PyAES and will show you a warning.
+.. note:: When TgCrypto is not detected in your system, Pyrogram will automatically fall back to a slower Python-only
+ implementation and will show you a warning.
-The reason about being an optional package is that TgCrypto requires some extra system tools in order to be compiled.
+The reason about being an optional package is that TgCrypto requires extra system tools in order to be compiled.
The errors you receive when trying to install TgCrypto are system dependent, but also descriptive enough to understand
what you should do next:
@@ -26,7 +26,4 @@ what you should do next:
- **Linux**: Install a proper C compiler (``gcc``, ``clang``) and the Python header files (``python3-dev``).
- **Termux**: Install ``clang`` package.
-.. _TgCrypto: https://github.com/pyrogram/tgcrypto
-
-.. [1] Although TgCrypto is intended for Pyrogram, it is shipped as a standalone package and can thus be used for
- other Python projects too.
+.. _TgCrypto: https://github.com/pyrogram/tgcrypto
\ No newline at end of file
diff --git a/docs/source/topics/use-filters.rst b/docs/source/topics/use-filters.rst
index 7e5219e1..eda6d7ad 100644
--- a/docs/source/topics/use-filters.rst
+++ b/docs/source/topics/use-filters.rst
@@ -19,16 +19,15 @@ Single Filters
Let's start right away with a simple example:
-- This example will show you how to **only** handle messages containing an :class:`~pyrogram.Audio` object and
+- This example will show you how to **only** handle messages containing a :class:`~pyrogram.types.Sticker` object and
ignore any other message. Filters are passed as the first argument of the decorator:
.. code-block:: python
- :emphasize-lines: 4
from pyrogram import filters
- @app.on_message(filters.audio)
+ @app.on_message(filters.sticker)
def my_handler(client, message):
print(message)
@@ -36,7 +35,6 @@ Let's start right away with a simple example:
callback function itself:
.. code-block:: python
- :emphasize-lines: 9
from pyrogram import filters
from pyrogram.handlers import MessageHandler
@@ -46,12 +44,12 @@ Let's start right away with a simple example:
print(message)
- app.add_handler(MessageHandler(my_handler, filters.audio))
+ app.add_handler(MessageHandler(my_handler, filters.sticker))
Combining Filters
-----------------
-Filters can also be used in a more advanced way by inverting and combining more filters together using bitwise
+Filters can be used in a more advanced way by inverting and combining more filters together using bitwise
operators ``~``, ``&`` and ``|``:
- Use ``~`` to invert a filter (behaves like the ``not`` operator).
diff --git a/docs/source/topics/voice-calls.rst b/docs/source/topics/voice-calls.rst
index 19950bf4..aef4030c 100644
--- a/docs/source/topics/voice-calls.rst
+++ b/docs/source/topics/voice-calls.rst
@@ -1,8 +1,8 @@
Voice Calls
===========
-Both private voice calls and group voice calls are currently supported by third-party libraries that integrate with
-Pyrogram.
+Both private voice calls and group voice calls are currently supported by third-party, external libraries that integrate
+with Pyrogram.
Libraries
---------
diff --git a/pyrogram/client.py b/pyrogram/client.py
index c5c72af8..65514cf6 100644
--- a/pyrogram/client.py
+++ b/pyrogram/client.py
@@ -32,6 +32,7 @@ from pathlib import Path
from typing import Union, List, Optional
import pyrogram
+from pyrogram import __version__, __license__
from pyrogram import raw
from pyrogram import utils
from pyrogram.crypto import aes
@@ -281,6 +282,10 @@ class Client(Methods, Scaffold):
if self.bot_token:
return await self.sign_in_bot(self.bot_token)
+ print(f"Welcome to Pyrogram (version {__version__})")
+ print(f"Pyrogram is free software and comes with ABSOLUTELY NO WARRANTY. Licensed\n"
+ f"under the terms of the {__license__}.\n")
+
while True:
try:
if not self.phone_number:
@@ -428,7 +433,6 @@ class Client(Methods, Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 10,14,18,22
from pyrogram import Client
@@ -436,23 +440,23 @@ class Client(Methods, Scaffold):
with app:
# Default combined mode: Markdown + HTML
- app.send_message("haskell", "1. **markdown** and html")
+ app.send_message("me", "1. **markdown** and html")
# Force Markdown-only, HTML is disabled
app.set_parse_mode("markdown")
- app.send_message("haskell", "2. **markdown** and html")
+ app.send_message("me", "2. **markdown** and html")
# Force HTML-only, Markdown is disabled
app.set_parse_mode("html")
- app.send_message("haskell", "3. **markdown** and html")
+ app.send_message("me", "3. **markdown** and html")
# Disable the parser completely
app.set_parse_mode(None)
- app.send_message("haskell", "4. **markdown** and html")
+ app.send_message("me", "4. **markdown** and html")
# Bring back the default combined mode
app.set_parse_mode()
- app.send_message("haskell", "5. **markdown** and html")
+ app.send_message("me", "5. **markdown** and html")
"""
self.parse_mode = parse_mode
@@ -937,8 +941,8 @@ class Client(Methods, Scaffold):
await self.loop.run_in_executor(self.executor, func)
if len(chunk) < limit:
- break
-
+ break
+
r = await session.send(
raw.functions.upload.GetFile(
location=location,
diff --git a/pyrogram/connection/transport/tcp/tcp_abridged.py b/pyrogram/connection/transport/tcp/tcp_abridged.py
index cee97831..0282e668 100644
--- a/pyrogram/connection/transport/tcp/tcp_abridged.py
+++ b/pyrogram/connection/transport/tcp/tcp_abridged.py
@@ -17,7 +17,6 @@
# along with Pyrogram. If not, see .
import logging
-
from typing import Optional
from .tcp import TCP
diff --git a/pyrogram/connection/transport/tcp/tcp_full.py b/pyrogram/connection/transport/tcp/tcp_full.py
index 7befddb1..8c80f454 100644
--- a/pyrogram/connection/transport/tcp/tcp_full.py
+++ b/pyrogram/connection/transport/tcp/tcp_full.py
@@ -17,9 +17,9 @@
# along with Pyrogram. If not, see .
import logging
-from typing import Optional
from binascii import crc32
from struct import pack, unpack
+from typing import Optional
from .tcp import TCP
diff --git a/pyrogram/connection/transport/tcp/tcp_intermediate.py b/pyrogram/connection/transport/tcp/tcp_intermediate.py
index 659c30e4..6b18ab15 100644
--- a/pyrogram/connection/transport/tcp/tcp_intermediate.py
+++ b/pyrogram/connection/transport/tcp/tcp_intermediate.py
@@ -17,8 +17,8 @@
# along with Pyrogram. If not, see .
import logging
-from typing import Optional
from struct import pack, unpack
+from typing import Optional
from .tcp import TCP
diff --git a/pyrogram/connection/transport/tcp/tcp_intermediate_o.py b/pyrogram/connection/transport/tcp/tcp_intermediate_o.py
index be783f04..c257fdd5 100644
--- a/pyrogram/connection/transport/tcp/tcp_intermediate_o.py
+++ b/pyrogram/connection/transport/tcp/tcp_intermediate_o.py
@@ -18,8 +18,8 @@
import logging
import os
-from typing import Optional
from struct import pack, unpack
+from typing import Optional
from pyrogram.crypto import aes
from .tcp import TCP
diff --git a/pyrogram/errors/rpc_error.py b/pyrogram/errors/rpc_error.py
index 71a7249f..a9fd6655 100644
--- a/pyrogram/errors/rpc_error.py
+++ b/pyrogram/errors/rpc_error.py
@@ -39,7 +39,7 @@ class RPCError(Exception):
is_unknown: bool = False,
is_signed: bool = False
):
- super().__init__("[{}{} {}]: {} {}".format(
+ super().__init__("Telegram says: [{}{} {}] - {} {}".format(
"-" if is_signed else "",
self.CODE,
self.ID or self.NAME,
diff --git a/pyrogram/filters.py b/pyrogram/filters.py
index b6d27087..e583e063 100644
--- a/pyrogram/filters.py
+++ b/pyrogram/filters.py
@@ -934,12 +934,3 @@ class chat(Filter, set):
and message.from_user
and message.from_user.is_self
and not message.outgoing)))
-
-
-# region dan_filter
-async def dan_filter(_, __, m: Message):
- return bool(m.from_user and m.from_user.id == 23122162)
-
-
-dan = create(dan_filter)
-# endregion
diff --git a/pyrogram/methods/bots/__init__.py b/pyrogram/methods/bots/__init__.py
index 8cc7dd30..1e6b9146 100644
--- a/pyrogram/methods/bots/__init__.py
+++ b/pyrogram/methods/bots/__init__.py
@@ -23,8 +23,8 @@ from .get_inline_bot_results import GetInlineBotResults
from .request_callback_answer import RequestCallbackAnswer
from .send_game import SendGame
from .send_inline_bot_result import SendInlineBotResult
-from .set_game_score import SetGameScore
from .set_bot_commands import SetBotCommands
+from .set_game_score import SetGameScore
class Bots(
diff --git a/pyrogram/methods/chats/get_chat_member.py b/pyrogram/methods/chats/get_chat_member.py
index 74aff5da..711eafdd 100644
--- a/pyrogram/methods/chats/get_chat_member.py
+++ b/pyrogram/methods/chats/get_chat_member.py
@@ -47,8 +47,8 @@ class GetChatMember(Scaffold):
Example:
.. code-block:: python
- dan = app.get_chat_member("pyrogramchat", "haskell")
- print(dan)
+ member = app.get_chat_member(chat_id, "me")
+ print(member)
"""
chat = await self.resolve_peer(chat_id)
user = await self.resolve_peer(user_id)
diff --git a/pyrogram/methods/chats/get_chat_members.py b/pyrogram/methods/chats/get_chat_members.py
index d22cc446..c984107c 100644
--- a/pyrogram/methods/chats/get_chat_members.py
+++ b/pyrogram/methods/chats/get_chat_members.py
@@ -57,16 +57,17 @@ class GetChatMembers(Scaffold):
offset (``int``, *optional*):
Sequential number of the first member to be returned.
- Only applicable to supergroups and channels. Defaults to 0 [1]_.
+ Only applicable to supergroups and channels. Defaults to 0.
limit (``int``, *optional*):
Limits the number of members to be retrieved.
Only applicable to supergroups and channels.
- Defaults to 200, which is also the maximum server limit allowed per method call.
+ Defaults to 200.
query (``str``, *optional*):
Query string to filter members based on their display names and usernames.
- Only applicable to supergroups and channels. Defaults to "" (empty string) [2]_.
+ Only applicable to supergroups and channels. Defaults to "" (empty string).
+ A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only
filter (``str``, *optional*):
Filter used to select the kind of members you want to retrieve. Only applicable for supergroups
@@ -80,11 +81,6 @@ class GetChatMembers(Scaffold):
Only applicable to supergroups and channels.
Defaults to *"recent"*.
- .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
- on channels.
-
- .. [2] A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only.
-
Returns:
List of :obj:`~pyrogram.types.ChatMember`: On success, a list of chat members is returned.
@@ -95,13 +91,13 @@ class GetChatMembers(Scaffold):
.. code-block:: python
# Get first 200 recent members
- app.get_chat_members("pyrogramchat")
+ app.get_chat_members(chat_id)
# Get all administrators
- app.get_chat_members("pyrogramchat", filter="administrators")
+ app.get_chat_members(chat_id, filter="administrators")
# Get all bots
- app.get_chat_members("pyrogramchat", filter="bots")
+ app.get_chat_members(chat_id, filter="bots")
"""
peer = await self.resolve_peer(chat_id)
diff --git a/pyrogram/methods/chats/get_chat_members_count.py b/pyrogram/methods/chats/get_chat_members_count.py
index 3fc80e5d..896b244d 100644
--- a/pyrogram/methods/chats/get_chat_members_count.py
+++ b/pyrogram/methods/chats/get_chat_members_count.py
@@ -42,7 +42,7 @@ class GetChatMembersCount(Scaffold):
Example:
.. code-block:: python
- count = app.get_chat_members_count("pyrogramchat")
+ count = app.get_chat_members_count(chat_id)
print(count)
"""
peer = await self.resolve_peer(chat_id)
diff --git a/pyrogram/methods/chats/iter_chat_members.py b/pyrogram/methods/chats/iter_chat_members.py
index 3db39355..c4144384 100644
--- a/pyrogram/methods/chats/iter_chat_members.py
+++ b/pyrogram/methods/chats/iter_chat_members.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from string import ascii_lowercase
from typing import Union, AsyncGenerator, Optional
from pyrogram import raw
@@ -33,10 +32,6 @@ class Filters:
ADMINISTRATORS = "administrators"
-QUERIES = [""] + [str(i) for i in range(10)] + list(ascii_lowercase)
-QUERYABLE_FILTERS = (Filters.ALL, Filters.BANNED, Filters.RESTRICTED)
-
-
class IterChatMembers(Scaffold):
async def iter_chat_members(
self,
@@ -57,11 +52,11 @@ class IterChatMembers(Scaffold):
limit (``int``, *optional*):
Limits the number of members to be retrieved.
- By default, no limit is applied and all members are returned [1]_.
query (``str``, *optional*):
Query string to filter members based on their display names and usernames.
- Defaults to "" (empty string) [2]_.
+ Defaults to "" (empty string).
+ A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only.
filter (``str``, *optional*):
Filter used to select the kind of members you want to retrieve. Only applicable for supergroups
@@ -74,11 +69,6 @@ class IterChatMembers(Scaffold):
*"administrators"* - chat administrators only.
Defaults to *"recent"*.
- .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
- on channels.
-
- .. [2] A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only.
-
Returns:
``Generator``: A generator yielding :obj:`~pyrogram.types.ChatMember` objects.
@@ -86,58 +76,52 @@ class IterChatMembers(Scaffold):
.. code-block:: python
# Iterate though all chat members
- for member in app.iter_chat_members("pyrogramchat"):
+ for member in app.iter_chat_members(chat_id):
print(member.user.first_name)
# Iterate though all administrators
- for member in app.iter_chat_members("pyrogramchat", filter="administrators"):
+ for member in app.iter_chat_members(chat_id, filter="administrators"):
print(member.user.first_name)
# Iterate though all bots
- for member in app.iter_chat_members("pyrogramchat", filter="bots"):
+ for member in app.iter_chat_members(chat_id, filter="bots"):
print(member.user.first_name)
"""
current = 0
yielded = set()
- queries = [query] if query else QUERIES
total = limit or (1 << 31) - 1
limit = min(200, total)
resolved_chat_id = await self.resolve_peer(chat_id)
+ offset = 0
- if filter not in QUERYABLE_FILTERS:
- queries = [""]
+ while True:
+ chat_members = await self.get_chat_members(
+ chat_id=chat_id,
+ offset=offset,
+ limit=limit,
+ query=query,
+ filter=filter
+ )
- for q in queries:
- offset = 0
+ if not chat_members:
+ break
- while True:
- chat_members = await self.get_chat_members(
- chat_id=chat_id,
- offset=offset,
- limit=limit,
- query=q,
- filter=filter
- )
+ if isinstance(resolved_chat_id, raw.types.InputPeerChat):
+ total = len(chat_members)
- if not chat_members:
- break
+ offset += len(chat_members)
- if isinstance(resolved_chat_id, raw.types.InputPeerChat):
- total = len(chat_members)
+ for chat_member in chat_members:
+ user_id = chat_member.user.id
- offset += len(chat_members)
+ if user_id in yielded:
+ continue
- for chat_member in chat_members:
- user_id = chat_member.user.id
+ yield chat_member
- if user_id in yielded:
- continue
+ yielded.add(chat_member.user.id)
- yield chat_member
+ current += 1
- yielded.add(chat_member.user.id)
-
- current += 1
-
- if current >= total:
- return
+ if current >= total:
+ return
diff --git a/pyrogram/methods/chats/set_administrator_title.py b/pyrogram/methods/chats/set_administrator_title.py
index fff4d617..e0a32bdf 100644
--- a/pyrogram/methods/chats/set_administrator_title.py
+++ b/pyrogram/methods/chats/set_administrator_title.py
@@ -52,7 +52,7 @@ class SetAdministratorTitle(Scaffold):
Example:
.. code-block:: python
- app.set_administrator_title(chat_id, user_id, "ฅ^•ﻌ•^ฅ")
+ app.set_administrator_title(chat_id, user_id, "Admin Title")
"""
chat_id = await self.resolve_peer(chat_id)
user_id = await self.resolve_peer(user_id)
diff --git a/pyrogram/methods/chats/set_slow_mode.py b/pyrogram/methods/chats/set_slow_mode.py
index 19e64925..084e775c 100644
--- a/pyrogram/methods/chats/set_slow_mode.py
+++ b/pyrogram/methods/chats/set_slow_mode.py
@@ -45,10 +45,10 @@ class SetSlowMode(Scaffold):
.. code-block:: python
# Set slow mode to 60 seconds
- app.set_slow_mode("pyrogramchat", 60)
+ app.set_slow_mode(chat_id, 60)
# Disable slow mode
- app.set_slow_mode("pyrogramchat", None)
+ app.set_slow_mode(chat_id, None)
"""
await self.send(
diff --git a/pyrogram/methods/contacts/add_contact.py b/pyrogram/methods/contacts/add_contact.py
index 5d00253b..79b85b9c 100644
--- a/pyrogram/methods/contacts/add_contact.py
+++ b/pyrogram/methods/contacts/add_contact.py
@@ -38,7 +38,7 @@ class AddContact(Scaffold):
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target user.
- first_name (``str``, *optional*):
+ first_name (``str``):
User's first name.
last_name (``str``, *optional*):
diff --git a/pyrogram/methods/contacts/import_contacts.py b/pyrogram/methods/contacts/import_contacts.py
index 4039cbe5..9ba190f3 100644
--- a/pyrogram/methods/contacts/import_contacts.py
+++ b/pyrogram/methods/contacts/import_contacts.py
@@ -43,9 +43,9 @@ class ImportContacts(Scaffold):
from pyrogram.types import InputPhoneContact
app.import_contacts([
- InputPhoneContact("39123456789", "Foo"),
- InputPhoneContact("38987654321", "Bar"),
- InputPhoneContact("01234567891", "Baz")])
+ InputPhoneContact("+1-123-456-7890", "Foo"),
+ InputPhoneContact("+1-456-789-0123", "Bar"),
+ InputPhoneContact("+1-789-012-3456", "Baz")])
"""
imported_contacts = await self.send(
raw.functions.contacts.ImportContacts(
diff --git a/pyrogram/methods/messages/copy_media_group.py b/pyrogram/methods/messages/copy_media_group.py
index 7845863c..4866d824 100644
--- a/pyrogram/methods/messages/copy_media_group.py
+++ b/pyrogram/methods/messages/copy_media_group.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from typing import Union, List, Optional
+from typing import Union, List
from pyrogram import types, utils, raw
from pyrogram.scaffold import Scaffold
@@ -103,7 +103,8 @@ class CopyMediaGroup(Scaffold):
**await self.parser.parse(
captions[i] if isinstance(captions, list) and i < len(captions) and captions[i] else
captions if isinstance(captions, str) and i == 0 else
- message.caption if message.caption and message.caption != "None" and not type(captions) is str else "")
+ message.caption if message.caption and message.caption != "None" and not type(
+ captions) is str else "")
)
)
diff --git a/pyrogram/methods/messages/download_media.py b/pyrogram/methods/messages/download_media.py
index 826da89e..be5da060 100644
--- a/pyrogram/methods/messages/download_media.py
+++ b/pyrogram/methods/messages/download_media.py
@@ -92,7 +92,7 @@ class DownloadMedia(Scaffold):
app.download_media(message)
# Download from file id
- app.download_media("CAADBAADzg4AAvLQYAEz_x2EOgdRwBYE")
+ app.download_media(message.photo.file_id)
# Keep track of the progress while downloading
def progress(current, total):
diff --git a/pyrogram/methods/messages/forward_messages.py b/pyrogram/methods/messages/forward_messages.py
index 9218bf6e..fc278059 100644
--- a/pyrogram/methods/messages/forward_messages.py
+++ b/pyrogram/methods/messages/forward_messages.py
@@ -67,7 +67,6 @@ class ForwardMessages(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 2,5
# Forward a single message
app.forward_messages("me", "pyrogram", 20)
diff --git a/pyrogram/methods/messages/get_history.py b/pyrogram/methods/messages/get_history.py
index 0227cd6e..98a2f77e 100644
--- a/pyrogram/methods/messages/get_history.py
+++ b/pyrogram/methods/messages/get_history.py
@@ -72,13 +72,13 @@ class GetHistory(Scaffold):
.. code-block:: python
# Get the last 100 messages of a chat
- app.get_history("pyrogramchat")
+ app.get_history(chat_id)
# Get the last 3 messages of a chat
- app.get_history("pyrogramchat", limit=3)
+ app.get_history(chat_id, limit=3)
# Get 3 messages after skipping the first 5
- app.get_history("pyrogramchat", offset=5, limit=3)
+ app.get_history(chat_id, offset=5, limit=3)
"""
offset_id = offset_id or (1 if reverse else 0)
diff --git a/pyrogram/methods/messages/get_history_count.py b/pyrogram/methods/messages/get_history_count.py
index 191a58e0..6552d527 100644
--- a/pyrogram/methods/messages/get_history_count.py
+++ b/pyrogram/methods/messages/get_history_count.py
@@ -48,7 +48,7 @@ class GetHistoryCount(Scaffold):
Example:
.. code-block:: python
- app.get_history_count("pyrogramchat")
+ app.get_history_count(chat_id)
"""
r = await self.send(
diff --git a/pyrogram/methods/messages/get_media_group.py b/pyrogram/methods/messages/get_media_group.py
index 83fff12a..b429224f 100644
--- a/pyrogram/methods/messages/get_media_group.py
+++ b/pyrogram/methods/messages/get_media_group.py
@@ -50,7 +50,7 @@ class GetMediaGroup(Scaffold):
In case the passed message_id is negative or equal 0.
In case target message doesn't belong to a media group.
"""
-
+
# There can be maximum 10 items in a media group.
messages = await self.get_messages(chat_id, [msg_id for msg_id in range(message_id - 9, message_id + 10)],
replies=0)
@@ -66,7 +66,7 @@ class GetMediaGroup(Scaffold):
# There can be maximum 10 items in a media group.
# The if/else condition to fix the problem of getting correct `media_group_id` when it has `message_id` less then 10.
- media_group_id = messages[9].media_group_id if len(messages) == 19 else messages[message_id-1].media_group_id
+ media_group_id = messages[9].media_group_id if len(messages) == 19 else messages[message_id - 1].media_group_id
if media_group_id is None:
raise ValueError("The message doesn't belong to a media group")
diff --git a/pyrogram/methods/messages/get_messages.py b/pyrogram/methods/messages/get_messages.py
index 39455ec4..cb4d2abb 100644
--- a/pyrogram/methods/messages/get_messages.py
+++ b/pyrogram/methods/messages/get_messages.py
@@ -71,10 +71,10 @@ class GetMessages(Scaffold):
.. code-block:: python
# Get one message
- app.get_messages("pyrogramchat", 51110)
+ app.get_messages(chat_id, 12345)
# Get more than one message (list of messages)
- app.get_messages("pyrogramchat", [44625, 51110])
+ app.get_messages(chat_id, [12345, 12346])
# Get message by ignoring any replied-to message
app.get_messages(chat_id, message_id, replies=0)
diff --git a/pyrogram/methods/messages/read_history.py b/pyrogram/methods/messages/read_history.py
index d06d8dcb..e7477397 100644
--- a/pyrogram/methods/messages/read_history.py
+++ b/pyrogram/methods/messages/read_history.py
@@ -47,10 +47,10 @@ class ReadHistory(Scaffold):
.. code-block:: python
# Mark the whole chat as read
- app.read_history("pyrogramlounge")
+ app.read_history(chat_id)
# Mark messages as read only up to the given message id
- app.read_history("pyrogramlounge", 123456)
+ app.read_history(chat_id, 123456)
"""
peer = await self.resolve_peer(chat_id)
diff --git a/pyrogram/methods/messages/search_global.py b/pyrogram/methods/messages/search_global.py
index bac5d804..b016653d 100644
--- a/pyrogram/methods/messages/search_global.py
+++ b/pyrogram/methods/messages/search_global.py
@@ -53,6 +53,8 @@ class SearchGlobal(Scaffold):
) -> Optional[AsyncGenerator["types.Message", None]]:
"""Search messages globally from all of your chats.
+ If you want to get the messages count only, see :meth:`~pyrogram.Client.search_global_count`.
+
.. note::
Due to server-side limitations, you can only get up to around ~10,000 messages and each message
@@ -91,12 +93,12 @@ class SearchGlobal(Scaffold):
Example:
.. code-block:: python
- # Search for "pyrogram". Get the first 420 results
- for message in app.search_global("pyrogram", limit=420):
+ # Search for "pyrogram". Get the first 50 results
+ for message in app.search_global("pyrogram", limit=50):
print(message.text)
- # Search for recent photos from Global. Get the first 69 results
- for message in app.search_global(filter="photo", limit=69):
+ # Search for recent photos from Global. Get the first 20 results
+ for message in app.search_global(filter="photo", limit=20):
print(message.photo)
"""
try:
diff --git a/pyrogram/methods/messages/search_messages.py b/pyrogram/methods/messages/search_messages.py
index f8d0cb33..b62d4cfe 100644
--- a/pyrogram/methods/messages/search_messages.py
+++ b/pyrogram/methods/messages/search_messages.py
@@ -101,6 +101,8 @@ class SearchMessages(Scaffold):
) -> Optional[AsyncGenerator["types.Message", None]]:
"""Search for text and media messages inside a specific chat.
+ If you want to get the messages count only, see :meth:`~pyrogram.Client.search_messages_count`.
+
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
@@ -142,7 +144,7 @@ class SearchMessages(Scaffold):
Limits the number of messages to be retrieved.
By default, no limit is applied and all messages are returned.
- from_user (``int`` | ``str``):
+ from_user (``int`` | ``str``, *optional*):
Unique identifier (int) or username (str) of the target user you want to search for messages from.
Returns:
@@ -151,16 +153,16 @@ class SearchMessages(Scaffold):
Example:
.. code-block:: python
- # Search for text messages in @pyrogramchat. Get the last 333 results
- for message in app.search_messages("pyrogramchat", query="dan", limit=333):
+ # Search for text messages in chat. Get the last 120 results
+ for message in app.search_messages(chat_id, query="hello", limit=120):
print(message.text)
- # Search for pinned messages in @pyrogramchat
- for message in app.search_messages("pyrogramchat", filter="pinned"):
+ # Search for pinned messages in chat
+ for message in app.search_messages(chat_id, filter="pinned"):
print(message.text)
- # Search for messages containing "hi" sent by @haskell in @pyrogramchat
- for message in app.search_messages("pyrogramchat", "hi", from_user="haskell"):
+ # Search for messages containing "hello" sent by yourself in chat
+ for message in app.search_messages(chat, "hello", from_user="me"):
print(message.text)
"""
current = 0
diff --git a/pyrogram/methods/messages/send_animation.py b/pyrogram/methods/messages/send_animation.py
index d1ee9585..3a95a950 100644
--- a/pyrogram/methods/messages/send_animation.py
+++ b/pyrogram/methods/messages/send_animation.py
@@ -158,7 +158,7 @@ class SendAnimation(Scaffold):
app.send_animation("me", "animation.gif")
# Add caption to the animation
- app.send_animation("me", "animation.gif", caption="cat")
+ app.send_animation("me", "animation.gif", caption="animation caption")
# Unsave the animation once is sent
app.send_animation("me", "animation.gif", unsave=True)
diff --git a/pyrogram/methods/messages/send_audio.py b/pyrogram/methods/messages/send_audio.py
index eeb45f65..6ca16fe1 100644
--- a/pyrogram/methods/messages/send_audio.py
+++ b/pyrogram/methods/messages/send_audio.py
@@ -149,18 +149,17 @@ class SendAudio(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 2,5,8-10,13-16
# Send audio file by uploading from file
app.send_audio("me", "audio.mp3")
# Add caption to the audio
- app.send_audio("me", "audio.mp3", caption="shoegaze")
+ app.send_audio("me", "audio.mp3", caption="audio caption")
# Set audio metadata
app.send_audio(
"me", "audio.mp3",
- title="Printemps émeraude", performer="Alcest", duration=440)
+ title="Title", performer="Performer", duration=234)
# Keep track of the progress while uploading
def progress(current, total):
diff --git a/pyrogram/methods/messages/send_cached_media.py b/pyrogram/methods/messages/send_cached_media.py
index 1f1517e7..4e7b8149 100644
--- a/pyrogram/methods/messages/send_cached_media.py
+++ b/pyrogram/methods/messages/send_cached_media.py
@@ -91,7 +91,7 @@ class SendCachedMedia(Scaffold):
Example:
.. code-block:: python
- app.send_cached_media("me", "CAADBAADzg4AAvLQYAEz_x2EOgdRwBYE")
+ app.send_cached_media("me", file_id)
"""
r = await self.send(
diff --git a/pyrogram/methods/messages/send_contact.py b/pyrogram/methods/messages/send_contact.py
index f744fab0..5ce3b013 100644
--- a/pyrogram/methods/messages/send_contact.py
+++ b/pyrogram/methods/messages/send_contact.py
@@ -85,7 +85,7 @@ class SendContact(Scaffold):
Example:
.. code-block:: python
- app.send_contact("me", "+39 123 456 7890", "Dan")
+ app.send_contact("me", "+1-123-456-7890", "Name")
"""
r = await self.send(
raw.functions.messages.SendMedia(
diff --git a/pyrogram/methods/messages/send_dice.py b/pyrogram/methods/messages/send_dice.py
index 6c7f70cd..5d89b03c 100644
--- a/pyrogram/methods/messages/send_dice.py
+++ b/pyrogram/methods/messages/send_dice.py
@@ -78,13 +78,13 @@ class SendDice(Scaffold):
.. code-block:: python
# Send a dice
- app.send_dice("pyrogramlounge")
+ app.send_dice(chat_id)
# Send a dart
- app.send_dice("pyrogramlounge", "🎯")
+ app.send_dice(chat_id, "🎯")
# Send a basketball
- app.send_dice("pyrogramlounge", "🏀")
+ app.send_dice(chat_id, "🏀")
"""
r = await self.send(
diff --git a/pyrogram/methods/messages/send_document.py b/pyrogram/methods/messages/send_document.py
index 3661b255..82be26d1 100644
--- a/pyrogram/methods/messages/send_document.py
+++ b/pyrogram/methods/messages/send_document.py
@@ -146,7 +146,7 @@ class SendDocument(Scaffold):
app.send_document("me", "document.zip")
# Add caption to the document file
- app.send_document("me", "document.zip", caption="archive")
+ app.send_document("me", "document.zip", caption="document caption")
# Keep track of the progress while uploading
def progress(current, total):
diff --git a/pyrogram/methods/messages/send_media_group.py b/pyrogram/methods/messages/send_media_group.py
index dc8ca7f0..9f4c5e54 100644
--- a/pyrogram/methods/messages/send_media_group.py
+++ b/pyrogram/methods/messages/send_media_group.py
@@ -83,7 +83,7 @@ class SendMediaGroup(Scaffold):
[
InputMediaPhoto("photo1.jpg"),
InputMediaPhoto("photo2.jpg", caption="photo caption"),
- InputMediaVideo("video.mp4", caption="a video")
+ InputMediaVideo("video.mp4", caption="video caption")
]
)
"""
diff --git a/pyrogram/methods/messages/send_message.py b/pyrogram/methods/messages/send_message.py
index 54fcfe48..5277ec1f 100644
--- a/pyrogram/methods/messages/send_message.py
+++ b/pyrogram/methods/messages/send_message.py
@@ -88,10 +88,9 @@ class SendMessage(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 2,5,8,11,21-23,26-32
# Simple example
- app.send_message("haskell", "Thanks for creating **Pyrogram**!")
+ app.send_message("me", "Message sent with **Pyrogram**!")
# Disable web page previews
app.send_message("me", "https://docs.pyrogram.org", disable_web_page_preview=True)
@@ -119,7 +118,7 @@ class SendMessage(Scaffold):
chat_id, "These are inline buttons",
reply_markup=InlineKeyboardMarkup(
[
- [InlineKeyboardButton("Data", callback_data="hidden_callback_data")],
+ [InlineKeyboardButton("Data", callback_data="callback_data")],
[InlineKeyboardButton("Docs", url="https://docs.pyrogram.org")]
]))
"""
diff --git a/pyrogram/methods/messages/send_sticker.py b/pyrogram/methods/messages/send_sticker.py
index 144bba37..4aa3ce28 100644
--- a/pyrogram/methods/messages/send_sticker.py
+++ b/pyrogram/methods/messages/send_sticker.py
@@ -113,7 +113,7 @@ class SendSticker(Scaffold):
app.send_sticker("me", "sticker.webp")
# Send sticker using file_id
- app.send_sticker("me", "CAADBAADzg4AAvLQYAEz_x2EOgdRwBYE")
+ app.send_sticker("me", file_id)
"""
file = None
diff --git a/pyrogram/methods/messages/send_video.py b/pyrogram/methods/messages/send_video.py
index 23563175..8eff5d97 100644
--- a/pyrogram/methods/messages/send_video.py
+++ b/pyrogram/methods/messages/send_video.py
@@ -163,7 +163,7 @@ class SendVideo(Scaffold):
app.send_video("me", "video.mp4")
# Add caption to the video
- app.send_video("me", "video.mp4", caption="recording")
+ app.send_video("me", "video.mp4", caption="video caption")
# Send self-destructing video
app.send_video("me", "video.mp4", ttl_seconds=10)
diff --git a/pyrogram/methods/messages/send_voice.py b/pyrogram/methods/messages/send_voice.py
index 9828ccf8..3782d41b 100644
--- a/pyrogram/methods/messages/send_voice.py
+++ b/pyrogram/methods/messages/send_voice.py
@@ -132,7 +132,7 @@ class SendVoice(Scaffold):
app.send_voice("me", "voice.ogg")
# Add caption to the voice note
- app.send_voice("me", "voice.ogg", caption="voice note")
+ app.send_voice("me", "voice.ogg", caption="voice caption")
# Set voice note duration
app.send_voice("me", "voice.ogg", duration=20)
diff --git a/pyrogram/methods/users/get_common_chats.py b/pyrogram/methods/users/get_common_chats.py
index 45ab2fe7..6674d229 100644
--- a/pyrogram/methods/users/get_common_chats.py
+++ b/pyrogram/methods/users/get_common_chats.py
@@ -42,7 +42,7 @@ class GetCommonChats(Scaffold):
Example:
.. code-block:: python
- common = app.get_common_chats("haskell")
+ common = app.get_common_chats(user_id)
print(common)
"""
diff --git a/pyrogram/methods/users/get_profile_photos.py b/pyrogram/methods/users/get_profile_photos.py
index 0a4686ca..fb6f93ca 100644
--- a/pyrogram/methods/users/get_profile_photos.py
+++ b/pyrogram/methods/users/get_profile_photos.py
@@ -54,13 +54,13 @@ class GetProfilePhotos(Scaffold):
.. code-block:: python
# Get the first 100 profile photos of a user
- app.get_profile_photos("haskell")
+ app.get_profile_photos("me")
# Get only the first profile photo of a user
- app.get_profile_photos("haskell", limit=1)
+ app.get_profile_photos("me", limit=1)
# Get 3 profile photos of a user, skip the first 5
- app.get_profile_photos("haskell", limit=3, offset=5)
+ app.get_profile_photos("me", limit=3, offset=5)
"""
peer_id = await self.resolve_peer(chat_id)
diff --git a/pyrogram/methods/users/get_profile_photos_count.py b/pyrogram/methods/users/get_profile_photos_count.py
index 10aca0c5..d27c9da5 100644
--- a/pyrogram/methods/users/get_profile_photos_count.py
+++ b/pyrogram/methods/users/get_profile_photos_count.py
@@ -38,7 +38,7 @@ class GetProfilePhotosCount(Scaffold):
Example:
.. code-block:: python
- count = app.get_profile_photos_count("haskell")
+ count = app.get_profile_photos_count("me")
print(count)
"""
diff --git a/pyrogram/methods/users/get_users.py b/pyrogram/methods/users/get_users.py
index 4da15e9b..3758eaea 100644
--- a/pyrogram/methods/users/get_users.py
+++ b/pyrogram/methods/users/get_users.py
@@ -47,7 +47,7 @@ class GetUsers(Scaffold):
.. code-block:: python
# Get information about one user
- app.get_users("haskell")
+ app.get_users("me")
# Get information about multiple users at once
app.get_users([user1, user2, user3])
diff --git a/pyrogram/methods/users/iter_profile_photos.py b/pyrogram/methods/users/iter_profile_photos.py
index 50af4c44..3ebd7f50 100644
--- a/pyrogram/methods/users/iter_profile_photos.py
+++ b/pyrogram/methods/users/iter_profile_photos.py
@@ -54,7 +54,7 @@ class IterProfilePhotos(Scaffold):
Example:
.. code-block:: python
- for photo in app.iter_profile_photos("haskell"):
+ for photo in app.iter_profile_photos("me"):
print(photo.file_id)
"""
current = 0
diff --git a/pyrogram/methods/utilities/add_handler.py b/pyrogram/methods/utilities/add_handler.py
index c2f85269..466e6431 100644
--- a/pyrogram/methods/utilities/add_handler.py
+++ b/pyrogram/methods/utilities/add_handler.py
@@ -42,7 +42,6 @@ class AddHandler(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 8
from pyrogram import Client
from pyrogram.handlers import MessageHandler
diff --git a/pyrogram/methods/utilities/export_session_string.py b/pyrogram/methods/utilities/export_session_string.py
index 84aceb46..545520a2 100644
--- a/pyrogram/methods/utilities/export_session_string.py
+++ b/pyrogram/methods/utilities/export_session_string.py
@@ -32,7 +32,6 @@ class ExportSessionString(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 6
from pyrogram import Client
diff --git a/pyrogram/methods/utilities/idle.py b/pyrogram/methods/utilities/idle.py
index 7b41f7af..0b3c9a1e 100644
--- a/pyrogram/methods/utilities/idle.py
+++ b/pyrogram/methods/utilities/idle.py
@@ -50,7 +50,6 @@ async def idle():
Example:
.. code-block:: python
- :emphasize-lines: 13
from pyrogram import Client, idle
diff --git a/pyrogram/methods/utilities/remove_handler.py b/pyrogram/methods/utilities/remove_handler.py
index 97c7f183..8447f8a9 100644
--- a/pyrogram/methods/utilities/remove_handler.py
+++ b/pyrogram/methods/utilities/remove_handler.py
@@ -37,7 +37,6 @@ class RemoveHandler(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 11
from pyrogram import Client
from pyrogram.handlers import MessageHandler
diff --git a/pyrogram/methods/utilities/restart.py b/pyrogram/methods/utilities/restart.py
index afd22bb4..9c9e5109 100644
--- a/pyrogram/methods/utilities/restart.py
+++ b/pyrogram/methods/utilities/restart.py
@@ -40,7 +40,6 @@ class Restart(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 8
from pyrogram import Client
diff --git a/pyrogram/methods/utilities/run.py b/pyrogram/methods/utilities/run.py
index 6a55b28c..53f66f44 100644
--- a/pyrogram/methods/utilities/run.py
+++ b/pyrogram/methods/utilities/run.py
@@ -28,16 +28,13 @@ class Run(Scaffold):
"""Start the client, idle the main script and finally stop the client.
This is a convenience method that calls :meth:`~pyrogram.Client.start`, :meth:`~pyrogram.idle` and
- :meth:`~pyrogram.Client.stop` in sequence. It makes running a client less verbose, but is not suitable in case
- you want to run more than one client in a single main script, since :meth:`~pyrogram.idle` will block after
- starting the own client.
+ :meth:`~pyrogram.Client.stop` in sequence. It makes running a single client less verbose.
Raises:
ConnectionError: In case you try to run an already started client.
Example:
.. code-block:: python
- :emphasize-lines: 7
from pyrogram import Client
diff --git a/pyrogram/methods/utilities/start.py b/pyrogram/methods/utilities/start.py
index 0f08d223..62e8acfc 100644
--- a/pyrogram/methods/utilities/start.py
+++ b/pyrogram/methods/utilities/start.py
@@ -39,7 +39,6 @@ class Start(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 4
from pyrogram import Client
diff --git a/pyrogram/methods/utilities/stop.py b/pyrogram/methods/utilities/stop.py
index 38f0d4c4..4f338d3a 100644
--- a/pyrogram/methods/utilities/stop.py
+++ b/pyrogram/methods/utilities/stop.py
@@ -39,7 +39,6 @@ class Stop(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 8
from pyrogram import Client
diff --git a/pyrogram/methods/utilities/stop_transmission.py b/pyrogram/methods/utilities/stop_transmission.py
index a0d04b4c..6f76f11f 100644
--- a/pyrogram/methods/utilities/stop_transmission.py
+++ b/pyrogram/methods/utilities/stop_transmission.py
@@ -29,7 +29,6 @@ class StopTransmission(Scaffold):
Example:
.. code-block:: python
- :emphasize-lines: 9
from pyrogram import Client
@@ -42,6 +41,6 @@ class StopTransmission(Scaffold):
client.stop_transmission()
with app:
- app.send_document("me", "files.zip", progress=progress, progress_args=(app,))
+ app.send_document("me", "file.zip", progress=progress, progress_args=(app,))
"""
raise pyrogram.StopTransmission
diff --git a/pyrogram/raw/core/primitives/vector.py b/pyrogram/raw/core/primitives/vector.py
index 48b2eed9..a150fba7 100644
--- a/pyrogram/raw/core/primitives/vector.py
+++ b/pyrogram/raw/core/primitives/vector.py
@@ -33,7 +33,7 @@ class Vector(bytes, TLObject):
def read_bare(b: BytesIO, size: int) -> Union[int, Any]:
if size == 4:
return Int.read(b)
-
+
if size == 8:
return Long.read(b)
diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py
index 1cf8c1b1..8df167a7 100644
--- a/pyrogram/session/session.py
+++ b/pyrogram/session/session.py
@@ -25,7 +25,6 @@ from hashlib import sha1
from io import BytesIO
import pyrogram
-from pyrogram import __copyright__, __license__, __version__
from pyrogram import raw
from pyrogram.connection import Connection
from pyrogram.crypto import mtproto
@@ -54,8 +53,6 @@ class Session:
ACKS_THRESHOLD = 8
PING_INTERVAL = 5
- notice_displayed = False
-
def __init__(
self,
client: "pyrogram.Client",
@@ -65,11 +62,6 @@ class Session:
is_media: bool = False,
is_cdn: bool = False
):
- if not Session.notice_displayed:
- print(f"Pyrogram v{__version__}, {__copyright__}")
- print(f"Licensed under the terms of the {__license__}", end="\n\n")
- Session.notice_displayed = True
-
self.client = client
self.dc_id = dc_id
self.auth_key = auth_key
diff --git a/pyrogram/types/bots_and_keyboards/__init__.py b/pyrogram/types/bots_and_keyboards/__init__.py
index a1f3a662..fa6aa050 100644
--- a/pyrogram/types/bots_and_keyboards/__init__.py
+++ b/pyrogram/types/bots_and_keyboards/__init__.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from .bot_command import BotCommand
from .callback_game import CallbackGame
from .callback_query import CallbackQuery
from .force_reply import ForceReply
@@ -26,7 +27,6 @@ from .keyboard_button import KeyboardButton
from .login_url import LoginUrl
from .reply_keyboard_markup import ReplyKeyboardMarkup
from .reply_keyboard_remove import ReplyKeyboardRemove
-from .bot_command import BotCommand
__all__ = [
"CallbackGame",
diff --git a/pyrogram/types/inline_mode/__init__.py b/pyrogram/types/inline_mode/__init__.py
index 9d464eb4..d22937b9 100644
--- a/pyrogram/types/inline_mode/__init__.py
+++ b/pyrogram/types/inline_mode/__init__.py
@@ -21,9 +21,9 @@ from .inline_query import InlineQuery
from .inline_query_result import InlineQueryResult
from .inline_query_result_animation import InlineQueryResultAnimation
from .inline_query_result_article import InlineQueryResultArticle
+from .inline_query_result_audio import InlineQueryResultAudio
from .inline_query_result_photo import InlineQueryResultPhoto
from .inline_query_result_video import InlineQueryResultVideo
-from .inline_query_result_audio import InlineQueryResultAudio
__all__ = [
"InlineQuery", "InlineQueryResult", "InlineQueryResultArticle", "InlineQueryResultPhoto",
diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py
index 9690baf9..1d70d773 100644
--- a/pyrogram/types/messages_and_media/message.py
+++ b/pyrogram/types/messages_and_media/message.py
@@ -1370,7 +1370,7 @@ class Message(Object, Update):
Example:
.. code-block:: python
- message.reply_contact(phone_number, "Dan")
+ message.reply_contact("+1-123-456-7890", "Name")
Parameters:
phone_number (``str``):
diff --git a/pyrogram/types/messages_and_media/message_entity.py b/pyrogram/types/messages_and_media/message_entity.py
index 9a211fde..864bf547 100644
--- a/pyrogram/types/messages_and_media/message_entity.py
+++ b/pyrogram/types/messages_and_media/message_entity.py
@@ -87,7 +87,7 @@ class MessageEntity(Object):
- "bot_command": ``/start@pyrogrambot``.
- "url": ``https://pyrogram.org`` (see *url* below).
- "email": ``do-not-reply@pyrogram.org``.
- - "phone_number": ``+69-420-1337``.
+ - "phone_number": ``+1-123-456-7890``.
- "bold": **bold text**.
- "italic": *italic text*.
- "underline": underlined text.
diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py
index a925c7df..6ccd9465 100644
--- a/pyrogram/types/user_and_chats/chat.py
+++ b/pyrogram/types/user_and_chats/chat.py
@@ -228,7 +228,7 @@ class Chat(Object):
permissions=types.ChatPermissions._parse(getattr(chat, "default_banned_rights", None)),
members_count=getattr(chat, "participants_count", None),
dc_id=getattr(getattr(chat, "photo", None), "dc_id", None),
- has_protected_content=chat.noforwards,
+ has_protected_content=getattr(chat, "noforwards", None),
client=client
)
@@ -252,7 +252,7 @@ class Chat(Object):
permissions=types.ChatPermissions._parse(getattr(channel, "default_banned_rights", None)),
members_count=getattr(channel, "participants_count", None),
dc_id=getattr(getattr(channel, "photo", None), "dc_id", None),
- has_protected_content=channel.noforwards,
+ has_protected_content=getattr(channel, "noforwards", None),
client=client
)
diff --git a/setup.py b/setup.py
index c2e2ce96..5cbd5eb2 100644
--- a/setup.py
+++ b/setup.py
@@ -133,7 +133,7 @@ if len(argv) > 1 and argv[1] in ["bdist_wheel", "install", "develop"]:
setup(
name="Pyrogram",
version=version,
- description="Telegram MTProto API Client Library and Framework for Python",
+ description="Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/pyrogram",
@@ -153,6 +153,7 @@ setup(
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
@@ -166,7 +167,7 @@ setup(
keywords="telegram chat messenger mtproto api client library python",
project_urls={
"Tracker": "https://github.com/pyrogram/pyrogram/issues",
- "Community": "https://t.me/Pyrogram",
+ "Community": "https://t.me/pyrogram",
"Source": "https://github.com/pyrogram/pyrogram",
"Documentation": "https://docs.pyrogram.org",
},