diff --git a/console.py b/console.py index b9f8d1d..68a37fd 100644 --- a/console.py +++ b/console.py @@ -1,3 +1,4 @@ +""" # vim: set autoindent ts=4 sts=4 sw=4 textwidth=79 expandtab: # -*- coding=UTF-8; tab-width: 4 -*- # import os @@ -550,3 +551,4 @@ class ConsoleInput(QtWidgets.QLineEdit): parent.text.area.keyPressEvent(event) else: super(ConsoleInput, self).keyPressEvent(event) +""" diff --git a/convo.py b/convo.py index 612267e..7de6644 100644 --- a/convo.py +++ b/convo.py @@ -390,6 +390,7 @@ class PesterText(QtWidgets.QTextEdit): self.textSelected = False self.copyAvailable[bool].connect(self.textReady) self.urls = {} + self.lastmsg = None for k in smiledict: self.addAnimation( QtCore.QUrl("smilies/%s" % (smiledict[k])), @@ -549,9 +550,13 @@ class PesterText(QtWidgets.QTextEdit): and not parent.isBot(chum.handle) ): idlethreshhold = 60 - if ( - not hasattr(self, "lastmsg") - ) or datetime.now() - self.lastmsg > timedelta(0, idlethreshhold): + do_idle_send = False + if self.lastmsg is None: + do_idle_send = True + else: + if datetime.now() - self.lastmsg > timedelta(0, idlethreshhold): + do_idle_send = True + if do_idle_send: verb = window.theme["convo/text/idle"] idlemsg = me.idlemsg(systemColor, verb) parent.textArea.append(convertTags(idlemsg)) @@ -995,7 +1000,7 @@ class PesterConvo(QtWidgets.QFrame): def closeEvent(self, event): self.mainwindow.waitingMessages.messageAnswered(self.title()) - for movie in self.textArea.urls: + for movie in self.textArea.urls.copy(): movie.setFileName("") # Required, sometimes, for some reason. . . movie.stop() del movie diff --git a/memos.py b/memos.py index a3af349..005896d 100644 --- a/memos.py +++ b/memos.py @@ -398,12 +398,7 @@ class MemoText(PesterText): # new chum! time current newtime = timedelta(0) time = TimeTracker(newtime) - - # 'handle' undefined? - try: - parent.times[handle] = time - except: - parent.times[chum.handle] = time + parent.times[chum.handle] = time else: time = parent.time diff --git a/ostools.py b/ostools.py index 7b94d61..e598184 100644 --- a/ostools.py +++ b/ostools.py @@ -1,7 +1,6 @@ import os import sys import ctypes -import platform try: from PyQt6.QtCore import QStandardPaths @@ -26,20 +25,6 @@ def isOSXBundle(): return isOSX() and (os.path.abspath(".").find(".app") != -1) -def isOSXLeopard(): - return isOSX() and platform.mac_ver()[0].startswith("10.5") - - -def osVer(): - if isWin32(): - return " ".join(platform.win32_ver()) - elif isOSX(): - ver = platform.mac_ver() - return " ".join((ver[0], " (", ver[2], ")")) - elif isLinux(): - return " ".join(platform.linux_distribution()) - - def isRoot(): """Return True if running with elevated privileges.""" # Windows diff --git a/oyoyo/client.py b/oyoyo/client.py index e5f1689..0a0adcb 100644 --- a/oyoyo/client.py +++ b/oyoyo/client.py @@ -100,7 +100,7 @@ class IRCClient: self.username = None self.host = None self.port = None - self.connect_cb = None + #self.connect_cb = None self.timeout = None self.blocking = None self.ssl = None @@ -273,8 +273,8 @@ class IRCClient: helpers.nick(self, self.nick) helpers.user(self, self.username, self.realname) - if self.connect_cb: - self.connect_cb(self) + #if self.connect_cb: + # self.connect_cb(self) def conn(self): """returns a generator object.""" @@ -337,11 +337,7 @@ class IRCClient: PchumLog.warning("conn exception %s in %s" % (e, self)) if self._end: break - try: # a little dance of compatibility to get the errno - errno = e.errno - except AttributeError: - errno = e[0] - if not self.blocking and errno == 11: + if not self.blocking and e.errno == 11: pass else: raise e diff --git a/oyoyo/helpers.py b/oyoyo/helpers.py index 6dbb897..1d142cf 100644 --- a/oyoyo/helpers.py +++ b/oyoyo/helpers.py @@ -115,35 +115,24 @@ def identify(cli, passwd, authuser="NickServ"): def quit(cli, msg): cli.send("QUIT %s" % (msg)) +def nick(cli, nick): + cli.send(f"NICK", nick) def user(cli, username, realname): cli.send("USER", username, "0", "*", ":" + realname) +def join(cli, channel): + """Protocol potentially allows multiple channels or keys.""" + cli.send("JOIN", channel) -_simple = ( - "join", - "part", - "nick", - "notice", - "invite", -) +def part(cli, channel): + cli.send("PART", channel) +def notice(cli, target, text): + cli.send("NOTICE", target, text) -def _addsimple(): - import sys - - def simplecmd(cmd_name): - def f(cli, *args): - cli.send(cmd_name, *args) - - return f - - m = sys.modules[__name__] - for t in _simple: - setattr(m, t, simplecmd(t.upper())) - - -_addsimple() +def invite(cli, nick, channel): + cli.send("INVITE", nick, channel) def _addNumerics(): diff --git a/pesterchum.py b/pesterchum.py index 6de0ccf..7d08f17 100755 --- a/pesterchum.py +++ b/pesterchum.py @@ -1461,6 +1461,7 @@ class PesterWindow(MovingWindow): self.menu.setNativeMenuBar(False) self.menu.setObjectName("mainmenu") + """ if self.theme.has_key("main/menus/client/console"): self.console = AttrDict( dict( @@ -1498,7 +1499,8 @@ class PesterWindow(MovingWindow): # ~self.connect(self.console.shortcuts.curwgt, # ~ QtCore.SIGNAL('activate()'), self.console. self.console.is_open = False - + """ + filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"]) self.filemenu = filemenu filemenu.addAction(opts) @@ -2003,6 +2005,7 @@ class PesterWindow(MovingWindow): self.tabmemo = MemoTabWindow(self) self.tabmemo.windowClosed.connect(self.memoTabsClosed) + """ @QtCore.pyqtSlot() def toggleConsole(self): if not _CONSOLE: @@ -2070,6 +2073,7 @@ class PesterWindow(MovingWindow): self.console.is_open = False self.console.window = None PchumLog.info("Console closed.") + """ def newMemo(self, channel, timestr, secret=False, invite=False): if channel == "#pesterchum": @@ -2215,10 +2219,10 @@ class PesterWindow(MovingWindow): ## else: ## self.console.action.setText("Console") # has_key doesn't work out here for some reason, possibly because of inherits? - try: - self.console.action.setText(self.theme["main/menus/client/console"]) - except: - self.console.action.setText("Console") + #try: + # self.console.action.setText(self.theme["main/menus/client/console"]) + #except: + # self.console.action.setText("Console") try: self.reportBugAction.setText(self.theme["main/menus/help/reportbug"]) diff --git a/profile.py b/profile.py index 90678f9..f93c6d9 100644 --- a/profile.py +++ b/profile.py @@ -225,15 +225,12 @@ with a backup from: %s" pzip.writestr(x, f.read()) PchumLog.info("Updated backups-%s." % current_backup) - except OSError as e: - PchumLog.warning("Failed to make backup, no permission?") - PchumLog.warning(e) except shutil.Error as e: - PchumLog.warning("Failed to make backup, shutil error?") - PchumLog.warning(e) + PchumLog.warning(f"Failed to make backup, shutil error?\n{e}") except zipfile.BadZipFile as e: - PchumLog.warning("Failed to make backup, BadZipFile?") - PchumLog.warning(e) + PchumLog.warning(f"Failed to make backup, BadZipFile?\n{e}") + except OSError as e: + PchumLog.warning(f"Failed to make backup, no permission?\n{e}") def chums(self): if "chums" not in self.config: @@ -736,6 +733,7 @@ class userProfile(object): return self.mentions def setMentions(self, mentions): + i = None try: for (i, m) in enumerate(mentions): re.compile(m)