mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Don't raise exceptions in case of non-existent plugins folder
Don't even warn in case the default plugins folder doesn't exist
This commit is contained in:
parent
0b79f96b4f
commit
4e516d097f
@ -231,22 +231,30 @@ class Client(Methods, BaseClient):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if self.plugins_dir is not None:
|
if self.plugins_dir is not None:
|
||||||
for i in os.listdir(self.plugins_dir):
|
try:
|
||||||
module = import_module("{}.{}".format(self.plugins_dir, i.split(".")[0]))
|
dirs = os.listdir(self.plugins_dir)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
if self.plugins_dir == Client.PLUGINS_DIR:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
log.warning(e)
|
||||||
|
else:
|
||||||
|
for i in dirs:
|
||||||
|
module = import_module("{}.{}".format(self.plugins_dir, i.split(".")[0]))
|
||||||
|
|
||||||
for j in dir(module):
|
for j in dir(module):
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
handler, group = getattr(module, j)
|
handler, group = getattr(module, j)
|
||||||
|
|
||||||
if isinstance(handler, Handler) and isinstance(group, int):
|
if isinstance(handler, Handler) and isinstance(group, int):
|
||||||
self.add_handler(handler, group)
|
self.add_handler(handler, group)
|
||||||
|
|
||||||
log.info('{}("{}") from "{}/{}" registered in group {}'.format(
|
log.info('{}("{}") from "{}/{}" registered in group {}'.format(
|
||||||
type(handler).__name__, j, self.plugins_dir, i, group)
|
type(handler).__name__, j, self.plugins_dir, i, group)
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.session.start()
|
self.session.start()
|
||||||
self.is_started = True
|
self.is_started = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user