mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-25 11:28:05 +00:00
Update documentation
This commit is contained in:
parent
b7b7e8ec69
commit
ccadabca4a
@ -141,9 +141,9 @@ Meta
|
|||||||
topics/create-filters
|
topics/create-filters
|
||||||
topics/more-on-updates
|
topics/more-on-updates
|
||||||
topics/client-settings
|
topics/client-settings
|
||||||
topics/synchronous
|
|
||||||
topics/text-formatting
|
|
||||||
topics/speedups
|
topics/speedups
|
||||||
|
topics/text-formatting
|
||||||
|
topics/synchronous
|
||||||
topics/smart-plugins
|
topics/smart-plugins
|
||||||
topics/storage-engines
|
topics/storage-engines
|
||||||
topics/serializing
|
topics/serializing
|
||||||
|
@ -45,21 +45,44 @@ Installation
|
|||||||
Usage
|
Usage
|
||||||
^^^^^
|
^^^^^
|
||||||
|
|
||||||
Call ``uvloop.install()`` before calling ``asyncio.run()`` or ``app.run()``
|
Call ``uvloop.install()`` before calling ``asyncio.run()`` or ``app.run()``.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import uvloop
|
import uvloop
|
||||||
|
|
||||||
|
from pyrogram import Client
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
app = Client("my_account")
|
app = Client("my_account")
|
||||||
|
|
||||||
async with app:
|
async with app:
|
||||||
print(await app.get_me())
|
print(await app.get_me())
|
||||||
|
|
||||||
|
|
||||||
uvloop.install()
|
uvloop.install()
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
||||||
|
The ``uvloop.install()`` call also needs to be placed before creating a Client instance.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import uvloop
|
||||||
|
from pyrogram import Client
|
||||||
|
|
||||||
|
uvloop.install()
|
||||||
|
|
||||||
|
app = Client("my_account")
|
||||||
|
|
||||||
|
|
||||||
|
@app.on_message()
|
||||||
|
async def hello(client, message):
|
||||||
|
print(await client.get_me())
|
||||||
|
|
||||||
|
|
||||||
|
app.run()
|
||||||
|
|
||||||
.. _TgCrypto: https://github.com/pyrogram/tgcrypto
|
.. _TgCrypto: https://github.com/pyrogram/tgcrypto
|
||||||
.. _uvloop: https://github.com/MagicStack/uvloop
|
.. _uvloop: https://github.com/MagicStack/uvloop
|
||||||
|
@ -71,3 +71,18 @@ possible.
|
|||||||
@app.on_edited_message()
|
@app.on_edited_message()
|
||||||
def handler2(client, message):
|
def handler2(client, message):
|
||||||
message.forward("me")
|
message.forward("me")
|
||||||
|
|
||||||
|
uvloop usage
|
||||||
|
------------
|
||||||
|
|
||||||
|
When using Pyrogram in its synchronous mode combined with uvloop, you need to call ``uvloop.install()`` before importing
|
||||||
|
Pyrogram.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import uvloop
|
||||||
|
uvloop.install()
|
||||||
|
|
||||||
|
from pyrogram import Client
|
||||||
|
|
||||||
|
...
|
Loading…
x
Reference in New Issue
Block a user