aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-01-30 11:20:14 +0000
committerGravatar jesopo2019-01-30 11:20:14 +0000
commit8a832b72306941c866a98ab2c6261dac8afd9f16 (patch)
tree89f75e82db2eef0b7550045eac71fe92798c4356 /modules
parentAdd a private `channelset` command (set.py) (diff)
signature
Check all hooks for a command and pick the first applicable one, to allow for
private_only and channel_only commands to share the same command string (commands.py)
Diffstat (limited to 'modules')
-rw-r--r--modules/commands.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/modules/commands.py b/modules/commands.py
index 8e3772eb..db65250f 100644
--- a/modules/commands.py
+++ b/modules/commands.py
@@ -140,24 +140,33 @@ class Module(ModuleManager.BaseModule):
if ignore:
return
- hook = self.get_hook(command)
- alias_of = self._get_alias_of(hook)
- if alias_of:
- if self.has_command(alias_of):
- hook = self.get_hook(alias_of)
+ hook = None
+ target = None
+ for potential_hook in self.get_hook(command):
+ hook = self.get_hook(command)
+ alias_of = self._get_alias_of(hook)
+ if alias_of:
+ if self.has_command(alias_of):
+ hook = self.get_hook(alias_of)
+ else:
+ raise ValueError(
+ "'%s' is an alias of unknown command '%s'"
+ % (command.lower(), alias_of.lower()))
+
+ is_channel = False
+ if not is_channel and hook.kwargs.get("channel_only"):
+ continue
+ if is_channel and hook.kwargs.get("private_only"):
+ continue
+
+ hook = potential_hook
+ if "channel" in event:
+ target = event["channel"]
+ is_channel = True
else:
- raise ValueError("'%s' is an alias of unknown command '%s'"
- % (command.lower(), alias_of.lower()))
+ target = event["user"]
- is_channel = False
- if "channel" in event:
- target = event["channel"]
- is_channel = True
- else:
- target = event["user"]
- if not is_channel and hook.kwargs.get("channel_only"):
- return
- if is_channel and hook.kwargs.get("private_only"):
+ if not hook:
return
module_name = self._get_prefix(hook) or ""