aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2018-09-06 17:25:38 +0100
committerGravatar jesopo2018-09-06 17:25:38 +0100
commit73bdaff9772ee52f96d45503548356db473102b2 (patch)
treebfba033c48ae5a5d17296248511bab589512fa23
parentAdd !ignore and !unignore in commands.py (diff)
signature
Add !topic and !topicappend in channel_op.py
-rw-r--r--IRCChannel.py2
-rw-r--r--modules/channel_op.py54
2 files changed, 33 insertions, 23 deletions
diff --git a/IRCChannel.py b/IRCChannel.py
index 11a5bf9e..0dfd6884 100644
--- a/IRCChannel.py
+++ b/IRCChannel.py
@@ -113,6 +113,8 @@ class Channel(object):
self.server.send_mode(self.name, "+b", hostmask)
def send_unban(self, hostmask):
self.server.send_mode(self.name, "-b", hostmask)
+ def send_topic(self, topic):
+ self.server.send_topic(self.name, topic)
def mode_or_above(self, user, mode):
mode_orders = list(self.server.mode_prefixes.values())
diff --git a/modules/channel_op.py b/modules/channel_op.py
index 7f80d5b3..1cdc4e15 100644
--- a/modules/channel_op.py
+++ b/modules/channel_op.py
@@ -4,41 +4,44 @@ class Module(object):
_name = "Channel Op"
def __init__(self, bot, events, exports):
self.bot = bot
- events.on("received").on("command").on("kick", "k"
- ).hook(self.kick, channel_only=True, require_mode="o",
- min_args=1, help="Kick a user from the channel",
- usage="<nickname> [reason]")
- events.on("received").on("command").on("ban"
- ).hook(self.ban, channel_only=True, require_mode="o",
- min_args=1, help="Ban a user/hostmask from the channel",
- usage="<nickname/hostmask>")
- events.on("received").on("command").on("unban"
- ).hook(self.unban, channel_only=True, require_mode="o",
- min_args=1, help="Unban a user/hostmask from the channel",
- usage="<nickname/hostmask>")
+ events.on("received.command").on("kick", "k").hook(self.kick,
+ channel_only=True, require_mode="o", usage="<nickname> [reason]",
+ min_args=1, help="Kick a user from the channel")
+ events.on("received.command.ban").hook(self.ban, channel_only=True,
+ require_mode="o", min_args=1, usage="<nickname/hostmask>",
+ help="Ban a user/hostmask from the channel")
+ events.on("received.command.unban").hook(self.unban,
+ channel_only=True, require_mode="o", usage="<nickname/hostmask>",
+ min_args=1, help="Unban a user/hostmask from the channel")
- events.on("received").on("command").on("kickban", "kb"
+ events.on("received.command").on("kickban", "kb"
).hook(self.kickban, channel_only=True, require_mode="o",
min_args=1, help="Kickban a user from the channel",
usage="<nickanme> [reason]")
- events.on("received").on("command").on("op"
+ events.on("received.command.op"
).hook(self.op, channel_only=True, require_mode="o",
help="Give +o to a user", usage="[nickname]")
- events.on("received").on("command").on("deop"
+ events.on("received.command.deop"
).hook(self.deop, channel_only=True, require_mode="o",
help="Take +o from a user", usage="[nickname]")
- events.on("received").on("command").on("voice"
- ).hook(self.voice, channel_only=True, require_mode="o",
- help="Give +v to a user", usage="[nickname]")
- events.on("received").on("command").on("devoice"
- ).hook(self.devoice, channel_only=True, require_mode="o",
- help="Take +v from a user", usage="[nickname]")
+ events.on("received.command.voice").hook(self.voice,
+ channel_only=True, require_mode="o", usage="[nickname]",
+ help="Give +v to a user")
+ events.on("received.command.devoice").hook(self.devoice,
+ channel_only=True, require_mode="o", usage="[nickname]",
+ help="Take +v from a user")
- events.on("received").on("message").on("channel").hook(
- self.highlight_spam)
+ events.on("received.command.topic").hook(self.topic, min_args=1,
+ require_mode="o", channel_only=True, usage="<topic>",
+ help="Set the topic of the current channel")
+ events.on("received.command").on("topicappend", "tappend").hook(
+ self.tappend, min_args=1, require_mode="o", channel_only=True,
+ usage="<topic>", help="Set the topic of the current channel")
+
+ events.on("received.message.channel").hook(self.highlight_spam)
exports.add("channelset", {"setting": "highlight-spam-threshold",
"help": "Set the number of nicknames in a message that "
@@ -118,6 +121,11 @@ class Module(object):
"args_split"][0]
event["target"].send_mode("-v", target)
+ def topic(self, event):
+ event["target"].send_topic(event["args"])
+ def tappend(self, event):
+ event["target"].send_topic(event["target"].topic + event["args"])
+
def highlight_spam(self, event):
if event["channel"].get_setting("highlight-spam-protection", False):
nicknames = list(map(lambda user: user.nickname,