diff --git a/convo.py b/convo.py index a7a452d..488a96c 100644 --- a/convo.py +++ b/convo.py @@ -1,21 +1,23 @@ import logging import logging.config -import ostools -_datadir = ostools.getDataDir() -logging.config.fileConfig(_datadir + "logging.ini") -PchumLog = logging.getLogger('pchumLogger') from string import Template from time import strftime from datetime import datetime, timedelta + from PyQt6 import QtCore, QtGui, QtWidgets +import ostools from dataobjs import PesterHistory -from parsetools import convertTags, lexMessage, mecmd, colorBegin, colorEnd, \ - smiledict#, img2smiley +from parsetools import (convertTags, lexMessage, mecmd, colorBegin, colorEnd, + smiledict) import parsetools - from pnc.dep.attrdict import AttrDict + +_datadir = ostools.getDataDir() +logging.config.fileConfig(_datadir + "logging.ini") +PchumLog = logging.getLogger('pchumLogger') + class PesterTabWindow(QtWidgets.QFrame): def __init__(self, mainwindow, parent=None, convo="convo"): super(PesterTabWindow, self).__init__(parent) @@ -206,7 +208,9 @@ class PesterTabWindow(QtWidgets.QFrame): return False def notifyNewMessage(self, handle): i = self.tabIndices[handle] - self.tabs.setTabTextColor(i, QtGui.QColor(self.mainwindow.theme["%s/tabs/newmsgcolor" % (self.type)])) + self.tabs.setTabTextColor(i, + QtGui.QColor(self.mainwindow.theme["%s/tabs/newmsgcolor" + % (self.type)])) convo = self.convos[handle] # Create a function for the icon to use # TODO: Let us disable this. @@ -225,7 +229,9 @@ class PesterTabWindow(QtWidgets.QFrame): self.resize(*theme["convo/size"]) self.setStyleSheet(theme["convo/tabwindow/style"]) self.tabs.setShape(QtWidgets.QTabBar.Shape(theme["convo/tabs/tabstyle"])) - self.tabs.setStyleSheet("QTabBar::tab{ %s } QTabBar::tab:selected { %s }" % (theme["convo/tabs/style"], theme["convo/tabs/selectedstyle"])) + self.tabs.setStyleSheet("QTabBar::tab{ %s } QTabBar::tab:selected { %s }" + % (theme["convo/tabs/style"], + theme["convo/tabs/selectedstyle"])) def changeTheme(self, theme): self.initTheme(theme) @@ -382,7 +388,20 @@ class PesterText(QtWidgets.QTextEdit): self.textSelected = ready def initTheme(self, theme): if "convo/scrollbar" in theme: - self.setStyleSheet("QTextEdit { %s } QScrollBar:vertical { %s } QScrollBar::handle:vertical { %s } QScrollBar::add-line:vertical { %s } QScrollBar::sub-line:vertical { %s } QScrollBar:up-arrow:vertical { %s } QScrollBar:down-arrow:vertical { %s }" % (theme["convo/textarea/style"], theme["convo/scrollbar/style"], theme["convo/scrollbar/handle"], theme["convo/scrollbar/downarrow"], theme["convo/scrollbar/uparrow"], theme["convo/scrollbar/uarrowstyle"], theme["convo/scrollbar/darrowstyle"] )) + self.setStyleSheet("QTextEdit { %s }" + "QScrollBar:vertical { %s }" + "QScrollBar::handle:vertical { %s }" + "QScrollBar::add-line:vertical { %s }" + "QScrollBar::sub-line:vertical { %s }" + "QScrollBar:up-arrow:vertical { %s }" + "QScrollBar:down-arrow:vertical { %s }" + % (theme["convo/textarea/style"], + theme["convo/scrollbar/style"], + theme["convo/scrollbar/handle"], + theme["convo/scrollbar/downarrow"], + theme["convo/scrollbar/uparrow"], + theme["convo/scrollbar/uarrowstyle"], + theme["convo/scrollbar/darrowstyle"])) else: self.setStyleSheet("QTextEdit { %s }" % (theme["convo/textarea/style"])) def addMessage(self, lexmsg, chum): @@ -453,7 +472,10 @@ class PesterText(QtWidgets.QTextEdit): lexmsg[0:0] = [colorBegin("" % (color), color), "%s: " % (initials)] lexmsg.append(colorEnd("")) - self.append("" + time + convertTags(lexmsg) + "") + self.append("" + + time + + convertTags(lexmsg) + + "") #self.append('' # + '' # + '' @@ -512,7 +534,8 @@ class PesterText(QtWidgets.QTextEdit): if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier: QtWidgets.QApplication.clipboard().setText(url) else: - QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.ParsingMode.TolerantMode)) + QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, + QtCore.QUrl.ParsingMode.TolerantMode)) QtWidgets.QTextEdit.mousePressEvent(self, event) def mouseMoveEvent(self, event): QtWidgets.QTextEdit.mouseMoveEvent(self, event) @@ -569,7 +592,9 @@ class PesterConvo(QtWidgets.QFrame): self.mainwindow = mainwindow theme = self.mainwindow.theme self.resize(*theme["convo/size"]) - self.setStyleSheet("QtWidgets.QFrame#%s { %s }" % (chum.handle, theme["convo/style"])) + self.setStyleSheet("QtWidgets.QFrame#%s { %s }" + % (chum.handle, + theme["convo/style"])) self.setWindowIcon(self.icon()) self.setWindowTitle(self.title()) @@ -577,10 +602,12 @@ class PesterConvo(QtWidgets.QFrame): self.chumLabel = QtWidgets.QLabel(t.safe_substitute(handle=chum.handle), self) self.chumLabel.setStyleSheet(self.mainwindow.theme["convo/chumlabel/style"]) - self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]]) + self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] + | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]]) self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"]) self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"]) - self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding)) + self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, + QtWidgets.QSizePolicy.Policy.MinimumExpanding)) self.textArea = PesterText(self.mainwindow.theme, self) self.textInput = PesterInput(self.mainwindow.theme, self) self.textInput.setFocus() @@ -909,7 +936,10 @@ class PesterConvo(QtWidgets.QFrame): @QtCore.pyqtSlot() def openChumLogs(self): currentChum = self.chum.handle - self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) + self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, + self.mainwindow.config, + self.mainwindow.theme, + self.mainwindow) self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.raise_() diff --git a/dataobjs.py b/dataobjs.py index c0c0460..8c85521 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -202,9 +202,9 @@ class pesterQuirks(object): recvparts.append(q.apply(part)) # Reconstruct and update string. string = '' - print("excludes: " + str(excludes)) - print("sendparts: " + str(sendparts)) - print("recvparts: " + str(recvparts)) + #print("excludes: " + str(excludes)) + #print("sendparts: " + str(sendparts)) + #print("recvparts: " + str(recvparts)) for part in range(0, len(excludes)): string += recvparts[part] string += excludes[part].group() @@ -235,10 +235,6 @@ class pesterQuirks(object): string = q.apply(string) elif q.type == 'suffix' and lastStr: string = q.apply(string) - - - - newlist.append(string) final = [] for n in newlist: diff --git a/memos.py b/memos.py index f25b71f..1e3f18b 100644 --- a/memos.py +++ b/memos.py @@ -11,8 +11,8 @@ import parsetools from dataobjs import PesterProfile, PesterHistory from generic import PesterIcon, RightClickList, mysteryTime from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow -from parsetools import convertTags, timeProtocol, \ - lexMessage, colorBegin, mecmd, smiledict +from parsetools import (convertTags, timeProtocol, lexMessage, colorBegin, + mecmd, smiledict) from logviewer import PesterLogViewer _datadir = ostools.getDataDir() @@ -248,7 +248,8 @@ class MemoTabWindow(PesterTabWindow): newindex = self.tabs.addTab(convo.channel) self.tabIndices[convo.channel] = newindex self.tabs.setCurrentIndex(newindex) - self.tabs.setTabIcon(newindex, PesterIcon(self.mainwindow.theme["memos/memoicon"])) + self.tabs.setTabIcon(newindex, + PesterIcon(self.mainwindow.theme["memos/memoicon"])) def updateBlocked(self): pass def updateMood(self): @@ -275,19 +276,35 @@ class MemoText(PesterText): self.copyAvailable[bool].connect(self.textReady) self.urls = {} for k in smiledict: - self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])) + self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), + "smilies/%s" % (smiledict[k])) #self.mainwindow.animationSetting[bool].connect(self.animateChanged) def initTheme(self, theme): if "memos/scrollbar" in theme: - self.setStyleSheet("QTextEdit { %s } QScrollBar:vertical { %s } QScrollBar::handle:vertical { %s } QScrollBar::add-line:vertical { %s } QScrollBar::sub-line:vertical { %s } QScrollBar:up-arrow:vertical { %s } QScrollBar:down-arrow:vertical { %s }" % (theme["memos/textarea/style"], theme["memos/scrollbar/style"], theme["memos/scrollbar/handle"], theme["memos/scrollbar/downarrow"], theme["memos/scrollbar/uparrow"], theme["memos/scrollbar/uarrowstyle"], theme["memos/scrollbar/darrowstyle"] )) + self.setStyleSheet("QTextEdit { %s }" + "QScrollBar:vertical { %s }" + "QScrollBar::handle:vertical { %s }" + "QScrollBar::add-line:vertical { %s }" + "QScrollBar::sub-line:vertical { %s }" + "QScrollBar:up-arrow:vertical { %s }" + "QScrollBar:down-arrow:vertical { %s }" + % (theme["memos/textarea/style"], + theme["memos/scrollbar/style"], + theme["memos/scrollbar/handle"], + theme["memos/scrollbar/downarrow"], + theme["memos/scrollbar/uparrow"], + theme["memos/scrollbar/uarrowstyle"], + theme["memos/scrollbar/darrowstyle"] )) else: self.setStyleSheet("QTextEdit { %s }" % theme["memos/textarea/style"]) # So it doesn't inherit the memo's background image. # Fixes floating "PESTERLOG:" try: - self.setStyleSheet(self.styleSheet() + " QMenu{" + theme["main/defaultwindow/style"] + "}") + self.setStyleSheet(self.styleSheet() + + ("QMenu{ %s }" + % theme["main/defaultwindow/style"])) except: pass @@ -343,7 +360,10 @@ class MemoText(PesterText): if time.isFirstTime(): grammar = time.getGrammar() - joinmsg = chum.memojoinmsg(systemColor, time.getTime(), grammar, window.theme["convo/text/joinmemo"]) + joinmsg = chum.memojoinmsg(systemColor, + time.getTime(), + grammar, + window.theme["convo/text/joinmemo"]) self.append(convertTags(joinmsg)) parent.mainwindow.chatlog.log(parent.channel, joinmsg) time.openCurrentTime() @@ -369,7 +389,6 @@ class MemoInput(PesterInput): # karxi: Because of the use of stylesheet_path, we don't have to rewrite # this code. # Neat, huh? - pass # So vim recognizes the end of this class class PesterMemo(PesterConvo): # TODO: Clean up inheritance between these!! The inits are ugly. @@ -382,7 +401,8 @@ class PesterMemo(PesterConvo): self.time = TimeTracker(txt2delta(timestr)) self.setWindowTitle(channel) self.channelLabel = QtWidgets.QLabel(self) - self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding)) + self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, + QtWidgets.QSizePolicy.Policy.Expanding)) self.textArea = MemoText(self.mainwindow.theme, self) self.textInput = MemoInput(self.mainwindow.theme, self) @@ -395,7 +415,8 @@ class PesterMemo(PesterConvo): self.userlist = RightClickList(self) - self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)) + self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, + QtWidgets.QSizePolicy.Policy.Expanding)) self.userlist.optionsMenu = QtWidgets.QMenu(self) self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self) self.pesterChumAction.triggered.connect(self.newPesterSlot) @@ -538,7 +559,11 @@ class PesterMemo(PesterConvo): p = self.mainwindow.profile() timeGrammar = self.time.getGrammar() systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"]) - msg = p.memoopenmsg(systemColor, self.time.getTime(), timeGrammar, self.mainwindow.theme["convo/text/openmemo"], self.channel) + msg = p.memoopenmsg(systemColor, + self.time.getTime(), + timeGrammar, + self.mainwindow.theme["convo/text/openmemo"], + self.channel) self.time.openCurrentTime() self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) @@ -558,11 +583,13 @@ class PesterMemo(PesterConvo): if self.userlist.isHidden(): self.userlist.show() self.miniUserlist.setText(">\n>") - self.miniUserlist.setStyleSheet("%s border-width: 2px 0px 2px 2px;" % self.miniUserlist.styleSheet()) + self.miniUserlist.setStyleSheet("%s border-width: 2px 0px 2px 2px;" + % self.miniUserlist.styleSheet()) else: self.userlist.hide() self.miniUserlist.setText("<\n<") - self.miniUserlist.setStyleSheet("%s border-width: 2px;" % self.miniUserlist.styleSheet()) + self.miniUserlist.setStyleSheet("%s border-width: 2px;" + % self.miniUserlist.styleSheet()) def title(self): return self.channel @@ -603,25 +630,63 @@ class PesterMemo(PesterConvo): else: self.channelLabel.setText(t.safe_substitute(channel=self.channel)) self.channelLabel.setStyleSheet(theme["memos/label/style"]) - self.channelLabel.setAlignment(self.aligndict["h"][theme["memos/label/align/h"]] | self.aligndict["v"][theme["memos/label/align/v"]]) + self.channelLabel.setAlignment(self.aligndict["h"][theme["memos/label/align/h"]] + | self.aligndict["v"][theme["memos/label/align/v"]]) self.channelLabel.setMaximumHeight(theme["memos/label/maxheight"]) self.channelLabel.setMinimumHeight(theme["memos/label/minheight"]) self.userlist.optionsMenu.setStyleSheet(theme["main/defaultwindow/style"]) scrolls = "width: 12px; height: 12px; border: 0; padding: 0;" if "main/chums/scrollbar" in theme: - self.userlist.setStyleSheet("QListWidget { %s } QScrollBar { %s } QScrollBar::handle { %s } QScrollBar::add-line { %s } QScrollBar::sub-line { %s } QScrollBar:up-arrow { %s } QScrollBar:down-arrow { %s }" % (theme["memos/userlist/style"], theme["main/chums/scrollbar/style"] + scrolls, theme["main/chums/scrollbar/handle"], theme["main/chums/scrollbar/downarrow"], theme["main/chums/scrollbar/uparrow"], theme["main/chums/scrollbar/uarrowstyle"], theme["main/chums/scrollbar/darrowstyle"] )) + self.userlist.setStyleSheet("QListWidget { %s }" + "QScrollBar { %s }" + "QScrollBar::handle { %s }" + "QScrollBar::add-line { %s }" + "QScrollBar::sub-line { %s }" + "QScrollBar:up-arrow { %s }" + "QScrollBar:down-arrow { %s }" + % (theme["memos/userlist/style"], + theme["main/chums/scrollbar/style"] + scrolls, + theme["main/chums/scrollbar/handle"], + theme["main/chums/scrollbar/downarrow"], + theme["main/chums/scrollbar/uparrow"], + theme["main/chums/scrollbar/uarrowstyle"], + theme["main/chums/scrollbar/darrowstyle"])) elif "convo/scrollbar" in theme: - self.userlist.setStyleSheet("QListWidget { %s } QScrollBar { %s } QScrollBar::handle { %s } QScrollBar::add-line { %s } QScrollBar::sub-line { %s } QScrollBar:up-arrow { %s } QScrollBar:down-arrow { %s }" % (theme["memos/userlist/style"], theme["convo/scrollbar/style"] + scrolls, theme["convo/scrollbar/handle"], "display:none;", "display:none;", "display:none;", "display:none;" )) + self.userlist.setStyleSheet("QListWidget { %s }" + "QScrollBar { %s }" + "QScrollBar::handle { %s }" + "QScrollBar::add-line { %s }" + "QScrollBar::sub-line { %s }" + "QScrollBar:up-arrow { %s }" + "QScrollBar:down-arrow { %s }" + % (theme["memos/userlist/style"], + theme["convo/scrollbar/style"] + scrolls, + theme["convo/scrollbar/handle"], + "display: none;", + "display: none;", + "display: none;", + "display: none;")) else: - self.userlist.setStyleSheet("QListWidget { %s } QScrollBar { %s } QScrollBar::handle { %s }" % (theme["memos/userlist/style"], scrolls, "background-color: black;")) + self.userlist.setStyleSheet("QListWidget { %s }" + "QScrollBar { %s }" + "QScrollBar::handle { %s }" + % (theme["memos/userlist/style"], + scrolls, + "background-color: black;")) self.userlist.setFixedWidth(theme["memos/userlist/width"]) if self.userlist.isHidden(): borders = "border-width: 2px;" else: borders = "border-width: 2px 0px 2px 2px;" - self.miniUserlist.setStyleSheet("%s padding: 0px; margin: 0px; margin-left: 5px; width: 10px; height: 90px; %s" % (theme["memos/userlist/style"], borders)) + self.miniUserlist.setStyleSheet("padding: 0px;" + "margin: 0px;" + "margin-left: 5px;" + "width: 10px;" + "height: 90px;" + + borders + + theme["memos/userlist/style"]) self.addchumAction.setText(theme["main/menus/rclickchumlist/addchum"]) self.banuserAction.setText(theme["main/menus/rclickchumlist/banuser"]) @@ -639,7 +704,12 @@ class PesterMemo(PesterConvo): self.timeinput.setFixedWidth(theme["memos/time/text/width"]) self.timeinput.setStyleSheet(theme["memos/time/text/style"]) - slidercss = "QSlider { %s } QSlider::groove { %s } QSlider::handle { %s }" % (theme["memos/time/slider/style"], theme["memos/time/slider/groove"], theme["memos/time/slider/handle"]) + slidercss = ("QSlider { %s }" + "Slider::groove { %s }" + "QSlider::handle { %s }" + % (theme["memos/time/slider/style"], + theme["memos/time/slider/groove"], + theme["memos/time/slider/handle"])) self.timeslider.setStyleSheet(slidercss) larrow = PesterIcon(self.mainwindow.theme["memos/time/arrows/left"]) @@ -1012,7 +1082,8 @@ class PesterMemo(PesterConvo): self.modes = "+" + "".join(chanmodes) if self.mainwindow.advanced: t = Template(self.mainwindow.theme["memos/label/text"]) - self.channelLabel.setText(t.safe_substitute(channel=self.channel) + "(%s)" % (self.modes)) + self.channelLabel.setText(t.safe_substitute(channel=self.channel) + + "(%s)" % (self.modes)) def timeUpdate(self, handle, cmd): window = self.mainwindow @@ -1051,7 +1122,9 @@ class PesterMemo(PesterConvo): self.times[handle].setCurrent(close) grammar = self.times[handle].getGrammar() self.times[handle].removeTime(close) - msg = chum.memoclosemsg(systemColor, grammar, window.theme["convo/text/closememo"]) + msg = chum.memoclosemsg(systemColor, + grammar, + window.theme["convo/text/closememo"]) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) elif timed not in self.times[handle]: @@ -1097,9 +1170,11 @@ class PesterMemo(PesterConvo): else: self.close() msgbox = QtWidgets.QMessageBox() - msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.mainwindow.theme["main/defaultwindow/style"]) msgbox.setText("%s: Invites only!" % (c)) - msgbox.setInformativeText("This channel is invite-only. You must get an invitation from someone on the inside before entering.") + msgbox.setInformativeText("This channel is invite-only. " + "You must get an invitation from someone on the inside before entering.") msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.exec() @@ -1115,7 +1190,8 @@ class PesterMemo(PesterConvo): else: self.close() msgbox = QtWidgets.QMessageBox() - msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.mainwindow.theme["main/defaultwindow/style"]) msgbox.setText("%s: D: CANT JOIN MEMO!!!" % (c)) msgbox.setInformativeText(reason) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) @@ -1216,7 +1292,9 @@ class PesterMemo(PesterConvo): if update == "netsplit": if not hasattr(self, "netsplit"): self.netsplit = [] - QtCore.QTimer.singleShot(1500, self, QtCore.SLOT('dumpNetsplit()')) + QtCore.QTimer.singleShot(1500, + self, + QtCore.SLOT('dumpNetsplit()')) for c in chums: chum = PesterProfile(h) self.userlist.takeItem(self.userlist.row(c)) @@ -1226,17 +1304,22 @@ class PesterMemo(PesterConvo): while self.times[h].getTime() is not None: t = self.times[h] grammar = t.getGrammar() - allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number)) + allinitials.append("%s%s%s" % (grammar.pcf, + chum.initials(), + grammar.number)) self.times[h].removeTime(t.getTime()) if update == "netsplit": self.netsplit.extend(allinitials) else: - msg = chum.memoclosemsg(systemColor, allinitials, self.mainwindow.theme["convo/text/closememo"]) + msg = chum.memoclosemsg(systemColor, + allinitials, + self.mainwindow.theme["convo/text/closememo"]) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) if update == "nick": self.addUser(newnick) - newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlag.MatchExactly) + newchums = self.userlist.findItems(newnick, + QtCore.Qt.MatchFlag.MatchExactly) for nc in newchums: for c in chums: nc.founder = c.founder @@ -1277,7 +1360,8 @@ class PesterMemo(PesterConvo): if chum is self.mainwindow.profile(): # are you next? msgbox = QtWidgets.QMessageBox() - msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.mainwindow.theme["main/defaultwindow/style"]) msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"]) # Add ban(kick) reason @@ -1319,7 +1403,11 @@ class PesterMemo(PesterConvo): self.mainwindow.joinChannel.emit(self.channel) me = self.mainwindow.profile() self.time.openCurrentTime() - msg = me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel) + msg = me.memoopenmsg(systemColor, + self.time.getTime(), + self.time.getGrammar(), + self.mainwindow.theme["convo/text/openmemo"], + self.channel) self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) elif ret == QtWidgets.QMessageBox.StandardButton.Cancel: @@ -1349,9 +1437,10 @@ class PesterMemo(PesterConvo): elif update == "+o": if self.mainwindow.config.opvoiceMessages(): (chum, opchum, opgrammar) = self.chumOPstuff(h, op) - PchumLog.debug("chum.handle = %s\nopchum.handle = %s\nopgrammar = %s\n systemColor = %s\n" % (chum.handle, opchum.handle, opgrammar, systemColor)) + #PchumLog.debug("chum.handle = %s\nopchum.handle = %s\nopgrammar = %s\n systemColor = %s\n" + # % (chum.handle, opchum.handle, opgrammar, systemColor)) msg = chum.memoopmsg(opchum, opgrammar, systemColor) - PchumLog.debug("post memoopmsg") + #PchumLog.debug("post memoopmsg") self.textArea.append(convertTags(msg)) self.mainwindow.chatlog.log(self.channel, msg) for c in chums: @@ -1469,7 +1558,9 @@ class PesterMemo(PesterConvo): if not self.userlist.currentItem(): return currentHandle = str(self.userlist.currentItem().text()) - (reason, ok) = QtWidgets.QInputDialog.getText(self, "Ban User", "Enter the reason you are banning this user (optional):") + (reason, ok) = QtWidgets.QInputDialog.getText(self, + "Ban User", + "Enter the reason you are banning this user (optional):") if ok: self.mainwindow.kickUser.emit("%s:%s" % (currentHandle, reason), self.channel) @QtCore.pyqtSlot() @@ -1500,7 +1591,10 @@ class PesterMemo(PesterConvo): @QtCore.pyqtSlot() def openChumLogs(self): currentChum = self.channel - self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) + self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, + self.mainwindow.config, + self.mainwindow.theme, + self.mainwindow) self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.raise_() @@ -1511,7 +1605,9 @@ class PesterMemo(PesterConvo): if not hasattr(self, 'invitechums'): self.invitechums = None if not self.invitechums: - (chum, ok) = QtWidgets.QInputDialog.getText(self, "Invite to Chat", "Enter the chumhandle of the user you'd like to invite:") + (chum, ok) = QtWidgets.QInputDialog.getText(self, + "Invite to Chat", + "Enter the chumhandle of the user you'd like to invite:") if ok: chum = str(chum) self.mainwindow.inviteChum.emit(chum, self.channel) @@ -1581,7 +1677,107 @@ class PesterMemo(PesterConvo): windowClosed = QtCore.pyqtSignal('QString') -timelist = ["0:00", "0:01", "0:02", "0:04", "0:06", "0:10", "0:14", "0:22", "0:30", "0:41", "1:00", "1:34", "2:16", "3:14", "4:13", "4:20", "5:25", "6:12", "7:30", "8:44", "10:25", "11:34", "14:13", "16:12", "17:44", "22:22", "25:10", "33:33", "42:00", "43:14", "50:00", "62:12", "75:00", "88:44", "100", "133", "143", "188", "200", "222", "250", "314", "333", "413", "420", "500", "600", "612", "888", "1000", "1025"] +timelist = ["0:00", + "0:01", + "0:02", + "0:04", + "0:06", + "0:10", + "0:14", + "0:22", + "0:30", + "0:41", + "1:00", + "1:34", + "2:16", + "3:14", + "4:13", + "4:20", + "5:25", + "6:12", + "7:30", + "8:44", + "10:25", + "11:34", + "14:13", + "16:12", + "17:44", + "22:22", + "25:10", + "33:33", + "42:00", + "43:14", + "50:00", + "62:12", + "75:00", + "88:44", + "100", + "133", + "143", + "188", + "200", + "222", + "250", + "314", + "333", + "413", + "420", + "500", + "600", + "612", + "888", + "1000", + "1025"] -timedlist = [timedelta(0), timedelta(0, 60), timedelta(0, 120), timedelta(0, 240), timedelta(0, 360), timedelta(0, 600), timedelta(0, 840), timedelta(0, 1320), timedelta(0, 1800), timedelta(0, 2460), timedelta(0, 3600), timedelta(0, 5640), timedelta(0, 8160), timedelta(0, 11640), timedelta(0, 15180), timedelta(0, 15600), timedelta(0, 19500), timedelta(0, 22320), timedelta(0, 27000), timedelta(0, 31440), timedelta(0, 37500), timedelta(0, 41640), timedelta(0, 51180), timedelta(0, 58320), timedelta(0, 63840), timedelta(0, 80520), timedelta(1, 4200), timedelta(1, 34380), timedelta(1, 64800), timedelta(1, 69240), timedelta(2, 7200), timedelta(2, 51120), timedelta(3, 10800), timedelta(3, 60240), timedelta(4, 14400), timedelta(5, 46800), timedelta(5, 82800), timedelta(7, 72000), timedelta(8, 28800), timedelta(9, 21600), timedelta(10, 36000), timedelta(13, 7200), timedelta(13, 75600), timedelta(17, 18000), timedelta(17, 43200), timedelta(20, 72000), timedelta(25), timedelta(25, 43200), timedelta(37), timedelta(41, 57600), timedelta(42, 61200)] +timedlist = [timedelta(0), + timedelta(0, 60), + timedelta(0, 120), + timedelta(0, 240), + timedelta(0, 360), + timedelta(0, 600), + timedelta(0, 840), + timedelta(0, 1320), + timedelta(0, 1800), + timedelta(0, 2460), + timedelta(0, 3600), + timedelta(0, 5640), + timedelta(0, 8160), + timedelta(0, 11640), + timedelta(0, 15180), + timedelta(0, 15600), + timedelta(0, 19500), + timedelta(0, 22320), + timedelta(0, 27000), + timedelta(0, 31440), + timedelta(0, 37500), + timedelta(0, 41640), + timedelta(0, 51180), + timedelta(0, 58320), + timedelta(0, 63840), + timedelta(0, 80520), + timedelta(1, 4200), + timedelta(1, 34380), + timedelta(1, 64800), + timedelta(1, 69240), + timedelta(2, 7200), + timedelta(2, 51120), + timedelta(3, 10800), + timedelta(3, 60240), + timedelta(4, 14400), + timedelta(5, 46800), + timedelta(5, 82800), + timedelta(7, 72000), + timedelta(8, 28800), + timedelta(9, 21600), + timedelta(10, 36000), + timedelta(13, 7200), + timedelta(13, 75600), + timedelta(17, 18000), + timedelta(17, 43200), + timedelta(20, 72000), + timedelta(25), + timedelta(25, 43200), + timedelta(37), + timedelta(41, 57600), + timedelta(42, 61200)] diff --git a/menus.py b/menus.py index 63fd88f..d5eced6 100644 --- a/menus.py +++ b/menus.py @@ -1585,7 +1585,11 @@ class PesterUserlist(QtWidgets.QDialog): self.searchbox.setFocus() @QtCore.pyqtSlot() def updateUsers(self): - names = self.mainwindow.namesdb["#pesterchum"] + try: + names = self.mainwindow.namesdb["#pesterchum"] + except KeyError: + # Not in #pesterchum? + return self.userarea.clear() for n in names: if str(self.searchbox.text()) == "" or n.lower().find(str(self.searchbox.text()).lower()) != -1: diff --git a/oyoyo/cmdhandler.py b/oyoyo/cmdhandler.py index cdecb4b..8b334c0 100644 --- a/oyoyo/cmdhandler.py +++ b/oyoyo/cmdhandler.py @@ -107,9 +107,9 @@ class CommandHandler(object): try: f(*args) except TypeError as e: - logging.warning("Failed to pass command, did the server pass an unsupported paramater? " + str(e)) + logging.info("Failed to pass command, did the server pass an unsupported paramater? " + str(e)) except Exception as e: - logging.warning("Failed to pass command, %s" % str(e)) + logging.info("Failed to pass command, %s" % str(e)) @protected def __unhandled__(self, cmd, *args): diff --git a/pesterchum.py b/pesterchum.py index 4a3a2d4..33a54e8 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -12,18 +12,19 @@ QString = str if os.path.dirname(sys.argv[0]): os.chdir(os.path.dirname(sys.argv[0])) print("Usage: pesterchum.py [OPTIONS]") -print("Use -h/--help to see the available options.\nLogging is configured in logging.ini") +print("Use -h/--help to see the available options." + "\nLogging is configured in logging.ini") # Help if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]): print("Possible arguments:") help_arguments = (" -l, --logging\n Specify level of logging, possible values are:\n" - + " CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.\n" - + " The default value is WARNING.\n" - + " (See https://docs.python.org/3/library/logging.html)\n\n" - + " -s, --server\n Specify server override. (legacy)\n\n" - + " -p, --port\n Specify port override. (legacy)\n\n" - + " --advanced\n Enable advanced.\n\n" - + " --no-honk\n Disable honking.\n") + " CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.\n" + " The default value is WARNING.\n" + " (See https://docs.python.org/3/library/logging.html)\n\n" + " -s, --server\n Specify server override. (legacy)\n\n" + " -p, --port\n Specify port override. (legacy)\n\n" + " --advanced\n Enable advanced.\n\n" + " --no-honk\n Disable honking.\n") print(help_arguments) sys.exit() @@ -605,13 +606,16 @@ class chumArea(RightClickTree): #self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder) def getChums(self, handle): - chums = self.findItems(handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive) + chums = self.findItems(handle, QtCore.Qt.MatchFlag.MatchExactly + | QtCore.Qt.MatchFlag.MatchRecursive) return chums def showAllChums(self): for c in self.chums: chandle = c.handle - if not len(self.findItems(chandle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)): + if not len(self.findItems(chandle, + QtCore.Qt.MatchFlag.MatchExactly + | QtCore.Qt.MatchFlag.MatchRecursive)): #if True:# For if it doesn't work at all :/ chumLabel = chumListing(c, self.mainwindow) self.addItem(chumLabel) @@ -720,7 +724,9 @@ class chumArea(RightClickTree): if text.rfind(" (") != -1: text = text[0:text.rfind(" (")] curgroups.append(text) - if not self.findItems(chumLabel.handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive): + if not self.findItems(chumLabel.handle, + QtCore.Qt.MatchFlag.MatchExactly + | QtCore.Qt.MatchFlag.MatchRecursive): #if True:# For if it doesn't work at all :/ if chumLabel.chum.group not in curgroups: child_1 = QtWidgets.QTreeWidgetItem(["%s" % (chumLabel.chum.group)]) @@ -773,7 +779,9 @@ class chumArea(RightClickTree): if self.mainwindow.config.showOnlineNumbers(): self.showOnlineNumbers() else: # usually means this is now the trollslum - if not self.findItems(chumLabel.handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive): + if not self.findItems(chumLabel.handle, + QtCore.Qt.MatchFlag.MatchExactly + | QtCore.Qt.MatchFlag.MatchRecursive): #if True:# For if it doesn't work at all :/ self.topLevelItem(0).addChild(chumLabel) self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder) @@ -933,7 +941,10 @@ class chumArea(RightClickTree): if not currentChum: return currentChum = currentChum.text(0) - self.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) + self.pesterlogviewer = PesterLogViewer(currentChum, + self.mainwindow.config, + self.mainwindow.theme, + self.mainwindow) self.pesterlogviewer.rejected.connect(self.closeActiveLog) self.pesterlogviewer.show() self.pesterlogviewer.raise_() @@ -947,7 +958,9 @@ class chumArea(RightClickTree): currentChum = self.currentItem() if not currentChum: return - (notes, ok) = QtWidgets.QInputDialog.getText(self, "Notes", "Enter your notes...") + (notes, ok) = QtWidgets.QInputDialog.getText(self, + "Notes", + "Enter your notes...") if ok: notes = str(notes) self.mainwindow.chumdb.setNotes(currentChum.handle, notes) @@ -957,12 +970,15 @@ class chumArea(RightClickTree): if not hasattr(self, 'renamegroupdialog'): self.renamegroupdialog = None if not self.renamegroupdialog: - (gname, ok) = QtWidgets.QInputDialog.getText(self, "Rename Group", "Enter a new name for the group:") + (gname, ok) = QtWidgets.QInputDialog.getText(self, + "Rename Group", + "Enter a new name for the group:") if ok: gname = str(gname) if re.search("[^A-Za-z0-9_\s]", gname) is not None: msgbox = QtWidgets.QMessageBox() - msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.mainwindow.theme["main/defaultwindow/style"]) msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME") msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.exec() @@ -1140,7 +1156,9 @@ class TrollSlumWindow(QtWidgets.QFrame): if self.addtrolldialog: return self.addtrolldialog = QtWidgets.QInputDialog(self) - (handle, ok) = self.addtrolldialog.getText(self, "Add Troll", "Enter Troll Handle:") + (handle, ok) = self.addtrolldialog.getText(self, + "Add Troll", + "Enter Troll Handle:") if ok: handle = str(handle) if not (PesterProfile.checkLength(handle) and @@ -1162,8 +1180,8 @@ class PesterWindow(MovingWindow): def __init__(self, options, parent=None, app=None): super(PesterWindow, self).__init__(None, - (QtCore.Qt.WindowType.CustomizeWindowHint | - QtCore.Qt.WindowType.FramelessWindowHint)) + (QtCore.Qt.WindowType.CustomizeWindowHint + | QtCore.Qt.WindowType.FramelessWindowHint)) # For debugging _CONSOLE_ENV.PAPP = self @@ -1200,7 +1218,10 @@ class PesterWindow(MovingWindow): self.userprofile = userProfile(self.config.defaultprofile()) self.theme = self.userprofile.getTheme() else: - self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) + self.userprofile = userProfile(PesterProfile("pesterClient%d" + % (random.randint(100,999)), + QtGui.QColor("black"), + Mood(0))) self.theme = self.userprofile.getTheme() except Exception as e: msgBox = QtWidgets.QMessageBox() @@ -1208,14 +1229,15 @@ class PesterWindow(MovingWindow): msgBox.setWindowTitle(":(") msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links self.filename = _datadir+"pesterchum.js" - msgBox.setText("

