Use a better name for the special plugin attribute when decorating funcs

This commit is contained in:
Dan 2019-07-11 17:14:38 +02:00
parent 5fe8fba3df
commit e1197e066e
8 changed files with 10 additions and 10 deletions

View File

@ -1108,7 +1108,7 @@ class Client(Methods, BaseClient):
for name in vars(module).keys():
# noinspection PyBroadException
try:
handler, group = getattr(module, name).pyrogram_plugin
handler, group = getattr(module, name).handler
if isinstance(handler, Handler) and isinstance(group, int):
self.add_handler(handler, group)
@ -1143,7 +1143,7 @@ class Client(Methods, BaseClient):
for name in handlers:
# noinspection PyBroadException
try:
handler, group = getattr(module, name).pyrogram_plugin
handler, group = getattr(module, name).handler
if isinstance(handler, Handler) and isinstance(group, int):
self.add_handler(handler, group)
@ -1181,7 +1181,7 @@ class Client(Methods, BaseClient):
for name in handlers:
# noinspection PyBroadException
try:
handler, group = getattr(module, name).pyrogram_plugin
handler, group = getattr(module, name).handler
if isinstance(handler, Handler) and isinstance(group, int):
self.remove_handler(handler, group)

View File

@ -47,7 +47,7 @@ class OnCallbackQuery(BaseClient):
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.CallbackQueryHandler(func, filters), group)
elif isinstance(self, Filter) or self is None:
func.pyrogram_plugin = (
func.handler = (
pyrogram.CallbackQueryHandler(func, self),
group if filters is None else filters
)

View File

@ -47,7 +47,7 @@ class OnDeletedMessages(BaseClient):
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.DeletedMessagesHandler(func, filters), group)
elif isinstance(self, Filter) or self is None:
func.pyrogram_plugin = (
func.handler = (
pyrogram.DeletedMessagesHandler(func, self),
group if filters is None else filters
)

View File

@ -46,7 +46,7 @@ class OnInlineQuery(BaseClient):
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.InlineQueryHandler(func, filters), group)
elif isinstance(self, Filter) or self is None:
func.pyrogram_plugin = (
func.handler = (
pyrogram.InlineQueryHandler(func, self),
group if filters is None else filters
)

View File

@ -46,7 +46,7 @@ class OnMessage(BaseClient):
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.MessageHandler(func, filters), group)
elif isinstance(self, Filter) or self is None:
func.pyrogram_plugin = (
func.handler = (
pyrogram.MessageHandler(func, self),
group if filters is None else filters
)

View File

@ -46,7 +46,7 @@ class OnPoll(BaseClient):
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.PollHandler(func, filters), group)
elif isinstance(self, Filter) or self is None:
func.pyrogram_plugin = (
func.handler = (
pyrogram.PollHandler(func, self),
group if filters is None else filters
)

View File

@ -40,7 +40,7 @@ class OnRawUpdate(BaseClient):
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.RawUpdateHandler(func), group)
else:
func.pyrogram_plugin = (
func.handler = (
pyrogram.RawUpdateHandler(func),
group if self is None else group
)

View File

@ -44,7 +44,7 @@ class OnUserStatus(BaseClient):
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.UserStatusHandler(func, filters), group)
elif isinstance(self, Filter) or self is None:
func.pyrogram_plugin = (
func.handler = (
pyrogram.UserStatusHandler(func, self),
group if filters is None else filters
)