add ${BNICK} (bot's own nick) and ${CTRIGGER} (command trigger) to aliases

This commit is contained in:
jesopo 2020-04-07 19:30:32 +01:00
parent 8a3f10e360
commit 2b0dfcc155
2 changed files with 8 additions and 4 deletions

View file

@ -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))

View file

@ -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")