diff --git a/TODO.mkdn b/TODO.mkdn index 08af9c1..ee00f2a 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -34,7 +34,6 @@ Bugs * right clicking an offline chum and choosing remove asks you why you're reporting someone, and if you hit cancel the menus stop working * Closing a timeclone doesn't actually cease for everyone else * Kill Zalgo -* Handle netsplits Windows Bugs ------------ diff --git a/dataobjs.py b/dataobjs.py index 4b0ee60..71a0054 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -236,6 +236,8 @@ class PesterProfile(object): return "%s %s." % (syscolor.name(), self.colorhtml(), ", ".join(initials), verb) else: return "%s%s%s %s." % (syscolor.name(), self.colorhtml(), initials.pcf, self.initials(), initials.number, verb) + def memonetsplitmsg(self, syscolor, initials): + return "Netsplit quits: %s" % (syscolor.name(), ", ".join(initials)) def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel): (temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when) timetext = timeDifference(td) diff --git a/irc.py b/irc.py index 9a6cfe4..72f57ca 100644 --- a/irc.py +++ b/irc.py @@ -396,8 +396,14 @@ class PesterHandler(DefaultCommandHandler): helpers.nick(self.client, newnick) self.parent.nickCollision.emit(nick, newnick) def quit(self, nick, reason): + print reason handle = nick[0:nick.find("!")] - self.parent.userPresentUpdate.emit(handle, "", "quit") + server = self.parent.mainwindow.config.server() + baseserver = server[server.rfind(".", 0, server.rfind(".")):] + if reason.count(baseserver) == 2: + self.parent.userPresentUpdate.emit(handle, "", "netsplit") + else: + self.parent.userPresentUpdate.emit(handle, "", "quit") self.parent.moodUpdated.emit(handle, Mood("offline")) def kick(self, opnick, channel, handle, reason): op = opnick[0:opnick.find("!")] diff --git a/memos.py b/memos.py index 8a919b0..ca5ae6c 100644 --- a/memos.py +++ b/memos.py @@ -876,6 +876,16 @@ class PesterMemo(PesterConvo): icon = QtGui.QIcon() c.setIcon(icon) + @QtCore.pyqtSlot() + def dumpNetsplit(self): + self.splitTimer.stop() + chum = self.mainwindow.profile() + systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"]) + msg = chum.memonetsplitmsg(systemColor, self.netsplit) + self.textArea.append(convertTags(msg)) + self.mainwindow.chatlog.log(self.channel, msg) + self.netsplit = [] + @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) def userPresentChange(self, handle, channel, update): h = unicode(handle) @@ -903,7 +913,13 @@ class PesterMemo(PesterConvo): chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"]) # print exit - if update == "quit" or update == "left" or update == "nick": + if update in ("quit", "left", "nick", "netsplit"): + if update == "netsplit": + if not hasattr(self, "netsplit"): + self.netsplit = [] + self.splitTimer = QtCore.QTimer(self) + self.connect(self.splitTimer, QtCore.SIGNAL('timeout()'), + self, QtCore.SLOT('dumpNetsplit()')) for c in chums: chum = PesterProfile(h) self.userlist.takeItem(self.userlist.row(c)) @@ -915,9 +931,15 @@ class PesterMemo(PesterConvo): grammar = t.getGrammar() allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number)) self.times[h].removeTime(t.getTime()) - msg = chum.memoclosemsg(systemColor, allinitials, self.mainwindow.theme["convo/text/closememo"]) - self.textArea.append(convertTags(msg)) - self.mainwindow.chatlog.log(self.channel, msg) + if update == "netsplit": + self.netsplit.extend(initials) + if self.splitTimer.isActive(): + self.splitTimer.stop() + self.splitTimer.start(1000) + else: + msg = chum.memoclosemsg(systemColor, allinitials, self.mainwindow.theme["convo/text/closememo"]) + self.textArea.append(convertTags(msg)) + self.mainwindow.chatlog.log(self.channel, msg) if update == "nick": self.addUser(newnick) newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlags(0)) diff --git a/pesterchum.py b/pesterchum.py index 0bf799d..b568790 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -2261,7 +2261,7 @@ class PesterWindow(MovingWindow): l = n.split(":") oldnick = l[0] newnick = l[1] - if update == "quit": + if update in ("quit", "netsplit"): for c in self.namesdb.keys(): try: i = self.namesdb[c].index(n)