mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Remove token parameter
This commit is contained in:
parent
ef71dcf56a
commit
813b7958e3
@ -81,10 +81,10 @@ class Client:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
session_name (:obj:`str`):
|
session_name (:obj:`str`):
|
||||||
Name to uniquely identify an authorized session. It will be used
|
Name to uniquely identify a session of either a User or a Bot.
|
||||||
to save the session to a file named *<session_name>.session* and to load
|
For Users: pass a string of your choice, e.g.: "my_main_account".
|
||||||
it when you restart your script. As long as a valid session file exists,
|
For Bots: pass your Bot API token, e.g.: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
|
||||||
Pyrogram won't ask you again to input your phone number.
|
Note: as long as a valid User session file exists, Pyrogram won't ask you again to input your phone number.
|
||||||
|
|
||||||
api_key (:obj:`tuple`, optional):
|
api_key (:obj:`tuple`, optional):
|
||||||
Your Telegram API Key as tuple: *(api_id, api_hash)*.
|
Your Telegram API Key as tuple: *(api_id, api_hash)*.
|
||||||
@ -92,8 +92,8 @@ class Client:
|
|||||||
don't want to use the *config.ini* file.
|
don't want to use the *config.ini* file.
|
||||||
|
|
||||||
proxy (:obj:`dict`, optional):
|
proxy (:obj:`dict`, optional):
|
||||||
Your SOCKS5 Proxy settings as dict: *{hostname: str, port: int, username: str, password: str}*.
|
Your SOCKS5 Proxy settings as dict,
|
||||||
E.g.: *dict(hostname="11.22.33.44", port=1080, username="user", password="pass")*.
|
e.g.: *dict(hostname="11.22.33.44", port=1080, username="user", password="pass")*.
|
||||||
*username* and *password* can be omitted if your proxy doesn't require authorization.
|
*username* and *password* can be omitted if your proxy doesn't require authorization.
|
||||||
This is an alternative way to setup a proxy if you don't want to use the *config.ini* file.
|
This is an alternative way to setup a proxy if you don't want to use the *config.ini* file.
|
||||||
|
|
||||||
@ -102,10 +102,6 @@ class Client:
|
|||||||
Only applicable for new sessions and will be ignored in case previously
|
Only applicable for new sessions and will be ignored in case previously
|
||||||
created sessions are loaded.
|
created sessions are loaded.
|
||||||
|
|
||||||
token (:obj:`str`, optional):
|
|
||||||
Pass your Bot API token to log-in as Bot.
|
|
||||||
E.g.: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
|
|
||||||
|
|
||||||
phone_number (:obj:`str`, optional):
|
phone_number (:obj:`str`, optional):
|
||||||
Pass your phone number (with your Country Code prefix included) to avoid
|
Pass your phone number (with your Country Code prefix included) to avoid
|
||||||
entering it manually. Only applicable for new sessions.
|
entering it manually. Only applicable for new sessions.
|
||||||
@ -132,6 +128,7 @@ class Client:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:t\.me/joinchat/)([\w-]+)$")
|
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:t\.me/joinchat/)([\w-]+)$")
|
||||||
|
BOT_TOKEN_RE = re.compile(r"^\d+:[\w-]+$")
|
||||||
DIALOGS_AT_ONCE = 100
|
DIALOGS_AT_ONCE = 100
|
||||||
UPDATES_WORKERS = 1
|
UPDATES_WORKERS = 1
|
||||||
DOWNLOAD_WORKERS = 1
|
DOWNLOAD_WORKERS = 1
|
||||||
@ -141,7 +138,6 @@ class Client:
|
|||||||
api_key: tuple or APIKey = None,
|
api_key: tuple or APIKey = None,
|
||||||
proxy: dict or Proxy = None,
|
proxy: dict or Proxy = None,
|
||||||
test_mode: bool = False,
|
test_mode: bool = False,
|
||||||
token: str = None,
|
|
||||||
phone_number: str = None,
|
phone_number: str = None,
|
||||||
phone_code: str or callable = None,
|
phone_code: str or callable = None,
|
||||||
password: str = None,
|
password: str = None,
|
||||||
@ -153,7 +149,6 @@ class Client:
|
|||||||
self.proxy = proxy
|
self.proxy = proxy
|
||||||
self.test_mode = test_mode
|
self.test_mode = test_mode
|
||||||
|
|
||||||
self.token = token
|
|
||||||
self.phone_number = phone_number
|
self.phone_number = phone_number
|
||||||
self.password = password
|
self.password = password
|
||||||
self.phone_code = phone_code
|
self.phone_code = phone_code
|
||||||
@ -162,6 +157,8 @@ class Client:
|
|||||||
|
|
||||||
self.workers = workers
|
self.workers = workers
|
||||||
|
|
||||||
|
self.token = None
|
||||||
|
|
||||||
self.dc_id = None
|
self.dc_id = None
|
||||||
self.auth_key = None
|
self.auth_key = None
|
||||||
self.user_id = None
|
self.user_id = None
|
||||||
@ -195,6 +192,10 @@ class Client:
|
|||||||
Raises:
|
Raises:
|
||||||
:class:`pyrogram.Error`
|
:class:`pyrogram.Error`
|
||||||
"""
|
"""
|
||||||
|
if self.BOT_TOKEN_RE.match(self.session_name):
|
||||||
|
self.token = self.session_name
|
||||||
|
self.session_name = self.session_name.split(":")[0]
|
||||||
|
|
||||||
self.load_config()
|
self.load_config()
|
||||||
self.load_session(self.session_name)
|
self.load_session(self.session_name)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user