A profile error occured, trying to switch to default pesterClient profile." + \ - "

" + str(e) + "<\h3><\html>") - #"\" if pesterchum acts oddly you might want to try backing up and then deleting \"" + \ - #_datadir+"pesterchum.js" + \ - #"\"") + msgBox.setText("

A profile error occured," + "trying to switch to default pesterClient profile." + "

%s<\h3><\html>" % e) PchumLog.critical(e) msgBox.exec() - self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) + self.userprofile = userProfile(PesterProfile("pesterClient%d" + % (random.randint(100,999)), + QtGui.QColor("black"), + Mood(0))) self.theme = self.userprofile.getTheme() # karxi: For the record, these are set via commandline arguments. By @@ -1563,8 +1585,8 @@ class PesterWindow(MovingWindow): @QtCore.pyqtSlot() def closeToTray(self): # I'm just gonna include a toast here to make sure people don't get confused. :'3 - t = self.tm.Toast("Notice:", "Pesterchum has been minimized to your tray. \ - \n(This behavior is configurable in settings.)") + t = self.tm.Toast("Notice:", + "Pesterchum has been minimized to your tray.") t.show() self.hide() self.closeToTraySignal.emit() @@ -1597,7 +1619,10 @@ class PesterWindow(MovingWindow): elif not self.config.notifyOptions() & self.config.NEWCONVO: if msg[:11] != "PESTERCHUM:": if handle.upper() not in BOTNAMES: - t = self.tm.Toast("From: %s" % handle, re.sub("", "", msg)) + t = self.tm.Toast("From: %s" % handle, + re.sub("", + "", + msg)) t.show() else: if msg == "PESTERCHUM:CEASE": @@ -1668,7 +1693,9 @@ class PesterWindow(MovingWindow): self.namesound.play() return if not memo.notifications_muted: - if self.honk and re.search(r"\bhonk\b", convertTags(msg, "text"), re.I): + if self.honk and re.search(r"\bhonk\b", + convertTags(msg, "text"), + re.I): # TODO: I've got my eye on you, Gamzee. self.honksound.play() elif self.config.memoPing() or memo.always_beep: @@ -1874,10 +1901,13 @@ class PesterWindow(MovingWindow): self.backgroundImage = QtGui.QPixmap(theme["main/background-image"]) self.setMask(self.backgroundImage.mask()) - self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " + self.menu.setStyleSheet(("QMenuBar { background: transparent; %s }" + "QMenuBar::item { background: transparent; %s }") % (theme["main/menubar/style"], theme["main/menu/menuitem"]) - + "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }" + + ("QMenu { background: transparent; %s }" + "QMenu::item::selected { %s }" + "QMenu::item::disabled { %s }") % (theme["main/menu/style"], theme["main/menu/selected"], theme["main/menu/disabled"])) @@ -2004,7 +2034,9 @@ class PesterWindow(MovingWindow): # This is a better spot to put this :) # Setting QMessageBox's style usually doesn't do anything. - self.setStyleSheet("QInputDialog { %s } QMessageBox { %s }" % (self.theme["main/defaultwindow/style"], self.theme["main/defaultwindow/style"])) + self.setStyleSheet("QInputDialog { %s } QMessageBox { %s }" + % (self.theme["main/defaultwindow/style"], + self.theme["main/defaultwindow/style"])) if theme["main/mychumhandle/colorswatch/text"]: self.mychumcolor.setText(theme["main/mychumhandle/colorswatch/text"]) @@ -2168,7 +2200,9 @@ class PesterWindow(MovingWindow): def doAutoIdentify(self): if self.userprofile.getAutoIdentify(): - self.sendMessage.emit("identify " + self.userprofile.getNickServPass(), "NickServ") + self.sendMessage.emit("identify " + + self.userprofile.getNickServPass(), + "NickServ") def doAutoJoins(self): if not self.autoJoinDone: @@ -2221,7 +2255,10 @@ class PesterWindow(MovingWindow): except KeyError: chumopen = self.convos[h.lower()].chumopen if chumopen: - self.chatlog.log(chum.handle, self.profile().pestermsg(chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/ceasepester"])) + self.chatlog.log(chum.handle, + self.profile().pestermsg(chum, + QtGui.QColor(self.theme["convo/systemMsgColor"]), + self.theme["convo/text/ceasepester"])) self.convoClosed.emit(handle) self.chatlog.finish(h) del self.convos[h] @@ -2273,9 +2310,12 @@ class PesterWindow(MovingWindow): if h.upper() == "NICKSERV" and m.startswith("Your nickname is now being changed to"): changedto = m[39:-1] msgbox = QtWidgets.QMessageBox() - msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") - msgbox.setText("This chumhandle has been registered; you may not use it.") - msgbox.setInformativeText("Your handle is now being changed to %s." % (changedto)) + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.theme["main/defaultwindow/style"]) + msgbox.setText("This chumhandle has been registered; " + "you may not use it.") + msgbox.setInformativeText("Your handle is now being changed to %s." + % (changedto)) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.exec() elif h == self.randhandler.randNick: @@ -2298,8 +2338,11 @@ class PesterWindow(MovingWindow): msgbox = QtWidgets.QMessageBox() msgbox.setText("You're invited!") msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") - msgbox.setInformativeText("%s has invited you to the memo: %s\nWould you like to join them?" % (handle, channel)) - msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel) + msgbox.setInformativeText(("%s has invited you to the memo: %s" + "\nWould you like to join them?") + % (handle, channel)) + msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok + | QtWidgets.QMessageBox.StandardButton.Cancel) # Find the Cancel button and make it default for b in msgbox.buttons(): if msgbox.buttonRole(b) == QtWidgets.QMessageBox.ButtonRole.RejectRole: @@ -2433,9 +2476,13 @@ class PesterWindow(MovingWindow): def removeChum(self, chumlisting): self.config.removeChum(chumlisting) def reportChum(self, handle): - (reason, ok) = QtWidgets.QInputDialog.getText(self, "Report User", "Enter the reason you are reporting this user (optional):") + (reason, ok) = QtWidgets.QInputDialog.getText(self, + "Report User", + "Enter the reason you are reporting this user (optional):") if ok: - self.sendMessage.emit("REPORT %s %s" % (handle, reason) , "calSprite") + self.sendMessage.emit("REPORT %s %s" + % (handle, reason), + "calSprite") @QtCore.pyqtSlot(QString) def blockChum(self, handle): @@ -2444,7 +2491,9 @@ class PesterWindow(MovingWindow): self.config.removeChum(h) if h in self.convos: convo = self.convos[h] - msg = self.profile().pestermsg(convo.chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/blocked"]) + msg = self.profile().pestermsg(convo.chum, + QtGui.QColor(self.theme["convo/systemMsgColor"]), + self.theme["convo/text/blocked"]) convo.textArea.append(convertTags(msg)) self.chatlog.log(convo.chum.handle, msg) convo.updateBlocked() @@ -2461,7 +2510,9 @@ class PesterWindow(MovingWindow): self.config.delBlocklist(h) if h in self.convos: convo = self.convos[h] - msg = self.profile().pestermsg(convo.chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/unblocked"]) + msg = self.profile().pestermsg(convo.chum, + QtGui.QColor(self.theme["convo/systemMsgColor"]), + self.theme["convo/text/unblocked"]) convo.textArea.append(convertTags(msg)) self.chatlog.log(convo.chum.handle, msg) convo.updateMood(convo.chum.mood, unblocked=True) @@ -2735,7 +2786,9 @@ class PesterWindow(MovingWindow): msgbox = QtWidgets.QMessageBox() msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME") msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) - msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")#Style :) (memos/style or convo/style works :3 ) + #Style :) (memos/style or convo/style works :3 ) + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.theme["main/defaultwindow/style"]) msgbox.exec() self.addgroupdialog = None return @@ -3063,28 +3116,33 @@ class PesterWindow(MovingWindow): try: self.userprofile = userProfile(handle) self.changeTheme(self.userprofile.getTheme()) - except (json.JSONDecodeError, FileNotFoundError) as e: + except (json.JSONDecodeError, FileNotFoundError, ValueError) as e: msgBox = QtWidgets.QMessageBox() - msgBox.setIcon(QtWidgets.QMessageBox.StandardButton.Warning) + msgBox.setIcon(QtWidgets.QMessageBox.Icon.Warning) msgBox.setWindowTitle(":(") msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links self.filename = _datadir+"pesterchum.js" try: - msgBox.setText("

