pass user on get.command events, so e.g. aliases know user nicknames

This commit is contained in:
jesopo 2019-12-17 14:29:37 +00:00
parent f489ad5dc0
commit 00a8129634

View file

@ -73,11 +73,12 @@ class Module(ModuleManager.BaseModule):
server.get_setting(COMMAND_METHOD, server.get_setting(COMMAND_METHOD,
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, args): def _find_command_hook(self, server, target, is_channel, command, user,
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) server=server, target=target, is_channel=is_channel, user=user)
command = command_event.command command = command_event.command
args = command_event.args args = command_event.args
@ -303,7 +304,8 @@ class Module(ModuleManager.BaseModule):
if command: if command:
try: try:
hook, command, args_split = self._find_command_hook( hook, command, args_split = self._find_command_hook(
event["server"], event["channel"], True, command, args) event["server"], event["channel"], True, command,
event["user"], 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" %
@ -361,7 +363,8 @@ 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, args) event["server"], event["user"], False, command,
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")