Add a mechanism to ignore specific commands for a whole network
This commit is contained in:
parent
ac19e9cc95
commit
0114d35d4c
4 changed files with 19 additions and 4 deletions
|
@ -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"],
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue