Inform in memos on Netsplit

This commit is contained in:
Kiooeht 2011-07-17 01:58:19 -07:00
parent 5775fbadf4
commit 838c5efcd5
5 changed files with 36 additions and 7 deletions

View file

@ -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
------------

View file

@ -236,6 +236,8 @@ class PesterProfile(object):
return "<c=%s><c=%s>%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), ", ".join(initials), verb)
else:
return "<c=%s><c=%s>%s%s%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), initials.pcf, self.initials(), initials.number, verb)
def memonetsplitmsg(self, syscolor, initials):
return "<c=%s>Netsplit quits: <c=black>%s</c></c>" % (syscolor.name(), ", ".join(initials))
def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel):
(temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when)
timetext = timeDifference(td)

6
irc.py
View file

@ -396,7 +396,13 @@ 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("!")]
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):

View file

@ -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,6 +931,12 @@ class PesterMemo(PesterConvo):
grammar = t.getGrammar()
allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number))
self.times[h].removeTime(t.getTime())
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)

View file

@ -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)