diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 41b0bfdb..225ddd08 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -110,6 +110,7 @@ class Client(Methods, BaseClient): bot_token (``str``, *optional*): Pass your Bot API token to create a bot session, e.g.: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11" 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*): Pass your phone number as string (with your Country Code prefix included) to avoid entering it manually. @@ -1237,6 +1238,11 @@ class Client(Methods, BaseClient): def load_config(self): parser = ConfigParser() 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: pass diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index f80127c2..5d892bbe 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -211,8 +211,7 @@ class Filters: @staticmethod def command( commands: str or list, - prefix: str or list = "/", - separator: str = " ", + prefixes: str or list = "/", case_sensitive: bool = False ): """Filter commands, i.e.: text messages starting with "/" or any other custom prefix. @@ -224,40 +223,63 @@ class Filters: a command arrives, the command itself and its arguments will be stored in the *command* field of the :obj:`Message`. - prefix (``str`` | ``list``, *optional*): + prefixes (``str`` | ``list``, *optional*): A prefix or a list of prefixes as string the filter should look for. - Defaults to "/" (slash). Examples: ".", "!", ["/", "!", "."]. - Can be None or "" (empty string) to allow commands with no prefix at all. - - separator (``str``, *optional*): - The command arguments separator. Defaults to " " (white space). - Examples: /start first second, /start-first-second, /start.first.second. + Defaults to "/" (slash). Examples: ".", "!", ["/", "!", "."], list(".:!"). + Pass None or "" (empty string) to allow commands with no prefix at all. case_sensitive (``bool``, *optional*): Pass True if you want your command(s) to be case sensitive. Defaults to False. Examples: when True, command="Start" would trigger /Start but not /start. """ + command_re = re.compile(r"([\"'])(.*?)(?