Skip to content

Commit 5edd971

Browse files
committed
Update docs to use bot_token parameter
1 parent 1491308 commit 5edd971

2 files changed

Lines changed: 32 additions & 29 deletions

File tree

docs/source/start/Setup.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,19 @@ and as long as you keep the session alive, Pyrogram won't ask you again to enter
9292
Bot Authorization
9393
-----------------
9494

95-
Bots are a special kind of users and are authorized via their tokens (instead of phone numbers), which are created by
95+
Bots are a special kind of users that are authorized via their tokens (instead of phone numbers), which are created by
9696
BotFather_. Bot tokens replace the Users' phone numbers only — you still need to
9797
`configure a Telegram API key <#configuration>`_ with Pyrogram, even when using Bots.
9898

99-
The authorization process is automatically managed. All you need to do is pass the bot token as ``session_name``.
100-
The session file will be named after the Bot user_id, which is ``123456.session`` for the example below.
99+
The authorization process is automatically managed. All you need to do is choose a ``session_name`` (can be anything,
100+
but is usually your bot username) and pass your bot token using the ``bot_token`` parameter.
101+
The session file will be named after the session name, which will be ``pyrogrambot.session`` for the example below.
101102

102103
.. code-block:: python
103104
104105
from pyrogram import Client
105106
106-
app = Client("123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11")
107+
app = Client("pyrogrambot", bot_token="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11")
107108
app.run()
108109
109110
.. _installed Pyrogram: Installation.html

pyrogram/client/client.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -183,31 +183,33 @@ class Client(Methods, BaseClient):
183183

184184
terms_of_service_displayed = False
185185

186-
def __init__(self,
187-
session_name: str,
188-
api_id: Union[int, str] = None,
189-
api_hash: str = None,
190-
app_version: str = None,
191-
device_model: str = None,
192-
system_version: str = None,
193-
lang_code: str = None,
194-
ipv6: bool = False,
195-
proxy: dict = None,
196-
test_mode: bool = False,
197-
phone_number: str = None,
198-
phone_code: Union[str, callable] = None,
199-
password: str = None,
200-
recovery_code: callable = None,
201-
force_sms: bool = False,
202-
bot_token: str = None,
203-
first_name: str = None,
204-
last_name: str = None,
205-
workers: int = BaseClient.WORKERS,
206-
workdir: str = BaseClient.WORKDIR,
207-
config_file: str = BaseClient.CONFIG_FILE,
208-
plugins: dict = None,
209-
no_updates: bool = None,
210-
takeout: bool = None):
186+
def __init__(
187+
self,
188+
session_name: str,
189+
api_id: Union[int, str] = None,
190+
api_hash: str = None,
191+
app_version: str = None,
192+
device_model: str = None,
193+
system_version: str = None,
194+
lang_code: str = None,
195+
ipv6: bool = False,
196+
proxy: dict = None,
197+
test_mode: bool = False,
198+
phone_number: str = None,
199+
phone_code: Union[str, callable] = None,
200+
password: str = None,
201+
recovery_code: callable = None,
202+
force_sms: bool = False,
203+
bot_token: str = None,
204+
first_name: str = None,
205+
last_name: str = None,
206+
workers: int = BaseClient.WORKERS,
207+
workdir: str = BaseClient.WORKDIR,
208+
config_file: str = BaseClient.CONFIG_FILE,
209+
plugins: dict = None,
210+
no_updates: bool = None,
211+
takeout: bool = None
212+
):
211213
super().__init__()
212214

213215
self.session_name = session_name

0 commit comments

Comments
 (0)