diff options
| author | 2018-10-03 13:22:37 +0100 | |
|---|---|---|
| committer | 2018-10-03 13:22:37 +0100 | |
| commit | 69d58eede2e9bf83aa1ed1d8fcf956efde494726 (patch) | |
| tree | 11aa30f2a357f3be23ad97315dae3df051455cbe /modules/channel_op.py | |
| parent | Add a way to not add a user automatically in IRCServer.get_user (diff) | |
Move src/Utils.py in to src/utils/, splitting functionality out in to modules of
related functionality
Diffstat (limited to 'modules/channel_op.py')
| -rw-r--r-- | modules/channel_op.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/modules/channel_op.py b/modules/channel_op.py index 93c8101a..b2c1e3af 100644 --- a/modules/channel_op.py +++ b/modules/channel_op.py @@ -1,25 +1,25 @@ -from src import ModuleManager, Utils +from src import ModuleManager, utils class UserNotFoundException(Exception): pass class InvalidTimeoutException(Exception): pass -@Utils.export("channelset", {"setting": "highlight-spam-threshold", +@utils.export("channelset", {"setting": "highlight-spam-threshold", "help": "Set the number of nicknames in a message that qualifies as spam", - "validate": Utils.int_or_none}) -@Utils.export("channelset", {"setting": "highlight-spam-protection", + "validate": utils.int_or_none}) +@utils.export("channelset", {"setting": "highlight-spam-protection", "help": "Enable/Disable highlight spam protection", - "validate": Utils.bool_or_none}) -@Utils.export("channelset", {"setting": "highlight-spam-ban", + "validate": utils.bool_or_none}) +@utils.export("channelset", {"setting": "highlight-spam-ban", "help": "Enable/Disable banning highlight spammers " - "instead of just kicking", "validate": Utils.bool_or_none}) -@Utils.export("channelset", {"setting": "ban-format", + "instead of just kicking", "validate": utils.bool_or_none}) +@utils.export("channelset", {"setting": "ban-format", "help": "Set ban format ($n = nick, $u = username, $h = hostname)"}) class Module(ModuleManager.BaseModule): _name = "Channel Op" - @Utils.hook("timer.unban") + @utils.hook("timer.unban") def _timer_unban(self, event): server = self.bot.get_server(event["server_id"]) if server.has_channel(event["channel_name"]): @@ -33,7 +33,7 @@ class Module(ModuleManager.BaseModule): else: raise UserNotFoundException("That user is not in this channel") - @Utils.hook("received.command.kick|k", channel_only=True, min_args=1) + @utils.hook("received.command.kick|k", channel_only=True, min_args=1) def kick(self, event): """ :help: Kick a user from the current channel @@ -77,7 +77,7 @@ class Module(ModuleManager.BaseModule): event["target"].send_unban(target) return target - @Utils.hook("received.command.ban", channel_only=True, min_args=1) + @utils.hook("received.command.ban", channel_only=True, min_args=1) def ban(self, event): """ :help: Ban a user/hostmask from the current channel @@ -88,7 +88,7 @@ class Module(ModuleManager.BaseModule): event["args_split"][0]) def _temp_ban(self, event, accept_hostmask): - timeout = Utils.from_pretty_time(event["args_split"][1]) + timeout = utils.from_pretty_time(event["args_split"][1]) if not timeout: raise InvalidTimeoutException( "Please provided a valid time above 0 seconds") @@ -103,7 +103,7 @@ class Module(ModuleManager.BaseModule): self.bot.timers.add_persistent("unban", timeout, server_id=event["server"].id, channel_name=event["target"].name, hostmask=hostmask) - @Utils.hook("received.command.tempban|tb", channel_only=True, min_args=2) + @utils.hook("received.command.tempban|tb", channel_only=True, min_args=2) def temp_ban(self, event): """ :help: Temporarily ban someone from the current channel @@ -115,7 +115,7 @@ class Module(ModuleManager.BaseModule): except InvalidTimeoutException as e: event["stderr"].set_prefix("Tempban") event["stderr"].write(str(e)) - @Utils.hook("received.command.tempkickban|tkb", channel_only=True, + @utils.hook("received.command.tempkickban|tkb", channel_only=True, min_args=2) def temp_kick_ban(self, event): """ @@ -134,7 +134,7 @@ class Module(ModuleManager.BaseModule): except UserNotFoundException as e: event["stderr"].write(str(e)) - @Utils.hook("received.command.unban", channel_only=True, min_args=1) + @utils.hook("received.command.unban", channel_only=True, min_args=1) def unban(self, event): """ :help: Unban a user/hostmask from the current channel @@ -144,7 +144,7 @@ class Module(ModuleManager.BaseModule): self._ban(event["server"], event["target"], False, event["args_split"][0]) - @Utils.hook("received.command.kickban|kb", channel_only=True, min_args=1) + @utils.hook("received.command.kickban|kb", channel_only=True, min_args=1) def kickban(self, event): """ :help: Kick and ban a user from the current channel @@ -160,7 +160,7 @@ class Module(ModuleManager.BaseModule): event["stderr"].set_prefix("Kickban") event["stderr"].write(str(e)) - @Utils.hook("received.command.op", channel_only=True) + @utils.hook("received.command.op", channel_only=True) def op(self, event): """ :help: Op a user in the current channel @@ -170,7 +170,7 @@ class Module(ModuleManager.BaseModule): target = event["user"].nickname if not event["args_split"] else event[ "args_split"][0] event["target"].send_mode("+o", target) - @Utils.hook("received.command.deop", channel_only=True) + @utils.hook("received.command.deop", channel_only=True) def deop(self, event): """ :help: Remove op from a user in the current channel @@ -181,7 +181,7 @@ class Module(ModuleManager.BaseModule): "args_split"][0] event["target"].send_mode("-o", target) - @Utils.hook("received.command.voice", channel_only=True) + @utils.hook("received.command.voice", channel_only=True) def voice(self, event): """ :help: Voice a user in the current channel @@ -191,7 +191,7 @@ class Module(ModuleManager.BaseModule): target = event["user"].nickname if not event["args_split"] else event[ "args_split"][0] event["target"].send_mode("+v", target) - @Utils.hook("received.command.devoice", channel_only=True) + @utils.hook("received.command.devoice", channel_only=True) def devoice(self, event): """ :help: Remove voice from a user in the current channel @@ -202,7 +202,7 @@ class Module(ModuleManager.BaseModule): "args_split"][0] event["target"].send_mode("-v", target) - @Utils.hook("received.command.topic", min_args=1, channel_only=True) + @utils.hook("received.command.topic", min_args=1, channel_only=True) def topic(self, event): """ :help: Set the topic in the current channel @@ -210,7 +210,7 @@ class Module(ModuleManager.BaseModule): :require_mode: o """ event["target"].send_topic(event["args"]) - @Utils.hook("received.command.tappend", min_args=1, channel_only=True) + @utils.hook("received.command.tappend", min_args=1, channel_only=True) def tappend(self, event): """ :help: Append to the topic in the current channel @@ -219,7 +219,7 @@ class Module(ModuleManager.BaseModule): """ event["target"].send_topic(event["target"].topic + event["args"]) - @Utils.hook("received.message.channel") + @utils.hook("received.message.channel") def highlight_spam(self, event): if event["channel"].get_setting("highlight-spam-protection", False): nicknames = list(map(lambda user: user.nickname, @@ -238,7 +238,7 @@ class Module(ModuleManager.BaseModule): event["channel"].send_kick(event["user"].nickname, "highlight spam detected") - @Utils.hook("received.command.leave", channel_only=True) + @utils.hook("received.command.leave", channel_only=True) def leave(self, event): """ :help: Part me from the current channel |
