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.hook("get.command")
@utils.kwarg("priority", EventManager.PRIORITY_HIGH) @utils.kwarg("priority", EventManager.PRIORITY_HIGH)
def get_command(self, event): def get_command(self, event):
event["kwargs"]["CTRIGGER"] = event["command_prefix"]
event["kwargs"]["BNICK"] = event["server"].nickname
event["kwargs"]["NICK"] = event["user"].nickname event["kwargs"]["NICK"] = event["user"].nickname
if event["is_channel"]: if event["is_channel"]:
event["kwargs"]["CHAN"] = event["target"].name event["kwargs"]["CHAN"] = event["target"].name
random_user = random.choice(list(event["target"].users)) 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() self.bot.get_setting(COMMAND_METHOD, default))).upper()
def _find_command_hook(self, server, target, is_channel, command, user, def _find_command_hook(self, server, target, is_channel, command, user,
args): command_prefix, args):
if not self.has_command(command): if not self.has_command(command):
command_event = CommandEvent(command, args) command_event = CommandEvent(command, args)
self.events.on("get.command").call(command=command_event, self.events.on("get.command").call(command=command_event,
server=server, target=target, is_channel=is_channel, user=user, server=server, target=target, is_channel=is_channel, user=user,
kwargs={}) command_prefix=command_prefix, kwargs={})
command = command_event.command command = command_event.command
args = command_event.args args = command_event.args
@ -305,7 +305,7 @@ class Module(ModuleManager.BaseModule):
try: try:
hook, command, args_split = self._find_command_hook( hook, command, args_split = self._find_command_hook(
event["server"], event["channel"], True, command, event["server"], event["channel"], True, command,
event["user"], args) event["user"], command_prefix, args)
except BadContextException: except BadContextException:
event["channel"].send_message( event["channel"].send_message(
"%s: That command is not valid in a channel" % "%s: That command is not valid in a channel" %
@ -367,7 +367,7 @@ class Module(ModuleManager.BaseModule):
try: try:
hook, command, args_split = self._find_command_hook( hook, command, args_split = self._find_command_hook(
event["server"], event["user"], False, command, event["server"], event["user"], False, command,
event["user"], args) event["user"], "", args)
except BadContextException: except BadContextException:
event["user"].send_message( event["user"].send_message(
"That command is not valid in a PM") "That command is not valid in a PM")