From a531a34ce8e2f66c06d1a383dc968389b699e8d2 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Wed, 13 Jul 2011 00:24:22 -0700 Subject: [PATCH] Founder(+q), admin(+a), and halfop(+h) support --- CHANGELOG.mkdn | 1 + memos.py | 229 ++++++++++++++++++---------------- themes/pesterchum/admin.png | Bin 0 -> 433 bytes themes/pesterchum/founder.png | Bin 0 -> 433 bytes themes/pesterchum/halfop.png | Bin 0 -> 224 bytes themes/pesterchum/style.js | 5 +- themes/trollian/halfop.png | Bin 0 -> 239 bytes themes/trollian/style.js | 1 + 8 files changed, 130 insertions(+), 106 deletions(-) create mode 100644 themes/pesterchum/admin.png create mode 100644 themes/pesterchum/founder.png create mode 100644 themes/pesterchum/halfop.png create mode 100644 themes/trollian/halfop.png 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 0000000000000000000000000000000000000000..b1e7e0056c4105f327030fe36f3c8bdf4ccf8cf5 GIT binary patch literal 433 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ueoXKL{?^yL>WGgtNdSvY3H^?=T269?xHq0un4Ma7+i%V23co99s*NWytY#aSX9I zeRpyo-vI><=lJsf)|>fFgV{Ev+&n)^LV0QHf{WqN>#VMEo8rFs#hbh*+*cH$EIa#Ep-pY)^&X{ z-g}Jmr;EIpX7v4YKzk)iTq8`6H8KcQ-B16k%6J1u7SC(p>c?Txs{=Xm9eF^fq|8QK^!}O4opLCeoAIqB>@eL T+bSb~8W=oX{an^LB{Ts5p(BG= literal 0 HcmV?d00001 diff --git a/themes/pesterchum/founder.png b/themes/pesterchum/founder.png new file mode 100644 index 0000000000000000000000000000000000000000..259e97ec846267505a0fd4d1eeb10d1a5b1a6afe GIT binary patch literal 433 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ueoXKL{?^yL>WGgtNdSvY3H^?=T269?xHq0un4Ma7+i%V23co99s*NWytY#aSX9I zJ$I6$5Q88Oi}COO_UGd^B~FxB*2TOlxN)Y~uNh3N%N8Fv^M-|y-N0kPAwH>}(;XVM zPfkowt!eSrDb_s^_2BwqrsG>)OJ`hqBYF9h?19Ei>Cn{MHQT-jiCT!R_z+aU^qqZY z#NKd5q8XAWfm|GbdSQ!~;8yHv_7>GRLx(d^fo1c=IR!KmE TcW})^paup{S3j3^P6QQ33r;MV|~?xYWdeb0oujj M>FVdQ&MBb@0A@=~Y5)KL literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..78b443b6b2e8c2525ed340ed707267af9190a067 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85sBugD~Uq{1qucLG}_)Usv|q?7ZxJ5;eyk-T?~bd%8G=Se#xv z=^$@|0S|NTk=cdDE^064=rHI9Om(ve_>-l4SF_8fWykNv_8F4D?X@?|JSy1k&h~x5 z?&Y%s4hr@NF&*IJY4Sa=U7>lsi6TP->*Sf@A=jozr%YN^QOo_Ojydd?e)ktwrPVQ0 ceeOSC30Pp5uCV>CJkV+ePgg&ebxsLQ0B}oDyZ`_I literal 0 HcmV?d00001 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" } } }