From 2b0dfcc1556741dab5452a8e1ece5f439023728c Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 7 Apr 2020 19:30:32 +0100 Subject: [PATCH] add ${BNICK} (bot's own nick) and ${CTRIGGER} (command trigger) to aliases --- modules/alias_variables.py | 4 ++++ src/core_modules/commands/__init__.py | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/alias_variables.py b/modules/alias_variables.py index 6f2499a3..b618a7c6 100644 --- a/modules/alias_variables.py +++ b/modules/alias_variables.py @@ -5,7 +5,11 @@ class Module(ModuleManager.BaseModule): @utils.hook("get.command") @utils.kwarg("priority", EventManager.PRIORITY_HIGH) def get_command(self, event): + event["kwargs"]["CTRIGGER"] = event["command_prefix"] + + event["kwargs"]["BNICK"] = event["server"].nickname event["kwargs"]["NICK"] = event["user"].nickname + if event["is_channel"]: event["kwargs"]["CHAN"] = event["target"].name random_user = random.choice(list(event["target"].users)) diff --git a/src/core_modules/commands/__init__.py b/src/core_modules/commands/__init__.py index 777cb692..3a0e74cd 100644 --- a/src/core_modules/commands/__init__.py +++ b/src/core_modules/commands/__init__.py @@ -73,12 +73,12 @@ class Module(ModuleManager.BaseModule): self.bot.get_setting(COMMAND_METHOD, default))).upper() def _find_command_hook(self, server, target, is_channel, command, user, - args): + command_prefix, args): if not self.has_command(command): command_event = CommandEvent(command, args) self.events.on("get.command").call(command=command_event, server=server, target=target, is_channel=is_channel, user=user, - kwargs={}) + command_prefix=command_prefix, kwargs={}) command = command_event.command args = command_event.args @@ -305,7 +305,7 @@ class Module(ModuleManager.BaseModule): try: hook, command, args_split = self._find_command_hook( event["server"], event["channel"], True, command, - event["user"], args) + event["user"], command_prefix, args) except BadContextException: event["channel"].send_message( "%s: That command is not valid in a channel" % @@ -367,7 +367,7 @@ class Module(ModuleManager.BaseModule): try: hook, command, args_split = self._find_command_hook( event["server"], event["user"], False, command, - event["user"], args) + event["user"], "", args) except BadContextException: event["user"].send_message( "That command is not valid in a PM")