From 8f178acd5e94d5d5df9b4ce980c856f3a2198829 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 12 Jul 2014 13:19:53 +0200 Subject: [PATCH] [TASK] Disable privmsg reaction, add reconnect support. --- monitor/bot.py | 11 +++++++++++ twisted/plugins/monitorbot_plugin.py | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/monitor/bot.py b/monitor/bot.py index 068f2de..6f02a03 100644 --- a/monitor/bot.py +++ b/monitor/bot.py @@ -33,6 +33,8 @@ class MonitorBot(irc.IRCClient): def privmsg(self, user, channel, msg): """Called when the bot receives a message.""" + pass + """ sendTo = None prefix = '' senderNick = user.split('!', 1)[0] @@ -55,6 +57,7 @@ class MonitorBot(irc.IRCClient): "sent message to {receiver}, triggered by {sender}:\n\t{reply}" .format(receiver=sendTo, sender=senderNick, reply=reply) ) + """ class MonitorBotFactory(protocol.ClientFactory): protocol = MonitorBot @@ -64,3 +67,11 @@ class MonitorBotFactory(protocol.ClientFactory): self.channel = channel self.nickname = nickname self.realname = realname + + def clientConnectionLost(self, connector, reason): + """If we get disconnected, reconnect to server.""" + connector.connect() + + def clientConnectionFailed(self, connector, reason): + print "connection failed:", reason + reactor.stop() diff --git a/twisted/plugins/monitorbot_plugin.py b/twisted/plugins/monitorbot_plugin.py index fd68f2b..5f37b97 100644 --- a/twisted/plugins/monitorbot_plugin.py +++ b/twisted/plugins/monitorbot_plugin.py @@ -67,7 +67,6 @@ class MonitorBotService(Service): msg = "ftp> /%s (%s)" % (new_path, ', '.join(humanReadableMask(mask))) if msg not in self._messages: self._messages.append(msg) - self._callid = reactor.callLater(5.0, sendQueuedMessages) def sendQueuedMessages():