2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

More logs when loading plugins

This commit is contained in:
Dan 2018-10-12 17:54:52 +02:00
parent 6c05f9ff42
commit 4bb50ee35f

View File

@ -233,13 +233,14 @@ class Client(Methods, BaseClient):
if self.plugins_dir is not None:
try:
dirs = os.listdir(self.plugins_dir)
except FileNotFoundError as e:
except FileNotFoundError:
if self.plugins_dir == Client.PLUGINS_DIR:
pass
log.info("No plugin loaded: default directory is missing")
else:
log.warning(e)
log.warning('No plugin loaded: "{}" directory is missing'.format(self.plugins_dir))
else:
plugins_dir = self.plugins_dir.lstrip("./").replace("/", ".")
plugins_count = 0
for i in dirs:
module = import_module("{}.{}".format(plugins_dir, i.split(".")[0]))
@ -252,12 +253,20 @@ class Client(Methods, BaseClient):
if isinstance(handler, Handler) and isinstance(group, int):
self.add_handler(handler, group)
log.info('{}("{}") from "{}/{}" registered in group {}'.format(
log.info('{}("{}") from "{}/{}" loaded in group {}'.format(
type(handler).__name__, j, self.plugins_dir, i, group)
)
plugins_count += 1
except Exception:
pass
log.warning('Successfully loaded {} plugin{} from "{}"'.format(
plugins_count,
"s" if plugins_count > 1 else "",
self.plugins_dir
))
self.session.start()
self.is_started = True