mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Merge develop -> asyncio-dev
This commit is contained in:
commit
6dbd842106
@ -366,6 +366,7 @@ def pyrogram_api():
|
|||||||
InlineQueryResultArticle
|
InlineQueryResultArticle
|
||||||
InlineQueryResultPhoto
|
InlineQueryResultPhoto
|
||||||
InlineQueryResultAnimation
|
InlineQueryResultAnimation
|
||||||
|
ChosenInlineResult
|
||||||
""",
|
""",
|
||||||
input_message_content="""
|
input_message_content="""
|
||||||
InputMessageContent
|
InputMessageContent
|
||||||
|
6
compiler/docs/template/bound-methods.rst
vendored
6
compiler/docs/template/bound-methods.rst
vendored
@ -20,6 +20,12 @@ some of the required arguments.
|
|||||||
|
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
.. currentmodule:: pyrogram
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
Message
|
Message
|
||||||
|
6
compiler/docs/template/methods.rst
vendored
6
compiler/docs/template/methods.rst
vendored
@ -13,6 +13,12 @@ This page is about Pyrogram methods. All the methods listed here are bound to a
|
|||||||
with app:
|
with app:
|
||||||
app.send_message("haskell", "hi")
|
app.send_message("haskell", "hi")
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
.. currentmodule:: pyrogram.Client
|
.. currentmodule:: pyrogram.Client
|
||||||
|
|
||||||
Utilities
|
Utilities
|
||||||
|
7
compiler/docs/template/types.rst
vendored
7
compiler/docs/template/types.rst
vendored
@ -13,8 +13,13 @@ This page is about Pyrogram types. All types listed here are accessible through
|
|||||||
**Optional** fields may not exist when irrelevant -- i.e.: they will contain the value of ``None`` and aren't shown
|
**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()``.
|
when, for example, using ``print()``.
|
||||||
|
|
||||||
.. currentmodule:: pyrogram
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
Users & Chats
|
Users & Chats
|
||||||
-------------
|
-------------
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
sphinx
|
sphinx
|
||||||
sphinx_rtd_theme
|
sphinx_rtd_theme
|
||||||
sphinx_copybutton
|
sphinx_copybutton
|
||||||
|
sphinx_tabs
|
||||||
pypandoc
|
pypandoc
|
||||||
requests
|
requests
|
@ -17,6 +17,8 @@ This page is about the Client class, which exposes high-level methods for an eas
|
|||||||
with app:
|
with app:
|
||||||
app.send_message("me", "Hi!")
|
app.send_message("me", "Hi!")
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Details
|
Details
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@ functions.
|
|||||||
|
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
.. currentmodule:: pyrogram
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
Index
|
Index
|
||||||
@ -35,6 +41,7 @@ Index
|
|||||||
- :meth:`~Client.on_message`
|
- :meth:`~Client.on_message`
|
||||||
- :meth:`~Client.on_callback_query`
|
- :meth:`~Client.on_callback_query`
|
||||||
- :meth:`~Client.on_inline_query`
|
- :meth:`~Client.on_inline_query`
|
||||||
|
- :meth:`~Client.on_chosen_inline_result`
|
||||||
- :meth:`~Client.on_deleted_messages`
|
- :meth:`~Client.on_deleted_messages`
|
||||||
- :meth:`~Client.on_user_status`
|
- :meth:`~Client.on_user_status`
|
||||||
- :meth:`~Client.on_poll`
|
- :meth:`~Client.on_poll`
|
||||||
@ -50,6 +57,7 @@ Details
|
|||||||
.. autodecorator:: pyrogram.Client.on_message()
|
.. autodecorator:: pyrogram.Client.on_message()
|
||||||
.. autodecorator:: pyrogram.Client.on_callback_query()
|
.. autodecorator:: pyrogram.Client.on_callback_query()
|
||||||
.. autodecorator:: pyrogram.Client.on_inline_query()
|
.. autodecorator:: pyrogram.Client.on_inline_query()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_chosen_inline_result()
|
||||||
.. autodecorator:: pyrogram.Client.on_deleted_messages()
|
.. autodecorator:: pyrogram.Client.on_deleted_messages()
|
||||||
.. autodecorator:: pyrogram.Client.on_user_status()
|
.. autodecorator:: pyrogram.Client.on_user_status()
|
||||||
.. autodecorator:: pyrogram.Client.on_poll()
|
.. autodecorator:: pyrogram.Client.on_poll()
|
||||||
|
@ -15,6 +15,12 @@ follow the usual *PascalCase* convention.
|
|||||||
except FloodWait as e:
|
except FloodWait as e:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
303 - SeeOther
|
303 - SeeOther
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -20,6 +20,12 @@ For a much more convenient way of registering callback functions have a look at
|
|||||||
|
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
.. currentmodule:: pyrogram
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
Index
|
Index
|
||||||
@ -32,6 +38,7 @@ Index
|
|||||||
- :class:`DeletedMessagesHandler`
|
- :class:`DeletedMessagesHandler`
|
||||||
- :class:`CallbackQueryHandler`
|
- :class:`CallbackQueryHandler`
|
||||||
- :class:`InlineQueryHandler`
|
- :class:`InlineQueryHandler`
|
||||||
|
- :class:`ChosenInlineResultHandler`
|
||||||
- :class:`UserStatusHandler`
|
- :class:`UserStatusHandler`
|
||||||
- :class:`PollHandler`
|
- :class:`PollHandler`
|
||||||
- :class:`DisconnectHandler`
|
- :class:`DisconnectHandler`
|
||||||
@ -47,6 +54,7 @@ Details
|
|||||||
.. autoclass:: DeletedMessagesHandler()
|
.. autoclass:: DeletedMessagesHandler()
|
||||||
.. autoclass:: CallbackQueryHandler()
|
.. autoclass:: CallbackQueryHandler()
|
||||||
.. autoclass:: InlineQueryHandler()
|
.. autoclass:: InlineQueryHandler()
|
||||||
|
.. autoclass:: ChosenInlineResultHandler()
|
||||||
.. autoclass:: UserStatusHandler()
|
.. autoclass:: UserStatusHandler()
|
||||||
.. autoclass:: PollHandler()
|
.. autoclass:: PollHandler()
|
||||||
.. autoclass:: DisconnectHandler()
|
.. autoclass:: DisconnectHandler()
|
||||||
|
@ -35,7 +35,8 @@ extensions = [
|
|||||||
"sphinx.ext.autodoc",
|
"sphinx.ext.autodoc",
|
||||||
"sphinx.ext.napoleon",
|
"sphinx.ext.napoleon",
|
||||||
"sphinx.ext.autosummary",
|
"sphinx.ext.autosummary",
|
||||||
"sphinx_copybutton"
|
"sphinx_copybutton",
|
||||||
|
"sphinx_tabs.tabs"
|
||||||
]
|
]
|
||||||
|
|
||||||
master_doc = "index"
|
master_doc = "index"
|
||||||
|
@ -13,7 +13,8 @@ This FAQ page provides answers to common questions about Pyrogram and, to some e
|
|||||||
.. contents:: Contents
|
.. contents:: Contents
|
||||||
:backlinks: none
|
:backlinks: none
|
||||||
:local:
|
:local:
|
||||||
:depth: 1
|
|
||||||
|
-----
|
||||||
|
|
||||||
What is Pyrogram?
|
What is Pyrogram?
|
||||||
-----------------
|
-----------------
|
||||||
@ -366,6 +367,20 @@ Having said that, here's some insights about limits:
|
|||||||
- Limits vary based on methods and the arguments passed to methods. For example: log-ins are expensive and thus have
|
- Limits vary based on methods and the arguments passed to methods. For example: log-ins are expensive and thus have
|
||||||
stricter limits; replying to a user command could cause a flood wait in case the user starts flooding, but
|
stricter limits; replying to a user command could cause a flood wait in case the user starts flooding, but
|
||||||
such limit will only be applied to that particular chat (i.e.: other users are not affected).
|
such limit will only be applied to that particular chat (i.e.: other users are not affected).
|
||||||
|
- You can catch Flood Wait exceptions in your code and wait the required seconds before continuing, this way:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import time
|
||||||
|
from pyrogram.errors import FloodWait
|
||||||
|
|
||||||
|
try:
|
||||||
|
... # Your code
|
||||||
|
except FloodWait as e:
|
||||||
|
time.sleep(e.x) # Wait "x" seconds before continuing
|
||||||
|
|
||||||
|
|
||||||
|
More info about error handling can be found `here <start/errors>`_.
|
||||||
|
|
||||||
My account has been deactivated/limited!
|
My account has been deactivated/limited!
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
@ -8,6 +8,11 @@ general. Some words may as well link to dedicated articles in case the topic is
|
|||||||
|
|
||||||
If you think something interesting could be added here, feel free to propose it by opening a `Feature Request`_.
|
If you think something interesting could be added here, feel free to propose it by opening a `Feature Request`_.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Terms
|
Terms
|
||||||
-----
|
-----
|
||||||
|
@ -11,6 +11,12 @@ We recommend using the latest versions of both Python 3 and pip.
|
|||||||
|
|
||||||
Pyrogram supports **Python 3** only, starting from version 3.5.3. **PyPy** is supported too.
|
Pyrogram supports **Python 3** only, starting from version 3.5.3. **PyPy** is supported too.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Install Pyrogram
|
Install Pyrogram
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@ Project Setup
|
|||||||
We have just :doc:`installed Pyrogram <install>`. In this page we'll discuss what you need to do in order to set up a
|
We have just :doc:`installed Pyrogram <install>`. In this page we'll discuss what you need to do in order to set up a
|
||||||
project with the library. Let's see how it's done.
|
project with the library. Let's see how it's done.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
API Keys
|
API Keys
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -9,6 +9,12 @@ This is a collection of remarkable projects made with Pyrogram.
|
|||||||
|
|
||||||
If you'd like to propose a project that's worth being listed here, feel free to open a `Feature Request`_.
|
If you'd like to propose a project that's worth being listed here, feel free to open a `Feature Request`_.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Projects Showcase
|
Projects Showcase
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@ Authorization
|
|||||||
Once a :doc:`project is set up <../intro/setup>`, you will still have to follow a few steps before you can actually use Pyrogram to make
|
Once a :doc:`project is set up <../intro/setup>`, you will still have to follow a few steps before you can actually use Pyrogram to make
|
||||||
API calls. This section provides all the information you need in order to authorize yourself as user or bot.
|
API calls. This section provides all the information you need in order to authorize yourself as user or bot.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
User Authorization
|
User Authorization
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -8,6 +8,12 @@ to control the behaviour of your application. Pyrogram errors all live inside th
|
|||||||
|
|
||||||
from pyrogram import errors
|
from pyrogram import errors
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
RPCError
|
RPCError
|
||||||
--------
|
--------
|
||||||
|
|
||||||
@ -94,6 +100,6 @@ The value is stored in the ``x`` attribute of the exception object:
|
|||||||
from pyrogram.errors import FloodWait
|
from pyrogram.errors import FloodWait
|
||||||
|
|
||||||
try:
|
try:
|
||||||
...
|
... # Your code
|
||||||
except FloodWait as e:
|
except FloodWait as e:
|
||||||
time.sleep(e.x) # Wait "x" seconds before continuing
|
time.sleep(e.x) # Wait "x" seconds before continuing
|
||||||
|
@ -4,6 +4,12 @@ Calling Methods
|
|||||||
At this point, we have successfully :doc:`installed Pyrogram <../intro/install>` and :doc:`authorized <auth>` our
|
At this point, we have successfully :doc:`installed Pyrogram <../intro/install>` and :doc:`authorized <auth>` our
|
||||||
account; we are now aiming towards the core of the library. It's time to start playing with the API!
|
account; we are now aiming towards the core of the library. It's time to start playing with the API!
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Basic Usage
|
Basic Usage
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@ Handling Updates
|
|||||||
Calling :doc:`API methods <invoking>` sequentially is cool, but how to react when, for example, a new message arrives?
|
Calling :doc:`API methods <invoking>` sequentially is cool, but how to react when, for example, a new message arrives?
|
||||||
This page deals with updates and how to handle such events in Pyrogram. Let's have a look at how they work.
|
This page deals with updates and how to handle such events in Pyrogram. Let's have a look at how they work.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Defining Updates
|
Defining Updates
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ found it to be useful, give Pyrogram a `Star on GitHub`_. Your appreciation mean
|
|||||||
<a class="github-button" href="https://github.com/pyrogram/pyrogram" data-size="large" data-show-count="true" aria-label="Star pyrogram/pyrogram on GitHub">Star</a>
|
<a class="github-button" href="https://github.com/pyrogram/pyrogram" data-size="large" data-show-count="true" aria-label="Star pyrogram/pyrogram on GitHub">Star</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Donate
|
Donate
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -8,6 +8,12 @@ Telegram API.
|
|||||||
In this section, you'll be shown the alternative way of communicating with Telegram using Pyrogram: the main "raw"
|
In this section, you'll be shown the alternative way of communicating with Telegram using Pyrogram: the main "raw"
|
||||||
Telegram API with its functions and types.
|
Telegram API with its functions and types.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Telegram Raw API
|
Telegram Raw API
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@ -3,6 +3,12 @@ Bots Interaction
|
|||||||
|
|
||||||
Users can interact with other bots via plain text messages as well as inline queries.
|
Users can interact with other bots via plain text messages as well as inline queries.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Inline Bots
|
Inline Bots
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@ Configuration File
|
|||||||
As already mentioned in previous pages, Pyrogram can be configured by the use of an INI file.
|
As already mentioned in previous pages, Pyrogram can be configured by the use of an INI file.
|
||||||
This page explains how this file is structured, how to use it and why.
|
This page explains how this file is structured, how to use it and why.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -9,6 +9,12 @@ for example) you can use :meth:`~pyrogram.Filters.create`.
|
|||||||
|
|
||||||
At the moment, the built-in filters are intended to be used with the :class:`~pyrogram.MessageHandler` only.
|
At the moment, the built-in filters are intended to be used with the :class:`~pyrogram.MessageHandler` only.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Custom Filters
|
Custom Filters
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@ Debugging
|
|||||||
When working with the API, chances are you'll stumble upon bugs, get stuck and start wondering how to continue. Nothing
|
When working with the API, chances are you'll stumble upon bugs, get stuck and start wondering how to continue. Nothing
|
||||||
to actually worry about -- that's normal -- and luckily for you, Pyrogram provides some commodities to help you in this.
|
to actually worry about -- that's normal -- and luckily for you, Pyrogram provides some commodities to help you in this.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Caveman Debugging
|
Caveman Debugging
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@ More on Updates
|
|||||||
Here we'll show some advanced usages when working with :doc:`update handlers <../start/updates>` and
|
Here we'll show some advanced usages when working with :doc:`update handlers <../start/updates>` and
|
||||||
:doc:`filters <use-filters>`.
|
:doc:`filters <use-filters>`.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Handler Groups
|
Handler Groups
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -6,6 +6,12 @@ already superior to, what is usually called, the official Bot API, in many respe
|
|||||||
why Pyrogram might be a better choice for your project by comparing the two APIs, but first, let's make it clear what
|
why Pyrogram might be a better choice for your project by comparing the two APIs, but first, let's make it clear what
|
||||||
actually is the MTProto and the Bot API.
|
actually is the MTProto and the Bot API.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
What is the MTProto API?
|
What is the MTProto API?
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@ SOCKS5 Proxy
|
|||||||
Pyrogram supports proxies with and without authentication. This feature allows Pyrogram to exchange data with Telegram
|
Pyrogram supports proxies with and without authentication. This feature allows Pyrogram to exchange data with Telegram
|
||||||
through an intermediate SOCKS5 proxy server.
|
through an intermediate SOCKS5 proxy server.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -8,6 +8,12 @@ Since there's no built-in task scheduler in Pyrogram, this page will only show e
|
|||||||
with the main Python schedule libraries such as ``schedule`` and ``apscheduler``. For more detailed information, you can
|
with the main Python schedule libraries such as ``schedule`` and ``apscheduler``. For more detailed information, you can
|
||||||
visit and learn from each library documentation.
|
visit and learn from each library documentation.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Using ``schedule``
|
Using ``schedule``
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -5,6 +5,12 @@ Serializing means converting a Pyrogram object, which exists as Python class ins
|
|||||||
easily shared and stored anywhere. Pyrogram provides two formats for serializing its objects: one good looking for
|
easily shared and stored anywhere. Pyrogram provides two formats for serializing its objects: one good looking for
|
||||||
humans and another more compact for machines that is able to recover the original structures.
|
humans and another more compact for machines that is able to recover the original structures.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
For Humans - str(obj)
|
For Humans - str(obj)
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
@ -20,6 +20,12 @@ That's how a session looks like on the Android app, showing the three main piece
|
|||||||
- ``device_model``: **CPython 3.7.2**
|
- ``device_model``: **CPython 3.7.2**
|
||||||
- ``system_version``: **Linux 4.15.0-23-generic**
|
- ``system_version``: **Linux 4.15.0-23-generic**
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Set Custom Values
|
Set Custom Values
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
@ -9,6 +9,12 @@ different Pyrogram applications with **minimal boilerplate code**.
|
|||||||
|
|
||||||
Smart Plugins are completely optional and disabled by default.
|
Smart Plugins are completely optional and disabled by default.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -5,6 +5,12 @@ Every time you login to Telegram, some personal piece of data are created and he
|
|||||||
and the server, Telegram). This session data is uniquely bound to your own account, indefinitely (until you logout or
|
and the server, Telegram). This session data is uniquely bound to your own account, indefinitely (until you logout or
|
||||||
decide to manually terminate it) and is used to authorize a client to execute API calls on behalf of your identity.
|
decide to manually terminate it) and is used to authorize a client to execute API calls on behalf of your identity.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Persisting Sessions
|
Persisting Sessions
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
@ -18,6 +18,12 @@ Telegram's test servers without hassle. All you need to do is start a new sessio
|
|||||||
Don't worry about your contacts and chats, they will be kept untouched inside the production environment;
|
Don't worry about your contacts and chats, they will be kept untouched inside the production environment;
|
||||||
accounts authorized on test servers reside in a different, parallel instance of a Telegram database.
|
accounts authorized on test servers reside in a different, parallel instance of a Telegram database.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Test Mode in Official Apps
|
Test Mode in Official Apps
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
@ -17,6 +17,12 @@ Pyrogram uses a custom Markdown dialect for text formatting which adds some uniq
|
|||||||
texts easier in both Markdown and HTML. You can send sophisticated text messages and media captions using a great
|
texts easier in both Markdown and HTML. You can send sophisticated text messages and media captions using a great
|
||||||
variety of decorations that can also be nested in order to combine multiple styles together.
|
variety of decorations that can also be nested in order to combine multiple styles together.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Basic Styles
|
Basic Styles
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -21,10 +21,23 @@ The reason about being an optional package is that TgCrypto requires some extra
|
|||||||
The errors you receive when trying to install TgCrypto are system dependent, but also descriptive enough to understand
|
The errors you receive when trying to install TgCrypto are system dependent, but also descriptive enough to understand
|
||||||
what you should do next:
|
what you should do next:
|
||||||
|
|
||||||
- **Windows**: Install `Visual C++ 2015 Build Tools <https://www.microsoft.com/en-us/download/details.aspx?id=48159>`_.
|
.. tabs::
|
||||||
- **macOS**: A pop-up will automatically ask you to install the command line developer tools.
|
|
||||||
- **Linux**: Install a proper C compiler (``gcc``, ``clang``) and the Python header files (``python3-dev``).
|
.. tab:: Windows
|
||||||
- **Termux (Android)**: Install ``clang`` package.
|
|
||||||
|
Install `Visual C++ 2015 Build Tools <https://www.microsoft.com/en-us/download/details.aspx?id=48159>`_.
|
||||||
|
|
||||||
|
.. tab:: macOS
|
||||||
|
|
||||||
|
A pop-up will automatically ask you to install the command line developer tools.
|
||||||
|
|
||||||
|
.. tab:: Linux
|
||||||
|
|
||||||
|
Install a proper C compiler (``gcc``, ``clang``) and the Python header files (``python3-dev``).
|
||||||
|
|
||||||
|
.. tab:: Termux
|
||||||
|
|
||||||
|
Install ``clang`` package.
|
||||||
|
|
||||||
.. _TgCrypto: https://github.com/pyrogram/tgcrypto
|
.. _TgCrypto: https://github.com/pyrogram/tgcrypto
|
||||||
|
|
||||||
|
@ -7,6 +7,12 @@ comes from the server, but there's much more than that to come.
|
|||||||
Here we'll discuss about :class:`~pyrogram.Filters`. Filters enable a fine-grain control over what kind of
|
Here we'll discuss about :class:`~pyrogram.Filters`. Filters enable a fine-grain control over what kind of
|
||||||
updates are allowed or not to be passed in your callback functions, based on their inner details.
|
updates are allowed or not to be passed in your callback functions, based on their inner details.
|
||||||
|
|
||||||
|
.. contents:: Contents
|
||||||
|
:backlinks: none
|
||||||
|
:local:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Single Filters
|
Single Filters
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -26,12 +26,14 @@ from pyrogram.api.types import (
|
|||||||
UpdateEditMessage, UpdateEditChannelMessage,
|
UpdateEditMessage, UpdateEditChannelMessage,
|
||||||
UpdateDeleteMessages, UpdateDeleteChannelMessages,
|
UpdateDeleteMessages, UpdateDeleteChannelMessages,
|
||||||
UpdateBotCallbackQuery, UpdateInlineBotCallbackQuery,
|
UpdateBotCallbackQuery, UpdateInlineBotCallbackQuery,
|
||||||
UpdateUserStatus, UpdateBotInlineQuery, UpdateMessagePoll
|
UpdateUserStatus, UpdateBotInlineQuery, UpdateMessagePoll,
|
||||||
|
UpdateBotInlineSend
|
||||||
)
|
)
|
||||||
from . import utils
|
from . import utils
|
||||||
from ..handlers import (
|
from ..handlers import (
|
||||||
CallbackQueryHandler, MessageHandler, DeletedMessagesHandler,
|
CallbackQueryHandler, MessageHandler, DeletedMessagesHandler,
|
||||||
UserStatusHandler, RawUpdateHandler, InlineQueryHandler, PollHandler
|
UserStatusHandler, RawUpdateHandler, InlineQueryHandler, PollHandler,
|
||||||
|
ChosenInlineResultHandler
|
||||||
)
|
)
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -92,13 +94,17 @@ class Dispatcher:
|
|||||||
async def poll_parser(update, users, chats):
|
async def poll_parser(update, users, chats):
|
||||||
return pyrogram.Poll._parse_update(self.client, update), PollHandler
|
return pyrogram.Poll._parse_update(self.client, update), PollHandler
|
||||||
|
|
||||||
|
async def chosen_inline_result_parser(update, users, chats):
|
||||||
|
return pyrogram.ChosenInlineResult._parse(self.client, update, users), ChosenInlineResultHandler
|
||||||
|
|
||||||
self.update_parsers = {
|
self.update_parsers = {
|
||||||
Dispatcher.MESSAGE_UPDATES: message_parser,
|
Dispatcher.MESSAGE_UPDATES: message_parser,
|
||||||
Dispatcher.DELETE_MESSAGES_UPDATES: deleted_messages_parser,
|
Dispatcher.DELETE_MESSAGES_UPDATES: deleted_messages_parser,
|
||||||
Dispatcher.CALLBACK_QUERY_UPDATES: callback_query_parser,
|
Dispatcher.CALLBACK_QUERY_UPDATES: callback_query_parser,
|
||||||
(UpdateUserStatus,): user_status_parser,
|
(UpdateUserStatus,): user_status_parser,
|
||||||
(UpdateBotInlineQuery,): inline_query_parser,
|
(UpdateBotInlineQuery,): inline_query_parser,
|
||||||
(UpdateMessagePoll,): poll_parser
|
(UpdateMessagePoll,): poll_parser,
|
||||||
|
(UpdateBotInlineSend,): chosen_inline_result_parser
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple}
|
self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple}
|
||||||
|
@ -24,8 +24,9 @@ from .message_handler import MessageHandler
|
|||||||
from .poll_handler import PollHandler
|
from .poll_handler import PollHandler
|
||||||
from .raw_update_handler import RawUpdateHandler
|
from .raw_update_handler import RawUpdateHandler
|
||||||
from .user_status_handler import UserStatusHandler
|
from .user_status_handler import UserStatusHandler
|
||||||
|
from .chosen_inline_result_handler import ChosenInlineResultHandler
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"MessageHandler", "DeletedMessagesHandler", "CallbackQueryHandler", "RawUpdateHandler", "DisconnectHandler",
|
"MessageHandler", "DeletedMessagesHandler", "CallbackQueryHandler", "RawUpdateHandler", "DisconnectHandler",
|
||||||
"UserStatusHandler", "InlineQueryHandler", "PollHandler"
|
"UserStatusHandler", "InlineQueryHandler", "PollHandler", "ChosenInlineResultHandler"
|
||||||
]
|
]
|
||||||
|
48
pyrogram/client/handlers/chosen_inline_result_handler.py
Normal file
48
pyrogram/client/handlers/chosen_inline_result_handler.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrogram is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from .handler import Handler
|
||||||
|
|
||||||
|
|
||||||
|
class ChosenInlineResultHandler(Handler):
|
||||||
|
"""The ChosenInlineResultHandler handler class. Used to handle chosen inline results coming from inline queries.
|
||||||
|
It is intended to be used with :meth:`~Client.add_handler`
|
||||||
|
|
||||||
|
For a nicer way to register this handler, have a look at the
|
||||||
|
:meth:`~Client.on_chosen_inline_query` decorator.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
callback (``callable``):
|
||||||
|
Pass a function that will be called when a new chosen inline result arrives.
|
||||||
|
It takes *(client, chosen_inline_result)* as positional arguments (look at the section below for a
|
||||||
|
detailed description).
|
||||||
|
|
||||||
|
filters (:obj:`Filters`):
|
||||||
|
Pass one or more filters to allow only a subset of chosen inline results to be passed
|
||||||
|
in your callback function.
|
||||||
|
|
||||||
|
Other parameters:
|
||||||
|
client (:obj:`Client`):
|
||||||
|
The Client itself, useful when you want to call other API methods inside the message handler.
|
||||||
|
|
||||||
|
chosen_inline_result (:obj:`ChosenInlineResult`):
|
||||||
|
The received chosen inline result.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, callback: callable, filters=None):
|
||||||
|
super().__init__(callback, filters)
|
@ -24,6 +24,7 @@ from .on_message import OnMessage
|
|||||||
from .on_poll import OnPoll
|
from .on_poll import OnPoll
|
||||||
from .on_raw_update import OnRawUpdate
|
from .on_raw_update import OnRawUpdate
|
||||||
from .on_user_status import OnUserStatus
|
from .on_user_status import OnUserStatus
|
||||||
|
from .on_chosen_inline_result import OnChosenInlineResult
|
||||||
|
|
||||||
|
|
||||||
class Decorators(
|
class Decorators(
|
||||||
@ -34,6 +35,7 @@ class Decorators(
|
|||||||
OnDisconnect,
|
OnDisconnect,
|
||||||
OnUserStatus,
|
OnUserStatus,
|
||||||
OnInlineQuery,
|
OnInlineQuery,
|
||||||
OnPoll
|
OnPoll,
|
||||||
|
OnChosenInlineResult
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrogram is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram.client.filters.filter import Filter
|
||||||
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
|
class OnChosenInlineResult(BaseClient):
|
||||||
|
def on_chosen_inline_result(
|
||||||
|
self=None,
|
||||||
|
filters=None,
|
||||||
|
group: int = 0
|
||||||
|
) -> callable:
|
||||||
|
"""Decorator for handling chosen inline results.
|
||||||
|
|
||||||
|
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the :obj:`~pyrogram.ChosenInlineResult`.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
filters (:obj:`~pyrogram.Filters`, *optional*):
|
||||||
|
Pass one or more filters to allow only a subset of chosen inline results to be passed
|
||||||
|
in your function.
|
||||||
|
|
||||||
|
group (``int``, *optional*):
|
||||||
|
The group identifier, defaults to 0.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def decorator(func: Callable) -> Callable:
|
||||||
|
if isinstance(self, pyrogram.Client):
|
||||||
|
self.add_handler(pyrogram.ChosenInlineResultHandler(func, filters), group)
|
||||||
|
elif isinstance(self, Filter) or self is None:
|
||||||
|
func.handler = (
|
||||||
|
pyrogram.ChosenInlineResultHandler(func, self),
|
||||||
|
group if filters is None else filters
|
||||||
|
)
|
||||||
|
|
||||||
|
return func
|
||||||
|
|
||||||
|
return decorator
|
@ -61,7 +61,7 @@ class SendCachedMedia(BaseClient):
|
|||||||
A valid file reference obtained by a recently fetched media message.
|
A valid file reference obtained by a recently fetched media message.
|
||||||
To be used in combination with a file id in case a file reference is needed.
|
To be used in combination with a file id in case a file reference is needed.
|
||||||
|
|
||||||
caption (``bool``, *optional*):
|
caption (``str``, *optional*):
|
||||||
Media caption, 0-1024 characters.
|
Media caption, 0-1024 characters.
|
||||||
|
|
||||||
parse_mode (``str``, *optional*):
|
parse_mode (``str``, *optional*):
|
||||||
|
@ -21,8 +21,9 @@ from .inline_query_result import InlineQueryResult
|
|||||||
from .inline_query_result_animation import InlineQueryResultAnimation
|
from .inline_query_result_animation import InlineQueryResultAnimation
|
||||||
from .inline_query_result_article import InlineQueryResultArticle
|
from .inline_query_result_article import InlineQueryResultArticle
|
||||||
from .inline_query_result_photo import InlineQueryResultPhoto
|
from .inline_query_result_photo import InlineQueryResultPhoto
|
||||||
|
from .chosen_inline_result import ChosenInlineResult
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"InlineQuery", "InlineQueryResult", "InlineQueryResultArticle", "InlineQueryResultPhoto",
|
"InlineQuery", "InlineQueryResult", "InlineQueryResultArticle", "InlineQueryResultPhoto",
|
||||||
"InlineQueryResultAnimation"
|
"InlineQueryResultAnimation", "ChosenInlineResult"
|
||||||
]
|
]
|
||||||
|
117
pyrogram/client/types/inline_mode/chosen_inline_result.py
Normal file
117
pyrogram/client/types/inline_mode/chosen_inline_result.py
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrogram is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrogram is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from base64 import b64encode
|
||||||
|
from struct import pack
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram.api import types
|
||||||
|
from pyrogram.client.types.object import Object
|
||||||
|
from pyrogram.client.types.update import Update
|
||||||
|
from pyrogram.client.types.user_and_chats import User
|
||||||
|
from pyrogram.client.types.messages_and_media import Location
|
||||||
|
from pyrogram.client.ext import utils
|
||||||
|
|
||||||
|
|
||||||
|
class ChosenInlineResult(Object, Update):
|
||||||
|
"""A :doc:`result <InlineQueryResult>` of an inline query chosen by the user and sent to their chat partner.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
result_id (``str``):
|
||||||
|
The unique identifier for the result that was chosen.
|
||||||
|
|
||||||
|
from_user (:obj:`User`):
|
||||||
|
The user that chose the result.
|
||||||
|
|
||||||
|
query (``str``):
|
||||||
|
The query that was used to obtain the result.
|
||||||
|
|
||||||
|
location (:obj:`Location`, *optional*):
|
||||||
|
Sender location, only for bots that require user location.
|
||||||
|
|
||||||
|
inline_message_id (``str``, *optional*):
|
||||||
|
Identifier of the sent inline message.
|
||||||
|
Available only if there is an :doc:`inline keyboard <InlineKeyboardMarkup>` attached to the message.
|
||||||
|
Will be also received in :doc:`callback queries <CallbackQuery>` and can be used to edit the message.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
It is necessary to enable inline feedback via `@Botfather <https://t.me/botfather>`_ in order to receive these
|
||||||
|
objects in updates.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
client: "pyrogram.BaseClient" = None,
|
||||||
|
result_id: str,
|
||||||
|
from_user: User,
|
||||||
|
query: str,
|
||||||
|
location: "pyrogram.Location" = None,
|
||||||
|
inline_message_id: str = None,
|
||||||
|
):
|
||||||
|
super().__init__(client)
|
||||||
|
|
||||||
|
self.result_id = result_id
|
||||||
|
self.from_user = from_user
|
||||||
|
self.query = query
|
||||||
|
self.location = location
|
||||||
|
self.inline_message_id = inline_message_id
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(client, chosen_inline_result: types.UpdateBotInlineSend, users) -> "ChosenInlineResult":
|
||||||
|
inline_message_id = None
|
||||||
|
|
||||||
|
if isinstance(chosen_inline_result.msg_id, types.InputBotInlineMessageID):
|
||||||
|
inline_message_id = b64encode(
|
||||||
|
pack(
|
||||||
|
"<iqq",
|
||||||
|
chosen_inline_result.msg_id.dc_id,
|
||||||
|
chosen_inline_result.msg_id.id,
|
||||||
|
chosen_inline_result.msg_id.access_hash
|
||||||
|
),
|
||||||
|
b"-_"
|
||||||
|
).decode().rstrip("=")
|
||||||
|
|
||||||
|
return ChosenInlineResult(
|
||||||
|
result_id=str(chosen_inline_result.id),
|
||||||
|
from_user=User._parse(client, users[chosen_inline_result.user_id]),
|
||||||
|
query=chosen_inline_result.query,
|
||||||
|
location=Location(
|
||||||
|
longitude=chosen_inline_result.geo.long,
|
||||||
|
latitude=chosen_inline_result.geo.lat,
|
||||||
|
client=client
|
||||||
|
) if chosen_inline_result.geo else None,
|
||||||
|
inline_message_id=inline_message_id
|
||||||
|
)
|
@ -523,7 +523,7 @@ class Message(Object, Update):
|
|||||||
|
|
||||||
if media:
|
if media:
|
||||||
if isinstance(media, types.MessageMediaPhoto):
|
if isinstance(media, types.MessageMediaPhoto):
|
||||||
photo = Photo._parse(client, media.photo)
|
photo = Photo._parse(client, media)
|
||||||
elif isinstance(media, types.MessageMediaGeo):
|
elif isinstance(media, types.MessageMediaGeo):
|
||||||
location = Location._parse(client, media.geo)
|
location = Location._parse(client, media.geo)
|
||||||
elif isinstance(media, types.MessageMediaContact):
|
elif isinstance(media, types.MessageMediaContact):
|
||||||
|
@ -42,6 +42,9 @@ class Photo(Object):
|
|||||||
height (``int``):
|
height (``int``):
|
||||||
Photo height.
|
Photo height.
|
||||||
|
|
||||||
|
ttl_seconds (``int``):
|
||||||
|
Time-to-live seconds, for secret photos.
|
||||||
|
|
||||||
file_size (``int``):
|
file_size (``int``):
|
||||||
File size.
|
File size.
|
||||||
|
|
||||||
@ -60,6 +63,7 @@ class Photo(Object):
|
|||||||
file_ref: str,
|
file_ref: str,
|
||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
|
ttl_seconds: int,
|
||||||
file_size: int,
|
file_size: int,
|
||||||
date: int,
|
date: int,
|
||||||
thumbs: List[Thumbnail]
|
thumbs: List[Thumbnail]
|
||||||
@ -70,12 +74,15 @@ class Photo(Object):
|
|||||||
self.file_ref = file_ref
|
self.file_ref = file_ref
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
|
self.ttl_seconds = ttl_seconds
|
||||||
self.file_size = file_size
|
self.file_size = file_size
|
||||||
self.date = date
|
self.date = date
|
||||||
self.thumbs = thumbs
|
self.thumbs = thumbs
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, photo: types.Photo) -> "Photo":
|
def _parse(client, media_photo: types.MessageMediaPhoto) -> "Photo":
|
||||||
|
photo = media_photo.photo
|
||||||
|
|
||||||
if isinstance(photo, types.Photo):
|
if isinstance(photo, types.Photo):
|
||||||
big = photo.sizes[-1]
|
big = photo.sizes[-1]
|
||||||
|
|
||||||
@ -91,6 +98,7 @@ class Photo(Object):
|
|||||||
file_ref=encode_file_ref(photo.file_reference),
|
file_ref=encode_file_ref(photo.file_reference),
|
||||||
width=big.w,
|
width=big.w,
|
||||||
height=big.h,
|
height=big.h,
|
||||||
|
ttl_seconds=media_photo.ttl_seconds,
|
||||||
file_size=big.size,
|
file_size=big.size,
|
||||||
date=photo.date,
|
date=photo.date,
|
||||||
thumbs=Thumbnail._parse(client, photo),
|
thumbs=Thumbnail._parse(client, photo),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user