2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

Update docs to use bot_token parameter

This commit is contained in:
Dan 2019-03-22 12:39:15 +01:00
parent 149130831b
commit 5edd971118
2 changed files with 32 additions and 29 deletions

View File

@ -92,18 +92,19 @@ and as long as you keep the session alive, Pyrogram won't ask you again to enter
Bot Authorization 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 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. `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 authorization process is automatically managed. All you need to do is choose a ``session_name`` (can be anything,
The session file will be named after the Bot user_id, which is ``123456.session`` for the example below. 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 .. code-block:: python
from pyrogram import Client from pyrogram import Client
app = Client("123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11") app = Client("pyrogrambot", bot_token="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11")
app.run() app.run()
.. _installed Pyrogram: Installation.html .. _installed Pyrogram: Installation.html

View File

@ -183,31 +183,33 @@ class Client(Methods, BaseClient):
terms_of_service_displayed = False terms_of_service_displayed = False
def __init__(self, def __init__(
session_name: str, self,
api_id: Union[int, str] = None, session_name: str,
api_hash: str = None, api_id: Union[int, str] = None,
app_version: str = None, api_hash: str = None,
device_model: str = None, app_version: str = None,
system_version: str = None, device_model: str = None,
lang_code: str = None, system_version: str = None,
ipv6: bool = False, lang_code: str = None,
proxy: dict = None, ipv6: bool = False,
test_mode: bool = False, proxy: dict = None,
phone_number: str = None, test_mode: bool = False,
phone_code: Union[str, callable] = None, phone_number: str = None,
password: str = None, phone_code: Union[str, callable] = None,
recovery_code: callable = None, password: str = None,
force_sms: bool = False, recovery_code: callable = None,
bot_token: str = None, force_sms: bool = False,
first_name: str = None, bot_token: str = None,
last_name: str = None, first_name: str = None,
workers: int = BaseClient.WORKERS, last_name: str = None,
workdir: str = BaseClient.WORKDIR, workers: int = BaseClient.WORKERS,
config_file: str = BaseClient.CONFIG_FILE, workdir: str = BaseClient.WORKDIR,
plugins: dict = None, config_file: str = BaseClient.CONFIG_FILE,
no_updates: bool = None, plugins: dict = None,
takeout: bool = None): no_updates: bool = None,
takeout: bool = None
):
super().__init__() super().__init__()
self.session_name = session_name self.session_name = session_name