aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BerryClient/commands.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/BerryClient/commands.py b/BerryClient/commands.py
index 532c0a2..20771ef 100644
--- a/BerryClient/commands.py
+++ b/BerryClient/commands.py
@@ -7,7 +7,7 @@ log = logging.getLogger(__name__)
PREFIX = "#"
COMMANDS = {}
-def command(name=None):
+def command(name=None, aliases=None):
def decorator(func):
func_name = name or func.__name__
@@ -15,7 +15,7 @@ def command(name=None):
try:
retval = func(core, *args)
if retval:
- core.postToChat(f"[{func_name}] {retval}")
+ log.info(retval)
except Exception as e:
log.exception(e)
@@ -24,11 +24,19 @@ def command(name=None):
if func.__doc__:
description = func.__doc__.strip().split("\n")[0]
- COMMANDS[func_name] = {
+ cmd = {
"func": wrapper,
- "description": description
+ "description": description,
+ "alias": False,
}
+ COMMANDS[func_name] = cmd
+ if aliases:
+ for alias in aliases:
+ alias_cmd = cmd.copy()
+ alias_cmd["alias"] = True
+ COMMANDS[alias] = alias_cmd
+
return decorator
@on_chat_post()