[TASK] Disable privmsg reaction, add reconnect support.
This commit is contained in:
parent
3f82e07b45
commit
8f178acd5e
|
@ -33,6 +33,8 @@ class MonitorBot(irc.IRCClient):
|
||||||
|
|
||||||
def privmsg(self, user, channel, msg):
|
def privmsg(self, user, channel, msg):
|
||||||
"""Called when the bot receives a message."""
|
"""Called when the bot receives a message."""
|
||||||
|
pass
|
||||||
|
"""
|
||||||
sendTo = None
|
sendTo = None
|
||||||
prefix = ''
|
prefix = ''
|
||||||
senderNick = user.split('!', 1)[0]
|
senderNick = user.split('!', 1)[0]
|
||||||
|
@ -55,6 +57,7 @@ class MonitorBot(irc.IRCClient):
|
||||||
"sent message to {receiver}, triggered by {sender}:\n\t{reply}"
|
"sent message to {receiver}, triggered by {sender}:\n\t{reply}"
|
||||||
.format(receiver=sendTo, sender=senderNick, reply=reply)
|
.format(receiver=sendTo, sender=senderNick, reply=reply)
|
||||||
)
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
class MonitorBotFactory(protocol.ClientFactory):
|
class MonitorBotFactory(protocol.ClientFactory):
|
||||||
protocol = MonitorBot
|
protocol = MonitorBot
|
||||||
|
@ -64,3 +67,11 @@ class MonitorBotFactory(protocol.ClientFactory):
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.nickname = nickname
|
self.nickname = nickname
|
||||||
self.realname = realname
|
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()
|
||||||
|
|
|
@ -67,7 +67,6 @@ class MonitorBotService(Service):
|
||||||
msg = "ftp> /%s (%s)" % (new_path, ', '.join(humanReadableMask(mask)))
|
msg = "ftp> /%s (%s)" % (new_path, ', '.join(humanReadableMask(mask)))
|
||||||
if msg not in self._messages:
|
if msg not in self._messages:
|
||||||
self._messages.append(msg)
|
self._messages.append(msg)
|
||||||
|
|
||||||
self._callid = reactor.callLater(5.0, sendQueuedMessages)
|
self._callid = reactor.callLater(5.0, sendQueuedMessages)
|
||||||
|
|
||||||
def sendQueuedMessages():
|
def sendQueuedMessages():
|
||||||
|
|
Loading…
Reference in New Issue