mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-02 23:35:17 +00:00
Merge branch 'master' into docs
This commit is contained in:
@@ -79,13 +79,13 @@ Installation
|
|||||||
|
|
||||||
.. code:: shell
|
.. code:: shell
|
||||||
|
|
||||||
$ pip install --upgrade pyrogram
|
$ pip3 install --upgrade pyrogram
|
||||||
|
|
||||||
- Or, with TgCrypto_:
|
- Or, with TgCrypto_:
|
||||||
|
|
||||||
.. code:: shell
|
.. code:: shell
|
||||||
|
|
||||||
$ pip install --upgrade pyrogram[tgcrypto]
|
$ pip3 install --upgrade pyrogram[tgcrypto]
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
@@ -160,9 +160,7 @@ License
|
|||||||
|
|
||||||
.. _`Layer 75`: compiler/api/source/main_api.tl
|
.. _`Layer 75`: compiler/api/source/main_api.tl
|
||||||
|
|
||||||
.. _`your own`: https://github.com/pyrogram/pyrogram/wiki/Getting-Started#api-keys
|
.. _`your own`: https://docs.pyrogram.ml/start/ProjectSetup/#api-keys
|
||||||
|
|
||||||
.. _`Introduction`: https://github.com/pyrogram/pyrogram/wiki/Getting-Started
|
|
||||||
|
|
||||||
.. _`Telegram`: https://t.me/haskell
|
.. _`Telegram`: https://t.me/haskell
|
||||||
|
|
||||||
|
@@ -337,13 +337,17 @@ class Client:
|
|||||||
size=document.size,
|
size=document.size,
|
||||||
progress=progress
|
progress=progress
|
||||||
)
|
)
|
||||||
elif isinstance(media, types.MessageMediaPhoto):
|
elif isinstance(media, (types.MessageMediaPhoto, types.Photo)):
|
||||||
photo = media.photo
|
if isinstance(media, types.MessageMediaPhoto):
|
||||||
|
photo = media.photo
|
||||||
|
else:
|
||||||
|
photo = media
|
||||||
|
|
||||||
if isinstance(photo, types.Photo):
|
if isinstance(photo, types.Photo):
|
||||||
if not file_name:
|
if not file_name:
|
||||||
file_name = "photo_{}.jpg".format(
|
file_name = "photo_{}_{}.jpg".format(
|
||||||
datetime.fromtimestamp(photo.date).strftime("%Y-%m-%d_%H-%M-%S")
|
datetime.fromtimestamp(photo.date).strftime("%Y-%m-%d_%H-%M-%S"),
|
||||||
|
self.rnd_id()
|
||||||
)
|
)
|
||||||
|
|
||||||
photo_loc = photo.sizes[-1].location
|
photo_loc = photo.sizes[-1].location
|
||||||
@@ -2587,11 +2591,15 @@ class Client:
|
|||||||
Raises:
|
Raises:
|
||||||
:class:`pyrogram.Error`
|
:class:`pyrogram.Error`
|
||||||
"""
|
"""
|
||||||
if isinstance(message, types.Message):
|
if isinstance(message, (types.Message, types.Photo)):
|
||||||
done = Event()
|
done = Event()
|
||||||
media = message.media
|
|
||||||
path = [None]
|
path = [None]
|
||||||
|
|
||||||
|
if isinstance(message, types.Message):
|
||||||
|
media = message.media
|
||||||
|
else:
|
||||||
|
media = message
|
||||||
|
|
||||||
if media is not None:
|
if media is not None:
|
||||||
self.download_queue.put((media, file_name, done, progress, path))
|
self.download_queue.put((media, file_name, done, progress, path))
|
||||||
else:
|
else:
|
||||||
@@ -2602,6 +2610,48 @@ class Client:
|
|||||||
|
|
||||||
return path[0]
|
return path[0]
|
||||||
|
|
||||||
|
def download_photo(self,
|
||||||
|
photo: types.Photo or types.UserProfilePhoto or types.ChatPhoto,
|
||||||
|
file_name: str = None,
|
||||||
|
block: bool = True):
|
||||||
|
"""Use this method to download a photo not contained inside a Message.
|
||||||
|
For example, a photo of a User or a Chat/Channel.
|
||||||
|
|
||||||
|
Photos are saved in the *downloads* folder.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
photo (:obj:`Photo <pyrogram.api.types.Photo>` | :obj:`UserProfilePhoto <pyrogram.api.types.UserProfilePhoto>` | :obj:`ChatPhoto <pyrogram.api.types.ChatPhoto>`):
|
||||||
|
The photo object.
|
||||||
|
|
||||||
|
file_name (:obj:`str`, optional):
|
||||||
|
Specify a custom *file_name* to be used.
|
||||||
|
|
||||||
|
block (:obj:`bool`, optional):
|
||||||
|
Blocks the code execution until the photo has been downloaded.
|
||||||
|
Defaults to True.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The relative path of the downloaded photo.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
:class:`pyrogram.Error`
|
||||||
|
"""
|
||||||
|
if isinstance(photo, (types.UserProfilePhoto, types.ChatPhoto)):
|
||||||
|
photo = types.Photo(
|
||||||
|
id=0,
|
||||||
|
access_hash=0,
|
||||||
|
date=int(time.time()),
|
||||||
|
sizes=[types.PhotoSize(
|
||||||
|
type="",
|
||||||
|
location=photo.photo_big,
|
||||||
|
w=0,
|
||||||
|
h=0,
|
||||||
|
size=0
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.download_media(photo, file_name, block)
|
||||||
|
|
||||||
def add_contacts(self, contacts: list):
|
def add_contacts(self, contacts: list):
|
||||||
"""Use this method to add contacts to your Telegram address book.
|
"""Use this method to add contacts to your Telegram address book.
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ class Session:
|
|||||||
|
|
||||||
INITIAL_SALT = 0x616e67656c696361
|
INITIAL_SALT = 0x616e67656c696361
|
||||||
NET_WORKERS = 1
|
NET_WORKERS = 1
|
||||||
WAIT_TIMEOUT = 10
|
WAIT_TIMEOUT = 30
|
||||||
MAX_RETRIES = 5
|
MAX_RETRIES = 5
|
||||||
ACKS_THRESHOLD = 8
|
ACKS_THRESHOLD = 8
|
||||||
PING_INTERVAL = 5
|
PING_INTERVAL = 5
|
||||||
|
21
setup.py
21
setup.py
@@ -42,12 +42,12 @@ setup(
|
|||||||
name="Pyrogram",
|
name="Pyrogram",
|
||||||
version=version,
|
version=version,
|
||||||
description="Telegram MTProto API Client Library for Python",
|
description="Telegram MTProto API Client Library for Python",
|
||||||
url="https://github.com/pyrogram/pyrogram",
|
long_description=readme,
|
||||||
|
url="https://github.com/pyrogram",
|
||||||
|
download_url="https://github.com/pyrogram/pyrogram/releases/latest",
|
||||||
author="Dan Tès",
|
author="Dan Tès",
|
||||||
author_email="admin@pyrogram.ml",
|
author_email="admin@pyrogram.ml",
|
||||||
license="LGPLv3+",
|
license="LGPLv3+",
|
||||||
keywords="telegram mtproto api client library python",
|
|
||||||
long_description=readme,
|
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
@@ -59,11 +59,24 @@ setup(
|
|||||||
"Programming Language :: Python :: 3.4",
|
"Programming Language :: Python :: 3.4",
|
||||||
"Programming Language :: Python :: 3.5",
|
"Programming Language :: Python :: 3.5",
|
||||||
"Programming Language :: Python :: 3.6",
|
"Programming Language :: Python :: 3.6",
|
||||||
|
"Programming Language :: Python :: Implementation",
|
||||||
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
|
"Programming Language :: Python :: Implementation :: PyPy",
|
||||||
"Topic :: Internet",
|
"Topic :: Internet",
|
||||||
|
"Topic :: Communications",
|
||||||
"Topic :: Communications :: Chat",
|
"Topic :: Communications :: Chat",
|
||||||
"Topic :: Software Development :: Libraries",
|
"Topic :: Software Development :: Libraries",
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules"
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
|
"Topic :: Software Development :: Libraries :: Application Frameworks"
|
||||||
],
|
],
|
||||||
|
keywords="telegram mtproto api client library python",
|
||||||
|
project_urls={
|
||||||
|
"Tracker": "https://github.com/pyrogram/pyrogram/issues",
|
||||||
|
"Community": "https://t.me/PyrogramChat",
|
||||||
|
"Source": "https://github.com/pyrogram/pyrogram",
|
||||||
|
"Documentation": "https://docs.pyrogram.ml",
|
||||||
|
},
|
||||||
|
python_requires="~=3.3",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
Reference in New Issue
Block a user