diff --git a/docs/source/start/Setup.rst b/docs/source/start/Setup.rst index 24caa1f4..26d9d1c6 100644 --- a/docs/source/start/Setup.rst +++ b/docs/source/start/Setup.rst @@ -92,18 +92,19 @@ and as long as you keep the session alive, Pyrogram won't ask you again to enter Bot Authorization ----------------- -Bots are a special kind of users and are authorized via their tokens (instead of phone numbers), which are created by +Bots are a special kind of users that are authorized via their tokens (instead of phone numbers), which are created by BotFather_. Bot tokens replace the Users' phone numbers only — you still need to `configure a Telegram API key <#configuration>`_ with Pyrogram, even when using Bots. -The authorization process is automatically managed. All you need to do is pass the bot token as ``session_name``. -The session file will be named after the Bot user_id, which is ``123456.session`` for the example below. +The authorization process is automatically managed. All you need to do is choose a ``session_name`` (can be anything, +but is usually your bot username) and pass your bot token using the ``bot_token`` parameter. +The session file will be named after the session name, which will be ``pyrogrambot.session`` for the example below. .. code-block:: python from pyrogram import Client - app = Client("123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11") + app = Client("pyrogrambot", bot_token="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11") app.run() .. _installed Pyrogram: Installation.html diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 737139ca..ca74e25b 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -183,31 +183,33 @@ class Client(Methods, BaseClient): terms_of_service_displayed = False - def __init__(self, - session_name: str, - api_id: Union[int, str] = None, - api_hash: str = None, - app_version: str = None, - device_model: str = None, - system_version: str = None, - lang_code: str = None, - ipv6: bool = False, - proxy: dict = None, - test_mode: bool = False, - phone_number: str = None, - phone_code: Union[str, callable] = None, - password: str = None, - recovery_code: callable = None, - force_sms: bool = False, - bot_token: str = None, - first_name: str = None, - last_name: str = None, - workers: int = BaseClient.WORKERS, - workdir: str = BaseClient.WORKDIR, - config_file: str = BaseClient.CONFIG_FILE, - plugins: dict = None, - no_updates: bool = None, - takeout: bool = None): + def __init__( + self, + session_name: str, + api_id: Union[int, str] = None, + api_hash: str = None, + app_version: str = None, + device_model: str = None, + system_version: str = None, + lang_code: str = None, + ipv6: bool = False, + proxy: dict = None, + test_mode: bool = False, + phone_number: str = None, + phone_code: Union[str, callable] = None, + password: str = None, + recovery_code: callable = None, + force_sms: bool = False, + bot_token: str = None, + first_name: str = None, + last_name: str = None, + workers: int = BaseClient.WORKERS, + workdir: str = BaseClient.WORKDIR, + config_file: str = BaseClient.CONFIG_FILE, + plugins: dict = None, + no_updates: bool = None, + takeout: bool = None + ): super().__init__() self.session_name = session_name