Skip to content

Commit ef78900

Browse files
committed
Fixes to the documentation
1 parent ade31f8 commit ef78900

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

docs/source/start/auth.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ User Authorization
1616

1717
In order to use the API, Telegram requires that users be authorized via their phone numbers.
1818
Pyrogram automatically manages this process, all you need to do is create an instance of the
19-
:class:`~pyrogram.Client` class by passing to it a ``session_name`` of your choice (e.g.: "my_account") and call
19+
:class:`~pyrogram.Client` class by passing to it a ``name`` of your choice (e.g.: "my_account") and call
2020
the :meth:`~pyrogram.Client.run` method:
2121

2222
.. code-block:: python
@@ -57,7 +57,7 @@ Bots are a special kind of users that are authorized via their tokens (instead o
5757
the `Bot Father`_. Bot tokens replace the users' phone numbers only — you still need to
5858
:doc:`configure a Telegram API key <../start/setup>` with Pyrogram, even when using bots.
5959

60-
The authorization process is automatically managed. All you need to do is choose a ``session_name`` (can be anything,
60+
The authorization process is automatically managed. All you need to do is choose a ``name`` (can be anything,
6161
usually your bot username) and pass your bot token using the ``bot_token`` parameter. The session file will be named
6262
after the session name, which will be ``my_bot.session`` for the example below.
6363

docs/source/topics/storage-engines.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ This is the most common storage engine. It is implemented by using **SQLite**, w
3131
The database will be saved to disk as a single portable file and is designed to efficiently store and retrieve
3232
data whenever they are needed.
3333

34-
To use this type of engine, simply pass any name of your choice to the ``session_name`` parameter of the
34+
To use this type of engine, simply pass any name of your choice to the ``name`` parameter of the
3535
:obj:`~pyrogram.Client` constructor, as usual:
3636

3737
.. code-block:: python
3838
3939
from pyrogram import Client
4040
41-
with Client("my_account") as app:
42-
print(app.get_me())
41+
async with Client("my_account") as app:
42+
print(await app.get_me())
4343
4444
Once you successfully log in (either with a user or a bot identity), a session file will be created and saved to disk as
4545
``my_account.session``. Any subsequent client restart will make Pyrogram search for a file named that way and the
@@ -48,15 +48,15 @@ session database will be automatically loaded.
4848
Memory Storage
4949
^^^^^^^^^^^^^^
5050

51-
In case you don't want to have any session file saved to disk, you can use an in-memory storage by passing the special
52-
session name "**:memory:**" to the ``session_name`` parameter of the :obj:`~pyrogram.Client` constructor:
51+
In case you don't want to have any session file saved to disk, you can use an in-memory storage by passing True to the
52+
``in_memory`` parameter of the :obj:`~pyrogram.Client` constructor:
5353

5454
.. code-block:: python
5555
5656
from pyrogram import Client
5757
58-
with Client(":memory:") as app:
59-
print(app.get_me())
58+
async with Client("my_account", in_memory=True) as app:
59+
print(await app.get_me())
6060
6161
This storage engine is still backed by SQLite, but the database exists purely in memory. This means that, once you stop
6262
a client, the entire database is discarded and the session details used for logging in again will be lost forever.
@@ -71,8 +71,8 @@ In case you want to use an in-memory storage, but also want to keep access to th
7171
7272
from pyrogram import Client
7373
74-
with Client(":memory:") as app:
75-
print(app.export_session_string())
74+
async with Client("my_account", in_memory=True) as app:
75+
print(await app.export_session_string())
7676
7777
...and save the resulting string. You can use this string as session name the next time you want to login
7878
using the same session; the storage used will still be in-memory:
@@ -83,8 +83,8 @@ using the same session; the storage used will still be in-memory:
8383
8484
session_string = "...ZnUIFD8jsjXTb8g_vpxx48k1zkov9sapD-tzjz-S4WZv70M..."
8585
86-
with Client(session_string) as app:
87-
print(app.get_me())
86+
async with Client("my_account", session_string=session_string) as app:
87+
print(await app.get_me())
8888
8989
Session strings are useful when you want to run authorized Pyrogram clients on platforms where their ephemeral
9090
filesystems makes it harder for a file-based storage engine to properly work as intended.

0 commit comments

Comments
 (0)