2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Added support for bot_token inside config.ini file (#296)

This commit is contained in:
trenoduro 2019-08-08 15:07:46 +02:00 committed by Dan
parent 7663d88758
commit 5164ea78c2

View File

@ -110,6 +110,7 @@ class Client(Methods, BaseClient):
bot_token (``str``, *optional*): bot_token (``str``, *optional*):
Pass your Bot API token to create a bot session, e.g.: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11" Pass your Bot API token to create a bot session, e.g.: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
Only applicable for new sessions. Only applicable for new sessions.
This is an alternative way to set it if you don't want to use the *config.ini* file.
phone_number (``str`` | ``callable``, *optional*): phone_number (``str`` | ``callable``, *optional*):
Pass your phone number as string (with your Country Code prefix included) to avoid entering it manually. Pass your phone number as string (with your Country Code prefix included) to avoid entering it manually.
@ -1229,6 +1230,11 @@ class Client(Methods, BaseClient):
parser = ConfigParser() parser = ConfigParser()
parser.read(str(self.config_file)) parser.read(str(self.config_file))
if self.bot_token:
pass
else:
self.bot_token = parser.get("pyrogram", "bot_token", fallback=None)
if self.api_id and self.api_hash: if self.api_id and self.api_hash:
pass pass
else: else: