From 0f197bbcff8de9958d442325182ac2e0a8ee259d Mon Sep 17 00:00:00 2001 From: Alex Tzonkov Date: Sun, 20 Jan 2019 23:28:20 -0800 Subject: [PATCH] Fixing bug with decorators and help Since we depend on __doc__ for the help documentaiton I am adding the use of functools to preserve the __doc__ string when decorating functions from utils. --- docs/dev_install.rst | 2 +- mmpy_bot/utils.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/dev_install.rst b/docs/dev_install.rst index 716f3932..0add74f5 100644 --- a/docs/dev_install.rst +++ b/docs/dev_install.rst @@ -11,7 +11,7 @@ Installation for development $ pip install -r requirements.txt $ pip install -r docs/requirements.txt $ touch local_settings.py # configure your local settings - $ matterbot # run bot + $ mmpy_bot # run bot .. code-block:: python diff --git a/mmpy_bot/utils.py b/mmpy_bot/utils.py index 28d52d2f..8122b3d9 100644 --- a/mmpy_bot/utils.py +++ b/mmpy_bot/utils.py @@ -3,6 +3,7 @@ import logging from six.moves import _thread, queue +from functools import wraps logger = logging.getLogger(__name__) @@ -34,6 +35,7 @@ def do_work(self): def allow_only_direct_message(): def plugin(func): + @wraps(func) def wrapper(message, *args, **kw): if not message.is_direct_message(): return message.reply("`Only direct messages is allowed`") @@ -46,6 +48,7 @@ def wrapper(message, *args, **kw): def allowed_users(*allowed_users_list): def plugin(func): + @wraps(func) def wrapper(message, *args, **kw): user = message.get_username() user_email = message.get_user_mail()