Failed to load: " + ("%s/%s.js" % (self.profiledir, self.profiledir, user)) + \ - "

Try to check for syntax errors if the file exists." + \ - "

If you got this message at launch you may want to change your default profile." + \ - "

" + str(e) + "<\h3><\html>") - #"\" if pesterchum acts oddly you might want to try backing up and then deleting \"" + \ - #_datadir+"pesterchum.js" + \ - #"\"") + msg = ("

Failed to load: " + "%s/%s.js" + "

" + "Try to check for syntax errors if the file exists." + "

" + "If you got this message at launch you may want to " + "change your default profile." + "

%s<\h3><\html>" + % (self.profiledir, self.profiledir, user, e)) + except: # More generic error for if not all variables are available. - msgBox.setText("Unspecified profile error." + \ - "

Try to check for syntax errors if the file exists." + \ - "

If you got this message at launch you may want to change your default profile." + \ - "

" + str(e) + "<\h3><\html>") - + msg = ("Unspecified profile error." + "

Try to check for syntax errors if the " + "file exists." + "

If you got this message at launch you may " + "want to change your default profile." + "

%s<\h3><\html>" % e) PchumLog.critical(e) + msgBox.setText(msg) msgBox.exec() return else: @@ -3145,7 +3203,8 @@ class PesterWindow(MovingWindow): closeWarning = QtWidgets.QMessageBox() closeWarning.setText("WARNING: CHANGING PROFILES WILL CLOSE ALL CONVERSATION WINDOWS!") closeWarning.setInformativeText("i warned you about windows bro!!!! i told you dog!") - closeWarning.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Cancel | QtWidgets.QMessageBox.StandardButton.Ok) + closeWarning.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Cancel + | QtWidgets.QMessageBox.StandardButton.Ok) closeWarning.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok) ret = closeWarning.exec() if ret == QtWidgets.QMessageBox.StandardButton.Cancel: @@ -3178,15 +3237,19 @@ class PesterWindow(MovingWindow): self.newConversation("nickServ") @QtCore.pyqtSlot() def launchHelp(self): - QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.ParsingMode.TolerantMode)) - QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://forum.homestuck.xyz/viewtopic.php?f=7&t=467", QtCore.QUrl.ParsingMode.TolerantMode)) + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", + QtCore.QUrl.ParsingMode.TolerantMode)) + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://forum.homestuck.xyz/viewtopic.php?f=7&t=467", + QtCore.QUrl.ParsingMode.TolerantMode)) @QtCore.pyqtSlot() def reportBug(self): - QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.ParsingMode.TolerantMode)) + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", + QtCore.QUrl.ParsingMode.TolerantMode)) @QtCore.pyqtSlot() def xyzRules(self): - QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://www.pesterchum.xyz/pesterchum-rules", QtCore.QUrl.ParsingMode.TolerantMode)) + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://www.pesterchum.xyz/pesterchum-rules", + QtCore.QUrl.ParsingMode.TolerantMode)) @QtCore.pyqtSlot(QString, QString) def nickCollision(self, handle, tmphandle): @@ -3196,7 +3259,10 @@ class PesterWindow(MovingWindow): self.loadingscreen = None self.mychumhandle.setText(tmphandle) - self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) + self.userprofile = userProfile(PesterProfile("pesterClient%d" + % (random.randint(100,999)), + QtGui.QColor("black"), + Mood(0))) self.changeTheme(self.userprofile.getTheme()) if not hasattr(self, 'chooseprofile'): @@ -3247,7 +3313,8 @@ class PesterWindow(MovingWindow): def tooManyPeeps(self): msg = QtWidgets.QMessageBox(self) msg.setText("D: TOO MANY PEOPLE!!!") - msg.setInformativeText("The server has hit max capacity. Please try again later.") + msg.setInformativeText("The server has hit max capacity." + "Please try again later.") #msg.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") msg.exec() @@ -3276,7 +3343,8 @@ class PesterWindow(MovingWindow): PchumLog.info("server: "+str(server)) except: msgbox = QtWidgets.QMessageBox() - msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.theme["main/defaultwindow/style"]) msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"])) msgbox.setInformativeText("Incorrect format :(") msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) @@ -3308,11 +3376,12 @@ class PesterWindow(MovingWindow): if os.path.isfile(_datadir + "serverlist.json"): PchumLog.error("Failed to load server list from serverlist.json.") msgbox = QtWidgets.QMessageBox() - msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") + msgbox.setStyleSheet("QMessageBox{ %s }" + % self.theme["main/defaultwindow/style"]) msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"])) - msgbox.setInformativeText("Failed to load server list, do you want to revert to defaults?\n" \ - + "If you choose no, Pesterchum will most likely crash unless you manually fix serverlist.json\n" \ - + "Please tell me if this error occurs :'3") + msgbox.setInformativeText("Failed to load server list, do you want to revert to defaults?\n" + "If you choose no, Pesterchum will most likely crash unless you manually fix serverlist.json\n" + "Please tell me if this error occurs :'3") msgbox.addButton(QtWidgets.QPushButton("Yes"), QtWidgets.QMessageBox.ButtonRole.YesRole) msgbox.addButton(QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.exec() @@ -3323,8 +3392,8 @@ class PesterWindow(MovingWindow): server_file.close() else: - PchumLog.warning("Failed to load server list because serverlist.json doesn't exist, " \ - + "this isn't an issue if this is the first time Pesterchum has been started.") + PchumLog.warning("Failed to load server list because serverlist.json doesn't exist, " + "this isn't an issue if this is the first time Pesterchum has been started.") with open(_datadir + "serverlist.json", "w") as server_file: server_file.write(json.dumps(default_server_list, indent = 4) ) server_file.close() @@ -3561,7 +3630,8 @@ class PesterWindow(MovingWindow): # Connect self.chooseServerWidged.accepted.connect(self.setServer) - self.chooseServerWidged.rejected.connect(self.killApp, QtCore.Qt.ConnectionType.QueuedConnection) + self.chooseServerWidged.rejected.connect(self.killApp, + QtCore.Qt.ConnectionType.QueuedConnection) # Show self.chooseServerWidged.show() @@ -3664,7 +3734,9 @@ class MainProgram(QtCore.QObject): self.widget = PesterWindow(options, parent=self, app=self.app) #self.widget.show() <== Already called in showLoading() - self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]), self.widget, self.app) + self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]), + self.widget, + self.app) self.traymenu = QtWidgets.QMenu() moodMenu = self.traymenu.addMenu("SET MOOD") @@ -3725,7 +3797,8 @@ class MainProgram(QtCore.QObject): self.trayicon.show() if self.widget.config.trayMessage(): self.trayicon.showMessage("Pesterchum", ("Pesterchum is still running in the system tray." - + '\n' + "Right click to close it.")) + "\n" + "Right click to close it.")) @QtCore.pyqtSlot() def trayMessageClick(self): @@ -3967,7 +4040,7 @@ class MainProgram(QtCore.QObject): # Show error to end user and log. try: # Log to log file - PchumLog.error(exc, value, tb) + PchumLog.error("%s, %s" % (exc, value)) # Try to write to separate logfile try: @@ -3997,7 +4070,6 @@ class MainProgram(QtCore.QObject): PchumLog.exception("app error") def run(self): - #PchumLog.critical("mreowww") <--- debug thingy :3 sys.exit(self.app.exec()) def _retrieveGlobals():