From 7b018e09060ca6c52824fe096fac0e418b2c73c7 Mon Sep 17 00:00:00 2001 From: karxi Date: Sat, 10 Dec 2016 19:49:58 -0500 Subject: [PATCH] Minor idle cleanup --- convo.py | 3 +-- pesterchum.py | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/convo.py b/convo.py index 2bec2ca..45a7050 100644 --- a/convo.py +++ b/convo.py @@ -406,8 +406,7 @@ class PesterText(QtGui.QTextEdit): window.chatlog.log(parent.chum.handle, lexmsg) else: if ((window.idler.auto or window.idler.manual) and parent.chumopen - and chum.handle.lower() not in ('nickserv', 'chanserv', - 'hostserv')): + and not parent.isBot(handle)): idlethreshhold = 60 if (not hasattr(self, 'lastmsg')) or \ datetime.now() - self.lastmsg > timedelta(0,idlethreshhold): diff --git a/pesterchum.py b/pesterchum.py index 899c4b2..a0ce772 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -2051,7 +2051,6 @@ class PesterWindow(MovingWindow): # karxi: TODO: Need to consider sticking an idle-setter here. @QtCore.pyqtSlot() def checkIdle(self): - # TODO: Streamline this later, because ew. newpos = QtGui.QCursor.pos() oldpos = self.idler.pos # Save the new position. @@ -2094,7 +2093,7 @@ class PesterWindow(MovingWindow): # might affect, but I've been using it for months and haven't # noticed any issues.... handle = convo.chum.handle - if handle.lower() in ("nickserv", "chanserv", "memoserv"): + if self.isBot(handle): # Don't send these idle messages. continue # karxi: Now we just use 'handle' instead of 'h'. @@ -2103,6 +2102,12 @@ class PesterWindow(MovingWindow): convo.textArea.append(convertTags(msg)) self.chatlog.log(handle, msg) self.sendMessage.emit("PESTERCHUM:IDLE", handle) + + # Presented here so it can be called by other scripts. + @staticmethod + def isBot(handle): + return handle.upper() in BOTNAMES + @QtCore.pyqtSlot() def importExternalConfig(self): f = QtGui.QFileDialog.getOpenFileName(self)