From 4a2fe110f27c4a0dca198003219524d37594a1ab Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Wed, 29 Jun 2011 10:19:22 -0700 Subject: [PATCH] Remote quirk shutoff --- CHANGELOG.mkdn | 1 + TODO.mkdn | 1 - irc.py | 15 ++++++++++++++- memos.py | 21 +++++++++++++++++++++ oyoyo/helpers.py | 6 ++++++ pesterchum.py | 15 ++++++++++++++- 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index 822da9d..f57bd04 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -52,6 +52,7 @@ CHANGELOG * MSPA comic update notifier - Kiooeht [evacipatedBox] * Volume control - Kiooeht [evacipatedBox] * Set IRC away on idle - Kiooeht [evacipatedBox] +* Remote quirk shutoff in memos - Kiooeht [evacipatedBox] * Bug fixes * Logviewer updates - Kiooeht [evacipatedBox] * Memo scrollbar thing - Kiooeht [evacipatedBox] diff --git a/TODO.mkdn b/TODO.mkdn index ebc0b2a..7fed7ff 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -14,7 +14,6 @@ Features * Colour saving boxes things? * Chum notes? * whowas for last seen online? -* Remote quirk disable * Tab completion of two letter names * Compress exit dumps into one line (eg. FTC, CTC, PTC1-12 ceased responding to memo) * Customizable name alerts diff --git a/irc.py b/irc.py index 30400c1..d3e3f1a 100644 --- a/irc.py +++ b/irc.py @@ -287,6 +287,15 @@ class PesterIRC(QtCore.QThread): except socket.error: self.setConnectionBroken() + @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + def killSomeQuirks(self, channel, handle): + c = unicode(channel) + h = unicode(handle) + try: + helpers.ctcp(self.cli, c, "NOQUIRKS", h) + except socket.error: + self.setConnectionBroken() + moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood) colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor) messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) @@ -305,6 +314,7 @@ class PesterIRC(QtCore.QThread): QtCore.QString) cannotSendToChan = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) tooManyPeeps = QtCore.pyqtSignal() + quirkDisable = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString) class PesterHandler(DefaultCommandHandler): def notice(self, nick, chan, msg): @@ -331,7 +341,10 @@ class PesterHandler(DefaultCommandHandler): handle = nick[0:nick.find("!")] logging.info("---> recv \"CTCP %s :%s\"" % (handle, msg[1:-1])) if msg[1:-1] == "VERSION": - helpers.notice(self.parent.cli, handle, "\x01VERSION Pesterchum %s\x01" % (_pcVersion)) + helpers.ctcp_reply(self.parent.cli, handle, "VERSION", "Pesterchum %s\x01" % (_pcVersion)) + elif msg[1:-1].startswith("NOQUIRKS") and chan[0] == "#": + op = nick[0:nick.find("!")] + self.parent.quirkDisable.emit(chan, msg[10:-1], op) return handle = nick[0:nick.find("!")] logging.info("---> recv \"PRIVMSG %s :%s\"" % (handle, msg)) diff --git a/memos.py b/memos.py index 926394c..2ffa6b9 100644 --- a/memos.py +++ b/memos.py @@ -374,6 +374,9 @@ class PesterMemo(PesterConvo): self.voiceAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self) self.connect(self.voiceAction, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('voiceSelectedUser()')) + self.quirkDisableAction = QtGui.QAction("Kill Quirk", self) + self.connect(self.quirkDisableAction, QtCore.SIGNAL('triggered()'), + self, QtCore.SLOT('killQuirkUser()')) self.userlist.optionsMenu.addAction(self.addchumAction) # ban & op list added if we are op @@ -538,6 +541,7 @@ class PesterMemo(PesterConvo): self.banuserAction.setText(theme["main/menus/rclickchumlist/banuser"]) self.opAction.setText(theme["main/menus/rclickchumlist/opuser"]) self.voiceAction.setText(theme["main/menus/rclickchumlist/voiceuser"]) + self.quirkDisableAction.setText("Kill Quirk") self.quirksOff.setText(theme["main/menus/rclickchumlist/quirksoff"]) self.logchum.setText(theme["main/menus/rclickchumlist/viewlog"]) @@ -748,6 +752,14 @@ class PesterMemo(PesterConvo): msgbox.setStandardButtons(QtGui.QMessageBox.Ok) ret = msgbox.exec_() + def quirkDisable(self, op, msg): + chums = self.userlist.findItems(op, QtCore.Qt.MatchFlags(0)) + for c in chums: + if c.op: + if msg == self.mainwindow.profile().handle: + self.quirksOff.setChecked(True) + self.applyquirks = False + @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) def userPresentChange(self, handle, channel, update): h = unicode(handle) @@ -887,6 +899,7 @@ class PesterMemo(PesterConvo): 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 == "-o": @@ -923,6 +936,7 @@ class PesterMemo(PesterConvo): 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 == "+v": @@ -1011,6 +1025,13 @@ class PesterMemo(PesterConvo): return currentHandle = unicode(self.userlist.currentItem().text()) self.mainwindow.setChannelMode.emit(self.channel, "+v", currentHandle) + @QtCore.pyqtSlot() + def killQuirkUser(self): + if not self.userlist.currentItem(): + return + currentHandle = unicode(self.userlist.currentItem().text()) + self.mainwindow.killSomeQuirks.emit(self.channel, currentHandle) + def resetSlider(self, time, send=True): self.timeinput.setText(delta2txt(time)) self.timeinput.setSlider() diff --git a/oyoyo/helpers.py b/oyoyo/helpers.py index a300f4f..c82ec9c 100644 --- a/oyoyo/helpers.py +++ b/oyoyo/helpers.py @@ -47,6 +47,12 @@ def mode(cli, channel, mode, options=None): cmd += " %s" % (options) cli.send(cmd) +def ctcp(cli, handle, cmd, msg=""): + cli.send("PRIVMSG", handle, "\x01%s %s\x01" % (cmd, msg)) + +def ctcp_reply(cli, handle, cmd, msg=""): + notice(cli, str(handle), "\x01%s %s\x01" % (cmd.upper(), msg)) + def msgrandom(cli, choices, dest, user=None): o = "%s: " % user if user else "" o += random.choice(choices) diff --git a/pesterchum.py b/pesterchum.py index 2cb08a3..ed42195 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -2201,6 +2201,14 @@ class PesterWindow(MovingWindow): if self.memos[c]: self.memos[c].timeUpdate(h, cmd) + @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + def quirkDisable(self, channel, msg, op): + (c, msg, op) = (unicode(channel), unicode(msg), unicode(op)) + if not self.memos.has_key(c): + return + memo = self.memos[c] + memo.quirkDisable(op, msg) + @QtCore.pyqtSlot(QtCore.QString, PesterList) def updateNames(self, channel, names): c = unicode(channel) @@ -2946,6 +2954,7 @@ class PesterWindow(MovingWindow): gainAttention = QtCore.pyqtSignal(QtGui.QWidget) pingServer = QtCore.pyqtSignal() setAway = QtCore.pyqtSignal(bool) + killSomeQuirks = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) class PesterTray(QtGui.QSystemTrayIcon): def __init__(self, icon, mainwindow, parent): @@ -3106,6 +3115,8 @@ class MainProgram(QtCore.QObject): 'inviteChum(QString, QString)'), ('pingServer()', 'pingServer()'), ('setAway(bool)', 'setAway(bool)'), + ('killSomeQuirks(QString, QString)', + 'killSomeQuirks(QString, QString)'), ('reconnectIRC()', 'reconnectIRC()') ] # IRC --> Main window @@ -3141,7 +3152,9 @@ class MainProgram(QtCore.QObject): ('cannotSendToChan(QString, QString)', 'cannotSendToChan(QString, QString)'), ('tooManyPeeps()', - 'tooManyPeeps()') + 'tooManyPeeps()'), + ('quirkDisable(QString, QString, QString)', + 'quirkDisable(QString, QString, QString)') ] def connectWidgets(self, irc, widget): self.connect(irc, QtCore.SIGNAL('finished()'),