diff --git a/MANIFEST.in b/MANIFEST.in
index 79c547f6..9f4d328c 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,7 +4,7 @@ recursive-include compiler *.py *.tl *.tsv *.txt
recursive-include pyrogram mime.types schema.sql
## Exclude
-prune pyrogram/api/errors/exceptions
+prune pyrogram/errors/exceptions
prune pyrogram/api/functions
prune pyrogram/api/types
exclude pyrogram/api/all.py
\ No newline at end of file
diff --git a/README.md b/README.md
index 4e758b5a..a4294175 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ app = Client("my_account")
@app.on_message(Filters.private)
def hello(client, message):
- message.reply("Hello {}".format(message.from_user.first_name))
+ message.reply_text("Hello {}".format(message.from_user.first_name))
app.run()
diff --git a/docs/robots.txt b/docs/robots.txt
index 1b9e8da6..e7799fdd 100644
--- a/docs/robots.txt
+++ b/docs/robots.txt
@@ -2,7 +2,7 @@ User-agent: *
Allow: /
-Disallow: /dev/*
-Disallow: /old/*
+Disallow: /dev*
+Disallow: /v0*
Sitemap: https://docs.pyrogram.org/sitemap.xml
\ No newline at end of file
diff --git a/docs/source/api/bound-methods.rst b/docs/source/api/bound-methods.rst
index 6a1cf1c3..679e1f8a 100644
--- a/docs/source/api/bound-methods.rst
+++ b/docs/source/api/bound-methods.rst
@@ -142,7 +142,7 @@ Details
.. automethod:: Chat.archive()
.. automethod:: Chat.unarchive()
.. automethod:: Chat.set_title()
-.. automethod:: Chat.set_description)
+.. automethod:: Chat.set_description()
.. automethod:: Chat.set_photo()
.. automethod:: Chat.kick_member()
.. automethod:: Chat.unban_member()
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 682c883c..b37bf2dc 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -106,7 +106,7 @@ Welcome to Pyrogram
@app.on_message(Filters.private)
def hello(client, message):
- message.reply("Hello {}".format(message.from_user.first_name))
+ message.reply_text("Hello {}".format(message.from_user.first_name))
app.run()
diff --git a/docs/source/topics/text-formatting.rst b/docs/source/topics/text-formatting.rst
index 03b50a8e..0194dc58 100644
--- a/docs/source/topics/text-formatting.rst
+++ b/docs/source/topics/text-formatting.rst
@@ -78,7 +78,7 @@ To strictly use this mode, pass "markdown" to the *parse_mode* parameter when us
"**bold**, "
"__italic__, "
"--underline--, "
- "~~strikethrough~~, "
+ "~~strike~~, "
"[mention](tg://user?id=23122162), "
"[URL](https://pyrogram.org), "
"`code`, "
@@ -128,7 +128,7 @@ The following tags are currently supported:
"bold, "
"italic, "
"underline, "
- "strikethrough, "
+ "strike, "
"mention, "
"URL, "
"code
\n\n"
@@ -202,7 +202,7 @@ Nested and Overlapping Entities
-------------------------------
You can also style texts with more than one decoration at once by nesting entities together. For example, you can send
-a text message with both :bold-underline:`bold and underline` styles, or a text that has both :italic-strike:`italic and
+a text message with both :bold-underline:`bold and underline` styles, or a text that has both :strike-italic:`italic and
strike` styles, and you can still combine both Markdown and HTML together.
Here there are some example texts you can try sending:
@@ -210,13 +210,13 @@ Here there are some example texts you can try sending:
**Markdown**:
- ``**bold, --underline--**``
-- ``**bold __italic --underline ~~striked~~--__**``
+- ``**bold __italic --underline ~~strike~~--__**``
- ``**bold __and** italic__``
**HTML**:
- ``bold, underline``
-- ``bold italic underline striked``
+- ``bold italic underline strike``
- ``bold and italic``
**Combined**:
diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py
index 3abfb6c6..8a3a0414 100644
--- a/pyrogram/client/methods/chats/export_chat_invite_link.py
+++ b/pyrogram/client/methods/chats/export_chat_invite_link.py
@@ -48,18 +48,15 @@ class ExportChatInviteLink(BaseClient):
Raises:
RPCError: In case of a Telegram RPC error.
+ ValueError: In case the chat_id belongs to a user.
"""
peer = await self.resolve_peer(chat_id)
- if isinstance(peer, types.InputPeerChat):
+ if isinstance(peer, (types.InputPeerChannel, types.InputPeerChat)):
return await self.send(
functions.messages.ExportChatInvite(
peer=peer
)
).link
- elif isinstance(peer, types.InputPeerChannel):
- return await self.send(
- functions.channels.ExportInvite(
- channel=peer
- )
- ).link
+ else:
+ raise ValueError('The chat_id "{}" belongs to a user'.format(chat_id))
diff --git a/pyrogram/client/parser/html.py b/pyrogram/client/parser/html.py
index c2547702..36cc54c1 100644
--- a/pyrogram/client/parser/html.py
+++ b/pyrogram/client/parser/html.py
@@ -108,7 +108,7 @@ class HTML:
self.client = client
async def parse(self, text: str):
- text = utils.add_surrogates(str(text or "").strip())
+ text = utils.add_surrogates(text)
parser = Parser(self.client)
parser.feed(text)
diff --git a/pyrogram/client/parser/parser.py b/pyrogram/client/parser/parser.py
index f685c942..cde26f0b 100644
--- a/pyrogram/client/parser/parser.py
+++ b/pyrogram/client/parser/parser.py
@@ -31,6 +31,8 @@ class Parser:
self.markdown = Markdown(client)
def parse(self, text: str, mode: str = ""):
+ text = str(text or "").strip()
+
if mode is None:
return OrderedDict([
("message", text),
diff --git a/pyrogram/client/storage/memory_storage.py b/pyrogram/client/storage/memory_storage.py
index bf000f35..e69d247f 100644
--- a/pyrogram/client/storage/memory_storage.py
+++ b/pyrogram/client/storage/memory_storage.py
@@ -59,8 +59,8 @@ class MemoryStorage(Storage):
(1, None, None, 0, None, None)
)
- def _import_session_string(self, string_session: str):
- decoded = base64.urlsafe_b64decode(string_session + "=" * (-len(string_session) % 4))
+ def _import_session_string(self, session_string: str):
+ decoded = base64.urlsafe_b64decode(session_string + "=" * (-len(session_string) % 4))
return struct.unpack(self.SESSION_STRING_FMT, decoded)
def export_session_string(self):
@@ -86,8 +86,6 @@ class MemoryStorage(Storage):
self.dc_id, self.test_mode, self.auth_key, self.user_id, self.is_bot = imported_session_string
self.date = 0
- self.name = ":memory:" + str(self.user_id or "")
-
# noinspection PyAttributeOutsideInit
def save(self):
self.date = int(time.time())
@@ -132,7 +130,7 @@ class MemoryStorage(Storage):
access_hash=access_hash
)
- raise ValueError("Invalid peer type")
+ raise ValueError("Invalid peer type: {}".format(peer_type))
def get_peer_by_id(self, peer_id: int):
r = self.conn.execute(
@@ -141,7 +139,7 @@ class MemoryStorage(Storage):
).fetchone()
if r is None:
- raise KeyError("ID not found")
+ raise KeyError("ID not found: {}".format(peer_id))
return self._get_input_peer(*r)
@@ -152,10 +150,10 @@ class MemoryStorage(Storage):
).fetchone()
if r is None:
- raise KeyError("Username not found")
+ raise KeyError("Username not found: {}".format(username))
if abs(time.time() - r[3]) > self.USERNAME_TTL:
- raise KeyError("Username expired")
+ raise KeyError("Username expired: {}".format(username))
return self._get_input_peer(*r[:3])
@@ -166,7 +164,7 @@ class MemoryStorage(Storage):
).fetchone()
if r is None:
- raise KeyError("Phone number not found")
+ raise KeyError("Phone number not found: {}".format(phone_number))
return self._get_input_peer(*r)
diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py
index 18527747..90b94ef6 100644
--- a/pyrogram/client/types/user_and_chats/user.py
+++ b/pyrogram/client/types/user_and_chats/user.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+import html
+
import pyrogram
from pyrogram.api import types
@@ -135,6 +137,12 @@ class User(Object):
self.photo = photo
self.restriction_reason = restriction_reason
+ def __format__(self, format_spec):
+ if format_spec == "mention":
+ return '{1}'.format(self.id, html.escape(self.first_name))
+
+ return html.escape(str(self))
+
@staticmethod
def _parse(client, user: types.User) -> "User" or None:
if user is None: