diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index cb70967..13bdade 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -57,6 +57,7 @@ CHANGELOG * Compress exit dumps into one line - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance]) * Display channel mode change message - Kiooeht [evacipatedBox] * Disable quirks in +c memos - Lexi [lexicalNuance] +* Founder, admin, and halfop support - Kiooeht [evacipatedBox] * Bug fixes * Logviewer updates - Kiooeht [evacipatedBox] * Memo scrollbar thing - Kiooeht [evacipatedBox] diff --git a/memos.py b/memos.py index 6ee7f3d..84ab54e 100644 --- a/memos.py +++ b/memos.py @@ -582,18 +582,16 @@ class PesterMemo(PesterConvo): self.layout.setContentsMargins(margins["left"], margins["top"], margins["right"], margins["bottom"]) for item in [self.userlist.item(i) for i in range(0,self.userlist.count())]: - if item.op: - icon = PesterIcon(self.mainwindow.theme["memos/op/icon"]) - item.setIcon(icon) - elif item.voice: - icon = PesterIcon(self.mainwindow.theme["memos/voice/icon"]) - item.setIcon(icon) + self.iconCrap(item) def addUser(self, handle): chumdb = self.mainwindow.chumdb defaultcolor = QtGui.QColor("black") - op = False - voice = False + founder = False + op = False + halfop = False + admin = False + voice = False if handle[0] == '@': op = True handle = handle[1:] @@ -602,23 +600,36 @@ class PesterMemo(PesterConvo): self.userlist.optionsMenu.addAction(self.banuserAction) self.optionsMenu.addMenu(self.chanModeMenu) self.op = True + elif handle[0] == '%': + halfop = True + handle = handle[1:] + if handle == self.mainwindow.profile().handle: + self.userlist.optionsMenu.addAction(self.opAction) + self.userlist.optionsMenu.addAction(self.banuserAction) + self.optionsMenu.addMenu(self.chanModeMenu) + self.halfop = True elif handle[0] == '+': voice = True handle = handle[1:] + elif handle[0] == '~': + founder = True + handle = handle[1:] + elif handle[0] == '&': + admin = True + handle = handle[1:] item = QtGui.QListWidgetItem(handle) if handle == self.mainwindow.profile().handle: color = self.mainwindow.profile().color else: color = chumdb.getColor(handle, defaultcolor) item.setTextColor(color) + item.founder = founder item.op = op + item.halfop = halfop + item.admin = admin item.voice = voice - if op: - icon = PesterIcon(self.mainwindow.theme["memos/op/icon"]) - item.setIcon(icon) - elif voice: - icon = PesterIcon(self.mainwindow.theme["memos/voice/icon"]) - item.setIcon(icon) + self.umodes = ["founder", "op", "halfop", "admin", "voice"] + self.iconCrap(item) self.userlist.addItem(item) self.sortUsers() @@ -628,7 +639,7 @@ class PesterMemo(PesterConvo): while listing is not None: users.append(self.userlist.takeItem(0)) listing = self.userlist.item(0) - users.sort(key=lambda x: ((0 if x.op else 1), (0 if x.voice else 1), x.text())) + users.sort(key=lambda x: ((0 if x.founder else (1 if x.op else (2 if x.halfop else (3 if x.admin else (4 if x.voice else 4))))), x.text())) for u in users: self.userlist.addItem(u) @@ -838,6 +849,33 @@ class PesterMemo(PesterConvo): self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) + def chumOPstuff(self, h, op): + 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") + return (chum, opchum, opgrammar) + def iconCrap(self, c, down=True): + for m in (self.umodes if down else reversed(self.umodes)): + if eval("c."+m): + icon = PesterIcon(self.mainwindow.theme["memos/"+m+"/icon"]) + c.setIcon(icon) + return + icon = QtGui.QIcon() + c.setIcon(icon) + @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) def userPresentChange(self, handle, channel, update): h = unicode(handle) @@ -857,7 +895,9 @@ class PesterMemo(PesterConvo): l = update.split(":") update = l[0] op = l[1] - if (update in ["join","left", "kick", "+o", "-o", "+v", "-v"]) \ + if (update in ["join","left", "kick", \ + "+q", "-q", "+o", "-o", "+h", "-h", \ + "+a", "-a", "+v", "-v"]) \ and channel != self.channel: return chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) @@ -883,14 +923,11 @@ class PesterMemo(PesterConvo): 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) + nc.founder = c.founder + nc.op = c.op + nc.halfop = c.halfop + nc.admin = c.admin + self.iconCrap(nc) self.sortUsers() elif update == "kick": if len(chums) == 0: @@ -950,31 +987,25 @@ class PesterMemo(PesterConvo): time = self.time.getTime() serverText = "PESTERCHUM:TIME>"+delta2txt(time, "server") self.messageSent.emit(serverText, self.title()) + elif update == "+q": + for c in chums: + c.founder = True + self.iconCrap(c) + self.sortUsers() + elif update == "-q": + for c in chums: + c.founder = False + self.iconCrap(c) + self.sortUsers() 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") + (chum, opchum, opgrammar) = self.chumOPstuff(h, op) 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) + self.iconCrap(c) if unicode(c.text()) == self.mainwindow.profile().handle: self.userlist.optionsMenu.addAction(self.opAction) self.userlist.optionsMenu.addAction(self.voiceAction) @@ -985,33 +1016,13 @@ class PesterMemo(PesterConvo): 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") + (chum, opchum, opgrammar) = self.chumOPstuff(h, op) 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) + self.iconCrap(c) if unicode(c.text()) == self.mainwindow.profile().handle: self.userlist.optionsMenu.removeAction(self.opAction) self.userlist.optionsMenu.removeAction(self.voiceAction) @@ -1019,62 +1030,70 @@ class PesterMemo(PesterConvo): self.userlist.optionsMenu.removeAction(self.quirkDisableAction) self.optionsMenu.removeAction(self.chanModeMenu.menuAction()) self.sortUsers() + elif update == "+h": + if self.mainwindow.config.opvoiceMessages(): + (chum, opchum, opgrammar) = self.chumOPstuff(h, op) + msg = chum.memoopmsg(opchum, opgrammar, systemColor) + self.textArea.append(convertTags(msg)) + self.mainwindow.chatlog.log(self.channel, msg) + for c in chums: + c.halfop = True + self.iconCrap(c) + 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.userlist.optionsMenu.addAction(self.quirkDisableAction) + self.optionsMenu.addMenu(self.chanModeMenu) + self.sortUsers() + elif update == "-h": + self.mainwindow.channelNames.emit(self.channel) + if self.mainwindow.config.opvoiceMessages(): + (chum, opchum, opgrammar) = self.chumOPstuff(h, op) + msg = chum.memodeopmsg(opchum, opgrammar, systemColor) + self.textArea.append(convertTags(msg)) + self.mainwindow.chatlog.log(self.channel, msg) + for c in chums: + c.halfop = False + self.iconCrap(c) + 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.userlist.optionsMenu.removeAction(self.quirkDisableAction) + self.optionsMenu.removeAction(self.chanModeMenu.menuAction()) + self.sortUsers() + elif update == "+a": + for c in chums: + c.admin = True + self.iconCrap(c) + self.sortUsers() + elif update == "-a": + for c in chums: + c.admin = False + self.iconCrap(c) + self.sortUsers() + elif c == self.channel and h == "" and update[0] in ["+","-"]: + self.updateChanModes(update, op) 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") + (chum, opchum, opgrammar) = self.chumOPstuff(h, op) 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.iconCrap(c) 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") + (chum, opchum, opgrammar) = self.chumOPstuff(h, op) 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.iconCrap(c) self.sortUsers() elif c == self.channel and h == "" and update[0] in ["+","-"]: self.updateChanModes(update, op) diff --git a/themes/pesterchum/admin.png b/themes/pesterchum/admin.png new file mode 100644 index 0000000..b1e7e00 Binary files /dev/null and b/themes/pesterchum/admin.png differ diff --git a/themes/pesterchum/founder.png b/themes/pesterchum/founder.png new file mode 100644 index 0000000..259e97e Binary files /dev/null and b/themes/pesterchum/founder.png differ diff --git a/themes/pesterchum/halfop.png b/themes/pesterchum/halfop.png new file mode 100644 index 0000000..594fbf7 Binary files /dev/null and b/themes/pesterchum/halfop.png differ diff --git a/themes/pesterchum/style.js b/themes/pesterchum/style.js index a96289b..61691bc 100644 --- a/themes/pesterchum/style.js +++ b/themes/pesterchum/style.js @@ -314,6 +314,9 @@ }, "systemMsgColor": "#646464", "op": { "icon": "$path/op.png" }, - "voice": { "icon": "$path/voice.png" } + "halfop": { "icon": "$path/halfop.png" }, + "voice": { "icon": "$path/voice.png" }, + "founder": { "icon": "$path/founder.png" }, + "admin": { "icon": "$path/admin.png" } } } diff --git a/themes/trollian/halfop.png b/themes/trollian/halfop.png new file mode 100644 index 0000000..78b443b Binary files /dev/null and b/themes/trollian/halfop.png differ diff --git a/themes/trollian/style.js b/themes/trollian/style.js index 216ca57..d824c98 100644 --- a/themes/trollian/style.js +++ b/themes/trollian/style.js @@ -346,6 +346,7 @@ }, "systemMsgColor": "#646464", "op": { "icon": "$path/op.png" }, + "halfop": { "icon": "$path/halfop.png" }, "voice": { "icon": "$path/voice.png" } } }