diff --git a/README.rst b/README.rst
index 0b9efb76..db2957c3 100644
--- a/README.rst
+++ b/README.rst
@@ -26,7 +26,7 @@ Features
- **Easy to use**: You can easily install Pyrogram using pip and start building your app right away.
- **High-level**: The low-level details of MTProto are abstracted and automatically handled.
- **Fast**: Crypto parts are boosted up by TgCrypto_, a high-performance library written in pure C.
-- **Updated** to the latest Telegram API version, currently Layer 81 on top of MTProto 2.0.
+- **Updated** to the latest Telegram API version, currently Layer 82 on top of MTProto 2.0.
- **Documented**: The Pyrogram API is well documented and resembles the Telegram Bot API.
- **Full API**, allowing to execute any advanced action an official client is able to do, and more.
@@ -78,14 +78,13 @@ Copyright & License
Telegram MTProto API Client Library for Python
-
+
Download
@@ -100,25 +99,25 @@ Copyright & License
-
-
-.. |logo| image:: https://pyrogram.ml/images/logo.png
+.. |logo| image:: https://raw.githubusercontent.com/pyrogram/logos/master/logos/pyrogram_logo2.png
:target: https://pyrogram.ml
:alt: Pyrogram
.. |description| replace:: **Telegram MTProto API Client Library for Python**
-.. |scheme| image:: "https://img.shields.io/badge/SCHEME-LAYER%2081-eda738.svg?longCache=true&style=for-the-badge&colorA=262b30"
+.. |scheme| image:: "https://img.shields.io/badge/SCHEME-LAYER%2082-eda738.svg?longCache=true&style=for-the-badge&colorA=262b30"
:target: compiler/api/source/main_api.tl
:alt: Scheme Layer
-.. |tgcrypto| image:: "https://img.shields.io/badge/TGCRYPTO-V1.0.4-eda738.svg?longCache=true&style=for-the-badge&colorA=262b30"
+.. |tgcrypto| image:: "https://img.shields.io/badge/TGCRYPTO-V1.1.1-eda738.svg?longCache=true&style=for-the-badge&colorA=262b30"
:target: https://github.com/pyrogram/tgcrypto
:alt: TgCrypto
diff --git a/compiler/error/source/403_FORBIDDEN.tsv b/compiler/error/source/403_FORBIDDEN.tsv
new file mode 100644
index 00000000..7bacbe7d
--- /dev/null
+++ b/compiler/error/source/403_FORBIDDEN.tsv
@@ -0,0 +1,2 @@
+id message
+CHAT_WRITE_FORBIDDEN You don't have rights to send messages in this chat
\ No newline at end of file
diff --git a/docs/source/index.rst b/docs/source/index.rst
index ec6b24f2..6e740dd0 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -5,8 +5,7 @@ Welcome to Pyrogram
@@ -26,11 +25,11 @@ Welcome to Pyrogram
-
-
diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst
index 45d40368..1cd1a072 100644
--- a/docs/source/pyrogram/Client.rst
+++ b/docs/source/pyrogram/Client.rst
@@ -57,10 +57,10 @@ Messages
edit_message_text
edit_message_caption
edit_message_reply_markup
+ edit_message_media
delete_messages
get_messages
get_history
- get_dialogs
Chats
-----
@@ -84,6 +84,8 @@ Chats
get_chat
get_chat_member
get_chat_members
+ get_chat_members_count
+ get_dialogs
Users
-----
diff --git a/docs/source/start/Installation.rst b/docs/source/start/Installation.rst
index bba927e4..d3ddfe7d 100644
--- a/docs/source/start/Installation.rst
+++ b/docs/source/start/Installation.rst
@@ -45,7 +45,7 @@ If no error shows up you are good to go.
>>> import pyrogram
>>> pyrogram.__version__
- '0.7.5'
+ '0.8.0'
.. _TgCrypto: https://docs.pyrogram.ml/resources/TgCrypto
.. _develop: http://github.com/pyrogram/pyrogram
\ No newline at end of file
diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py
index ceefdb8f..78147a81 100644
--- a/pyrogram/client/client.py
+++ b/pyrogram/client/client.py
@@ -183,6 +183,13 @@ class Client(Methods, BaseClient):
self.dispatcher = Dispatcher(self, workers)
+ def __enter__(self):
+ self.start()
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self.stop()
+
@property
def proxy(self):
return self._proxy
@@ -897,30 +904,18 @@ class Client(Methods, BaseClient):
"More info: https://docs.pyrogram.ml/start/ProjectSetup#configuration"
)
- for option in {"app_version", "device_model", "system_version", "lang_code"}:
+ for option in ["app_version", "device_model", "system_version", "lang_code"]:
if getattr(self, option):
pass
else:
- setattr(self, option, Client.APP_VERSION)
-
if parser.has_section("pyrogram"):
setattr(self, option, parser.get(
"pyrogram",
option,
fallback=getattr(Client, option.upper())
))
-
- if self.lang_code:
- pass
- else:
- self.lang_code = Client.LANG_CODE
-
- if parser.has_section("pyrogram"):
- self.lang_code = parser.get(
- "pyrogram",
- "lang_code",
- fallback=Client.LANG_CODE
- )
+ else:
+ setattr(self, option, getattr(Client, option.upper()))
if self._proxy:
self._proxy["enabled"] = True
diff --git a/pyrogram/client/methods/chats/get_chat_members_count.py b/pyrogram/client/methods/chats/get_chat_members_count.py
index 11aa5d1f..a8ce9780 100644
--- a/pyrogram/client/methods/chats/get_chat_members_count.py
+++ b/pyrogram/client/methods/chats/get_chat_members_count.py
@@ -32,7 +32,7 @@ class GetChatMembersCount(BaseClient):
On success, an integer is returned.
Raises:
- :class:`Error
+ :class:`Error `
``ValueError``: If a chat_id belongs to user.
"""
peer = await self.resolve_peer(chat_id)
diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py
index bd9cd0fd..547a5b99 100644
--- a/pyrogram/client/methods/messages/send_animation.py
+++ b/pyrogram/client/methods/messages/send_animation.py
@@ -73,9 +73,10 @@ class SendAnimation(BaseClient):
Animation height.
thumb (``str``, *optional*):
- Animation thumbnail.
- Pass a file path as string to send an image that exists on your local machine.
- Thumbnail should have 90 or less pixels of width and 90 or less pixels of height.
+ Thumbnail of the animation file sent.
+ The thumbnail should be in JPEG format and less than 200 KB in size.
+ A thumbnail's width and height should not exceed 90 pixels.
+ Thumbnails can't be reused and can be only uploaded as a new file.
disable_notification (``bool``, *optional*):
Sends the message silently.
diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py
index 15e87feb..919f74d2 100644
--- a/pyrogram/client/methods/messages/send_document.py
+++ b/pyrogram/client/methods/messages/send_document.py
@@ -30,7 +30,7 @@ class SendDocument(BaseClient):
async def send_document(self,
chat_id: int or str,
document: str,
- caption: str = "",
+ thumb: str = None,caption: str = "",
parse_mode: str = "",
disable_notification: bool = None,
reply_to_message_id: int = None,
@@ -51,6 +51,12 @@ class SendDocument(BaseClient):
pass an HTTP URL as a string for Telegram to get a file from the Internet, or
pass a file path as string to upload a new file that exists on your local machine.
+ thumb (``str``):
+ Thumbnail of the file sent.
+ The thumbnail should be in JPEG format and less than 200 KB in size.
+ A thumbnail's width and height should not exceed 90 pixels.
+ Thumbnails can't be reused and can be only uploaded as a new file.
+
caption (``str``, *optional*):
Document caption, 0-200 characters.
@@ -103,10 +109,12 @@ class SendDocument(BaseClient):
style = self.html if parse_mode.lower() == "html" else self.markdown
if os.path.exists(document):
+ thumb = None if thumb is None else await self.save_file(thumb)
file = await self.save_file(document, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + document.split(".")[-1], "text/plain"),
file=file,
+ thumb=thumb,
attributes=[
types.DocumentAttributeFilename(os.path.basename(document))
]
diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py
index 887c9179..93fdd8be 100644
--- a/pyrogram/client/methods/messages/send_video_note.py
+++ b/pyrogram/client/methods/messages/send_video_note.py
@@ -32,7 +32,7 @@ class SendVideoNote(BaseClient):
video_note: str,
duration: int = 0,
length: int = 1,
- disable_notification: bool = None,
+ thumb: str = None,disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup=None,
progress: callable = None,
@@ -57,6 +57,12 @@ class SendVideoNote(BaseClient):
length (``int``, *optional*):
Video width and height.
+ thumb (``str``, *optional*):
+ Thumbnail of the video sent.
+ The thumbnail should be in JPEG format and less than 200 KB in size.
+ A thumbnail's width and height should not exceed 90 pixels.
+ Thumbnails can't be reused and can be only uploaded as a new file.
+
disable_notification (``bool``, *optional*):
Sends the message silently.
Users will receive a notification with no sound.
@@ -100,10 +106,12 @@ class SendVideoNote(BaseClient):
file = None
if os.path.exists(video_note):
+ thumb = None if thumb is None else await self.save_file(thumb)
file = await self.save_file(video_note, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"],
file=file,
+ thumb=thumb,
attributes=[
types.DocumentAttributeVideo(
round_message=True,
diff --git a/pyrogram/client/types/input_media/input_media_animation.py b/pyrogram/client/types/input_media/input_media_animation.py
index 12fe0e03..14f8c2de 100644
--- a/pyrogram/client/types/input_media/input_media_animation.py
+++ b/pyrogram/client/types/input_media/input_media_animation.py
@@ -28,6 +28,12 @@ class InputMediaAnimation(InputMedia):
Pass a file_id as string to send a file that exists on the Telegram servers or
pass a file path as string to upload a new file that exists on your local machine.
+ thumb (``str``, *optional*):
+ Thumbnail of the animation file sent.
+ The thumbnail should be in JPEG format and less than 200 KB in size.
+ A thumbnail's width and height should not exceed 90 pixels.
+ Thumbnails can't be reused and can be only uploaded as a new file.
+
caption (``str``, *optional*):
Caption of the animation to be sent, 0-200 characters
@@ -48,6 +54,7 @@ class InputMediaAnimation(InputMedia):
def __init__(self,
media: str,
+ thumb: str = None,
caption: str = "",
parse_mode: str = "",
width: int = 0,
@@ -55,6 +62,7 @@ class InputMediaAnimation(InputMedia):
duration: int = 0):
super().__init__(media, caption, parse_mode)
+ self.thumb = thumb
self.width = width
self.height = height
self.duration = duration
diff --git a/pyrogram/client/types/input_media/input_media_audio.py b/pyrogram/client/types/input_media/input_media_audio.py
index 2c644107..83979b4a 100644
--- a/pyrogram/client/types/input_media/input_media_audio.py
+++ b/pyrogram/client/types/input_media/input_media_audio.py
@@ -29,6 +29,12 @@ class InputMediaAudio(InputMedia):
Pass a file_id as string to send an audio that exists on the Telegram servers or
pass a file path as string to upload a new audio that exists on your local machine.
+ thumb (``str``, *optional*):
+ Thumbnail of the music file album cover.
+ The thumbnail should be in JPEG format and less than 200 KB in size.
+ A thumbnail's width and height should not exceed 90 pixels.
+ Thumbnails can't be reused and can be only uploaded as a new file.
+
caption (``str``, *optional*):
Caption of the audio to be sent, 0-200 characters
@@ -49,6 +55,7 @@ class InputMediaAudio(InputMedia):
def __init__(self,
media: str,
+ thumb: str = None,
caption: str = "",
parse_mode: str = "",
duration: int = 0,
@@ -56,6 +63,7 @@ class InputMediaAudio(InputMedia):
title: str = ""):
super().__init__(media, caption, parse_mode)
+ self.thumb = thumb
self.duration = duration
self.performer = performer
self.title = title
diff --git a/pyrogram/client/types/input_media/input_media_document.py b/pyrogram/client/types/input_media/input_media_document.py
index f64da619..07965534 100644
--- a/pyrogram/client/types/input_media/input_media_document.py
+++ b/pyrogram/client/types/input_media/input_media_document.py
@@ -28,6 +28,12 @@ class InputMediaDocument(InputMedia):
Pass a file_id as string to send a file that exists on the Telegram servers or
pass a file path as string to upload a new file that exists on your local machine.
+ thumb (``str``):
+ Thumbnail of the file sent.
+ The thumbnail should be in JPEG format and less than 200 KB in size.
+ A thumbnail's width and height should not exceed 90 pixels.
+ Thumbnails can't be reused and can be only uploaded as a new file.
+
caption (``str``, *optional*):
Caption of the document to be sent, 0-200 characters
@@ -39,6 +45,9 @@ class InputMediaDocument(InputMedia):
def __init__(self,
media: str,
+ thumb: str = None,
caption: str = "",
parse_mode: str = ""):
super().__init__(media, caption, parse_mode)
+
+ self.thumb = thumb
diff --git a/pyrogram/client/types/input_media/input_media_video.py b/pyrogram/client/types/input_media/input_media_video.py
index c1f2c9ac..54ce5e5e 100644
--- a/pyrogram/client/types/input_media/input_media_video.py
+++ b/pyrogram/client/types/input_media/input_media_video.py
@@ -30,6 +30,12 @@ class InputMediaVideo(InputMedia):
pass a file path as string to upload a new video that exists on your local machine.
Sending video by a URL is currently unsupported.
+ thumb (``str``):
+ Thumbnail of the video sent.
+ The thumbnail should be in JPEG format and less than 200 KB in size.
+ A thumbnail's width and height should not exceed 90 pixels.
+ Thumbnails can't be reused and can be only uploaded as a new file.
+
caption (``str``, *optional*):
Caption of the video to be sent, 0-200 characters
@@ -53,6 +59,7 @@ class InputMediaVideo(InputMedia):
def __init__(self,
media: str,
+ thumb: str = None,
caption: str = "",
parse_mode: str = "",
width: int = 0,
@@ -61,6 +68,7 @@ class InputMediaVideo(InputMedia):
supports_streaming: bool = True):
super().__init__(media, caption, parse_mode)
+ self.thumb = thumb
self.width = width
self.height = height
self.duration = duration
diff --git a/pyrogram/client/types/messages_and_media/audio.py b/pyrogram/client/types/messages_and_media/audio.py
index 57731266..37f91992 100644
--- a/pyrogram/client/types/messages_and_media/audio.py
+++ b/pyrogram/client/types/messages_and_media/audio.py
@@ -30,7 +30,7 @@ class Audio(Object):
Duration of the audio in seconds as defined by sender.
thumb (:obj:`PhotoSize `, *optional*):
- Audio thumbnail.
+ Thumbnail of the music file album cover.
file_name (``str``, *optional*):
Audio file name.
diff --git a/pyrogram/crypto/aes.py b/pyrogram/crypto/aes.py
index e4fb94b1..f16688c4 100644
--- a/pyrogram/crypto/aes.py
+++ b/pyrogram/crypto/aes.py
@@ -27,22 +27,21 @@ try:
class AES:
- # TODO: Use new tgcrypto function names
@classmethod
def ige256_encrypt(cls, data: bytes, key: bytes, iv: bytes) -> bytes:
- return tgcrypto.ige_encrypt(data, key, iv)
+ return tgcrypto.ige256_encrypt(data, key, iv)
@classmethod
def ige256_decrypt(cls, data: bytes, key: bytes, iv: bytes) -> bytes:
- return tgcrypto.ige_decrypt(data, key, iv)
+ return tgcrypto.ige256_decrypt(data, key, iv)
@staticmethod
def ctr256_encrypt(data: bytes, key: bytes, iv: bytearray, state: bytearray = None) -> bytes:
- return tgcrypto.ctr_encrypt(data, key, iv, state or bytearray(1))
+ return tgcrypto.ctr256_encrypt(data, key, iv, state or bytearray(1))
@staticmethod
def ctr256_decrypt(data: bytes, key: bytes, iv: bytearray, state: bytearray = None) -> bytes:
- return tgcrypto.ctr_decrypt(data, key, iv, state or bytearray(1))
+ return tgcrypto.ctr256_decrypt(data, key, iv, state or bytearray(1))
@staticmethod
def xor(a: bytes, b: bytes) -> bytes:
diff --git a/setup.py b/setup.py
index b8d5c274..10789e98 100644
--- a/setup.py
+++ b/setup.py
@@ -172,7 +172,7 @@ setup(
packages=find_packages(exclude=["compiler*"]),
zip_safe=False,
install_requires=read("requirements.txt"),
- extras_require={"tgcrypto": ["tgcrypto>=1.0.4"]},
+ extras_require={"tgcrypto": ["tgcrypto==1.1.1"]},
cmdclass={
"clean": Clean,
"generate": Generate