def userPresentChange(self, handle, channel, update): h = unicode(handle) c = unicode(channel) update = unicode(update) if update[0:4] == "kick": # yeah, i'm lazy. l = update.split(":") update = l[0] op = l[1] reason = l[2] if update == "nick": l = h.split(":") oldnick = l[0] newnick = l[1] h = oldnick if update[0:1] in ["+", "-"]: l = update.split(":") update = l[0] op = l[1] if (update in ["join","left", "kick", "+o", "-o", "+v", "-v"]) \ and channel != self.channel: return 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": for c in chums: chum = PesterProfile(h) self.userlist.takeItem(self.userlist.row(c)) if not self.times.has_key(h): self.times[h] = TimeTracker(timedelta(0)) while self.times[h].getTime() is not None: t = self.times[h] grammar = t.getGrammar() msg = chum.memoclosemsg(systemColor, grammar, self.mainwindow.theme["convo/text/closememo"]) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) self.times[h].removeTime(t.getTime()) if update == "nick": self.addUser(newnick) newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlags(0)) for nc in newchums: for c in chums: if c.op: nc.op = True icon = PesterIcon(self.mainwindow.theme["memos/op/icon"]) nc.setIcon(icon) if c.voice: nc.voice = True icon = PesterIcon(self.mainwindow.theme["memos/voice/icon"]) nc.setIcon(icon) self.sortUsers() elif update == "kick": if len(chums) == 0: return c = chums[0] chum = PesterProfile(h) if h == self.mainwindow.profile().handle: chum = self.mainwindow.profile() ttracker = self.time curtime = self.time.getTime() elif self.times.has_key(h): ttracker = self.times[h] else: ttracker = TimeTracker(timedelta(0)) while ttracker.getTime() is not None: grammar = ttracker.getGrammar() opchum = PesterProfile(op) if self.times.has_key(op): opgrammar = self.times[op].getGrammar() elif op == self.mainwindow.profile().handle: opgrammar = self.time.getGrammar() else: opgrammar = TimeGrammar("CURRENT", "C", "RIGHT NOW") msg = chum.memobanmsg(opchum, opgrammar, systemColor, grammar, reason) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) ttracker.removeTime(ttracker.getTime()) if chum is self.mainwindow.profile(): # are you next? msgbox = QtGui.QMessageBox() msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"]) msgbox.setInformativeText("press 0k to rec0nnect or cancel to absc0nd") msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) ret = msgbox.exec_() if ret == QtGui.QMessageBox.Ok: self.userlist.clear() self.time = TimeTracker(curtime) self.resetSlider(curtime) self.mainwindow.joinChannel.emit(self.channel) me = self.mainwindow.profile() self.time.openCurrentTime() msg = me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) elif ret == QtGui.QMessageBox.Cancel: if self.parent(): i = self.parent().tabIndices[self.channel] self.parent().tabClose(i) else: self.close() else: # i warned you about those stairs bro self.userlist.takeItem(self.userlist.row(c)) elif update == "join": self.addUser(h) time = self.time.getTime() serverText = "PESTERCHUM:TIME>"+delta2txt(time, "server") self.messageSent.emit(serverText, self.title()) elif update == "+o": if self.mainwindow.config.opvoiceMessages(): chum = PesterProfile(h) if h == self.mainwindow.profile().handle: chum = self.mainwindow.profile() ttracker = self.time curtime = self.time.getTime() elif self.times.has_key(h): ttracker = self.times[h] else: ttracker = TimeTracker(timedelta(0)) opchum = PesterProfile(op) if self.times.has_key(op): opgrammar = self.times[op].getGrammar() elif op == self.mainwindow.profile().handle: opgrammar = self.time.getGrammar() else: opgrammar = TimeGrammar("CURRENT", "C", "RIGHT NOW") msg = chum.memoopmsg(opchum, opgrammar, systemColor) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) for c in chums: c.op = True icon = PesterIcon(self.mainwindow.theme["memos/op/icon"]) c.setIcon(icon) if unicode(c.text()) == self.mainwindow.profile().handle: self.userlist.optionsMenu.addAction(self.opAction) self.userlist.optionsMenu.addAction(self.voiceAction) self.userlist.optionsMenu.addAction(self.banuserAction) self.optionsMenu.addMenu(self.chanModeMenu) self.sortUsers() elif update == "-o": self.mainwindow.channelNames.emit(self.channel) if self.mainwindow.config.opvoiceMessages(): chum = PesterProfile(h) if h == self.mainwindow.profile().handle: chum = self.mainwindow.profile() ttracker = self.time curtime = self.time.getTime() elif self.times.has_key(h): ttracker = self.times[h] else: ttracker = TimeTracker(timedelta(0)) opchum = PesterProfile(op) if self.times.has_key(op): opgrammar = self.times[op].getGrammar() elif op == self.mainwindow.profile().handle: opgrammar = self.time.getGrammar() else: opgrammar = TimeGrammar("CURRENT", "C", "RIGHT NOW") msg = chum.memodeopmsg(opchum, opgrammar, systemColor) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) for c in chums: c.op = False if c.voice: icon = PesterIcon(self.mainwindow.theme["memos/voice/icon"]) c.setIcon(icon) else: icon = QtGui.QIcon() c.setIcon(icon) if unicode(c.text()) == self.mainwindow.profile().handle: self.userlist.optionsMenu.removeAction(self.opAction) self.userlist.optionsMenu.removeAction(self.voiceAction) self.userlist.optionsMenu.removeAction(self.banuserAction) self.optionsMenu.removeAction(self.chanModeMenu.menuAction()) self.sortUsers() elif update == "+v": if self.mainwindow.config.opvoiceMessages(): chum = PesterProfile(h) if h == self.mainwindow.profile().handle: chum = self.mainwindow.profile() ttracker = self.time curtime = self.time.getTime() elif self.times.has_key(h): ttracker = self.times[h] else: ttracker = TimeTracker(timedelta(0)) opchum = PesterProfile(op) if self.times.has_key(op): opgrammar = self.times[op].getGrammar() elif op == self.mainwindow.profile().handle: opgrammar = self.time.getGrammar() else: opgrammar = TimeGrammar("CURRENT", "C", "RIGHT NOW") msg = chum.memovoicemsg(opchum, opgrammar, systemColor) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) for c in chums: c.voice = True if not c.op: icon = PesterIcon(self.mainwindow.theme["memos/voice/icon"]) c.setIcon(icon) self.sortUsers() elif update == "-v": if self.mainwindow.config.opvoiceMessages(): chum = PesterProfile(h) if h == self.mainwindow.profile().handle: chum = self.mainwindow.profile() ttracker = self.time curtime = self.time.getTime() elif self.times.has_key(h): ttracker = self.times[h] else: ttracker = TimeTracker(timedelta(0)) opchum = PesterProfile(op) if self.times.has_key(op): opgrammar = self.times[op].getGrammar() elif op == self.mainwindow.profile().handle: opgrammar = self.time.getGrammar() else: opgrammar = TimeGrammar("CURRENT", "C", "RIGHT NOW") msg = chum.memodevoicemsg(opchum, opgrammar, systemColor) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) for c in chums: c.voice = False if c.op: icon = PesterIcon(self.mainwindow.theme["memos/op/icon"]) c.setIcon(icon) else: icon = QtGui.QIcon() c.setIcon(icon) self.sortUsers() elif c == self.channel and h == "" and update[0] in ["+","-"]: self.updateChanModes(update)