Report actual topic setter (use 333, not 332)

This commit is contained in:
jesopo 2018-08-29 15:17:06 +01:00
parent 3ec521538a
commit 669aa32c31
2 changed files with 14 additions and 10 deletions

View file

@ -17,8 +17,7 @@ class LineHandler(object):
bot.events.on("raw").on("311").hook(self.handle_311,
default_event=True)
bot.events.on("raw").on("332").hook(self.handle_332)
bot.events.on("raw").on("333").hook(self.handle_333,
default_event=True)
bot.events.on("raw").on("333").hook(self.handle_333)
bot.events.on("raw").on("353").hook(self.handle_353,
default_event=True)
bot.events.on("raw").on("366").hook(self.handle_366,
@ -137,7 +136,7 @@ class LineHandler(object):
channel.set_topic(event["arbitrary"])
self.bot.events.on("received").on("numeric").on("332"
).call(channel=channel, server=event["server"],
topic=event["arbitrary"], setter=event["args"][0])
topic=event["arbitrary"])
# channel topic changed
def topic(self, event):
@ -162,6 +161,9 @@ class LineHandler(object):
channel.set_topic_setter(nickname, username, hostname)
channel.set_topic_time(topic_time)
self.bot.events.on("received").on("numeric").on("333"
).call(channel=channel, setter=nickname, set_at=topic_time,
server=event["server"])
# on-join user list with status symbols
def handle_353(self, event):

View file

@ -32,7 +32,7 @@ class Module(object):
bot.events.on("self").on("kick").hook(self.self_kick)
bot.events.on("received").on("topic").hook(self.on_topic)
bot.events.on("received").on("numeric").on("332").hook(self.on_332)
bot.events.on("received").on("numeric").on("333").hook(self.on_333)
def print_line(self, event, line, channel=None):
timestamp = datetime.datetime.now().isoformat()
@ -105,10 +105,12 @@ class Module(object):
def self_kick(self, event):
self._on_kick(event, event["server"].nickname)
def _on_topic(self, setter, event):
self.print_line(event, "topic set by %s: %s" % (setter,
event["topic"]), channel=event["channel"].name)
def _on_topic(self, event, setter, action, topic, channel):
self.print_line(event, "topic %s by %s: %s" % (action, setter,
topic), channel=channel.name)
def on_topic(self, event):
self._on_topic(event["user"].nickname, event)
def on_332(self, event):
self._on_topic(event["setter"], event)
self._on_topic(event, event["user"].nickname, "changed",
event["topic"], event["channel"])
def on_333(self, event):
self._on_topic(event, event["setter"], "set",
event["channel"].topic, event["channel"])