Skip to content

Commit 73a1fee

Browse files
Fix stackable plugin decorators with include/exclude directives (pyrogram#643)
* combination of decorators with plugins has solved * fixing last pr: allow stackable plugin decorators even in exclude and include as well. * counting plugins has fixed * fix indentation * Update client.py * Update client.py Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com>
1 parent b6613fb commit 73a1fee

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

pyrogram/client.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def load_plugins(self):
724724
log.info('[{}] [LOAD] {}("{}") in group {} from "{}"'.format(
725725
self.session_name, type(handler).__name__, name, group, module_path))
726726

727-
count += 1
727+
count += 1
728728
except Exception:
729729
pass
730730
else:
@@ -749,15 +749,14 @@ def load_plugins(self):
749749
for name in handlers:
750750
# noinspection PyBroadException
751751
try:
752-
handler, group = getattr(module, name).handler
753-
754-
if isinstance(handler, Handler) and isinstance(group, int):
755-
self.add_handler(handler, group)
752+
for handler, group in getattr(module, name).handlers:
753+
if isinstance(handler, Handler) and isinstance(group, int):
754+
self.add_handler(handler, group)
756755

757-
log.info('[{}] [LOAD] {}("{}") in group {} from "{}"'.format(
758-
self.session_name, type(handler).__name__, name, group, module_path))
756+
log.info('[{}] [LOAD] {}("{}") in group {} from "{}"'.format(
757+
self.session_name, type(handler).__name__, name, group, module_path))
759758

760-
count += 1
759+
count += 1
761760
except Exception:
762761
if warn_non_existent_functions:
763762
log.warning('[{}] [LOAD] Ignoring non-existent function "{}" from "{}"'.format(
@@ -785,15 +784,14 @@ def load_plugins(self):
785784
for name in handlers:
786785
# noinspection PyBroadException
787786
try:
788-
handler, group = getattr(module, name).handler
789-
790-
if isinstance(handler, Handler) and isinstance(group, int):
791-
self.remove_handler(handler, group)
787+
for handler, group in getattr(module, name).handlers:
788+
if isinstance(handler, Handler) and isinstance(group, int):
789+
self.remove_handler(handler, group)
792790

793-
log.info('[{}] [UNLOAD] {}("{}") from group {} in "{}"'.format(
794-
self.session_name, type(handler).__name__, name, group, module_path))
791+
log.info('[{}] [UNLOAD] {}("{}") from group {} in "{}"'.format(
792+
self.session_name, type(handler).__name__, name, group, module_path))
795793

796-
count -= 1
794+
count -= 1
797795
except Exception:
798796
if warn_non_existent_functions:
799797
log.warning('[{}] [UNLOAD] Ignoring non-existent function "{}" from "{}"'.format(

0 commit comments

Comments
 (0)