aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-08-14 14:51:16 +0100
committerGravatar jesopo2019-08-14 14:51:16 +0100
commit9bc1b67831143441d7ae053b409bb15d5d7a9bdf (patch)
tree271e0f5d5e8f8dea3ecd7464cc15cdc63e272c5e
parentremove debug print (diff)
signature
add configurable default kick message per bot/server/channel
-rw-r--r--modules/channel_op.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/channel_op.py b/modules/channel_op.py
index 589e71f5..c3f20ba2 100644
--- a/modules/channel_op.py
+++ b/modules/channel_op.py
@@ -7,12 +7,18 @@ from src import ModuleManager, utils
KICK_REASON = "your behavior is not conducive to the desired environment"
+KICK_REASON_SETTING = utils.Setting("default-kick-reason",
+ "Set the default kick reason", example="have a nice trip")
+
@utils.export("channelset", utils.Setting("ban-format",
"Set ban format ($n = nick, $u = username, $h = hostname)",
example="*!$u@$h"))
@utils.export("serverset", utils.OptionsSetting("mute-method",
["qmode", "insp", "unreal", "none"],
"Set this server's method of muting users"))
+@utils.export("botset", KICK_REASON_SETTING)
+@utils.export("serverset", KICK_REASON_SETTING)
+@utils.export("channelset", KICK_REASON_SETTING)
class Module(ModuleManager.BaseModule):
def _parse_time(self, args, min_args):
if args[0][0] == "+":
@@ -24,10 +30,15 @@ class Module(ModuleManager.BaseModule):
return time, args[1:]
return None, args
+ def _kick_reason(self, server, channel):
+ return channel.get_setting("default-kick-reason",
+ server.get_setting("default-kick-reason",
+ self.bot.get_setting("default-kick-reson", KICK_REASON)))
+
def _kick(self, server, channel, target_nickname, reason):
target_user = server.get_user(target_nickname, create=False)
if target_user and channel.has_user(target_user):
- reason = " ".join(reason) or KICK_REASON
+ reason = " ".join(reason) or self._kick_reason(server, channel)
channel.send_kick(target_user.nickname, reason)
else:
raise utils.EventError("No such user")