don't use full event names to check what command we're in

This commit is contained in:
jesopo 2019-09-10 12:59:52 +01:00
parent bad108d7ce
commit 7fbb5b2823
3 changed files with 5 additions and 5 deletions

View file

@ -125,7 +125,7 @@ class Module(ModuleManager.BaseModule):
@utils.kwarg("require_access", "op") @utils.kwarg("require_access", "op")
@utils.kwarg("usage", "[nickname]") @utils.kwarg("usage", "[nickname]")
def op(self, event): def op(self, event):
add = event.name == "received.command.op" add = event["command"] == "op"
target = event["args_split"][0] if event["args"] else event[ target = event["args_split"][0] if event["args"] else event[
"user"].nickname "user"].nickname
event["target"].send_mode("+o" if add else "-o", target) event["target"].send_mode("+o" if add else "-o", target)
@ -137,7 +137,7 @@ class Module(ModuleManager.BaseModule):
@utils.kwarg("require_access", "voice") @utils.kwarg("require_access", "voice")
@utils.kwarg("usage", "[nickname]") @utils.kwarg("usage", "[nickname]")
def voice(self, event): def voice(self, event):
add = event.name == "received.command.voice" add = event["command"] == "voice"
target = event["args_split"][0] if event["args"] else event[ target = event["args_split"][0] if event["args"] else event[
"user"].nickname "user"].nickname
event["target"].send_mode("+v" if add else "-v", target) event["target"].send_mode("+v" if add else "-v", target)
@ -184,7 +184,7 @@ class Module(ModuleManager.BaseModule):
@utils.kwarg("require_access", "mute") @utils.kwarg("require_access", "mute")
@utils.kwarg("help", "Mute a given user") @utils.kwarg("help", "Mute a given user")
def _mute(self, event): def _mute(self, event):
add = event.name == "received.command.mute" add = event["command"] == "mute"
time, args = self._parse_time(event["args_split"], 1) time, args = self._parse_time(event["args_split"], 1)
target_name = args[0] target_name = args[0]

View file

@ -99,7 +99,7 @@ class Module(ModuleManager.BaseModule):
@utils.kwarg("require-mode", "o") @utils.kwarg("require-mode", "o")
@utils.kwarg("require-access", "cignore") @utils.kwarg("require-access", "cignore")
def cignore(self, event): def cignore(self, event):
remove = event.name == "received.command.cunignore" remove = event["command"] == "cunignore"
target_user = event["server"].get_user(event["args_split"][0]) target_user = event["server"].get_user(event["args_split"][0])
is_ignored = event["target"].get_user_setting(target_user.get_id(), is_ignored = event["target"].get_user_setting(target_user.get_id(),

View file

@ -96,7 +96,7 @@ class Module(ModuleManager.BaseModule):
@utils.kwarg("min_args", 1) @utils.kwarg("min_args", 1)
@utils.kwarg("usage", "<target>") @utils.kwarg("usage", "<target>")
def changepoint(self, event): def changepoint(self, event):
positive = event.name == "received.command.addpoint" positive = event["command"] == "addpoint"
success, message = self._karma(event["server"], event["user"], success, message = self._karma(event["server"], event["user"],
event["args"].strip(), positive) event["args"].strip(), positive)
event["stdout" if success else "stderr"].write(message) event["stdout" if success else "stderr"].write(message)