Display channel mode changes in memos

This commit is contained in:
Kiooeht 2011-07-10 02:13:00 -07:00
parent 475a6259b6
commit edba3f6fcc
4 changed files with 60 additions and 9 deletions

View file

@ -51,9 +51,11 @@ CHANGELOG
* Ping server if no ping from server to test connection - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance]) * Ping server if no ping from server to test connection - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance])
* MSPA comic update notifier - Kiooeht [evacipatedBox] * MSPA comic update notifier - Kiooeht [evacipatedBox]
* Volume control - Kiooeht [evacipatedBox] * Volume control - Kiooeht [evacipatedBox]
* Debug mode - illuminatedwax [ghostDunk]
* Set IRC away on idle - Kiooeht [evacipatedBox] * Set IRC away on idle - Kiooeht [evacipatedBox]
* Remote quirk shutoff in memos - Kiooeht [evacipatedBox] * Remote quirk shutoff in memos - Kiooeht [evacipatedBox]
* Compress exit dumps into one line - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance]) * Compress exit dumps into one line - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance])
* Display channel mode change message - Kiooeht [evacipatedBox]
* Bug fixes * Bug fixes
* Logviewer updates - Kiooeht [evacipatedBox] * Logviewer updates - Kiooeht [evacipatedBox]
* Memo scrollbar thing - Kiooeht [evacipatedBox] * Memo scrollbar thing - Kiooeht [evacipatedBox]

View file

@ -274,6 +274,12 @@ class PesterProfile(object):
opinit = opgrammar.pcf+opchum.initials()+opgrammar.number opinit = opgrammar.pcf+opchum.initials()+opgrammar.number
return "<c=%s>%s</c> took away <c=%s>%s</c>'s voice." % \ return "<c=%s>%s</c> took away <c=%s>%s</c>'s voice." % \
(opchum.colorhtml(), opinit, self.colorhtml(), self.initials()) (opchum.colorhtml(), opinit, self.colorhtml(), self.initials())
def memomodemsg(self, opchum, opgrammar, syscolor, modeverb, modeon):
opinit = opgrammar.pcf+opchum.initials()+opgrammar.number
if modeon: modeon = "now"
else: modeon = "no longer"
return "<c=%s>Memo is %s <c=black>%s</c> by <c=%s>%s</c></c>" % \
(syscolor.name(), modeon, modeverb, opchum.colorhtml(), opinit)
@staticmethod @staticmethod
def checkLength(handle): def checkLength(handle):

View file

@ -621,27 +621,67 @@ class PesterMemo(PesterConvo):
for u in users: for u in users:
self.userlist.addItem(u) self.userlist.addItem(u)
def updateChanModes(self, modes): def updateChanModes(self, modes, op):
if not hasattr(self, 'modes'): self.modes = "" if not hasattr(self, 'modes'): self.modes = ""
chanmodes = list(str(self.modes)) chanmodes = list(str(self.modes))
if chanmodes and chanmodes[0] == "+": chanmodes = chanmodes[1:] if chanmodes and chanmodes[0] == "+": chanmodes = chanmodes[1:]
modes = str(modes) modes = str(modes)
if op:
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
chum = self.mainwindow.profile()
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")
if modes[0] == "+": if modes[0] == "+":
for m in modes[1:]: for m in modes[1:]:
if m not in chanmodes: if m not in chanmodes:
chanmodes.extend(m) chanmodes.extend(m)
if modes.find("s") >= 0: self.chanHide.setChecked(True) if modes.find("s") >= 0:
if modes.find("i") >= 0: self.chanInvite.setChecked(True) self.chanHide.setChecked(True)
if modes.find("m") >= 0: self.chanMod.setChecked(True) if op:
msg = chum.memomodemsg(opchum, opgrammar, systemColor, "Secret", True)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
if modes.find("i") >= 0:
self.chanInvite.setChecked(True)
if op:
msg = chum.memomodemsg(opchum, opgrammar, systemColor, "Invite-Only", True)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
if modes.find("m") >= 0:
self.chanMod.setChecked(True)
if op:
msg = chum.memomodemsg(opchum, opgrammar, systemColor, "Mute", True)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
elif modes[0] == "-": elif modes[0] == "-":
for i in modes[1:]: for i in modes[1:]:
try: try:
chanmodes.remove(i) chanmodes.remove(i)
except ValueError: except ValueError:
pass pass
if modes.find("s") >= 0: self.chanHide.setChecked(False) if modes.find("s") >= 0:
if modes.find("i") >= 0: self.chanInvite.setChecked(False) self.chanHide.setChecked(False)
if modes.find("m") >= 0: self.chanMod.setChecked(False) if op:
msg = chum.memomodemsg(opchum, opgrammar, systemColor, "Secret", False)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
if modes.find("i") >= 0:
self.chanInvite.setChecked(False)
if op:
msg = chum.memomodemsg(opchum, opgrammar, systemColor, "Invite-Only", False)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
if modes.find("m") >= 0:
self.chanMod.setChecked(False)
if op:
msg = chum.memomodemsg(opchum, opgrammar, systemColor, "Mute", False)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
chanmodes.sort() chanmodes.sort()
self.modes = "+" + "".join(chanmodes) self.modes = "+" + "".join(chanmodes)
if self.mainwindow.advanced: if self.mainwindow.advanced:
@ -732,7 +772,7 @@ class PesterMemo(PesterConvo):
def modesUpdated(self, channel, modes): def modesUpdated(self, channel, modes):
c = unicode(channel) c = unicode(channel)
if c == self.channel: if c == self.channel:
self.updateChanModes(modes) self.updateChanModes(modes, None)
@QtCore.pyqtSlot(QtCore.QString) @QtCore.pyqtSlot(QtCore.QString)
def closeInviteOnly(self, channel): def closeInviteOnly(self, channel):
@ -999,7 +1039,7 @@ class PesterMemo(PesterConvo):
c.setIcon(icon) c.setIcon(icon)
self.sortUsers() self.sortUsers()
elif c == self.channel and h == "" and update[0] in ["+","-"]: elif c == self.channel and h == "" and update[0] in ["+","-"]:
self.updateChanModes(update) self.updateChanModes(update, op)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def addChumSlot(self): def addChumSlot(self):

View file

@ -2203,6 +2203,9 @@ class PesterWindow(MovingWindow):
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString) @QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
def cannotSendToChan(self, channel, msg): def cannotSendToChan(self, channel, msg):
self.deliverMemo(channel, "ChanServ", msg) self.deliverMemo(channel, "ChanServ", msg)
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
def modesUpdated(self, channel, modes):
self.modesUpdated.emit(channel, modes)
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
def timeCommand(self, chan, handle, command): def timeCommand(self, chan, handle, command):
(c, h, cmd) = (unicode(chan), unicode(handle), unicode(command)) (c, h, cmd) = (unicode(chan), unicode(handle), unicode(command))