Merge pull request #122 from Dpeta/str_typecasts_and_qstring
Remove most unnecessary str() typecasts and just use 'str' for Qt slots/signals
This commit is contained in:
commit
7c8e682c36
13 changed files with 274 additions and 317 deletions
29
convo.py
29
convo.py
|
@ -218,7 +218,7 @@ class PesterTabWindow(QtWidgets.QFrame):
|
|||
i = self.tabs.tabAt(self.mapFromGlobal(QtGui.QCursor.pos()))
|
||||
if i == -1:
|
||||
i = self.tabs.currentIndex()
|
||||
handle = str(self.tabs.tabText(i))
|
||||
handle = self.tabs.tabText(i)
|
||||
self.clearNewMessage(handle)
|
||||
|
||||
def convoHasFocus(self, handle):
|
||||
|
@ -267,13 +267,13 @@ class PesterTabWindow(QtWidgets.QFrame):
|
|||
self.tabs.setTabIcon(tabi, c.icon())
|
||||
currenttabi = self.tabs.currentIndex()
|
||||
if currenttabi >= 0:
|
||||
currentHandle = str(self.tabs.tabText(self.tabs.currentIndex()))
|
||||
currentHandle = self.tabs.tabText(self.tabs.currentIndex())
|
||||
self.setWindowIcon(self.convos[currentHandle].icon())
|
||||
self.defaultTabTextColor = self.getTabTextColor()
|
||||
|
||||
@QtCore.pyqtSlot(int)
|
||||
def tabClose(self, i):
|
||||
handle = str(self.tabs.tabText(i))
|
||||
handle = self.tabs.tabText(i)
|
||||
self.mainwindow.waitingMessages.messageAnswered(handle)
|
||||
# print(self.convos.keys())
|
||||
# I, legit don' t know why this is an issue, but, uh, yeah-
|
||||
|
@ -296,7 +296,7 @@ class PesterTabWindow(QtWidgets.QFrame):
|
|||
return
|
||||
if self.currentConvo == convo:
|
||||
currenti = self.tabs.currentIndex()
|
||||
currenth = str(self.tabs.tabText(currenti))
|
||||
currenth = self.tabs.tabText(currenti)
|
||||
self.currentConvo = self.convos[currenth]
|
||||
self.currentConvo.raiseChat()
|
||||
|
||||
|
@ -307,7 +307,7 @@ class PesterTabWindow(QtWidgets.QFrame):
|
|||
if self.changedTab:
|
||||
self.changedTab = False
|
||||
return
|
||||
handle = str(self.tabs.tabText(i))
|
||||
handle = self.tabs.tabText(i)
|
||||
convo = self.convos[handle]
|
||||
if self.currentConvo:
|
||||
self.layout.removeWidget(self.currentConvo)
|
||||
|
@ -344,7 +344,7 @@ class PesterMovie(QtGui.QMovie):
|
|||
if text.mainwindow.config.animations():
|
||||
movie = self
|
||||
url = text.urls[movie].toString()
|
||||
html = str(text.toHtml())
|
||||
html = text.toHtml()
|
||||
if html.find(url) != -1:
|
||||
try:
|
||||
# PyQt6
|
||||
|
@ -606,7 +606,7 @@ class PesterText(QtWidgets.QTextEdit):
|
|||
if url[0] == "#" and url != "#pesterchum":
|
||||
self.parent().mainwindow.showMemos(url[1:])
|
||||
elif url[0] == "@":
|
||||
handle = str(url[1:])
|
||||
handle = url[1:]
|
||||
self.parent().mainwindow.newConversation(handle)
|
||||
else:
|
||||
if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier:
|
||||
|
@ -664,7 +664,7 @@ class PesterInput(QtWidgets.QLineEdit):
|
|||
|
||||
def keyPressEvent(self, event):
|
||||
if event.key() == QtCore.Qt.Key.Key_Up:
|
||||
text = str(self.text())
|
||||
text = self.text()
|
||||
next = self.parent().history.next(text)
|
||||
if next is not None:
|
||||
self.setText(next)
|
||||
|
@ -1091,14 +1091,13 @@ class PesterConvo(QtWidgets.QFrame):
|
|||
|
||||
@QtCore.pyqtSlot()
|
||||
def sentMessage(self):
|
||||
# Offloaded to another function, like its sisters.
|
||||
# Fetch the raw text from the input box.
|
||||
text = self.textInput.text()
|
||||
text = str(self.textInput.text())
|
||||
"""Offloaded to another function, like its sisters.
|
||||
|
||||
Fetch the raw text from the input box.
|
||||
"""
|
||||
return parsetools.kxhandleInput(
|
||||
self,
|
||||
text,
|
||||
self.textInput.text(),
|
||||
flavor="convo",
|
||||
irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
|
||||
)
|
||||
|
@ -1152,8 +1151,8 @@ class PesterConvo(QtWidgets.QFrame):
|
|||
def toggleMute(self, toggled):
|
||||
self.notifications_muted = toggled
|
||||
|
||||
messageSent = QtCore.pyqtSignal("QString", "QString")
|
||||
windowClosed = QtCore.pyqtSignal("QString")
|
||||
messageSent = QtCore.pyqtSignal(str, str)
|
||||
windowClosed = QtCore.pyqtSignal(str)
|
||||
|
||||
aligndict = {
|
||||
"h": {
|
||||
|
|
|
@ -147,7 +147,7 @@ class pesterQuirks:
|
|||
|
||||
newlist = []
|
||||
for i, o in enumerate(lexed):
|
||||
if type(o) not in [str, str]:
|
||||
if not isinstance(o, str):
|
||||
if i == 0:
|
||||
string = " "
|
||||
for p in prefix:
|
||||
|
@ -250,7 +250,7 @@ class pesterQuirks:
|
|||
newlist.append(string)
|
||||
final = []
|
||||
for n in newlist:
|
||||
if type(n) in [str, str]:
|
||||
if isinstance(n, str):
|
||||
final.extend(lexMessage(n))
|
||||
else:
|
||||
final.append(n)
|
||||
|
@ -456,7 +456,7 @@ class PesterProfile:
|
|||
opinit,
|
||||
self.colorhtml(),
|
||||
", ".join(initials),
|
||||
str(reason),
|
||||
reason,
|
||||
)
|
||||
)
|
||||
else:
|
||||
|
@ -477,7 +477,7 @@ class PesterProfile:
|
|||
opinit,
|
||||
self.colorhtml(),
|
||||
initials,
|
||||
str(reason),
|
||||
reason,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class PesterList(list):
|
|||
class PesterIcon(QtGui.QIcon):
|
||||
def __init__(self, *x):
|
||||
super().__init__(x[0])
|
||||
if type(x[0]) in [str, str]:
|
||||
if isinstance(x[0], str):
|
||||
self.icon_pixmap = QtGui.QPixmap(x[0])
|
||||
else:
|
||||
self.icon_pixmap = None
|
||||
|
@ -117,7 +117,7 @@ class MultiTextDialog(QtWidgets.QDialog):
|
|||
if r == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
retval = {}
|
||||
for name, widget in self.inputs.items():
|
||||
retval[name] = str(widget.text())
|
||||
retval[name] = widget.text()
|
||||
return retval
|
||||
else:
|
||||
return None
|
||||
|
@ -150,7 +150,7 @@ class MovingWindow(QtWidgets.QFrame):
|
|||
self.moving = event.globalPos() - self.pos()
|
||||
except AttributeError as e:
|
||||
print("PyQt <= 5.14?")
|
||||
print(str(e))
|
||||
print(e)
|
||||
if event.button() == 1:
|
||||
self.moving = event.globalPos() - self.pos()
|
||||
|
||||
|
|
34
irc.py
34
irc.py
|
@ -437,7 +437,7 @@ class PesterIRC(QtCore.QThread):
|
|||
"""Update and send color, slot is called from main thread."""
|
||||
# Update color metadata field
|
||||
color = self.mainwindow.profile().color
|
||||
self._send_irc.metadata("*", "set", "color", str(color.name()))
|
||||
self._send_irc.metadata("*", "set", "color", color.name())
|
||||
# Send color messages
|
||||
for convo in list(self.mainwindow.convos.keys()):
|
||||
self._send_irc.privmsg(
|
||||
|
@ -1019,22 +1019,22 @@ class PesterIRC(QtCore.QThread):
|
|||
""" "METADATA DRAFT numeric reply 770 RPL_METADATASUBOK, we subbed to a key."""
|
||||
PchumLog.info("_metadatasubok: %s", params)
|
||||
|
||||
moodUpdated = QtCore.pyqtSignal("QString", Mood)
|
||||
colorUpdated = QtCore.pyqtSignal("QString", QtGui.QColor)
|
||||
messageReceived = QtCore.pyqtSignal("QString", "QString")
|
||||
memoReceived = QtCore.pyqtSignal("QString", "QString", "QString")
|
||||
noticeReceived = QtCore.pyqtSignal("QString", "QString")
|
||||
inviteReceived = QtCore.pyqtSignal("QString", "QString")
|
||||
timeCommand = QtCore.pyqtSignal("QString", "QString", "QString")
|
||||
namesReceived = QtCore.pyqtSignal("QString", PesterList)
|
||||
moodUpdated = QtCore.pyqtSignal(str, Mood)
|
||||
colorUpdated = QtCore.pyqtSignal(str, QtGui.QColor)
|
||||
messageReceived = QtCore.pyqtSignal(str, str)
|
||||
memoReceived = QtCore.pyqtSignal(str, str, str)
|
||||
noticeReceived = QtCore.pyqtSignal(str, str)
|
||||
inviteReceived = QtCore.pyqtSignal(str, str)
|
||||
timeCommand = QtCore.pyqtSignal(str, str, str)
|
||||
namesReceived = QtCore.pyqtSignal(str, PesterList)
|
||||
channelListReceived = QtCore.pyqtSignal(PesterList)
|
||||
nickCollision = QtCore.pyqtSignal("QString", "QString")
|
||||
getSvsnickedOn = QtCore.pyqtSignal("QString", "QString")
|
||||
myHandleChanged = QtCore.pyqtSignal("QString")
|
||||
chanInviteOnly = QtCore.pyqtSignal("QString")
|
||||
modesUpdated = QtCore.pyqtSignal("QString", "QString")
|
||||
nickCollision = QtCore.pyqtSignal(str, str)
|
||||
getSvsnickedOn = QtCore.pyqtSignal(str, str)
|
||||
myHandleChanged = QtCore.pyqtSignal(str)
|
||||
chanInviteOnly = QtCore.pyqtSignal(str)
|
||||
modesUpdated = QtCore.pyqtSignal(str, str)
|
||||
connected = QtCore.pyqtSignal()
|
||||
askToConnect = QtCore.pyqtSignal(Exception)
|
||||
userPresentUpdate = QtCore.pyqtSignal("QString", "QString", "QString")
|
||||
cannotSendToChan = QtCore.pyqtSignal("QString", "QString")
|
||||
signal_forbiddenchannel = QtCore.pyqtSignal("QString", "QString")
|
||||
userPresentUpdate = QtCore.pyqtSignal(str, str, str)
|
||||
cannotSendToChan = QtCore.pyqtSignal(str, str)
|
||||
signal_forbiddenchannel = QtCore.pyqtSignal(str, str)
|
||||
|
|
11
logviewer.py
11
logviewer.py
|
@ -42,10 +42,7 @@ class PesterLogHighlighter(QtGui.QSyntaxHighlighter):
|
|||
|
||||
def highlightBlock(self, text):
|
||||
for i in range(0, len(text) - (len(self.searchTerm) - 1)):
|
||||
if (
|
||||
str(text[i : i + len(self.searchTerm)]).lower()
|
||||
== str(self.searchTerm).lower()
|
||||
):
|
||||
if text[i : i + len(self.searchTerm)].lower() == self.searchTerm.lower():
|
||||
self.setFormat(i, len(self.searchTerm), self.hilightstyle)
|
||||
|
||||
|
||||
|
@ -297,7 +294,7 @@ class PesterLogViewer(QtWidgets.QDialog):
|
|||
if len(self.tree.currentItem().text(0)) > len("September 2011"):
|
||||
self.loadLog(self.timeToFile(self.tree.currentItem().text(0)))
|
||||
|
||||
def loadLog(self, fname):
|
||||
def loadLog(self, fname: str):
|
||||
fp = codecs.open(
|
||||
"%s/%s/%s/%s/%s"
|
||||
% (self.logpath, self.handle, self.chum, self.format, fname),
|
||||
|
@ -318,7 +315,7 @@ class PesterLogViewer(QtWidgets.QDialog):
|
|||
# textCur.movePosition(1)
|
||||
self.textArea.setTextCursor(textCur)
|
||||
self.instructions.setText(
|
||||
"Pesterlog with " + self.chum + " on " + self.fileToTime(str(fname))
|
||||
"Pesterlog with " + self.chum + " on " + self.fileToTime(fname)
|
||||
)
|
||||
|
||||
def logSearch(self, search):
|
||||
|
@ -359,7 +356,7 @@ class PesterLogText(PesterText):
|
|||
if url[0] == "#" and url != "#pesterchum":
|
||||
self.parent().parent.showMemos(url[1:])
|
||||
elif url[0] == "@":
|
||||
handle = str(url[1:])
|
||||
handle = url[1:]
|
||||
self.parent().parent.newConversation(handle)
|
||||
else:
|
||||
QtGui.QDesktopServices.openUrl(
|
||||
|
|
70
memos.py
70
memos.py
|
@ -30,8 +30,6 @@ PchumLog = logging.getLogger("pchumLogger")
|
|||
_valid_memo_msg_start = re.compile(
|
||||
r"^<c=((\d+,\d+,\d+)|(#([a-fA-F0-9]{6})|(#[a-fA-F0-9]{3})))>([A-Z]{3}):\s"
|
||||
)
|
||||
# Python 3
|
||||
QString = str
|
||||
|
||||
|
||||
def delta2txt(d, format="pc"):
|
||||
|
@ -242,7 +240,7 @@ class TimeInput(QtWidgets.QLineEdit):
|
|||
|
||||
@QtCore.pyqtSlot()
|
||||
def setSlider(self):
|
||||
value = str(self.text())
|
||||
value = self.text()
|
||||
timed = txt2delta(value)
|
||||
if isinstance(timed, mysteryTime):
|
||||
self.timeslider.setValue(0)
|
||||
|
@ -1010,10 +1008,9 @@ class PesterMemo(PesterConvo):
|
|||
PchumLog.debug("updateChanModes(%s, %s)", modes, op)
|
||||
if not hasattr(self, "modes"):
|
||||
self.modes = ""
|
||||
chanmodes = list(str(self.modes))
|
||||
chanmodes = list((self.modes))
|
||||
if chanmodes and chanmodes[0] == "+":
|
||||
chanmodes = chanmodes[1:]
|
||||
modes = str(modes)
|
||||
if op:
|
||||
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
|
||||
chum = self.mainwindow.profile()
|
||||
|
@ -1430,7 +1427,7 @@ class PesterMemo(PesterConvo):
|
|||
|
||||
@QtCore.pyqtSlot()
|
||||
def sentMessage(self):
|
||||
text = str(self.textInput.text())
|
||||
text = self.textInput.text()
|
||||
|
||||
return parsetools.kxhandleInput(
|
||||
self,
|
||||
|
@ -1439,10 +1436,9 @@ class PesterMemo(PesterConvo):
|
|||
irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
|
||||
)
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def namesUpdated(self, channel):
|
||||
c = str(channel)
|
||||
if c.lower() != self.channel.lower():
|
||||
if channel.lower() != self.channel.lower():
|
||||
return
|
||||
# get namesdb (unused)
|
||||
# namesdb = self.mainwindow.namesdb
|
||||
|
@ -1451,17 +1447,16 @@ class PesterMemo(PesterConvo):
|
|||
for n in self.mainwindow.namesdb[self.channel]:
|
||||
self.addUser(n)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def modesUpdated(self, channel, modes):
|
||||
PchumLog.debug("modesUpdated(%s, %s)", channel, modes)
|
||||
if channel.lower() == self.channel.lower():
|
||||
self.updateChanModes(modes, None)
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def closeInviteOnly(self, channel):
|
||||
c = str(channel)
|
||||
if c.lower() == self.channel.lower():
|
||||
self.mainwindow.inviteOnlyChan["QString"].disconnect(self.closeInviteOnly)
|
||||
if channel.lower() == self.channel.lower():
|
||||
self.mainwindow.inviteOnlyChan[str].disconnect(self.closeInviteOnly)
|
||||
if self.parent():
|
||||
PchumLog.info(self.channel)
|
||||
i = self.parent().tabIndices[self.channel]
|
||||
|
@ -1472,7 +1467,7 @@ class PesterMemo(PesterConvo):
|
|||
msgbox.setStyleSheet(
|
||||
"QMessageBox{ %s }" % self.mainwindow.theme["main/defaultwindow/style"]
|
||||
)
|
||||
msgbox.setText("%s: Invites only!" % (c))
|
||||
msgbox.setText(f"{channel}: Invites only!")
|
||||
msgbox.setInformativeText(
|
||||
"This channel is invite-only. "
|
||||
"You must get an invitation from someone on the inside before entering."
|
||||
|
@ -1480,13 +1475,10 @@ class PesterMemo(PesterConvo):
|
|||
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
||||
msgbox.exec()
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def closeForbidden(self, channel, reason):
|
||||
c = str(channel)
|
||||
if c.lower() == self.channel.lower():
|
||||
self.mainwindow.forbiddenChan["QString", "QString"].disconnect(
|
||||
self.closeForbidden
|
||||
)
|
||||
if channel.lower() == self.channel.lower():
|
||||
self.mainwindow.forbiddenChan[str, str].disconnect(self.closeForbidden)
|
||||
if self.parent():
|
||||
PchumLog.info(self.channel)
|
||||
i = self.parent().tabIndices[self.channel]
|
||||
|
@ -1497,7 +1489,7 @@ class PesterMemo(PesterConvo):
|
|||
msgbox.setStyleSheet(
|
||||
"QMessageBox{ %s }" % self.mainwindow.theme["main/defaultwindow/style"]
|
||||
)
|
||||
msgbox.setText("%s: D: CANT JOIN MEMO!!!" % (c))
|
||||
msgbox.setText(f"{channel}: D: CANT JOIN MEMO!!!")
|
||||
msgbox.setInformativeText(reason)
|
||||
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
||||
msgbox.exec()
|
||||
|
@ -1571,13 +1563,10 @@ class PesterMemo(PesterConvo):
|
|||
self.mainwindow.chatlog.log(self.channel, msg)
|
||||
del self.netsplit
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString, QString)
|
||||
def userPresentChange(self, handle, channel, update):
|
||||
# print("handle: %s, channel: %s, update: %s" % (handle, channel, update))
|
||||
h = str(handle)
|
||||
c = str(channel)
|
||||
update = str(update)
|
||||
# PchumLog.debug("h=%s\nc=%s\nupdate=%s" % (h,c,update))
|
||||
@QtCore.pyqtSlot(str, str, str)
|
||||
def userPresentChange(self, handle: str, channel: str, update: str):
|
||||
h = handle
|
||||
c = channel
|
||||
if update[0:4] == "kick": # yeah, i'm lazy.
|
||||
l = update.split(":")
|
||||
update = l[0]
|
||||
|
@ -1794,7 +1783,7 @@ class PesterMemo(PesterConvo):
|
|||
for c in chums:
|
||||
c.op = True
|
||||
self.iconCrap(c)
|
||||
if str(c.text()) == self.mainwindow.profile().handle:
|
||||
if (c.text()) == self.mainwindow.profile().handle:
|
||||
self.userlist.optionsMenu.addAction(self.opAction)
|
||||
self.userlist.optionsMenu.addAction(self.voiceAction)
|
||||
self.userlist.optionsMenu.addAction(self.banuserAction)
|
||||
|
@ -1811,7 +1800,7 @@ class PesterMemo(PesterConvo):
|
|||
for c in chums:
|
||||
c.op = False
|
||||
self.iconCrap(c)
|
||||
if str(c.text()) == self.mainwindow.profile().handle:
|
||||
if (c.text()) == self.mainwindow.profile().handle:
|
||||
self.userlist.optionsMenu.removeAction(self.opAction)
|
||||
self.userlist.optionsMenu.removeAction(self.voiceAction)
|
||||
self.userlist.optionsMenu.removeAction(self.banuserAction)
|
||||
|
@ -1827,7 +1816,7 @@ class PesterMemo(PesterConvo):
|
|||
for c in chums:
|
||||
c.halfop = True
|
||||
self.iconCrap(c)
|
||||
if str(c.text()) == self.mainwindow.profile().handle:
|
||||
if (c.text()) == self.mainwindow.profile().handle:
|
||||
self.userlist.optionsMenu.addAction(self.opAction)
|
||||
self.userlist.optionsMenu.addAction(self.voiceAction)
|
||||
self.userlist.optionsMenu.addAction(self.banuserAction)
|
||||
|
@ -1844,7 +1833,7 @@ class PesterMemo(PesterConvo):
|
|||
for c in chums:
|
||||
c.halfop = False
|
||||
self.iconCrap(c)
|
||||
if str(c.text()) == self.mainwindow.profile().handle:
|
||||
if (c.text()) == self.mainwindow.profile().handle:
|
||||
self.userlist.optionsMenu.removeAction(self.opAction)
|
||||
self.userlist.optionsMenu.removeAction(self.voiceAction)
|
||||
self.userlist.optionsMenu.removeAction(self.banuserAction)
|
||||
|
@ -1892,21 +1881,21 @@ class PesterMemo(PesterConvo):
|
|||
user = self.userlist.currentItem()
|
||||
if not user:
|
||||
return
|
||||
user = str(user.text())
|
||||
user = user.text()
|
||||
self.mainwindow.newConversation(user)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def addChumSlot(self):
|
||||
if not self.userlist.currentItem():
|
||||
return
|
||||
currentChum = PesterProfile(str(self.userlist.currentItem().text()))
|
||||
currentChum = PesterProfile((self.userlist.currentItem().text()))
|
||||
self.mainwindow.addChum(currentChum)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def banSelectedUser(self):
|
||||
if not self.userlist.currentItem():
|
||||
return
|
||||
currentHandle = str(self.userlist.currentItem().text())
|
||||
currentHandle = self.userlist.currentItem().text()
|
||||
(reason, ok) = QtWidgets.QInputDialog.getText(
|
||||
self, "Ban User", "Enter the reason you are banning this user (optional):"
|
||||
)
|
||||
|
@ -1917,21 +1906,21 @@ class PesterMemo(PesterConvo):
|
|||
def opSelectedUser(self):
|
||||
if not self.userlist.currentItem():
|
||||
return
|
||||
currentHandle = str(self.userlist.currentItem().text())
|
||||
currentHandle = self.userlist.currentItem().text()
|
||||
self.mainwindow.setChannelMode.emit(self.channel, "+o", currentHandle)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def voiceSelectedUser(self):
|
||||
if not self.userlist.currentItem():
|
||||
return
|
||||
currentHandle = str(self.userlist.currentItem().text())
|
||||
currentHandle = self.userlist.currentItem().text()
|
||||
self.mainwindow.setChannelMode.emit(self.channel, "+v", currentHandle)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def killQuirkUser(self):
|
||||
if not self.userlist.currentItem():
|
||||
return
|
||||
currentHandle = str(self.userlist.currentItem().text())
|
||||
currentHandle = self.userlist.currentItem().text()
|
||||
self.mainwindow.killSomeQuirks.emit(self.channel, currentHandle)
|
||||
|
||||
def resetSlider(self, time, send=True):
|
||||
|
@ -1964,7 +1953,6 @@ class PesterMemo(PesterConvo):
|
|||
"Enter the chumhandle of the user you'd like to invite:",
|
||||
)
|
||||
if ok:
|
||||
chum = str(chum)
|
||||
self.mainwindow.inviteChum.emit(chum, self.channel)
|
||||
self.invitechums = None
|
||||
|
||||
|
@ -2040,7 +2028,7 @@ class PesterMemo(PesterConvo):
|
|||
self.mainwindow.waitingMessages.messageAnswered(self.channel)
|
||||
self.windowClosed.emit(self.title())
|
||||
|
||||
windowClosed = QtCore.pyqtSignal("QString")
|
||||
windowClosed = QtCore.pyqtSignal(str)
|
||||
|
||||
|
||||
timelist = [
|
||||
|
|
83
menus.py
83
menus.py
|
@ -19,7 +19,6 @@ from version import _pcVersion
|
|||
from convo import PesterInput, PesterText
|
||||
from parsetools import lexMessage
|
||||
|
||||
QString = str
|
||||
_datadir = ostools.getDataDir()
|
||||
# Logger
|
||||
PchumLog = logging.getLogger("pchumLogger")
|
||||
|
@ -30,7 +29,7 @@ class PesterQuirkItem(QtWidgets.QTreeWidgetItem):
|
|||
parent = None
|
||||
QtWidgets.QTreeWidgetItem.__init__(self, parent)
|
||||
self.quirk = quirk
|
||||
self.setText(0, str(quirk))
|
||||
self.setText(0, str(quirk)) # Typecast required.
|
||||
|
||||
def update(self, quirk):
|
||||
self.quirk = quirk
|
||||
|
@ -236,7 +235,6 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
|
|||
self, "Add Group", "Enter a name for the new quirk group:"
|
||||
)
|
||||
if ok:
|
||||
gname = str(gname)
|
||||
if re.search(r"[^A-Za-z0-9_\s]", gname) is not None:
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
|
||||
|
@ -324,7 +322,7 @@ class QuirkTesterWindow(QtWidgets.QDialog):
|
|||
|
||||
@QtCore.pyqtSlot()
|
||||
def sentMessage(self):
|
||||
text = str(self.textInput.text())
|
||||
text = self.textInput.text()
|
||||
|
||||
return parsetools.kxhandleInput(
|
||||
self,
|
||||
|
@ -597,8 +595,8 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
|||
page.itemAt(3).layout().itemAt(0).widget().setCheckState(
|
||||
QtCore.Qt.CheckState(int(q["checkstate"]))
|
||||
)
|
||||
except (KeyError, ValueError) as e:
|
||||
print("KeyError: %s" % str(e))
|
||||
except (KeyError, ValueError):
|
||||
PchumLog.exception("Exception setting replace quirk.")
|
||||
elif q["type"] == "regexp":
|
||||
page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().setText(
|
||||
q["from"]
|
||||
|
@ -610,8 +608,8 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
|||
page.itemAt(2).layout().itemAt(3).layout().itemAt(
|
||||
0
|
||||
).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
||||
except (KeyError, ValueError) as e:
|
||||
print("KeyError: %s" % str(e))
|
||||
except (KeyError, ValueError):
|
||||
PchumLog.exception("Exception setting regexp quirk.")
|
||||
elif q["type"] == "random":
|
||||
self.regexp.setText(q["from"])
|
||||
for v in q["randomlist"]:
|
||||
|
@ -620,8 +618,8 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
|||
page.itemAt(2).layout().itemAt(2).layout().itemAt(
|
||||
0
|
||||
).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
||||
except (KeyError, ValueError) as e:
|
||||
print("KeyError: %s" % str(e))
|
||||
except (KeyError, ValueError):
|
||||
PchumLog.exception("Exception setting random quirk.")
|
||||
elif q["type"] == "spelling":
|
||||
self.slider.setValue(q["percentage"])
|
||||
try:
|
||||
|
@ -629,7 +627,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
|||
QtCore.Qt.CheckState(int(q["checkstate"]))
|
||||
)
|
||||
except (KeyError, ValueError) as e:
|
||||
print("KeyError: %s" % str(e))
|
||||
PchumLog.exception("Exception setting spelling quirk.")
|
||||
|
||||
self.setLayout(layout_0)
|
||||
|
||||
|
@ -668,11 +666,11 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
|||
|
||||
@QtCore.pyqtSlot(int)
|
||||
def printValue(self, value):
|
||||
self.current.setText(str(value) + "%")
|
||||
self.current.setText(f"{value}%")
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def addRandomString(self):
|
||||
text = str(self.replaceinput.text())
|
||||
text = self.replaceinput.text()
|
||||
item = QtWidgets.QListWidgetItem(text, self.replacelist)
|
||||
self.replaceinput.setText("")
|
||||
self.replaceinput.setFocus()
|
||||
|
@ -816,10 +814,10 @@ class PesterChooseQuirks(QtWidgets.QDialog):
|
|||
vdict["type"] = types[self.quirkadd.pages.currentIndex() - 1]
|
||||
page = self.quirkadd.pages.currentWidget().layout()
|
||||
if vdict["type"] in ("prefix", "suffix"):
|
||||
vdict["value"] = str(page.itemAt(1).layout().itemAt(1).widget().text())
|
||||
vdict["value"] = page.itemAt(1).layout().itemAt(1).widget().text()
|
||||
elif vdict["type"] == "replace":
|
||||
vdict["from"] = str(page.itemAt(1).layout().itemAt(1).widget().text())
|
||||
vdict["to"] = str(page.itemAt(2).layout().itemAt(1).widget().text())
|
||||
vdict["from"] = page.itemAt(1).layout().itemAt(1).widget().text()
|
||||
vdict["to"] = page.itemAt(2).layout().itemAt(1).widget().text()
|
||||
try:
|
||||
# PyQt6
|
||||
vdict["checkstate"] = str(
|
||||
|
@ -831,10 +829,10 @@ class PesterChooseQuirks(QtWidgets.QDialog):
|
|||
page.itemAt(3).layout().itemAt(0).widget().checkState()
|
||||
)
|
||||
elif vdict["type"] == "regexp":
|
||||
vdict["from"] = str(
|
||||
vdict["from"] = (
|
||||
page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().text()
|
||||
)
|
||||
vdict["to"] = str(
|
||||
vdict["to"] = (
|
||||
page.itemAt(2).layout().itemAt(2).layout().itemAt(1).widget().text()
|
||||
)
|
||||
try:
|
||||
|
@ -1070,7 +1068,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
|
|||
@QtCore.pyqtSlot()
|
||||
def validateProfile(self):
|
||||
if not self.profileBox or self.profileBox.currentIndex() == 0:
|
||||
handle = str(self.chumHandle.text())
|
||||
handle = self.chumHandle.text()
|
||||
if not PesterProfile.checkLength(handle):
|
||||
self.errorMsg.setText("PROFILE HANDLE IS TOO LONG")
|
||||
return
|
||||
|
@ -1085,7 +1083,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
|
|||
@QtCore.pyqtSlot()
|
||||
def deleteProfile(self):
|
||||
if self.profileBox and self.profileBox.currentIndex() > 0:
|
||||
handle = str(self.profileBox.currentText())
|
||||
handle = self.profileBox.currentText()
|
||||
if handle == self.parent.profile().handle:
|
||||
problem = QtWidgets.QMessageBox()
|
||||
# karxi Will probably change this to its own name later.
|
||||
|
@ -1176,7 +1174,7 @@ class PesterMentions(QtWidgets.QDialog):
|
|||
def addMention(self, mitem=None):
|
||||
d = {"label": "Mention:", "inputname": "value"}
|
||||
if mitem is not None:
|
||||
d["value"] = str(mitem.text())
|
||||
d["value"] = mitem.text()
|
||||
pdict = MultiTextDialog("ENTER MENTION", self, d).getText()
|
||||
if pdict is None:
|
||||
return
|
||||
|
@ -1731,7 +1729,7 @@ class PesterOptions(QtWidgets.QDialog):
|
|||
def addAutoJoin(self, mitem=None):
|
||||
d = {"label": "Memo:", "inputname": "value"}
|
||||
if mitem is not None:
|
||||
d["value"] = str(mitem.text())
|
||||
d["value"] = mitem.text()
|
||||
pdict = MultiTextDialog("ENTER MEMO", self, d).getText()
|
||||
if pdict is None:
|
||||
return
|
||||
|
@ -1774,7 +1772,7 @@ class PesterOptions(QtWidgets.QDialog):
|
|||
|
||||
@QtCore.pyqtSlot(int)
|
||||
def printValue(self, v):
|
||||
self.currentVol.setText(str(v) + "%")
|
||||
self.currentVol.setText(f"{v}%")
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def openMentions(self):
|
||||
|
@ -1797,7 +1795,7 @@ class PesterOptions(QtWidgets.QDialog):
|
|||
def updateMentions(self):
|
||||
m = []
|
||||
for i in range(self.mentionmenu.mentionlist.count()):
|
||||
m.append(str(self.mentionmenu.mentionlist.item(i).text()))
|
||||
m.append((self.mentionmenu.mentionlist.item(i).text()))
|
||||
self.parent().userprofile.setMentions(m)
|
||||
self.mentionmenu = None
|
||||
|
||||
|
@ -1815,7 +1813,7 @@ class PesterUserlist(QtWidgets.QDialog):
|
|||
self.searchbox = QtWidgets.QLineEdit(self)
|
||||
# self.searchbox.setStyleSheet(theme["convo/input/style"]) # which style is better?
|
||||
self.searchbox.setPlaceholderText("Search")
|
||||
self.searchbox.textChanged["QString"].connect(self.updateUsers)
|
||||
self.searchbox.textChanged[str].connect(self.updateUsers)
|
||||
|
||||
self.label = QtWidgets.QLabel("USERLIST")
|
||||
self.userarea = RightClickList(self)
|
||||
|
@ -1847,9 +1845,7 @@ class PesterUserlist(QtWidgets.QDialog):
|
|||
|
||||
self.mainwindow.namesUpdated.connect(self.updateUsers)
|
||||
|
||||
self.mainwindow.userPresentSignal["QString", "QString", "QString"].connect(
|
||||
self.updateUserPresent
|
||||
)
|
||||
self.mainwindow.userPresentSignal[str, str, str].connect(self.updateUserPresent)
|
||||
self.updateUsers()
|
||||
|
||||
self.searchbox.setFocus()
|
||||
|
@ -1863,10 +1859,9 @@ class PesterUserlist(QtWidgets.QDialog):
|
|||
return
|
||||
self.userarea.clear()
|
||||
for n in names:
|
||||
if (
|
||||
str(self.searchbox.text()) == ""
|
||||
or n.lower().find(str(self.searchbox.text()).lower()) != -1
|
||||
):
|
||||
if (self.searchbox.text()) == "" or n.lower().find(
|
||||
self.searchbox.text().lower()
|
||||
) != -1:
|
||||
# Strip channel membership prefixes
|
||||
n = n.strip("~").strip("@").strip("+").strip("&").strip("%")
|
||||
item = QtWidgets.QListWidgetItem(n)
|
||||
|
@ -1876,20 +1871,18 @@ class PesterUserlist(QtWidgets.QDialog):
|
|||
self.userarea.addItem(item)
|
||||
self.userarea.sortItems()
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString, QString)
|
||||
@QtCore.pyqtSlot(str, str, str)
|
||||
def updateUserPresent(self, handle, channel, update):
|
||||
h = str(handle)
|
||||
c = str(channel)
|
||||
if update == "quit":
|
||||
self.delUser(h)
|
||||
elif update == "left" and c == "#pesterchum":
|
||||
self.delUser(h)
|
||||
elif update == "join" and c == "#pesterchum":
|
||||
self.delUser(handle)
|
||||
elif update == "left" and channel == "#pesterchum":
|
||||
self.delUser(handle)
|
||||
elif update == "join" and channel == "#pesterchum":
|
||||
if (
|
||||
str(self.searchbox.text()) == ""
|
||||
or h.lower().find(str(self.searchbox.text()).lower()) != -1
|
||||
self.searchbox.text() == ""
|
||||
or handle.lower().find(self.searchbox.text().lower()) != -1
|
||||
):
|
||||
self.addUser(h)
|
||||
self.addUser(handle)
|
||||
|
||||
def addUser(self, name):
|
||||
item = QtWidgets.QListWidgetItem(name)
|
||||
|
@ -1928,8 +1921,8 @@ class PesterUserlist(QtWidgets.QDialog):
|
|||
return
|
||||
self.pesterChum.emit(cur.text())
|
||||
|
||||
addChum = QtCore.pyqtSignal("QString")
|
||||
pesterChum = QtCore.pyqtSignal("QString")
|
||||
addChum = QtCore.pyqtSignal(str)
|
||||
pesterChum = QtCore.pyqtSignal(str)
|
||||
|
||||
|
||||
class MemoListItem(QtWidgets.QTreeWidgetItem):
|
||||
|
@ -1939,7 +1932,7 @@ class MemoListItem(QtWidgets.QTreeWidgetItem):
|
|||
|
||||
def __lt__(self, other):
|
||||
column = self.treeWidget().sortColumn()
|
||||
if str(self.text(column)).isdigit() and str(other.text(column)).isdigit():
|
||||
if (self.text(column)).isdigit() and (other.text(column)).isdigit():
|
||||
return int(self.text(column)) < int(other.text(column))
|
||||
return self.text(column) < other.text(column)
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ PchumLog = logging.getLogger("pchumLogger")
|
|||
|
||||
# I'll clean up the things that are no longer needed once the transition is
|
||||
# actually finished.
|
||||
QString = str
|
||||
|
||||
_ctag_begin = re.compile(r"(?i)<c=(.*?)>")
|
||||
# _gtag_begin = re.compile(r"(?i)<g[a-f]>")
|
||||
|
@ -67,7 +66,7 @@ def lexer(string, objlist):
|
|||
for oType, regexp in objlist:
|
||||
newstringlist = []
|
||||
for stri, s in enumerate(stringlist):
|
||||
if type(s) not in [str, str]:
|
||||
if not isinstance(s, str):
|
||||
newstringlist.append(s)
|
||||
continue
|
||||
lasti = 0
|
||||
|
@ -269,9 +268,8 @@ class mecmd(lexercon.Chunk):
|
|||
kxpclexer = lexercon.Pesterchum()
|
||||
|
||||
|
||||
def kxlexMsg(string):
|
||||
# Do a bit of sanitization.
|
||||
msg = str(string)
|
||||
def kxlexMsg(msg: str):
|
||||
"""Do a bit of sanitization."""
|
||||
# TODO: Let people paste line-by-line normally. Maybe have a mass-paste
|
||||
# right-click option?
|
||||
msg = msg.replace("\n", " ").replace("\r", " ")
|
||||
|
@ -328,7 +326,7 @@ def balance(lexed):
|
|||
balanced.append(colorEnd("</c>"))
|
||||
if len(balanced) == 0:
|
||||
balanced.append("")
|
||||
if type(balanced[len(balanced) - 1]) not in [str, str]:
|
||||
if not isinstance(balanced[len(balanced) - 1], str):
|
||||
balanced.append("")
|
||||
return balanced
|
||||
|
||||
|
@ -337,12 +335,12 @@ def convertTags(lexed, format="html"):
|
|||
if format not in ["html", "bbcode", "ctag", "text"]:
|
||||
raise ValueError("Color format not recognized")
|
||||
|
||||
if type(lexed) in [str, str]:
|
||||
if isinstance(lexed, str):
|
||||
lexed = lexMessage(lexed)
|
||||
escaped = ""
|
||||
# firststr = True
|
||||
for i, o in enumerate(lexed):
|
||||
if type(o) in [str, str]:
|
||||
if isinstance(o, str):
|
||||
if format == "html":
|
||||
escaped += (
|
||||
o.replace("&", "&").replace(">", ">").replace("<", "<")
|
||||
|
@ -371,7 +369,7 @@ def _max_msg_len(mask=None, target=None, nick=None, ident=None):
|
|||
|
||||
if mask is not None:
|
||||
# Since this will be included in what we send
|
||||
limit -= len(str(mask))
|
||||
limit -= len(mask)
|
||||
else:
|
||||
# Since we should always be able to fetch this
|
||||
# karxi: ... Which we can't, right now, unlike in the old script.
|
||||
|
@ -829,7 +827,7 @@ def kxhandleInput(ctx, text=None, flavor=None, irc_compatible=False):
|
|||
# if ceased, rebegin
|
||||
if hasattr(ctx, "chumopen") and not ctx.chumopen:
|
||||
if not irc_compatible:
|
||||
ctx.mainwindow.newConvoStarted.emit(QString(ctx.title()), True)
|
||||
ctx.mainwindow.newConvoStarted.emit(str(ctx.title()), True)
|
||||
ctx.setChumOpen(True)
|
||||
|
||||
# Post-process and send the messages.
|
||||
|
@ -997,9 +995,7 @@ def parseRegexpFunctions(to):
|
|||
return parsed
|
||||
|
||||
|
||||
def img2smiley(string):
|
||||
string = str(string)
|
||||
|
||||
def img2smiley(string: str):
|
||||
def imagerep(mo):
|
||||
return reverse_smiley[mo.group(1)]
|
||||
|
||||
|
|
302
pesterchum.py
302
pesterchum.py
|
@ -163,8 +163,6 @@ BOTNAMES.extend(SERVICES)
|
|||
_CONSOLE = False
|
||||
_CONSOLE_ENV = {}
|
||||
_CONSOLE_ENV["PAPP"] = None
|
||||
# Python 3
|
||||
QString = str
|
||||
# Command line arguments
|
||||
_ARGUMENTS = parser.parse_args()
|
||||
|
||||
|
@ -485,7 +483,7 @@ class chumArea(RightClickTree):
|
|||
def getOptionsMenu(self):
|
||||
if not self.currentItem():
|
||||
return None
|
||||
text = str(self.currentItem().text(0))
|
||||
text = self.currentItem().text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
if text == "Chums":
|
||||
|
@ -537,11 +535,11 @@ class chumArea(RightClickTree):
|
|||
else:
|
||||
event.ignore()
|
||||
return
|
||||
thisitem = str(event.source().currentItem().text(0))
|
||||
thisitem = event.source().currentItem().text(0)
|
||||
if thisitem.rfind(" (") != -1:
|
||||
thisitem = thisitem[0 : thisitem.rfind(" (")]
|
||||
# Drop item is a group
|
||||
thisitem = str(event.source().currentItem().text(0))
|
||||
thisitem = event.source().currentItem().text(0)
|
||||
if thisitem.rfind(" (") != -1:
|
||||
thisitem = thisitem[0 : thisitem.rfind(" (")]
|
||||
if thisitem == "Chums" or thisitem in self.groups:
|
||||
|
@ -553,7 +551,7 @@ class chumArea(RightClickTree):
|
|||
droppos = self.itemAt(event.pos())
|
||||
if not droppos:
|
||||
return
|
||||
droppos = str(droppos.text(0))
|
||||
droppos = droppos.text(0)
|
||||
if droppos.rfind(" ") != -1:
|
||||
droppos = droppos[0 : droppos.rfind(" ")]
|
||||
if droppos == "Chums" or droppos in self.groups:
|
||||
|
@ -575,10 +573,10 @@ class chumArea(RightClickTree):
|
|||
|
||||
gTemp = []
|
||||
for i in range(self.topLevelItemCount()):
|
||||
text = str(self.topLevelItem(i).text(0))
|
||||
text = self.topLevelItem(i).text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
gTemp.append([str(text), self.topLevelItem(i).isExpanded()])
|
||||
gTemp.append([text, self.topLevelItem(i).isExpanded()])
|
||||
self.mainwindow.config.saveGroups(gTemp)
|
||||
# Drop item is a chum
|
||||
else:
|
||||
|
@ -590,7 +588,7 @@ class chumArea(RightClickTree):
|
|||
eventpos = event.pos()
|
||||
item = self.itemAt(eventpos)
|
||||
if item:
|
||||
text = str(item.text(0))
|
||||
text = item.text(0)
|
||||
# Figure out which group to drop into
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
|
@ -598,7 +596,7 @@ class chumArea(RightClickTree):
|
|||
group = text
|
||||
gitem = item
|
||||
else:
|
||||
ptext = str(item.parent().text(0))
|
||||
ptext = item.parent().text(0)
|
||||
if ptext.rfind(" ") != -1:
|
||||
ptext = ptext[0 : ptext.rfind(" ")]
|
||||
group = ptext
|
||||
|
@ -617,11 +615,11 @@ class chumArea(RightClickTree):
|
|||
chums = self.mainwindow.config.chums()
|
||||
if item == gitem:
|
||||
item = gitem.child(0)
|
||||
inPos = chums.index(str(item.text(0)))
|
||||
inPos = chums.index(item.text(0))
|
||||
if chums.index(thisitem) < inPos:
|
||||
inPos -= 1
|
||||
chums.remove(thisitem)
|
||||
chums.insert(inPos, str(thisitem))
|
||||
chums.insert(inPos, thisitem)
|
||||
|
||||
self.mainwindow.config.setChums(chums)
|
||||
else:
|
||||
|
@ -633,9 +631,9 @@ class chumArea(RightClickTree):
|
|||
currentGroup = self.currentItem()
|
||||
if currentGroup:
|
||||
if currentGroup.parent():
|
||||
text = str(currentGroup.parent().text(0))
|
||||
text = currentGroup.parent().text(0)
|
||||
else:
|
||||
text = str(currentGroup.text(0))
|
||||
text = currentGroup.text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
currentGroup = text
|
||||
|
@ -703,7 +701,7 @@ class chumArea(RightClickTree):
|
|||
return
|
||||
curgroups = []
|
||||
for i in range(self.topLevelItemCount()):
|
||||
text = str(self.topLevelItem(i).text(0))
|
||||
text = self.topLevelItem(i).text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
curgroups.append(text)
|
||||
|
@ -728,24 +726,24 @@ class chumArea(RightClickTree):
|
|||
totals = {"Chums": 0}
|
||||
online = {"Chums": 0}
|
||||
for g in self.groups:
|
||||
totals[str(g)] = 0
|
||||
online[str(g)] = 0
|
||||
totals[g] = 0
|
||||
online[g] = 0
|
||||
for c in self.chums:
|
||||
yes = c.mood.name() != "offline"
|
||||
if c.group == "Chums":
|
||||
totals[str(c.group)] = totals[str(c.group)] + 1
|
||||
totals[c.group] = totals[c.group] + 1
|
||||
if yes:
|
||||
online[str(c.group)] = online[str(c.group)] + 1
|
||||
online[c.group] = online[c.group] + 1
|
||||
elif c.group in totals:
|
||||
totals[str(c.group)] = totals[str(c.group)] + 1
|
||||
totals[c.group] = totals[c.group] + 1
|
||||
if yes:
|
||||
online[str(c.group)] = online[str(c.group)] + 1
|
||||
online[c.group] = online[c.group] + 1
|
||||
else:
|
||||
totals["Chums"] = totals["Chums"] + 1
|
||||
if yes:
|
||||
online["Chums"] = online["Chums"] + 1
|
||||
for i in range(self.topLevelItemCount()):
|
||||
text = str(self.topLevelItem(i).text(0))
|
||||
text = self.topLevelItem(i).text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
if text in online:
|
||||
|
@ -755,7 +753,7 @@ class chumArea(RightClickTree):
|
|||
|
||||
def hideOnlineNumbers(self):
|
||||
for i in range(self.topLevelItemCount()):
|
||||
text = str(self.topLevelItem(i).text(0))
|
||||
text = self.topLevelItem(i).text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
self.topLevelItem(i).setText(0, "%s" % (text))
|
||||
|
@ -773,7 +771,7 @@ class chumArea(RightClickTree):
|
|||
@QtCore.pyqtSlot()
|
||||
def expandGroup(self):
|
||||
item = self.currentItem()
|
||||
text = str(item.text(0))
|
||||
text = item.text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
|
||||
|
@ -789,7 +787,7 @@ class chumArea(RightClickTree):
|
|||
self.mainwindow.config.addGroup("Chums")
|
||||
curgroups = []
|
||||
for i in range(self.topLevelItemCount()):
|
||||
text = str(self.topLevelItem(i).text(0))
|
||||
text = self.topLevelItem(i).text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
curgroups.append(text)
|
||||
|
@ -812,7 +810,7 @@ class chumArea(RightClickTree):
|
|||
]:
|
||||
child_1.setExpanded(True)
|
||||
for i in range(self.topLevelItemCount()):
|
||||
text = str(self.topLevelItem(i).text(0))
|
||||
text = self.topLevelItem(i).text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
if text == chumLabel.chum.group:
|
||||
|
@ -832,7 +830,7 @@ class chumArea(RightClickTree):
|
|||
if fi > 0:
|
||||
while not bestj:
|
||||
for j in range(self.topLevelItem(i).childCount()):
|
||||
if chums[fi - c] == str(
|
||||
if chums[fi - c] == (
|
||||
self.topLevelItem(i).child(j).text(0)
|
||||
):
|
||||
bestj = j
|
||||
|
@ -1065,7 +1063,6 @@ class chumArea(RightClickTree):
|
|||
self, "Notes", "Enter your notes..."
|
||||
)
|
||||
if ok:
|
||||
notes = str(notes)
|
||||
self.mainwindow.chumdb.setNotes(currentChum.handle, notes)
|
||||
currentChum.setToolTip(0, "{}: {}".format(currentChum.handle, notes))
|
||||
|
||||
|
@ -1078,7 +1075,6 @@ class chumArea(RightClickTree):
|
|||
self, "Rename Group", "Enter a new name for the group:"
|
||||
)
|
||||
if ok:
|
||||
gname = str(gname)
|
||||
if re.search(r"[^A-Za-z0-9_\s]", gname) is not None:
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setStyleSheet(
|
||||
|
@ -1096,7 +1092,7 @@ class chumArea(RightClickTree):
|
|||
index = self.indexOfTopLevelItem(currentGroup)
|
||||
if index != -1:
|
||||
expanded = currentGroup.isExpanded()
|
||||
text = str(currentGroup.text(0))
|
||||
text = currentGroup.text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
self.mainwindow.config.delGroup(text)
|
||||
|
@ -1119,7 +1115,7 @@ class chumArea(RightClickTree):
|
|||
currentGroup = self.currentItem()
|
||||
if not currentGroup:
|
||||
return
|
||||
text = str(currentGroup.text(0))
|
||||
text = currentGroup.text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
self.mainwindow.config.delGroup(text)
|
||||
|
@ -1143,7 +1139,7 @@ class chumArea(RightClickTree):
|
|||
def moveToGroup(self, item):
|
||||
if not item:
|
||||
return
|
||||
group = str(item.text())
|
||||
group = item.text()
|
||||
chumLabel = self.currentItem()
|
||||
if not chumLabel:
|
||||
return
|
||||
|
@ -1152,8 +1148,8 @@ class chumArea(RightClickTree):
|
|||
self.takeItem(chumLabel)
|
||||
self.addItem(chumLabel)
|
||||
|
||||
removeChumSignal = QtCore.pyqtSignal("QString")
|
||||
blockChumSignal = QtCore.pyqtSignal("QString")
|
||||
removeChumSignal = QtCore.pyqtSignal(str)
|
||||
blockChumSignal = QtCore.pyqtSignal(str)
|
||||
|
||||
|
||||
class trollSlum(chumArea):
|
||||
|
@ -1211,7 +1207,7 @@ class trollSlum(chumArea):
|
|||
# TypeError: connect() failed between triggered(bool) and unblockChumSignal()
|
||||
# I'm not sure why this was here in the first place-
|
||||
# Does removing it break anything else...?
|
||||
# unblockChumSignal = QtCore.pyqtSignal('QString')
|
||||
# unblockChumSignal = QtCore.pyqtSignal(str)
|
||||
|
||||
|
||||
class TrollSlumWindow(QtWidgets.QFrame):
|
||||
|
@ -1282,7 +1278,6 @@ class TrollSlumWindow(QtWidgets.QFrame):
|
|||
self, "Add Troll", "Enter Troll Handle:"
|
||||
)
|
||||
if ok:
|
||||
handle = str(handle)
|
||||
if not (
|
||||
PesterProfile.checkLength(handle)
|
||||
and PesterProfile.checkValid(handle)[0]
|
||||
|
@ -1295,13 +1290,13 @@ class TrollSlumWindow(QtWidgets.QFrame):
|
|||
self.blockChumSignal.emit(handle)
|
||||
self.addtrolldialog = None
|
||||
|
||||
blockChumSignal = QtCore.pyqtSignal("QString")
|
||||
unblockChumSignal = QtCore.pyqtSignal("QString")
|
||||
blockChumSignal = QtCore.pyqtSignal(str)
|
||||
unblockChumSignal = QtCore.pyqtSignal(str)
|
||||
|
||||
|
||||
class PesterWindow(MovingWindow):
|
||||
disconnectIRC = QtCore.pyqtSignal()
|
||||
sendMessage = QtCore.pyqtSignal("QString", "QString")
|
||||
sendMessage = QtCore.pyqtSignal(str, str)
|
||||
|
||||
def __init__(self, options, parent=None, app=None):
|
||||
super().__init__(
|
||||
|
@ -1596,8 +1591,8 @@ class PesterWindow(MovingWindow):
|
|||
self.chumList.itemActivated[QtWidgets.QTreeWidgetItem, int].connect(
|
||||
self.pesterSelectedChum
|
||||
)
|
||||
self.chumList.removeChumSignal["QString"].connect(self.removeChum)
|
||||
self.chumList.blockChumSignal["QString"].connect(self.blockChum)
|
||||
self.chumList.removeChumSignal[str].connect(self.removeChum)
|
||||
self.chumList.blockChumSignal[str].connect(self.blockChum)
|
||||
|
||||
self.addChumButton = QtWidgets.QPushButton(
|
||||
self.theme["main/addchum/text"], self
|
||||
|
@ -1662,7 +1657,7 @@ class PesterWindow(MovingWindow):
|
|||
# if not ostools.isOSXLeopard():
|
||||
# QtCore.QTimer.singleShot(1000, self.mspacheck)
|
||||
|
||||
self.pcUpdate["QString", "QString"].connect(self.updateMsg)
|
||||
self.pcUpdate[str, str].connect(self.updateMsg)
|
||||
|
||||
self.mychumhandleLabel.adjustSize() # Required so "CHUMHANDLE:" regardless of style-sheet.
|
||||
self.moodsLabel.adjustSize() # Required so "MOOD:" regardless of style-sheet.
|
||||
|
@ -1707,7 +1702,7 @@ class PesterWindow(MovingWindow):
|
|||
# We probably tried to interact with a call not available on this kernel.
|
||||
PchumLog.exception("")
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def updateMsg(self, ver, url):
|
||||
if not hasattr(self, "updatemenu"):
|
||||
self.updatemenu = None
|
||||
|
@ -2027,18 +2022,19 @@ class PesterWindow(MovingWindow):
|
|||
self.tabconvo.show()
|
||||
else:
|
||||
convoWindow = PesterConvo(chum, initiated, self)
|
||||
convoWindow.messageSent["QString", "QString"].connect(
|
||||
self.sendMessage["QString", "QString"]
|
||||
)
|
||||
convoWindow.windowClosed["QString"].connect(self.closeConvo)
|
||||
convoWindow.messageSent[str, str].connect(self.sendMessage[str, str])
|
||||
convoWindow.windowClosed[str].connect(self.closeConvo)
|
||||
self.convos[chum.handle] = convoWindow
|
||||
if chum.handle.upper() in BOTNAMES or self.config.irc_compatibility_mode():
|
||||
if chum.handle.upper() in BOTNAMES:
|
||||
convoWindow.toggleQuirks(True)
|
||||
convoWindow.quirksOff.setChecked(True)
|
||||
if str(chum.handle).upper() in CUSTOMBOTS:
|
||||
self.newConvoStarted.emit(QString(chum.handle), initiated)
|
||||
if (
|
||||
not self.config.irc_compatibility_mode()
|
||||
or chum.handle.upper() in CUSTOMBOTS
|
||||
):
|
||||
self.newConvoStarted.emit(chum.handle, initiated)
|
||||
else:
|
||||
self.newConvoStarted.emit(QString(chum.handle), initiated)
|
||||
self.newConvoStarted.emit(chum.handle, initiated)
|
||||
convoWindow.show()
|
||||
|
||||
def createTabWindow(self):
|
||||
|
@ -2134,17 +2130,13 @@ class PesterWindow(MovingWindow):
|
|||
else:
|
||||
memoWindow = PesterMemo(channel, timestr, self, None)
|
||||
# connect signals
|
||||
self.inviteOnlyChan["QString"].connect(memoWindow.closeInviteOnly)
|
||||
self.forbiddenChan["QString", "QString"].connect(memoWindow.closeForbidden)
|
||||
memoWindow.messageSent["QString", "QString"].connect(
|
||||
self.sendMessage["QString", "QString"]
|
||||
)
|
||||
memoWindow.windowClosed["QString"].connect(self.closeMemo)
|
||||
self.namesUpdated["QString"].connect(memoWindow.namesUpdated)
|
||||
self.modesUpdated["QString", "QString"].connect(memoWindow.modesUpdated)
|
||||
self.userPresentSignal["QString", "QString", "QString"].connect(
|
||||
memoWindow.userPresentChange
|
||||
)
|
||||
self.inviteOnlyChan[str].connect(memoWindow.closeInviteOnly)
|
||||
self.forbiddenChan[str, str].connect(memoWindow.closeForbidden)
|
||||
memoWindow.messageSent[str, str].connect(self.sendMessage[str, str])
|
||||
memoWindow.windowClosed[str].connect(self.closeMemo)
|
||||
self.namesUpdated[str].connect(memoWindow.namesUpdated)
|
||||
self.modesUpdated[str, str].connect(memoWindow.modesUpdated)
|
||||
self.userPresentSignal[str, str, str].connect(memoWindow.userPresentChange)
|
||||
# chat client send memo open
|
||||
self.memos[channel] = memoWindow
|
||||
self.joinChannel.emit(channel) # race condition?
|
||||
|
@ -2593,7 +2585,7 @@ class PesterWindow(MovingWindow):
|
|||
def pesterSelectedChum(self):
|
||||
curChum = self.chumList.currentItem()
|
||||
if curChum:
|
||||
text = str(curChum.text(0))
|
||||
text = curChum.text(0)
|
||||
if text.rfind(" (") != -1:
|
||||
text = text[0 : text.rfind(" (")]
|
||||
if text not in self.chumList.groups and text != "Chums":
|
||||
|
@ -2608,9 +2600,9 @@ class PesterWindow(MovingWindow):
|
|||
chum.color = color
|
||||
self.newConversation(chum)
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def closeConvo(self, handle):
|
||||
h = str(handle)
|
||||
h = handle
|
||||
try:
|
||||
chum = self.convos[h].chum
|
||||
except KeyError:
|
||||
|
@ -2633,9 +2625,9 @@ class PesterWindow(MovingWindow):
|
|||
self.chatlog.finish(h)
|
||||
del self.convos[h]
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def closeMemo(self, channel):
|
||||
c = str(channel)
|
||||
c = channel
|
||||
self.chatlog.finish(c)
|
||||
self.leftChannel.emit(channel)
|
||||
try:
|
||||
|
@ -2656,31 +2648,30 @@ class PesterWindow(MovingWindow):
|
|||
del self.tabmemo
|
||||
self.tabmemo = None
|
||||
|
||||
@QtCore.pyqtSlot(QString, Mood)
|
||||
@QtCore.pyqtSlot(str, Mood)
|
||||
def updateMoodSlot(self, handle, mood):
|
||||
h = str(handle)
|
||||
h = handle
|
||||
self.updateMood(h, mood)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QtGui.QColor)
|
||||
@QtCore.pyqtSlot(str, QtGui.QColor)
|
||||
def updateColorSlot(self, handle, color):
|
||||
PchumLog.debug("updateColorSlot(%s, %s)", handle, color)
|
||||
self.changeColor(handle, color)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def deliverMessage(self, handle, msg):
|
||||
h = str(handle)
|
||||
m = str(msg)
|
||||
h = handle
|
||||
m = msg
|
||||
self.newMessage(h, m)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString, QString)
|
||||
@QtCore.pyqtSlot(str, str, str)
|
||||
def deliverMemo(self, chan, handle, msg):
|
||||
(c, h, m) = (str(chan), str(handle), str(msg))
|
||||
self.newMemoMsg(c, h, m)
|
||||
self.newMemoMsg(chan, handle, msg)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def deliverNotice(self, handle, msg):
|
||||
h = str(handle)
|
||||
m = str(msg)
|
||||
h = handle
|
||||
m = msg
|
||||
if h.upper() == "NICKSERV" and m.startswith(
|
||||
"Your nickname is now being changed to"
|
||||
):
|
||||
|
@ -2710,7 +2701,7 @@ class PesterWindow(MovingWindow):
|
|||
t = self.tm.Toast("%s:" % h, m)
|
||||
t.show()
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def deliverInvite(self, handle, channel):
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setText("You're invited!")
|
||||
|
@ -2739,44 +2730,41 @@ class PesterWindow(MovingWindow):
|
|||
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
|
||||
self.newMemo(str(channel), "+0:00")
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def chanInviteOnly(self, channel):
|
||||
self.inviteOnlyChan.emit(channel)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def cannotSendToChan(self, channel, msg):
|
||||
self.deliverMemo(channel, "ChanServ", msg)
|
||||
|
||||
# Unused and redefined.
|
||||
# @QtCore.pyqtSlot(QString, QString)
|
||||
# @QtCore.pyqtSlot(str, str)
|
||||
# def modesUpdated(self, channel, modes):
|
||||
# self.modesUpdated.emit(channel, modes)
|
||||
@QtCore.pyqtSlot(QString, QString, QString)
|
||||
@QtCore.pyqtSlot(str, str, str)
|
||||
def timeCommand(self, chan, handle, command):
|
||||
(c, h, cmd) = (str(chan), str(handle), str(command))
|
||||
if self.memos[c]:
|
||||
self.memos[c].timeUpdate(h, cmd)
|
||||
if self.memos[chan]:
|
||||
self.memos[chan].timeUpdate(handle, command)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString, QString)
|
||||
@QtCore.pyqtSlot(str, str, str)
|
||||
def quirkDisable(self, channel, msg, op):
|
||||
(c, msg, op) = (str(channel), str(msg), str(op))
|
||||
if c not in self.memos:
|
||||
if channel not in self.memos:
|
||||
return
|
||||
memo = self.memos[c]
|
||||
memo = self.memos[channel]
|
||||
memo.quirkDisable(op, msg)
|
||||
|
||||
@QtCore.pyqtSlot(QString, PesterList)
|
||||
@QtCore.pyqtSlot(str, PesterList)
|
||||
def updateNames(self, channel, names):
|
||||
c = str(channel)
|
||||
# update name DB
|
||||
self.namesdb[c] = names
|
||||
self.namesdb[channel] = names
|
||||
# warn interested party of names
|
||||
self.namesUpdated.emit(c)
|
||||
self.namesUpdated.emit(channel)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString, QString)
|
||||
@QtCore.pyqtSlot(str, str, str)
|
||||
def userPresentUpdate(self, handle, channel, update):
|
||||
c = str(channel)
|
||||
n = str(handle)
|
||||
c = channel
|
||||
n = handle
|
||||
# print("c=%s\nn=%s\nupdate=%s\n" % (c, n, update))
|
||||
if update == "nick":
|
||||
l = n.split(":")
|
||||
|
@ -2831,12 +2819,11 @@ class PesterWindow(MovingWindow):
|
|||
available_groups = [g[0] for g in self.config.getGroups()]
|
||||
self.addchumdialog = AddChumDialog(available_groups, self)
|
||||
ok = self.addchumdialog.exec()
|
||||
handle = str(self.addchumdialog.chumBox.text()).strip()
|
||||
newgroup = str(self.addchumdialog.newgroup.text()).strip()
|
||||
handle = (self.addchumdialog.chumBox.text()).strip()
|
||||
newgroup = (self.addchumdialog.newgroup.text()).strip()
|
||||
selectedGroup = self.addchumdialog.groupBox.currentText()
|
||||
group = newgroup if newgroup else selectedGroup
|
||||
if ok:
|
||||
handle = str(handle)
|
||||
if handle in [h.handle for h in self.chumList.chums]:
|
||||
self.addchumdialog = None
|
||||
return
|
||||
|
@ -2861,7 +2848,7 @@ class PesterWindow(MovingWindow):
|
|||
self.addChum(chum)
|
||||
self.addchumdialog = None
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def removeChum(self, chumlisting):
|
||||
self.config.removeChum(chumlisting)
|
||||
|
||||
|
@ -2874,9 +2861,9 @@ class PesterWindow(MovingWindow):
|
|||
if ok:
|
||||
self.sendMessage.emit("REPORT {} {}".format(handle, reason), "calSprite")
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def blockChum(self, handle):
|
||||
h = str(handle)
|
||||
h = handle
|
||||
self.config.addBlocklist(h)
|
||||
self.config.removeChum(h)
|
||||
if h in self.convos:
|
||||
|
@ -2897,9 +2884,9 @@ class PesterWindow(MovingWindow):
|
|||
if not self.config.irc_compatibility_mode():
|
||||
self.blockedChum.emit(handle)
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def unblockChum(self, handle):
|
||||
h = str(handle)
|
||||
h = handle
|
||||
self.config.delBlocklist(h)
|
||||
if h in self.convos:
|
||||
convo = self.convos[h]
|
||||
|
@ -3056,25 +3043,25 @@ class PesterWindow(MovingWindow):
|
|||
|
||||
@QtCore.pyqtSlot()
|
||||
def joinSelectedMemo(self):
|
||||
time = str(self.memochooser.timeinput.text())
|
||||
time = self.memochooser.timeinput.text()
|
||||
secret = self.memochooser.secretChannel.isChecked()
|
||||
invite = self.memochooser.inviteChannel.isChecked()
|
||||
|
||||
# Join the ones on the list first
|
||||
for SelectedMemo in self.memochooser.SelectedMemos():
|
||||
channel = "#" + str(SelectedMemo.target)
|
||||
channel = f"#{SelectedMemo.target}"
|
||||
self.newMemo(channel, time)
|
||||
|
||||
if self.memochooser.newmemoname():
|
||||
newmemo = self.memochooser.newmemoname()
|
||||
channel = str(newmemo).replace(" ", "_")
|
||||
channel = newmemo.replace(" ", "_")
|
||||
channel = re.sub(r"[^A-Za-z0-9#_\,]", "", channel)
|
||||
# Allow us to join more than one with this.
|
||||
chans = channel.split(",")
|
||||
# Filter out empty entries.
|
||||
chans = [_f for _f in chans if _f]
|
||||
for c in chans:
|
||||
c = "#" + c
|
||||
c = f"#{c}"
|
||||
# We should really change this code to only make the memo once
|
||||
# the server has confirmed that we've joined....
|
||||
self.newMemo(c, time, secret=secret, invite=invite)
|
||||
|
@ -3098,21 +3085,19 @@ class PesterWindow(MovingWindow):
|
|||
self.allusers = PesterUserlist(self.config, self.theme, self)
|
||||
self.allusers.accepted.connect(self.userListClose)
|
||||
self.allusers.rejected.connect(self.userListClose)
|
||||
self.allusers.addChum["QString"].connect(self.userListAdd)
|
||||
self.allusers.pesterChum["QString"].connect(self.userListPester)
|
||||
self.allusers.addChum[str].connect(self.userListAdd)
|
||||
self.allusers.pesterChum[str].connect(self.userListPester)
|
||||
self.requestNames.emit("#pesterchum")
|
||||
self.allusers.show()
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def userListAdd(self, handle):
|
||||
h = str(handle)
|
||||
chum = PesterProfile(h, chumdb=self.chumdb)
|
||||
chum = PesterProfile(handle, chumdb=self.chumdb)
|
||||
self.addChum(chum)
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def userListPester(self, handle):
|
||||
h = str(handle)
|
||||
self.newConversation(h)
|
||||
self.newConversation(handle)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def userListClose(self):
|
||||
|
@ -3133,7 +3118,7 @@ class PesterWindow(MovingWindow):
|
|||
@QtCore.pyqtSlot()
|
||||
def updateQuirks(self):
|
||||
for i in range(self.quirkmenu.quirkList.topLevelItemCount()):
|
||||
curgroup = str(self.quirkmenu.quirkList.topLevelItem(i).text(0))
|
||||
curgroup = self.quirkmenu.quirkList.topLevelItem(i).text(0)
|
||||
for j in range(self.quirkmenu.quirkList.topLevelItem(i).childCount()):
|
||||
item = self.quirkmenu.quirkList.topLevelItem(i).child(j)
|
||||
item.quirk.quirk["on"] = item.quirk.on = (
|
||||
|
@ -3162,7 +3147,7 @@ class PesterWindow(MovingWindow):
|
|||
)
|
||||
try:
|
||||
if ok:
|
||||
self.newConversation(str(chum))
|
||||
self.newConversation(chum)
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
|
@ -3194,7 +3179,6 @@ class PesterWindow(MovingWindow):
|
|||
self, "Add Group", "Enter a name for the new group:"
|
||||
)
|
||||
if ok:
|
||||
gname = str(gname)
|
||||
if re.search(r"[^A-Za-z0-9_\s]", gname) is not None:
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
|
||||
|
@ -3335,7 +3319,7 @@ class PesterWindow(MovingWindow):
|
|||
# timestamps
|
||||
timestampsetting = self.optionmenu.timestampcheck.isChecked()
|
||||
self.config.set("showTimeStamps", timestampsetting)
|
||||
timeformatsetting = str(self.optionmenu.timestampBox.currentText())
|
||||
timeformatsetting = self.optionmenu.timestampBox.currentText()
|
||||
if timeformatsetting == "12 hour":
|
||||
self.config.set("time12Format", True)
|
||||
else:
|
||||
|
@ -3445,7 +3429,7 @@ class PesterWindow(MovingWindow):
|
|||
self.config.set("blink", blinksetting)
|
||||
# toast notifications
|
||||
self.tm.setEnabled(self.optionmenu.notifycheck.isChecked())
|
||||
self.tm.setCurrentType(str(self.optionmenu.notifyOptions.currentText()))
|
||||
self.tm.setCurrentType(self.optionmenu.notifyOptions.currentText())
|
||||
notifysetting = 0
|
||||
if self.optionmenu.notifySigninCheck.isChecked():
|
||||
notifysetting |= self.config.SIGNIN
|
||||
|
@ -3478,11 +3462,11 @@ class PesterWindow(MovingWindow):
|
|||
autoidentify = self.optionmenu.autonickserv.isChecked()
|
||||
nickservpass = self.optionmenu.nickservpass.text()
|
||||
self.userprofile.setAutoIdentify(autoidentify)
|
||||
self.userprofile.setNickServPass(str(nickservpass))
|
||||
self.userprofile.setNickServPass(nickservpass)
|
||||
# auto join memos
|
||||
autojoins = []
|
||||
for i in range(self.optionmenu.autojoinlist.count()):
|
||||
autojoins.append(str(self.optionmenu.autojoinlist.item(i).text()))
|
||||
autojoins.append(self.optionmenu.autojoinlist.item(i).text())
|
||||
self.userprofile.setAutoJoins(autojoins)
|
||||
# advanced
|
||||
## user mode
|
||||
|
@ -3517,7 +3501,7 @@ class PesterWindow(MovingWindow):
|
|||
@QtCore.pyqtSlot()
|
||||
def themeSelected(self, override=False):
|
||||
if not override:
|
||||
themename = str(self.optionmenu.themeBox.currentText())
|
||||
themename = self.optionmenu.themeBox.currentText()
|
||||
else:
|
||||
themename = override
|
||||
if override or themename != self.theme.name:
|
||||
|
@ -3543,7 +3527,7 @@ class PesterWindow(MovingWindow):
|
|||
self.chooseprofile.profileBox
|
||||
and self.chooseprofile.profileBox.currentIndex() > 0
|
||||
):
|
||||
handle = str(self.chooseprofile.profileBox.currentText())
|
||||
handle = self.chooseprofile.profileBox.currentText()
|
||||
if handle == self.profile().handle:
|
||||
self.chooseprofile = None
|
||||
return
|
||||
|
@ -3586,7 +3570,7 @@ class PesterWindow(MovingWindow):
|
|||
msgBox.exec()
|
||||
return
|
||||
else:
|
||||
handle = str(self.chooseprofile.chumHandle.text())
|
||||
handle = self.chooseprofile.chumHandle.text()
|
||||
if handle == self.profile().handle:
|
||||
self.chooseprofile = None
|
||||
return
|
||||
|
@ -3613,8 +3597,8 @@ class PesterWindow(MovingWindow):
|
|||
return
|
||||
trolls = [PesterProfile(h) for h in self.config.getBlocklist()]
|
||||
self.trollslum = TrollSlumWindow(trolls, self)
|
||||
self.trollslum.blockChumSignal["QString"].connect(self.blockChum)
|
||||
self.trollslum.unblockChumSignal["QString"].connect(self.unblockChum)
|
||||
self.trollslum.blockChumSignal[str].connect(self.blockChum)
|
||||
self.trollslum.unblockChumSignal[str].connect(self.unblockChum)
|
||||
self.moodsRequest.emit(PesterList(trolls))
|
||||
self.trollslum.show()
|
||||
|
||||
|
@ -3724,7 +3708,7 @@ class PesterWindow(MovingWindow):
|
|||
)
|
||||
)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def nickCollision(self, handle, tmphandle):
|
||||
if hasattr(self, "loadingscreen"):
|
||||
if self.loadingscreen is not None:
|
||||
|
@ -3744,10 +3728,10 @@ class PesterWindow(MovingWindow):
|
|||
if not hasattr(self, "chooseprofile"):
|
||||
self.chooseprofile = None
|
||||
if not self.chooseprofile:
|
||||
h = str(handle)
|
||||
h = handle
|
||||
self.changeProfile(collision=h)
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def getSvsnickedOn(self, oldhandle, newhandle):
|
||||
if hasattr(self, "loadingscreen"):
|
||||
if self.loadingscreen is not None:
|
||||
|
@ -3765,7 +3749,7 @@ class PesterWindow(MovingWindow):
|
|||
if not self.chooseprofile:
|
||||
self.changeProfile(svsnick=(oldhandle, newhandle))
|
||||
|
||||
@QtCore.pyqtSlot(QString)
|
||||
@QtCore.pyqtSlot(str)
|
||||
def myHandleChanged(self, handle):
|
||||
# Update nick in channels
|
||||
for memo in self.memos.keys():
|
||||
|
@ -3800,7 +3784,7 @@ class PesterWindow(MovingWindow):
|
|||
# msg.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
|
||||
msg.exec()
|
||||
|
||||
@QtCore.pyqtSlot(QString, QString)
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def forbiddenchannel(self, channel, reason):
|
||||
self.forbiddenChan.emit(channel, reason)
|
||||
|
||||
|
@ -4215,41 +4199,41 @@ class PesterWindow(MovingWindow):
|
|||
if ret == QtWidgets.QMessageBox.StandardButton.Yes:
|
||||
self.parent.restartIRC(verify_hostname=False)
|
||||
|
||||
pcUpdate = QtCore.pyqtSignal("QString", "QString")
|
||||
pcUpdate = QtCore.pyqtSignal(str, str)
|
||||
closeToTraySignal = QtCore.pyqtSignal()
|
||||
newConvoStarted = QtCore.pyqtSignal("QString", bool, name="newConvoStarted")
|
||||
sendMessage = QtCore.pyqtSignal("QString", "QString")
|
||||
sendNotice = QtCore.pyqtSignal("QString", "QString")
|
||||
sendCTCP = QtCore.pyqtSignal("QString", "QString")
|
||||
convoClosed = QtCore.pyqtSignal("QString")
|
||||
newConvoStarted = QtCore.pyqtSignal(str, bool, name="newConvoStarted")
|
||||
sendMessage = QtCore.pyqtSignal(str, str)
|
||||
sendNotice = QtCore.pyqtSignal(str, str)
|
||||
sendCTCP = QtCore.pyqtSignal(str, str)
|
||||
convoClosed = QtCore.pyqtSignal(str)
|
||||
profileChanged = QtCore.pyqtSignal()
|
||||
animationSetting = QtCore.pyqtSignal(bool)
|
||||
moodRequest = QtCore.pyqtSignal(PesterProfile)
|
||||
moodsRequest = QtCore.pyqtSignal(PesterList)
|
||||
moodUpdated = QtCore.pyqtSignal()
|
||||
requestChannelList = QtCore.pyqtSignal()
|
||||
requestNames = QtCore.pyqtSignal("QString")
|
||||
namesUpdated = QtCore.pyqtSignal("QString")
|
||||
modesUpdated = QtCore.pyqtSignal("QString", "QString")
|
||||
userPresentSignal = QtCore.pyqtSignal("QString", "QString", "QString")
|
||||
requestNames = QtCore.pyqtSignal(str)
|
||||
namesUpdated = QtCore.pyqtSignal(str)
|
||||
modesUpdated = QtCore.pyqtSignal(str, str)
|
||||
userPresentSignal = QtCore.pyqtSignal(str, str, str)
|
||||
mycolorUpdated = QtCore.pyqtSignal()
|
||||
trayIconSignal = QtCore.pyqtSignal(int)
|
||||
blockedChum = QtCore.pyqtSignal("QString")
|
||||
unblockedChum = QtCore.pyqtSignal("QString")
|
||||
kickUser = QtCore.pyqtSignal("QString", "QString", "QString")
|
||||
joinChannel = QtCore.pyqtSignal("QString")
|
||||
leftChannel = QtCore.pyqtSignal("QString")
|
||||
setChannelMode = QtCore.pyqtSignal("QString", "QString", "QString")
|
||||
channelNames = QtCore.pyqtSignal("QString")
|
||||
inviteChum = QtCore.pyqtSignal("QString", "QString")
|
||||
inviteOnlyChan = QtCore.pyqtSignal("QString")
|
||||
forbiddenChan = QtCore.pyqtSignal("QString", "QString")
|
||||
blockedChum = QtCore.pyqtSignal(str)
|
||||
unblockedChum = QtCore.pyqtSignal(str)
|
||||
kickUser = QtCore.pyqtSignal(str, str, str)
|
||||
joinChannel = QtCore.pyqtSignal(str)
|
||||
leftChannel = QtCore.pyqtSignal(str)
|
||||
setChannelMode = QtCore.pyqtSignal(str, str, str)
|
||||
channelNames = QtCore.pyqtSignal(str)
|
||||
inviteChum = QtCore.pyqtSignal(str, str)
|
||||
inviteOnlyChan = QtCore.pyqtSignal(str)
|
||||
forbiddenChan = QtCore.pyqtSignal(str, str)
|
||||
closeSignal = QtCore.pyqtSignal()
|
||||
disconnectIRC = QtCore.pyqtSignal()
|
||||
gainAttention = QtCore.pyqtSignal(QtWidgets.QWidget)
|
||||
pingServer = QtCore.pyqtSignal()
|
||||
setAway = QtCore.pyqtSignal(bool)
|
||||
killSomeQuirks = QtCore.pyqtSignal("QString", "QString")
|
||||
killSomeQuirks = QtCore.pyqtSignal(str, str)
|
||||
|
||||
|
||||
class PesterTray(QtWidgets.QSystemTrayIcon):
|
||||
|
@ -4607,7 +4591,7 @@ class MainProgram(QtCore.QObject):
|
|||
traceback.print_tb(tb, file=f)
|
||||
f.close()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
print(e)
|
||||
|
||||
# Show msgbox
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
|
@ -4617,7 +4601,7 @@ class MainProgram(QtCore.QObject):
|
|||
"QMessageBox{" + self.widget.theme["main/defaultwindow/style"] + "}"
|
||||
)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
print(e)
|
||||
msgbox.setStyleSheet(
|
||||
"background-color: red; color: black; font-size: x-large;"
|
||||
)
|
||||
|
@ -4627,7 +4611,7 @@ class MainProgram(QtCore.QObject):
|
|||
)
|
||||
msgbox.exec()
|
||||
except Exception as e:
|
||||
print("failed to process uncaught except: " + str(e))
|
||||
print(f"Failed to process uncaught except: {e}")
|
||||
PchumLog.exception("app error")
|
||||
|
||||
def run(self):
|
||||
|
|
18
pytwmn.py
18
pytwmn.py
|
@ -54,8 +54,8 @@ def init(host="127.0.0.1", port=None):
|
|||
|
||||
class Notification:
|
||||
def __init__(self, title="", msg="", icon=""):
|
||||
self.title = str(title)
|
||||
self.msg = str(msg)
|
||||
self.title = title
|
||||
self.msg = msg
|
||||
if icon.startswith("file://"):
|
||||
icon = icon[7:]
|
||||
self.icon = icon
|
||||
|
@ -68,16 +68,16 @@ class Notification:
|
|||
try:
|
||||
if self.time is None:
|
||||
s.send(
|
||||
"<root><title>" + self.title + "</title>"
|
||||
"<content>" + self.msg + "</content>"
|
||||
"<icon>" + self.icon + "</icon></root>"
|
||||
f"<root><title>{self.title}</title>"
|
||||
f"<content>{self.msg}</content>"
|
||||
f"<icon>{self.icon}</icon></root>"
|
||||
)
|
||||
else:
|
||||
s.send(
|
||||
"<root><title>" + self.title + "</title>"
|
||||
"<content>" + self.msg + "</content>"
|
||||
"<icon>" + self.icon + "</icon>"
|
||||
"<duration>" + str(self.time) + "</duration></root>"
|
||||
f"<root><title>{self.title}</title>"
|
||||
f"<content>{self.msg}</content>"
|
||||
f"<icon>{self.icon}</icon>"
|
||||
f"<duration>{self.time}</duration></root>"
|
||||
)
|
||||
except:
|
||||
raise TwmnError(TwmnError.NO_TWMND)
|
||||
|
|
|
@ -77,6 +77,6 @@ class RandomHandler(QtCore.QObject):
|
|||
msgbox.setInformativeText("Try again later :(")
|
||||
msgbox.exec()
|
||||
return
|
||||
name = str(l[1])
|
||||
name = l[1]
|
||||
PchumLog.info("Random Encounter name is: %s", name)
|
||||
self.mainwindow.newConversation(name)
|
||||
|
|
4
toast.py
4
toast.py
|
@ -303,7 +303,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
|
|||
self.msg.setText(
|
||||
PesterToast.wrapText(
|
||||
self.msg.font(),
|
||||
str(self.msg.text()),
|
||||
self.msg.text(),
|
||||
self.parent().theme["toasts/width"],
|
||||
self.parent().theme["toasts/content/style"],
|
||||
)
|
||||
|
@ -328,7 +328,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
|
|||
def done(self):
|
||||
QtWidgets.QWidget.hide(self)
|
||||
t = self.machine.toasts[0]
|
||||
if t.title == str(self.title.text()) and t.msg == str(self.content):
|
||||
if t.title == self.title.text() and t.msg == self.content:
|
||||
self.machine.toasts.pop(0)
|
||||
self.machine.displaying = False
|
||||
if self.machine.on:
|
||||
|
|
|
@ -621,7 +621,7 @@ class userProfile:
|
|||
self.chat = user
|
||||
self.userprofile = {
|
||||
"handle": user.handle,
|
||||
"color": str(user.color.name()),
|
||||
"color": user.color.name(),
|
||||
"quirks": [],
|
||||
"theme": "pesterchum",
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue