]> jfr.im git - erebus.git/blobdiff - bot.py
include last and current question id in badq report
[erebus.git] / bot.py
diff --git a/bot.py b/bot.py
index d7502ba448e746295b5e3a9e303cd51843463e28..fa4eaf1b6eb123a77a0b6c780db3dde2164a202f 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -3,7 +3,7 @@
 # Erebus IRC bot - Author: John Runyon
 # "Bot" and "BotConnection" classes (handling a specific "arm")
 
-import socket, sys
+import socket, sys, time
 
 #bots = {'erebus': bot.Bot(nick='Erebus', user='erebus', bind='', server='irc.quakenet.org', port=6667, realname='Erebus')}
 class Bot(object):
@@ -80,7 +80,7 @@ class Bot(object):
                elif pieces[1] == "PART":
                        nick = pieces[0].split('!')[0][1:]
                        chan = self.parent.channel(pieces[2])
-                       
+
                        if nick != self.nick:
                                self.parent.user(nick).part(chan)
                                chan.userpart(self.parent.user(nick))
@@ -94,14 +94,15 @@ class Bot(object):
                elif pieces[1] == "NICK":
                        oldnick = pieces[0].split('!')[0][1:]
                        newnick = pieces[2][1:]
-                       self.parent.users[newnick.lower()] = self.parent.users[oldnick.lower()]
-                       del self.parent.users[oldnick.lower()]
-                       self.parent.user(newnick).nick(newnick)
+                       if newnick.lower() != oldnick.lower():
+                               self.parent.users[newnick.lower()] = self.parent.users[oldnick.lower()]
+                               del self.parent.users[oldnick.lower()]
+                       self.parent.users[newnick.lower()].nickchange(newnick)
 
                elif pieces[1] == "MODE": #TODO parse for ops/voices (at least)
                        pass
 
-       
+
        def parsemsg(self, user, target, msg):
                chan = None
                if len(msg) == 0:
@@ -204,7 +205,8 @@ class BotConnection(object):
 
        #TODO: rewrite send() to queue
        def send(self, line):
-               print self.parent.nick, '[O]', str(line)
+               print "%05.3f %s [O] %s" % (time.time() % 100000, self.parent.nick, line)
+#              print (time.time() % 1466400000), self.parent.nick, '[O]', str(line)
                self._write(line)
 
        def _write(self, line):
@@ -216,7 +218,8 @@ class BotConnection(object):
 
                while "\r\n" in self.buffer:
                        pieces = self.buffer.split("\r\n", 1)
-                       print self.parent.nick, '[I]', pieces[0]
+                       print "%05.3f %s [I] %s" % (time.time() % 100000, self.parent.nick, pieces[0])
+#                      print (time.time() % 1460000000), self.parent.nick, '[I]', pieces[0]
                        lines.append(pieces[0])
                        self.buffer = pieces[1]