From c5785a2d1484a98616b0fb8b5a7cb728eb094435 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 26 Jun 2019 14:37:26 +0100 Subject: implement @utils.kwarg() magic, use it for command.regex hooks --- src/utils/__init__.py | 5 +++++ src/utils/consts.py | 1 + 2 files changed, 6 insertions(+) (limited to 'src/utils') diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 4e947c4b..de812f5b 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -184,6 +184,11 @@ def export(setting: str, value: typing.Any): {"setting": setting, "value": value}) return module return _export_func +def kwarg(key: str, value: typing.Any): + def _kwarg_func(func): + _set_get_append(func, consts.BITBOT_KWARG_MAGIC, {key: value}) + return func + return _kwarg_func class MultiCheck(object): def __init__(self, diff --git a/src/utils/consts.py b/src/utils/consts.py index f5272cab..0c57b4b0 100644 --- a/src/utils/consts.py +++ b/src/utils/consts.py @@ -2,6 +2,7 @@ import typing from . import _consts_256_color BITBOT_HOOKS_MAGIC = "__bitbot_hooks" +BITBOT_KWARG_MAGIC = "__bitbot_kwarg" BITBOT_EXPORTS_MAGIC = "__bitbot_exports" class IRCColor(object): -- cgit v1.3.1-10-gc9f91