mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Feat: Add group Parameter to the Decorator.on_error.
Some checks are pending
Build-docs / build (push) Waiting to run
Pyrofork / build (macos-latest, 3.10) (push) Waiting to run
Pyrofork / build (macos-latest, 3.11) (push) Waiting to run
Pyrofork / build (macos-latest, 3.12) (push) Waiting to run
Pyrofork / build (macos-latest, 3.13) (push) Waiting to run
Pyrofork / build (macos-latest, 3.9) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.10) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.11) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.12) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.13) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.9) (push) Waiting to run
Some checks are pending
Build-docs / build (push) Waiting to run
Pyrofork / build (macos-latest, 3.10) (push) Waiting to run
Pyrofork / build (macos-latest, 3.11) (push) Waiting to run
Pyrofork / build (macos-latest, 3.12) (push) Waiting to run
Pyrofork / build (macos-latest, 3.13) (push) Waiting to run
Pyrofork / build (macos-latest, 3.9) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.10) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.11) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.12) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.13) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.9) (push) Waiting to run
Signed-off-by: Ling-ex <nekochan@rizkiofficial.com>
This commit is contained in:
parent
ce356e02f5
commit
a5cd3b92a6
1 changed files with 10 additions and 3 deletions
|
|
@ -24,7 +24,11 @@ from pyrogram.filters import Filter
|
|||
|
||||
|
||||
class OnError:
|
||||
def on_error(self=None, errors=None) -> Callable:
|
||||
def on_error(
|
||||
self=None,
|
||||
errors=None,
|
||||
group: int = 0,
|
||||
) -> Callable:
|
||||
"""Decorator for handling new errors.
|
||||
|
||||
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
|
||||
|
|
@ -34,16 +38,19 @@ class OnError:
|
|||
errors (:obj:`~Exception`, *optional*):
|
||||
Pass one or more errors to allow only a subset of errors to be passed
|
||||
in your function.
|
||||
|
||||
group (``int``, *optional*):
|
||||
The group identifier, defaults to 0.
|
||||
"""
|
||||
|
||||
def decorator(func: Callable) -> Callable:
|
||||
if isinstance(self, pyrogram.Client):
|
||||
self.add_handler(pyrogram.handlers.ErrorHandler(func, errors), 0)
|
||||
self.add_handler(pyrogram.handlers.ErrorHandler(func, errors), group)
|
||||
elif isinstance(self, Filter) or self is None:
|
||||
if not hasattr(func, "handlers"):
|
||||
func.handlers = []
|
||||
|
||||
func.handlers.append((pyrogram.handlers.ErrorHandler(func, self), 0))
|
||||
func.handlers.append((pyrogram.handlers.ErrorHandler(func, self), group))
|
||||
|
||||
return func
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue