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,
|
return target.get_setting(COMMAND_METHOD,
|
||||||
server.get_setting(COMMAND_METHOD, "PRIVMSG")).upper()
|
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):
|
if user.get_setting("ignore", False):
|
||||||
return True
|
return True
|
||||||
elif user.get_setting("ignore-%s" % command, False):
|
elif user.get_setting("ignore-%s" % command, False):
|
||||||
return True
|
return True
|
||||||
|
elif server.get_setting("ignore-%s" % command, False):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def message(self, event, command, args_index=1):
|
def message(self, event, command, args_index=1):
|
||||||
|
@ -364,6 +366,19 @@ class Module(ModuleManager.BaseModule):
|
||||||
event["stdout"].write("Removed ignore for '%s'%s" %
|
event["stdout"].write("Removed ignore for '%s'%s" %
|
||||||
(user.nickname, for_str))
|
(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")
|
@utils.hook("send.stdout")
|
||||||
def send_stdout(self, event):
|
def send_stdout(self, event):
|
||||||
stdout = outs.StdOut(event["server"], event["module_name"],
|
stdout = outs.StdOut(event["server"], event["module_name"],
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if match and not event["action"]:
|
if match and not event["action"]:
|
||||||
is_ignored_f = short_url = self.exports.get_one("is-ignored",
|
is_ignored_f = short_url = self.exports.get_one("is-ignored",
|
||||||
lambda _1, _2: False)
|
lambda _1, _2: False)
|
||||||
if is_ignored_f(event["user"], "karma"):
|
if is_ignored_f(event["server"], event["user"], "karma"):
|
||||||
return
|
return
|
||||||
|
|
||||||
verbose = event["channel"].get_setting("karma-verbose", False)
|
verbose = event["channel"].get_setting("karma-verbose", False)
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
return
|
return
|
||||||
is_ignored_f = short_url = self.exports.get_one("is-ignored",
|
is_ignored_f = short_url = self.exports.get_one("is-ignored",
|
||||||
lambda _1, _2: False)
|
lambda _1, _2: False)
|
||||||
if is_ignored_f(event["user"], "sed"):
|
if is_ignored_f(event["server"], event["user"], "sed"):
|
||||||
return
|
return
|
||||||
|
|
||||||
regex_flags = 0
|
regex_flags = 0
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if match and event["channel"].get_setting("auto-title", False):
|
if match and event["channel"].get_setting("auto-title", False):
|
||||||
is_ignored_f = short_url = self.exports.get_one("is-ignored",
|
is_ignored_f = short_url = self.exports.get_one("is-ignored",
|
||||||
lambda _1, _2: False)
|
lambda _1, _2: False)
|
||||||
if is_ignored_f(event["user"], "title"):
|
if is_ignored_f(event["server"], event["user"], "title"):
|
||||||
return
|
return
|
||||||
|
|
||||||
url = match.group(0)
|
url = match.group(0)
|
||||||
|
|
Loading…
Reference in a new issue