From f3af3ec2822171a6f268b03baa336015c1cf0ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= Date: Wed, 26 Aug 2009 17:51:55 +0200 Subject: [PATCH] Topic plugin: Restore topic automatically after join if not set. Signed-off-by: James Vega (cherry picked from commit 18ef6dadfcafeae54778f6876b57ecc0b4135153) Signed-off-by: Daniel Folkinshteyn --- plugins/Topic/plugin.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/Topic/plugin.py b/plugins/Topic/plugin.py index 3d9309ff0..b51614c96 100644 --- a/plugins/Topic/plugin.py +++ b/plugins/Topic/plugin.py @@ -232,6 +232,21 @@ class Topic(callbacks.Plugin): # We're joining a channel, let's watch for the topic. self.watchingFor332.add(msg.args[0]) + def do315(self, irc, msg): + # Try to restore the topic when not set yet. + channel = msg.args[1] + c = irc.state.channels[channel] + if irc.nick not in c.ops and 't' in c.modes: + self.log.debug('Not trying to restore topic in %s. I\'m not opped ' + 'and %s is +t.', channel, channel) + return + if c.topic == '': + try: + topics = self.lastTopics[channel] + self._sendTopics(irc, channel, topics) + except KeyError: + self.log.debug('No topic to auto-restore in %s.', channel) + def do332(self, irc, msg): if msg.args[1] in self.watchingFor332: self.watchingFor332.remove(msg.args[1])