diff options
| author | 2017-12-26 11:50:18 +0000 | |
|---|---|---|
| committer | 2017-12-26 11:50:18 +0000 | |
| commit | 14ffa6716df69ccccb60c97710b6a31d07a07df4 (patch) | |
| tree | 0df1e2218e98b5b70a33f38bc4318736ec94aaa3 /modules | |
| parent | Added a "replay" system to EventManager hooks, to replay missed .calls (diff) | |
| signature | ||
Added highlight spam detection/prevention logic to channel_op
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/channel_op.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/modules/channel_op.py b/modules/channel_op.py index 68391052..d24314d5 100644 --- a/modules/channel_op.py +++ b/modules/channel_op.py @@ -1,4 +1,4 @@ - +import Utils class Module(object): _name = "Channel Op" @@ -21,6 +21,16 @@ class Module(object): ).hook(self.voice, channel_only=True, require_mode="o") bot.events.on("received").on("command").on("devoice" ).hook(self.devoice, channel_only=True, require_mode="o") + bot.events.on("received").on("message").on("channel").hook(self.highlight_spam) + + bot.events.on("postboot").on("configure").on( + "channelset").call(setting="highlight-spam-threshold", + help="Set the number of nicknames in a message that qualifies as spam", + validate=Utils.int_or_none) + bot.events.on("postboot").on("configure").on( + "channelset").call(setting="highlight-spam-protection", + help="Enable/Disable highligh spam protection", + validate=Utils.bool_or_none) def kick(self, event): target = event["args_split"][0] @@ -69,3 +79,13 @@ class Module(object): target = event["user"].nickname if not event["args_split"] else event[ "args_split"][0] event["target"].send_mode("-v", target) + + def highlight_spam(self, event): + nicknames = list(map(lambda user: user.nickname, event["channel"].users) + ) + [event["server"].nickname] + if len(set(nicknames) & set(event["message_split"])) >= event["channel"].get_setting( + "highlight-spam-threshold", 10): + if event["channel"].get_setting("highlight-spam-protection", False): + if not event["channel"].mode_or_above(event["user"].nickname, "v"): + event["channel"].send_kick(event["user"].nickname, + "highlight spam detected") |
