Add a mechanism to ignore specific commands for a whole network

This commit is contained in:
jesopo 2019-05-06 17:08:56 +01:00
parent ac19e9cc95
commit 0114d35d4c
4 changed files with 19 additions and 4 deletions

View file

@ -79,11 +79,13 @@ class Module(ModuleManager.BaseModule):
return target.get_setting(COMMAND_METHOD,
server.get_setting(COMMAND_METHOD, "PRIVMSG")).upper()
def _is_ignored(self, user, command):
def _is_ignored(self, server, user, command):
if user.get_setting("ignore", False):
return True
elif user.get_setting("ignore-%s" % command, False):
return True
elif server.get_setting("ignore-%s" % command, False):
return True
return False
def message(self, event, command, args_index=1):
@ -364,6 +366,19 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write("Removed ignore for '%s'%s" %
(user.nickname, for_str))
@utils.hook("received.command.serverignore", in_args=1)
def server_ignore(self, event):
command = event["args_split"][0].lower()
setting = "ignore-%s" % command
if event["server"].get_setting(setting):
event["stderr"].write("I'm already ignoring '%s' for %s" %
(command, str(event["server"])))
else:
server.set_setting(setting, True)
event["stdout"].write("Now ignoring '%s' for %s" %
(command, str(event["server"])))
@utils.hook("send.stdout")
def send_stdout(self, event):
stdout = outs.StdOut(event["server"], event["module_name"],

View file

@ -31,7 +31,7 @@ class Module(ModuleManager.BaseModule):
if match and not event["action"]:
is_ignored_f = short_url = self.exports.get_one("is-ignored",
lambda _1, _2: False)
if is_ignored_f(event["user"], "karma"):
if is_ignored_f(event["server"], event["user"], "karma"):
return
verbose = event["channel"].get_setting("karma-verbose", False)

View file

@ -24,7 +24,7 @@ class Module(ModuleManager.BaseModule):
return
is_ignored_f = short_url = self.exports.get_one("is-ignored",
lambda _1, _2: False)
if is_ignored_f(event["user"], "sed"):
if is_ignored_f(event["server"], event["user"], "sed"):
return
regex_flags = 0

View file

@ -51,7 +51,7 @@ class Module(ModuleManager.BaseModule):
if match and event["channel"].get_setting("auto-title", False):
is_ignored_f = short_url = self.exports.get_one("is-ignored",
lambda _1, _2: False)
if is_ignored_f(event["user"], "title"):
if is_ignored_f(event["server"], event["user"], "title"):
return
url = match.group(0)