[ros-diffs] [cwittich] 24459: arty's IRC bot changes

cwittich at svn.reactos.org cwittich at svn.reactos.org
Sun Oct 8 23:41:07 CEST 2006


Author: cwittich
Date: Mon Oct  9 01:41:07 2006
New Revision: 24459

URL: http://svn.reactos.org/svn/reactos?rev=24459&view=rev
Log:
arty's IRC bot changes

Modified:
    trunk/tools/buildbot/buildbot/buildbot/status/words.py

Modified: trunk/tools/buildbot/buildbot/buildbot/status/words.py
URL: http://svn.reactos.org/svn/reactos/trunk/tools/buildbot/buildbot/buildbot/status/words.py?rev=24459&r1=24458&r2=24459&view=diff
==============================================================================
--- trunk/tools/buildbot/buildbot/buildbot/status/words.py (original)
+++ trunk/tools/buildbot/buildbot/buildbot/status/words.py Mon Oct  9 01:41:07 2006
@@ -2,7 +2,7 @@
 
 # code to deliver build status through twisted.words (instant messaging
 # protocols: irc, etc)
-
+import time
 import traceback, StringIO, re, shlex
 
 from twisted.internet import protocol, reactor
@@ -82,20 +82,44 @@
                        bot retrieves all status information
         """
         self.nickname = nickname
+	self.wantnick = nickname
         self.channels = channels
         self.password = password
         self.status = status
         self.categories = categories
         self.counter = 0
         self.hasQuit = 0
+	self.pingSelf = 1
+	self.hasReconnected = 0
+	self.timeout = 60
 
     def signedOn(self):
         if self.password:
+	    if self.nickname != self.wantnick:
+		    self.msg("Nickserv", "GHOST " + self.wantnick + " " + self.password)
+		    self.setNick(self.wantnick)
             self.msg("Nickserv", "IDENTIFY " + self.password)
         for c in self.channels:
             self.join(c)
+	reactor.callLater(self.timeout, self.checkPing)
+	self.lastping = time.time()
+    def checkPing(self):
+	if time.time() - self.lastping > (self.timeout * 2):
+		self.pingSelf = 1
+		log.msg("Dropping due to pingout")
+		self.shutdown()
+        if self.pingSelf:
+		self.ping(self.nickname)
+		self.monitor = reactor.callLater(self.timeout, self.checkPing)
+    def end(self):
+	self.pingSelf = 0
+    def shutdown(self):
+	self.sendLine("QUIT")
+	self.end()
     def joined(self, channel):
         log.msg("I have joined", channel)
+	if self.hasReconnected:
+		self.msg(channel, "Hello again")
     def left(self, channel):
         log.msg("I have left", channel)
     def kickedFrom(self, channel, kicker, message):
@@ -203,6 +227,19 @@
         for r in response:
             reactor.callLater(when, self.reply, reply, r)
             when += 2.5
+    def command_PING(self, user, reply, person):
+	self.reply(reply, "ping to " + person)
+	self.ping(person)
+    def pong(self, user, secs):
+	self.lastping = time.time()
+        log.msg("Pong from " + user + " took " + str(secs))
+#    def command_JOIN(self, user, reply, chan):
+#	self.reply(reply, "joining " + chan)
+#	self.join(chan)
+
+#    def command_PART(self, user, reply, chan):
+#	self.reply(reply, "parting " + chan)
+#	self.part(chan)
 
     def command_HELLO(self, user, reply, args):
         self.reply(reply, "yes?")
@@ -227,6 +264,9 @@
             self.reply(reply, str)
             return
     command_LIST.usage = "list builders - List configured builders"
+
+    def command_DEAD(self, user, reply, args):
+	self.pingSelf = 0
 
     def command_STATUS(self, user, reply, args):
         args = args.split()
@@ -464,6 +504,14 @@
     def command_EXCITED(self, user, reply, args):
         # like 'buildbot: destroy the sun!'
         self.reply(reply, "What you say!")
+
+#    def command_DISCON(self, user, reply, args):
+#	log.msg("Disconnecting on request: " + str(args))
+#	self.shutdown()
+
+    def connectionLost(self, reason = "foo"):
+	log.msg("Connection lost: " + str(reason))
+	self.shutdown()
 
     def action(self, user, channel, data):
         #log.msg("action: %s,%s,%s" % (user, channel, data))
@@ -511,6 +559,7 @@
         self.password = password
         self.channels = channels
         self.categories = categories
+	self.hasReconnected = False
 
     def __getstate__(self):
         d = self.__dict__.copy()
@@ -519,8 +568,12 @@
 
     def shutdown(self):
         self.shuttingDown = True
+	self.hasReconnected = True
         if self.p:
             self.p.quit("buildmaster reconfigured: bot disconnecting")
+	    self.p.end()
+	self.factory.shutdown()
+	del self.factory
 
     def buildProtocol(self, address):
         p = self.protocol(self.nickname, self.password,
@@ -529,6 +582,7 @@
         p.factory = self
         p.status = self.status
         p.control = self.control
+	p.hasReconnected = self.hasReconnected
         self.p = p
         return p
 




More information about the Ros-diffs mailing list