support server-wide message filters too
This commit is contained in:
parent
68e25a61bf
commit
8153047f7c
1 changed files with 8 additions and 3 deletions
|
@ -63,17 +63,22 @@ class Module(ModuleManager.BaseModule):
|
||||||
if not message == message_plain:
|
if not message == message_plain:
|
||||||
event["line"].args[1] = message
|
event["line"].args[1] = message
|
||||||
|
|
||||||
@utils.hook("received.command.cfilter", min_args=1)
|
@utils.hook("received.command.cfilter", channel_only=True)
|
||||||
|
@utils.hook("received.command.filter")
|
||||||
@utils.kwarg("help", "Add a message filter for the current channel")
|
@utils.kwarg("help", "Add a message filter for the current channel")
|
||||||
@utils.kwarg("permissions", "cfilter")
|
@utils.kwarg("permissions", "cfilter")
|
||||||
@utils.spec("!'list ?<index>int")
|
@utils.spec("!'list ?<index>int")
|
||||||
@utils.spec("!'add ?<m/pattern/>string|<s/pattern/replace/>string")
|
@utils.spec("!'add ?<m/pattern/>string|<s/pattern/replace/>string")
|
||||||
@utils.spec("!'remove !<index>int")
|
@utils.spec("!'remove !<index>int")
|
||||||
def cfilter(self, event):
|
def filter(self, event):
|
||||||
# mark output as "assured" so it can bypass filtering
|
# mark output as "assured" so it can bypass filtering
|
||||||
event["stdout"].assure()
|
event["stdout"].assure()
|
||||||
event["stderr"].assure()
|
event["stderr"].assure()
|
||||||
|
|
||||||
|
if event["command"] == "cfilter":
|
||||||
target = event["target"]
|
target = event["target"]
|
||||||
|
else:
|
||||||
|
target = event["server"]
|
||||||
filters = target.get_setting("message-filters", [])
|
filters = target.get_setting("message-filters", [])
|
||||||
|
|
||||||
if event["spec"][0] == "list":
|
if event["spec"][0] == "list":
|
||||||
|
|
Loading…
Reference in a new issue