mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-02 07:15:23 +00:00
Make plugins disabled by default
Users need to explicitly set plugins_dir parameter
This commit is contained in:
@@ -169,7 +169,7 @@ class Client(Methods, BaseClient):
|
|||||||
workers: int = BaseClient.WORKERS,
|
workers: int = BaseClient.WORKERS,
|
||||||
workdir: str = BaseClient.WORKDIR,
|
workdir: str = BaseClient.WORKDIR,
|
||||||
config_file: str = BaseClient.CONFIG_FILE,
|
config_file: str = BaseClient.CONFIG_FILE,
|
||||||
plugins_dir: str or None = BaseClient.PLUGINS_DIR):
|
plugins_dir: str = None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.session_name = session_name
|
self.session_name = session_name
|
||||||
@@ -983,9 +983,6 @@ class Client(Methods, BaseClient):
|
|||||||
try:
|
try:
|
||||||
dirs = os.listdir(self.plugins_dir)
|
dirs = os.listdir(self.plugins_dir)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
if self.plugins_dir == Client.PLUGINS_DIR:
|
|
||||||
log.info("No plugin loaded: default directory is missing")
|
|
||||||
else:
|
|
||||||
log.warning('No plugin loaded: "{}" directory is missing'.format(self.plugins_dir))
|
log.warning('No plugin loaded: "{}" directory is missing'.format(self.plugins_dir))
|
||||||
else:
|
else:
|
||||||
plugins_dir = self.plugins_dir.lstrip("./").replace("/", ".")
|
plugins_dir = self.plugins_dir.lstrip("./").replace("/", ".")
|
||||||
@@ -1010,11 +1007,14 @@ class Client(Methods, BaseClient):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if plugins_count > 0:
|
||||||
log.warning('Successfully loaded {} plugin{} from "{}"'.format(
|
log.warning('Successfully loaded {} plugin{} from "{}"'.format(
|
||||||
plugins_count,
|
plugins_count,
|
||||||
"s" if plugins_count > 1 else "",
|
"s" if plugins_count > 1 else "",
|
||||||
self.plugins_dir
|
self.plugins_dir
|
||||||
))
|
))
|
||||||
|
else:
|
||||||
|
log.warning('No plugin loaded: "{}" doesn\'t contain any valid plugin'.format(self.plugins_dir))
|
||||||
|
|
||||||
def save_session(self):
|
def save_session(self):
|
||||||
auth_key = base64.b64encode(self.auth_key).decode()
|
auth_key = base64.b64encode(self.auth_key).decode()
|
||||||
|
@@ -52,7 +52,6 @@ class BaseClient:
|
|||||||
WORKERS = 4
|
WORKERS = 4
|
||||||
WORKDIR = "."
|
WORKDIR = "."
|
||||||
CONFIG_FILE = "./config.ini"
|
CONFIG_FILE = "./config.ini"
|
||||||
PLUGINS_DIR = "./plugins"
|
|
||||||
|
|
||||||
MEDIA_TYPE_ID = {
|
MEDIA_TYPE_ID = {
|
||||||
0: "thumbnail",
|
0: "thumbnail",
|
||||||
|
Reference in New Issue
Block a user