From cdce13bacf2c15dab79c834bc30865f7c3020ae3 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Wed, 11 May 2011 23:28:07 -0700 Subject: [PATCH] Display OP, DeOP, Voice, and Devoice messages in memos --- TODO.mkdn | 1 + dataobjs.py | 16 +++++++++ irc.py | 16 ++++++++- memos.py | 89 ++++++++++++++++++++++++++++++++++++++++++++++++--- menus.py | 5 +++ pesterchum.py | 10 ++++-- 6 files changed, 130 insertions(+), 7 deletions(-) diff --git a/TODO.mkdn b/TODO.mkdn index 9c5df52..471252d 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -18,6 +18,7 @@ Bugs * Issues with connecting? Client not closing connection right? People keep getting "nick taken" messages * Windows XP SP2: sometimes mouse clicks dont register? must be some kinda crash * When using mood sort, scroll position jumps to last selected chum +* In memos, entering when someone has +ov and then they -o, you don't see that they have +v Mac Bugs -------- diff --git a/dataobjs.py b/dataobjs.py index 32a0d83..a81cd2e 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -252,6 +252,22 @@ class PesterProfile(object): return "%s %s [%s] %s %s." % \ (syscolor.name(), self.colorhtml(), temporal, self.handle, initials, timetext, verb) + def memoopmsg(self, opchum, opgrammar, syscolor): + opinit = opgrammar.pcf+opchum.initials()+opgrammar.number + return "%s made %s an OP." % \ + (opchum.colorhtml(), opinit, self.colorhtml(), self.initials()) + def memodeopmsg(self, opchum, opgrammar, syscolor): + opinit = opgrammar.pcf+opchum.initials()+opgrammar.number + return "%s took away %s's OP powers." % \ + (opchum.colorhtml(), opinit, self.colorhtml(), self.initials()) + def memovoicemsg(self, opchum, opgrammar, syscolor): + opinit = opgrammar.pcf+opchum.initials()+opgrammar.number + return "%s gave %s voice." % \ + (opchum.colorhtml(), opinit, self.colorhtml(), self.initials()) + def memodevoicemsg(self, opchum, opgrammar, syscolor): + opinit = opgrammar.pcf+opchum.initials()+opgrammar.number + return "%s took away %s's voice." % \ + (opchum.colorhtml(), opinit, self.colorhtml(), self.initials()) @staticmethod def checkLength(handle): diff --git a/irc.py b/irc.py index 8947e03..99470b2 100644 --- a/irc.py +++ b/irc.py @@ -321,7 +321,21 @@ class PesterHandler(DefaultCommandHandler): if channel == "#pesterchum": self.parent.moodUpdated.emit(handle, Mood("chummy")) def mode(self, op, channel, mode, handle=""): - self.parent.userPresentUpdate.emit(handle, channel, mode) + opnick = op[0:op.find("!")] + if op == channel or channel == self.parent.mainwindow.profile().handle: + modes = list(self.parent.mainwindow.modes) + if modes and modes[0] == "+": modes = modes[1:] + if mode[0] == "+": + modes.extend(mode[1:]) + elif mode[0] == "-": + for i in mode[1:]: + try: + modes.remove(i) + except ValueError: + pass + modes.sort() + self.parent.mainwindow.modes = "+" + "".join(modes) + self.parent.userPresentUpdate.emit(handle, channel, mode+":%s" % (op)) def nick(self, oldnick, newnick): oldhandle = oldnick[0:oldnick.find("!")] if oldhandle == self.mainwindow.profile().handle: diff --git a/memos.py b/memos.py index 0e86a08..c9499d1 100644 --- a/memos.py +++ b/memos.py @@ -648,6 +648,10 @@ class PesterMemo(PesterConvo): oldnick = l[0] newnick = l[1] h = oldnick + if update[0:2] in ["+o", "-o", "+v", "-v"]: + l = update.split(":") + update = l[0] + op = l[1] if (update in ["join","left", "kick", "+o", "-o", "+v", "-v"]) \ and channel != self.channel: return @@ -728,7 +732,26 @@ class PesterMemo(PesterConvo): serverText = "PESTERCHUM:TIME>"+delta2txt(time, "server") self.messageSent.emit(serverText, self.title()) elif update == "+o": - chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) + 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"]) @@ -738,7 +761,27 @@ class PesterMemo(PesterConvo): self.userlist.optionsMenu.addAction(self.voiceAction) self.userlist.optionsMenu.addAction(self.banuserAction) elif update == "-o": - chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) + 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: @@ -752,14 +795,52 @@ class PesterMemo(PesterConvo): self.userlist.optionsMenu.removeAction(self.voiceAction) self.userlist.optionsMenu.removeAction(self.banuserAction) elif update == "+v": - chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) + 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) elif update == "-v": - chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) + 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: diff --git a/menus.py b/menus.py index 829590d..4ecf1b2 100644 --- a/menus.py +++ b/menus.py @@ -666,6 +666,10 @@ class PesterOptions(QtGui.QDialog): if self.config.showSeconds(): self.secondscheck.setChecked(True) + self.memomessagecheck = QtGui.QCheckBox("Show OP and Voice Messages in Memos", self) + if self.config.opvoiceMessages(): + self.memomessagecheck.setChecked(True) + self.userlinkscheck = QtGui.QCheckBox("Disable #Memo and @User Links", self) self.userlinkscheck.setChecked(self.config.disableUserLinks()) self.userlinkscheck.setVisible(False) @@ -754,6 +758,7 @@ class PesterOptions(QtGui.QDialog): layout_chat.addWidget(self.timestampcheck) layout_chat.addWidget(self.timestampBox) layout_chat.addWidget(self.secondscheck) + layout_chat.addWidget(self.memomessagecheck) # Re-enable these when it's possible to disable User and Memo links #layout_chat.addWidget(hr) #layout_chat.addWidget(QtGui.QLabel("User and Memo Links")) diff --git a/pesterchum.py b/pesterchum.py index 353310e..ff44c90 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -346,6 +346,8 @@ class userConfig(object): return self.config.get('miniAction', 0) def closeAction(self): return self.config.get('closeAction', 1) + def opvoiceMessages(self): + return self.config.get('opvMessages', True) def addChum(self, chum): if chum.handle not in self.chums(): fp = open(self.filename) # what if we have two clients open?? @@ -777,7 +779,6 @@ class chumArea(RightClickTree): child_1 = QtGui.QTreeWidgetItem(["%s" % (g)]) j = 0 for h in self.groups: - print h + ":" + g if h == g: self.insertTopLevelItem(j, child_1) break @@ -2423,6 +2424,11 @@ class PesterWindow(MovingWindow): if closesetting != curclose: self.config.set('closeAction', closesetting) self.setButtonAction(self.closeButton, closesetting, curclose) + # op and voice messages + opvmesssetting = self.optionmenu.memomessagecheck.isChecked() + curopvmess = self.config.opvoiceMessages() + if opvmesssetting != curopvmess: + self.config.set('opvMessages', opvmesssetting) self.optionmenu = None def setButtonAction(self, button, setting, old): @@ -2630,7 +2636,7 @@ class MainProgram(QtCore.QObject): def __init__(self): QtCore.QObject.__init__(self) self.app = QtGui.QApplication(sys.argv) - self.app.setApplicationName("Pesterchum 3.14"); + self.app.setApplicationName("Pesterchum 3.14") if pygame.mixer: # we could set the frequency higher but i love how cheesy it sounds try: