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 * 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 * Closing a timeclone doesn't actually cease for everyone else
* Kill Zalgo * Kill Zalgo
* Handle netsplits
Windows Bugs 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) return "<c=%s><c=%s>%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), ", ".join(initials), verb)
else: else:
return "<c=%s><c=%s>%s%s%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), initials.pcf, self.initials(), initials.number, verb) 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): def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel):
(temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when) (temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when)
timetext = timeDifference(td) timetext = timeDifference(td)

8
irc.py
View file

@ -396,8 +396,14 @@ class PesterHandler(DefaultCommandHandler):
helpers.nick(self.client, newnick) helpers.nick(self.client, newnick)
self.parent.nickCollision.emit(nick, newnick) self.parent.nickCollision.emit(nick, newnick)
def quit(self, nick, reason): def quit(self, nick, reason):
print reason
handle = nick[0:nick.find("!")] 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")) self.parent.moodUpdated.emit(handle, Mood("offline"))
def kick(self, opnick, channel, handle, reason): def kick(self, opnick, channel, handle, reason):
op = opnick[0:opnick.find("!")] op = opnick[0:opnick.find("!")]

View file

@ -876,6 +876,16 @@ class PesterMemo(PesterConvo):
icon = QtGui.QIcon() icon = QtGui.QIcon()
c.setIcon(icon) 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) @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
def userPresentChange(self, handle, channel, update): def userPresentChange(self, handle, channel, update):
h = unicode(handle) h = unicode(handle)
@ -903,7 +913,13 @@ class PesterMemo(PesterConvo):
chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0))
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"]) systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
# print exit # 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: for c in chums:
chum = PesterProfile(h) chum = PesterProfile(h)
self.userlist.takeItem(self.userlist.row(c)) self.userlist.takeItem(self.userlist.row(c))
@ -915,9 +931,15 @@ class PesterMemo(PesterConvo):
grammar = t.getGrammar() grammar = t.getGrammar()
allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number)) allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number))
self.times[h].removeTime(t.getTime()) self.times[h].removeTime(t.getTime())
msg = chum.memoclosemsg(systemColor, allinitials, self.mainwindow.theme["convo/text/closememo"]) if update == "netsplit":
self.textArea.append(convertTags(msg)) self.netsplit.extend(initials)
self.mainwindow.chatlog.log(self.channel, msg) 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": if update == "nick":
self.addUser(newnick) self.addUser(newnick)
newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlags(0)) newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlags(0))

View file

@ -2261,7 +2261,7 @@ class PesterWindow(MovingWindow):
l = n.split(":") l = n.split(":")
oldnick = l[0] oldnick = l[0]
newnick = l[1] newnick = l[1]
if update == "quit": if update in ("quit", "netsplit"):
for c in self.namesdb.keys(): for c in self.namesdb.keys():
try: try:
i = self.namesdb[c].index(n) i = self.namesdb[c].index(n)