Remove most unnecessary str() typecasts.
This commit is contained in:
parent
69f409b9d1
commit
2398b5a626
12 changed files with 99 additions and 118 deletions
25
convo.py
25
convo.py
|
@ -218,7 +218,7 @@ class PesterTabWindow(QtWidgets.QFrame):
|
||||||
i = self.tabs.tabAt(self.mapFromGlobal(QtGui.QCursor.pos()))
|
i = self.tabs.tabAt(self.mapFromGlobal(QtGui.QCursor.pos()))
|
||||||
if i == -1:
|
if i == -1:
|
||||||
i = self.tabs.currentIndex()
|
i = self.tabs.currentIndex()
|
||||||
handle = str(self.tabs.tabText(i))
|
handle = self.tabs.tabText(i)
|
||||||
self.clearNewMessage(handle)
|
self.clearNewMessage(handle)
|
||||||
|
|
||||||
def convoHasFocus(self, handle):
|
def convoHasFocus(self, handle):
|
||||||
|
@ -267,13 +267,13 @@ class PesterTabWindow(QtWidgets.QFrame):
|
||||||
self.tabs.setTabIcon(tabi, c.icon())
|
self.tabs.setTabIcon(tabi, c.icon())
|
||||||
currenttabi = self.tabs.currentIndex()
|
currenttabi = self.tabs.currentIndex()
|
||||||
if currenttabi >= 0:
|
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.setWindowIcon(self.convos[currentHandle].icon())
|
||||||
self.defaultTabTextColor = self.getTabTextColor()
|
self.defaultTabTextColor = self.getTabTextColor()
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def tabClose(self, i):
|
def tabClose(self, i):
|
||||||
handle = str(self.tabs.tabText(i))
|
handle = self.tabs.tabText(i)
|
||||||
self.mainwindow.waitingMessages.messageAnswered(handle)
|
self.mainwindow.waitingMessages.messageAnswered(handle)
|
||||||
# print(self.convos.keys())
|
# print(self.convos.keys())
|
||||||
# I, legit don' t know why this is an issue, but, uh, yeah-
|
# I, legit don' t know why this is an issue, but, uh, yeah-
|
||||||
|
@ -296,7 +296,7 @@ class PesterTabWindow(QtWidgets.QFrame):
|
||||||
return
|
return
|
||||||
if self.currentConvo == convo:
|
if self.currentConvo == convo:
|
||||||
currenti = self.tabs.currentIndex()
|
currenti = self.tabs.currentIndex()
|
||||||
currenth = str(self.tabs.tabText(currenti))
|
currenth = self.tabs.tabText(currenti)
|
||||||
self.currentConvo = self.convos[currenth]
|
self.currentConvo = self.convos[currenth]
|
||||||
self.currentConvo.raiseChat()
|
self.currentConvo.raiseChat()
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ class PesterTabWindow(QtWidgets.QFrame):
|
||||||
if self.changedTab:
|
if self.changedTab:
|
||||||
self.changedTab = False
|
self.changedTab = False
|
||||||
return
|
return
|
||||||
handle = str(self.tabs.tabText(i))
|
handle = self.tabs.tabText(i)
|
||||||
convo = self.convos[handle]
|
convo = self.convos[handle]
|
||||||
if self.currentConvo:
|
if self.currentConvo:
|
||||||
self.layout.removeWidget(self.currentConvo)
|
self.layout.removeWidget(self.currentConvo)
|
||||||
|
@ -344,7 +344,7 @@ class PesterMovie(QtGui.QMovie):
|
||||||
if text.mainwindow.config.animations():
|
if text.mainwindow.config.animations():
|
||||||
movie = self
|
movie = self
|
||||||
url = text.urls[movie].toString()
|
url = text.urls[movie].toString()
|
||||||
html = str(text.toHtml())
|
html = text.toHtml()
|
||||||
if html.find(url) != -1:
|
if html.find(url) != -1:
|
||||||
try:
|
try:
|
||||||
# PyQt6
|
# PyQt6
|
||||||
|
@ -606,7 +606,7 @@ class PesterText(QtWidgets.QTextEdit):
|
||||||
if url[0] == "#" and url != "#pesterchum":
|
if url[0] == "#" and url != "#pesterchum":
|
||||||
self.parent().mainwindow.showMemos(url[1:])
|
self.parent().mainwindow.showMemos(url[1:])
|
||||||
elif url[0] == "@":
|
elif url[0] == "@":
|
||||||
handle = str(url[1:])
|
handle = url[1:]
|
||||||
self.parent().mainwindow.newConversation(handle)
|
self.parent().mainwindow.newConversation(handle)
|
||||||
else:
|
else:
|
||||||
if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier:
|
if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier:
|
||||||
|
@ -664,7 +664,7 @@ class PesterInput(QtWidgets.QLineEdit):
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
if event.key() == QtCore.Qt.Key.Key_Up:
|
if event.key() == QtCore.Qt.Key.Key_Up:
|
||||||
text = str(self.text())
|
text = self.text()
|
||||||
next = self.parent().history.next(text)
|
next = self.parent().history.next(text)
|
||||||
if next is not None:
|
if next is not None:
|
||||||
self.setText(next)
|
self.setText(next)
|
||||||
|
@ -1091,14 +1091,13 @@ class PesterConvo(QtWidgets.QFrame):
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def sentMessage(self):
|
def sentMessage(self):
|
||||||
# Offloaded to another function, like its sisters.
|
"""Offloaded to another function, like its sisters.
|
||||||
# Fetch the raw text from the input box.
|
|
||||||
text = self.textInput.text()
|
|
||||||
text = str(self.textInput.text())
|
|
||||||
|
|
||||||
|
Fetch the raw text from the input box.
|
||||||
|
"""
|
||||||
return parsetools.kxhandleInput(
|
return parsetools.kxhandleInput(
|
||||||
self,
|
self,
|
||||||
text,
|
self.textInput.text(),
|
||||||
flavor="convo",
|
flavor="convo",
|
||||||
irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
|
irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -147,7 +147,7 @@ class pesterQuirks:
|
||||||
|
|
||||||
newlist = []
|
newlist = []
|
||||||
for i, o in enumerate(lexed):
|
for i, o in enumerate(lexed):
|
||||||
if type(o) not in [str, str]:
|
if not isinstance(o, str):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
string = " "
|
string = " "
|
||||||
for p in prefix:
|
for p in prefix:
|
||||||
|
@ -250,7 +250,7 @@ class pesterQuirks:
|
||||||
newlist.append(string)
|
newlist.append(string)
|
||||||
final = []
|
final = []
|
||||||
for n in newlist:
|
for n in newlist:
|
||||||
if type(n) in [str, str]:
|
if isinstance(n, str):
|
||||||
final.extend(lexMessage(n))
|
final.extend(lexMessage(n))
|
||||||
else:
|
else:
|
||||||
final.append(n)
|
final.append(n)
|
||||||
|
@ -456,7 +456,7 @@ class PesterProfile:
|
||||||
opinit,
|
opinit,
|
||||||
self.colorhtml(),
|
self.colorhtml(),
|
||||||
", ".join(initials),
|
", ".join(initials),
|
||||||
str(reason),
|
reason,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -477,7 +477,7 @@ class PesterProfile:
|
||||||
opinit,
|
opinit,
|
||||||
self.colorhtml(),
|
self.colorhtml(),
|
||||||
initials,
|
initials,
|
||||||
str(reason),
|
reason,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PesterList(list):
|
||||||
class PesterIcon(QtGui.QIcon):
|
class PesterIcon(QtGui.QIcon):
|
||||||
def __init__(self, *x):
|
def __init__(self, *x):
|
||||||
super().__init__(x[0])
|
super().__init__(x[0])
|
||||||
if type(x[0]) in [str, str]:
|
if isinstance(x[0], str):
|
||||||
self.icon_pixmap = QtGui.QPixmap(x[0])
|
self.icon_pixmap = QtGui.QPixmap(x[0])
|
||||||
else:
|
else:
|
||||||
self.icon_pixmap = None
|
self.icon_pixmap = None
|
||||||
|
@ -117,7 +117,7 @@ class MultiTextDialog(QtWidgets.QDialog):
|
||||||
if r == QtWidgets.QDialog.DialogCode.Accepted:
|
if r == QtWidgets.QDialog.DialogCode.Accepted:
|
||||||
retval = {}
|
retval = {}
|
||||||
for name, widget in self.inputs.items():
|
for name, widget in self.inputs.items():
|
||||||
retval[name] = str(widget.text())
|
retval[name] = widget.text()
|
||||||
return retval
|
return retval
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@ -150,7 +150,7 @@ class MovingWindow(QtWidgets.QFrame):
|
||||||
self.moving = event.globalPos() - self.pos()
|
self.moving = event.globalPos() - self.pos()
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
print("PyQt <= 5.14?")
|
print("PyQt <= 5.14?")
|
||||||
print(str(e))
|
print(e)
|
||||||
if event.button() == 1:
|
if event.button() == 1:
|
||||||
self.moving = event.globalPos() - self.pos()
|
self.moving = event.globalPos() - self.pos()
|
||||||
|
|
||||||
|
|
2
irc.py
2
irc.py
|
@ -437,7 +437,7 @@ class PesterIRC(QtCore.QThread):
|
||||||
"""Update and send color, slot is called from main thread."""
|
"""Update and send color, slot is called from main thread."""
|
||||||
# Update color metadata field
|
# Update color metadata field
|
||||||
color = self.mainwindow.profile().color
|
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
|
# Send color messages
|
||||||
for convo in list(self.mainwindow.convos.keys()):
|
for convo in list(self.mainwindow.convos.keys()):
|
||||||
self._send_irc.privmsg(
|
self._send_irc.privmsg(
|
||||||
|
|
11
logviewer.py
11
logviewer.py
|
@ -42,10 +42,7 @@ class PesterLogHighlighter(QtGui.QSyntaxHighlighter):
|
||||||
|
|
||||||
def highlightBlock(self, text):
|
def highlightBlock(self, text):
|
||||||
for i in range(0, len(text) - (len(self.searchTerm) - 1)):
|
for i in range(0, len(text) - (len(self.searchTerm) - 1)):
|
||||||
if (
|
if text[i : i + len(self.searchTerm)].lower() == self.searchTerm.lower():
|
||||||
str(text[i : i + len(self.searchTerm)]).lower()
|
|
||||||
== str(self.searchTerm).lower()
|
|
||||||
):
|
|
||||||
self.setFormat(i, len(self.searchTerm), self.hilightstyle)
|
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"):
|
if len(self.tree.currentItem().text(0)) > len("September 2011"):
|
||||||
self.loadLog(self.timeToFile(self.tree.currentItem().text(0)))
|
self.loadLog(self.timeToFile(self.tree.currentItem().text(0)))
|
||||||
|
|
||||||
def loadLog(self, fname):
|
def loadLog(self, fname: str):
|
||||||
fp = codecs.open(
|
fp = codecs.open(
|
||||||
"%s/%s/%s/%s/%s"
|
"%s/%s/%s/%s/%s"
|
||||||
% (self.logpath, self.handle, self.chum, self.format, fname),
|
% (self.logpath, self.handle, self.chum, self.format, fname),
|
||||||
|
@ -318,7 +315,7 @@ class PesterLogViewer(QtWidgets.QDialog):
|
||||||
# textCur.movePosition(1)
|
# textCur.movePosition(1)
|
||||||
self.textArea.setTextCursor(textCur)
|
self.textArea.setTextCursor(textCur)
|
||||||
self.instructions.setText(
|
self.instructions.setText(
|
||||||
"Pesterlog with " + self.chum + " on " + self.fileToTime(str(fname))
|
"Pesterlog with " + self.chum + " on " + self.fileToTime(fname)
|
||||||
)
|
)
|
||||||
|
|
||||||
def logSearch(self, search):
|
def logSearch(self, search):
|
||||||
|
@ -359,7 +356,7 @@ class PesterLogText(PesterText):
|
||||||
if url[0] == "#" and url != "#pesterchum":
|
if url[0] == "#" and url != "#pesterchum":
|
||||||
self.parent().parent.showMemos(url[1:])
|
self.parent().parent.showMemos(url[1:])
|
||||||
elif url[0] == "@":
|
elif url[0] == "@":
|
||||||
handle = str(url[1:])
|
handle = url[1:]
|
||||||
self.parent().parent.newConversation(handle)
|
self.parent().parent.newConversation(handle)
|
||||||
else:
|
else:
|
||||||
QtGui.QDesktopServices.openUrl(
|
QtGui.QDesktopServices.openUrl(
|
||||||
|
|
50
memos.py
50
memos.py
|
@ -240,7 +240,7 @@ class TimeInput(QtWidgets.QLineEdit):
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def setSlider(self):
|
def setSlider(self):
|
||||||
value = str(self.text())
|
value = self.text()
|
||||||
timed = txt2delta(value)
|
timed = txt2delta(value)
|
||||||
if isinstance(timed, mysteryTime):
|
if isinstance(timed, mysteryTime):
|
||||||
self.timeslider.setValue(0)
|
self.timeslider.setValue(0)
|
||||||
|
@ -1008,10 +1008,9 @@ class PesterMemo(PesterConvo):
|
||||||
PchumLog.debug("updateChanModes(%s, %s)", modes, op)
|
PchumLog.debug("updateChanModes(%s, %s)", modes, op)
|
||||||
if not hasattr(self, "modes"):
|
if not hasattr(self, "modes"):
|
||||||
self.modes = ""
|
self.modes = ""
|
||||||
chanmodes = list(str(self.modes))
|
chanmodes = list((self.modes))
|
||||||
if chanmodes and chanmodes[0] == "+":
|
if chanmodes and chanmodes[0] == "+":
|
||||||
chanmodes = chanmodes[1:]
|
chanmodes = chanmodes[1:]
|
||||||
modes = str(modes)
|
|
||||||
if op:
|
if op:
|
||||||
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
|
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
|
||||||
chum = self.mainwindow.profile()
|
chum = self.mainwindow.profile()
|
||||||
|
@ -1428,7 +1427,7 @@ class PesterMemo(PesterConvo):
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def sentMessage(self):
|
def sentMessage(self):
|
||||||
text = str(self.textInput.text())
|
text = self.textInput.text()
|
||||||
|
|
||||||
return parsetools.kxhandleInput(
|
return parsetools.kxhandleInput(
|
||||||
self,
|
self,
|
||||||
|
@ -1439,8 +1438,7 @@ class PesterMemo(PesterConvo):
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def namesUpdated(self, channel):
|
def namesUpdated(self, channel):
|
||||||
c = str(channel)
|
if channel.lower() != self.channel.lower():
|
||||||
if c.lower() != self.channel.lower():
|
|
||||||
return
|
return
|
||||||
# get namesdb (unused)
|
# get namesdb (unused)
|
||||||
# namesdb = self.mainwindow.namesdb
|
# namesdb = self.mainwindow.namesdb
|
||||||
|
@ -1457,8 +1455,7 @@ class PesterMemo(PesterConvo):
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def closeInviteOnly(self, channel):
|
def closeInviteOnly(self, channel):
|
||||||
c = str(channel)
|
if channel.lower() == self.channel.lower():
|
||||||
if c.lower() == self.channel.lower():
|
|
||||||
self.mainwindow.inviteOnlyChan[str].disconnect(self.closeInviteOnly)
|
self.mainwindow.inviteOnlyChan[str].disconnect(self.closeInviteOnly)
|
||||||
if self.parent():
|
if self.parent():
|
||||||
PchumLog.info(self.channel)
|
PchumLog.info(self.channel)
|
||||||
|
@ -1470,7 +1467,7 @@ class PesterMemo(PesterConvo):
|
||||||
msgbox.setStyleSheet(
|
msgbox.setStyleSheet(
|
||||||
"QMessageBox{ %s }" % self.mainwindow.theme["main/defaultwindow/style"]
|
"QMessageBox{ %s }" % self.mainwindow.theme["main/defaultwindow/style"]
|
||||||
)
|
)
|
||||||
msgbox.setText("%s: Invites only!" % (c))
|
msgbox.setText(f"{channel}: Invites only!")
|
||||||
msgbox.setInformativeText(
|
msgbox.setInformativeText(
|
||||||
"This channel is invite-only. "
|
"This channel is invite-only. "
|
||||||
"You must get an invitation from someone on the inside before entering."
|
"You must get an invitation from someone on the inside before entering."
|
||||||
|
@ -1480,8 +1477,7 @@ class PesterMemo(PesterConvo):
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str, str)
|
@QtCore.pyqtSlot(str, str)
|
||||||
def closeForbidden(self, channel, reason):
|
def closeForbidden(self, channel, reason):
|
||||||
c = str(channel)
|
if channel.lower() == self.channel.lower():
|
||||||
if c.lower() == self.channel.lower():
|
|
||||||
self.mainwindow.forbiddenChan[str, str].disconnect(self.closeForbidden)
|
self.mainwindow.forbiddenChan[str, str].disconnect(self.closeForbidden)
|
||||||
if self.parent():
|
if self.parent():
|
||||||
PchumLog.info(self.channel)
|
PchumLog.info(self.channel)
|
||||||
|
@ -1493,7 +1489,7 @@ class PesterMemo(PesterConvo):
|
||||||
msgbox.setStyleSheet(
|
msgbox.setStyleSheet(
|
||||||
"QMessageBox{ %s }" % self.mainwindow.theme["main/defaultwindow/style"]
|
"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.setInformativeText(reason)
|
||||||
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
||||||
msgbox.exec()
|
msgbox.exec()
|
||||||
|
@ -1568,12 +1564,9 @@ class PesterMemo(PesterConvo):
|
||||||
del self.netsplit
|
del self.netsplit
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str, str, str)
|
@QtCore.pyqtSlot(str, str, str)
|
||||||
def userPresentChange(self, handle, channel, update):
|
def userPresentChange(self, handle: str, channel: str, update: str):
|
||||||
# print("handle: %s, channel: %s, update: %s" % (handle, channel, update))
|
h = handle
|
||||||
h = str(handle)
|
c = channel
|
||||||
c = str(channel)
|
|
||||||
update = str(update)
|
|
||||||
# PchumLog.debug("h=%s\nc=%s\nupdate=%s" % (h,c,update))
|
|
||||||
if update[0:4] == "kick": # yeah, i'm lazy.
|
if update[0:4] == "kick": # yeah, i'm lazy.
|
||||||
l = update.split(":")
|
l = update.split(":")
|
||||||
update = l[0]
|
update = l[0]
|
||||||
|
@ -1790,7 +1783,7 @@ class PesterMemo(PesterConvo):
|
||||||
for c in chums:
|
for c in chums:
|
||||||
c.op = True
|
c.op = True
|
||||||
self.iconCrap(c)
|
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.opAction)
|
||||||
self.userlist.optionsMenu.addAction(self.voiceAction)
|
self.userlist.optionsMenu.addAction(self.voiceAction)
|
||||||
self.userlist.optionsMenu.addAction(self.banuserAction)
|
self.userlist.optionsMenu.addAction(self.banuserAction)
|
||||||
|
@ -1807,7 +1800,7 @@ class PesterMemo(PesterConvo):
|
||||||
for c in chums:
|
for c in chums:
|
||||||
c.op = False
|
c.op = False
|
||||||
self.iconCrap(c)
|
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.opAction)
|
||||||
self.userlist.optionsMenu.removeAction(self.voiceAction)
|
self.userlist.optionsMenu.removeAction(self.voiceAction)
|
||||||
self.userlist.optionsMenu.removeAction(self.banuserAction)
|
self.userlist.optionsMenu.removeAction(self.banuserAction)
|
||||||
|
@ -1823,7 +1816,7 @@ class PesterMemo(PesterConvo):
|
||||||
for c in chums:
|
for c in chums:
|
||||||
c.halfop = True
|
c.halfop = True
|
||||||
self.iconCrap(c)
|
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.opAction)
|
||||||
self.userlist.optionsMenu.addAction(self.voiceAction)
|
self.userlist.optionsMenu.addAction(self.voiceAction)
|
||||||
self.userlist.optionsMenu.addAction(self.banuserAction)
|
self.userlist.optionsMenu.addAction(self.banuserAction)
|
||||||
|
@ -1840,7 +1833,7 @@ class PesterMemo(PesterConvo):
|
||||||
for c in chums:
|
for c in chums:
|
||||||
c.halfop = False
|
c.halfop = False
|
||||||
self.iconCrap(c)
|
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.opAction)
|
||||||
self.userlist.optionsMenu.removeAction(self.voiceAction)
|
self.userlist.optionsMenu.removeAction(self.voiceAction)
|
||||||
self.userlist.optionsMenu.removeAction(self.banuserAction)
|
self.userlist.optionsMenu.removeAction(self.banuserAction)
|
||||||
|
@ -1888,21 +1881,21 @@ class PesterMemo(PesterConvo):
|
||||||
user = self.userlist.currentItem()
|
user = self.userlist.currentItem()
|
||||||
if not user:
|
if not user:
|
||||||
return
|
return
|
||||||
user = str(user.text())
|
user = user.text()
|
||||||
self.mainwindow.newConversation(user)
|
self.mainwindow.newConversation(user)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def addChumSlot(self):
|
def addChumSlot(self):
|
||||||
if not self.userlist.currentItem():
|
if not self.userlist.currentItem():
|
||||||
return
|
return
|
||||||
currentChum = PesterProfile(str(self.userlist.currentItem().text()))
|
currentChum = PesterProfile((self.userlist.currentItem().text()))
|
||||||
self.mainwindow.addChum(currentChum)
|
self.mainwindow.addChum(currentChum)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def banSelectedUser(self):
|
def banSelectedUser(self):
|
||||||
if not self.userlist.currentItem():
|
if not self.userlist.currentItem():
|
||||||
return
|
return
|
||||||
currentHandle = str(self.userlist.currentItem().text())
|
currentHandle = self.userlist.currentItem().text()
|
||||||
(reason, ok) = QtWidgets.QInputDialog.getText(
|
(reason, ok) = QtWidgets.QInputDialog.getText(
|
||||||
self, "Ban User", "Enter the reason you are banning this user (optional):"
|
self, "Ban User", "Enter the reason you are banning this user (optional):"
|
||||||
)
|
)
|
||||||
|
@ -1913,21 +1906,21 @@ class PesterMemo(PesterConvo):
|
||||||
def opSelectedUser(self):
|
def opSelectedUser(self):
|
||||||
if not self.userlist.currentItem():
|
if not self.userlist.currentItem():
|
||||||
return
|
return
|
||||||
currentHandle = str(self.userlist.currentItem().text())
|
currentHandle = self.userlist.currentItem().text()
|
||||||
self.mainwindow.setChannelMode.emit(self.channel, "+o", currentHandle)
|
self.mainwindow.setChannelMode.emit(self.channel, "+o", currentHandle)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def voiceSelectedUser(self):
|
def voiceSelectedUser(self):
|
||||||
if not self.userlist.currentItem():
|
if not self.userlist.currentItem():
|
||||||
return
|
return
|
||||||
currentHandle = str(self.userlist.currentItem().text())
|
currentHandle = self.userlist.currentItem().text()
|
||||||
self.mainwindow.setChannelMode.emit(self.channel, "+v", currentHandle)
|
self.mainwindow.setChannelMode.emit(self.channel, "+v", currentHandle)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def killQuirkUser(self):
|
def killQuirkUser(self):
|
||||||
if not self.userlist.currentItem():
|
if not self.userlist.currentItem():
|
||||||
return
|
return
|
||||||
currentHandle = str(self.userlist.currentItem().text())
|
currentHandle = self.userlist.currentItem().text()
|
||||||
self.mainwindow.killSomeQuirks.emit(self.channel, currentHandle)
|
self.mainwindow.killSomeQuirks.emit(self.channel, currentHandle)
|
||||||
|
|
||||||
def resetSlider(self, time, send=True):
|
def resetSlider(self, time, send=True):
|
||||||
|
@ -1960,7 +1953,6 @@ class PesterMemo(PesterConvo):
|
||||||
"Enter the chumhandle of the user you'd like to invite:",
|
"Enter the chumhandle of the user you'd like to invite:",
|
||||||
)
|
)
|
||||||
if ok:
|
if ok:
|
||||||
chum = str(chum)
|
|
||||||
self.mainwindow.inviteChum.emit(chum, self.channel)
|
self.mainwindow.inviteChum.emit(chum, self.channel)
|
||||||
self.invitechums = None
|
self.invitechums = None
|
||||||
|
|
||||||
|
|
70
menus.py
70
menus.py
|
@ -29,7 +29,7 @@ class PesterQuirkItem(QtWidgets.QTreeWidgetItem):
|
||||||
parent = None
|
parent = None
|
||||||
QtWidgets.QTreeWidgetItem.__init__(self, parent)
|
QtWidgets.QTreeWidgetItem.__init__(self, parent)
|
||||||
self.quirk = quirk
|
self.quirk = quirk
|
||||||
self.setText(0, str(quirk))
|
self.setText(0, str(quirk)) # Typecast required.
|
||||||
|
|
||||||
def update(self, quirk):
|
def update(self, quirk):
|
||||||
self.quirk = quirk
|
self.quirk = quirk
|
||||||
|
@ -235,7 +235,6 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
|
||||||
self, "Add Group", "Enter a name for the new quirk group:"
|
self, "Add Group", "Enter a name for the new quirk group:"
|
||||||
)
|
)
|
||||||
if ok:
|
if ok:
|
||||||
gname = str(gname)
|
|
||||||
if re.search(r"[^A-Za-z0-9_\s]", gname) is not None:
|
if re.search(r"[^A-Za-z0-9_\s]", gname) is not None:
|
||||||
msgbox = QtWidgets.QMessageBox()
|
msgbox = QtWidgets.QMessageBox()
|
||||||
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
|
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
|
||||||
|
@ -323,7 +322,7 @@ class QuirkTesterWindow(QtWidgets.QDialog):
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def sentMessage(self):
|
def sentMessage(self):
|
||||||
text = str(self.textInput.text())
|
text = self.textInput.text()
|
||||||
|
|
||||||
return parsetools.kxhandleInput(
|
return parsetools.kxhandleInput(
|
||||||
self,
|
self,
|
||||||
|
@ -596,8 +595,8 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
||||||
page.itemAt(3).layout().itemAt(0).widget().setCheckState(
|
page.itemAt(3).layout().itemAt(0).widget().setCheckState(
|
||||||
QtCore.Qt.CheckState(int(q["checkstate"]))
|
QtCore.Qt.CheckState(int(q["checkstate"]))
|
||||||
)
|
)
|
||||||
except (KeyError, ValueError) as e:
|
except (KeyError, ValueError):
|
||||||
print("KeyError: %s" % str(e))
|
PchumLog.exception("Exception setting replace quirk.")
|
||||||
elif q["type"] == "regexp":
|
elif q["type"] == "regexp":
|
||||||
page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().setText(
|
page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().setText(
|
||||||
q["from"]
|
q["from"]
|
||||||
|
@ -609,8 +608,8 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
||||||
page.itemAt(2).layout().itemAt(3).layout().itemAt(
|
page.itemAt(2).layout().itemAt(3).layout().itemAt(
|
||||||
0
|
0
|
||||||
).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
||||||
except (KeyError, ValueError) as e:
|
except (KeyError, ValueError):
|
||||||
print("KeyError: %s" % str(e))
|
PchumLog.exception("Exception setting regexp quirk.")
|
||||||
elif q["type"] == "random":
|
elif q["type"] == "random":
|
||||||
self.regexp.setText(q["from"])
|
self.regexp.setText(q["from"])
|
||||||
for v in q["randomlist"]:
|
for v in q["randomlist"]:
|
||||||
|
@ -619,8 +618,8 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
||||||
page.itemAt(2).layout().itemAt(2).layout().itemAt(
|
page.itemAt(2).layout().itemAt(2).layout().itemAt(
|
||||||
0
|
0
|
||||||
).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
||||||
except (KeyError, ValueError) as e:
|
except (KeyError, ValueError):
|
||||||
print("KeyError: %s" % str(e))
|
PchumLog.exception("Exception setting random quirk.")
|
||||||
elif q["type"] == "spelling":
|
elif q["type"] == "spelling":
|
||||||
self.slider.setValue(q["percentage"])
|
self.slider.setValue(q["percentage"])
|
||||||
try:
|
try:
|
||||||
|
@ -628,7 +627,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
||||||
QtCore.Qt.CheckState(int(q["checkstate"]))
|
QtCore.Qt.CheckState(int(q["checkstate"]))
|
||||||
)
|
)
|
||||||
except (KeyError, ValueError) as e:
|
except (KeyError, ValueError) as e:
|
||||||
print("KeyError: %s" % str(e))
|
PchumLog.exception("Exception setting spelling quirk.")
|
||||||
|
|
||||||
self.setLayout(layout_0)
|
self.setLayout(layout_0)
|
||||||
|
|
||||||
|
@ -667,11 +666,11 @@ class PesterQuirkTypes(QtWidgets.QDialog):
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def printValue(self, value):
|
def printValue(self, value):
|
||||||
self.current.setText(str(value) + "%")
|
self.current.setText(f"{value}%")
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def addRandomString(self):
|
def addRandomString(self):
|
||||||
text = str(self.replaceinput.text())
|
text = self.replaceinput.text()
|
||||||
item = QtWidgets.QListWidgetItem(text, self.replacelist)
|
item = QtWidgets.QListWidgetItem(text, self.replacelist)
|
||||||
self.replaceinput.setText("")
|
self.replaceinput.setText("")
|
||||||
self.replaceinput.setFocus()
|
self.replaceinput.setFocus()
|
||||||
|
@ -815,10 +814,10 @@ class PesterChooseQuirks(QtWidgets.QDialog):
|
||||||
vdict["type"] = types[self.quirkadd.pages.currentIndex() - 1]
|
vdict["type"] = types[self.quirkadd.pages.currentIndex() - 1]
|
||||||
page = self.quirkadd.pages.currentWidget().layout()
|
page = self.quirkadd.pages.currentWidget().layout()
|
||||||
if vdict["type"] in ("prefix", "suffix"):
|
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":
|
elif vdict["type"] == "replace":
|
||||||
vdict["from"] = str(page.itemAt(1).layout().itemAt(1).widget().text())
|
vdict["from"] = page.itemAt(1).layout().itemAt(1).widget().text()
|
||||||
vdict["to"] = str(page.itemAt(2).layout().itemAt(1).widget().text())
|
vdict["to"] = page.itemAt(2).layout().itemAt(1).widget().text()
|
||||||
try:
|
try:
|
||||||
# PyQt6
|
# PyQt6
|
||||||
vdict["checkstate"] = str(
|
vdict["checkstate"] = str(
|
||||||
|
@ -830,10 +829,10 @@ class PesterChooseQuirks(QtWidgets.QDialog):
|
||||||
page.itemAt(3).layout().itemAt(0).widget().checkState()
|
page.itemAt(3).layout().itemAt(0).widget().checkState()
|
||||||
)
|
)
|
||||||
elif vdict["type"] == "regexp":
|
elif vdict["type"] == "regexp":
|
||||||
vdict["from"] = str(
|
vdict["from"] = (
|
||||||
page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().text()
|
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()
|
page.itemAt(2).layout().itemAt(2).layout().itemAt(1).widget().text()
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
@ -1069,7 +1068,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def validateProfile(self):
|
def validateProfile(self):
|
||||||
if not self.profileBox or self.profileBox.currentIndex() == 0:
|
if not self.profileBox or self.profileBox.currentIndex() == 0:
|
||||||
handle = str(self.chumHandle.text())
|
handle = self.chumHandle.text()
|
||||||
if not PesterProfile.checkLength(handle):
|
if not PesterProfile.checkLength(handle):
|
||||||
self.errorMsg.setText("PROFILE HANDLE IS TOO LONG")
|
self.errorMsg.setText("PROFILE HANDLE IS TOO LONG")
|
||||||
return
|
return
|
||||||
|
@ -1084,7 +1083,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def deleteProfile(self):
|
def deleteProfile(self):
|
||||||
if self.profileBox and self.profileBox.currentIndex() > 0:
|
if self.profileBox and self.profileBox.currentIndex() > 0:
|
||||||
handle = str(self.profileBox.currentText())
|
handle = self.profileBox.currentText()
|
||||||
if handle == self.parent.profile().handle:
|
if handle == self.parent.profile().handle:
|
||||||
problem = QtWidgets.QMessageBox()
|
problem = QtWidgets.QMessageBox()
|
||||||
# karxi Will probably change this to its own name later.
|
# karxi Will probably change this to its own name later.
|
||||||
|
@ -1175,7 +1174,7 @@ class PesterMentions(QtWidgets.QDialog):
|
||||||
def addMention(self, mitem=None):
|
def addMention(self, mitem=None):
|
||||||
d = {"label": "Mention:", "inputname": "value"}
|
d = {"label": "Mention:", "inputname": "value"}
|
||||||
if mitem is not None:
|
if mitem is not None:
|
||||||
d["value"] = str(mitem.text())
|
d["value"] = mitem.text()
|
||||||
pdict = MultiTextDialog("ENTER MENTION", self, d).getText()
|
pdict = MultiTextDialog("ENTER MENTION", self, d).getText()
|
||||||
if pdict is None:
|
if pdict is None:
|
||||||
return
|
return
|
||||||
|
@ -1730,7 +1729,7 @@ class PesterOptions(QtWidgets.QDialog):
|
||||||
def addAutoJoin(self, mitem=None):
|
def addAutoJoin(self, mitem=None):
|
||||||
d = {"label": "Memo:", "inputname": "value"}
|
d = {"label": "Memo:", "inputname": "value"}
|
||||||
if mitem is not None:
|
if mitem is not None:
|
||||||
d["value"] = str(mitem.text())
|
d["value"] = mitem.text()
|
||||||
pdict = MultiTextDialog("ENTER MEMO", self, d).getText()
|
pdict = MultiTextDialog("ENTER MEMO", self, d).getText()
|
||||||
if pdict is None:
|
if pdict is None:
|
||||||
return
|
return
|
||||||
|
@ -1773,7 +1772,7 @@ class PesterOptions(QtWidgets.QDialog):
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def printValue(self, v):
|
def printValue(self, v):
|
||||||
self.currentVol.setText(str(v) + "%")
|
self.currentVol.setText(f"{v}%")
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def openMentions(self):
|
def openMentions(self):
|
||||||
|
@ -1796,7 +1795,7 @@ class PesterOptions(QtWidgets.QDialog):
|
||||||
def updateMentions(self):
|
def updateMentions(self):
|
||||||
m = []
|
m = []
|
||||||
for i in range(self.mentionmenu.mentionlist.count()):
|
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.parent().userprofile.setMentions(m)
|
||||||
self.mentionmenu = None
|
self.mentionmenu = None
|
||||||
|
|
||||||
|
@ -1860,10 +1859,9 @@ class PesterUserlist(QtWidgets.QDialog):
|
||||||
return
|
return
|
||||||
self.userarea.clear()
|
self.userarea.clear()
|
||||||
for n in names:
|
for n in names:
|
||||||
if (
|
if (self.searchbox.text()) == "" or n.lower().find(
|
||||||
str(self.searchbox.text()) == ""
|
self.searchbox.text().lower()
|
||||||
or n.lower().find(str(self.searchbox.text()).lower()) != -1
|
) != -1:
|
||||||
):
|
|
||||||
# Strip channel membership prefixes
|
# Strip channel membership prefixes
|
||||||
n = n.strip("~").strip("@").strip("+").strip("&").strip("%")
|
n = n.strip("~").strip("@").strip("+").strip("&").strip("%")
|
||||||
item = QtWidgets.QListWidgetItem(n)
|
item = QtWidgets.QListWidgetItem(n)
|
||||||
|
@ -1875,18 +1873,16 @@ class PesterUserlist(QtWidgets.QDialog):
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str, str, str)
|
@QtCore.pyqtSlot(str, str, str)
|
||||||
def updateUserPresent(self, handle, channel, update):
|
def updateUserPresent(self, handle, channel, update):
|
||||||
h = str(handle)
|
|
||||||
c = str(channel)
|
|
||||||
if update == "quit":
|
if update == "quit":
|
||||||
self.delUser(h)
|
self.delUser(handle)
|
||||||
elif update == "left" and c == "#pesterchum":
|
elif update == "left" and channel == "#pesterchum":
|
||||||
self.delUser(h)
|
self.delUser(handle)
|
||||||
elif update == "join" and c == "#pesterchum":
|
elif update == "join" and channel == "#pesterchum":
|
||||||
if (
|
if (
|
||||||
str(self.searchbox.text()) == ""
|
self.searchbox.text() == ""
|
||||||
or h.lower().find(str(self.searchbox.text()).lower()) != -1
|
or handle.lower().find(self.searchbox.text().lower()) != -1
|
||||||
):
|
):
|
||||||
self.addUser(h)
|
self.addUser(handle)
|
||||||
|
|
||||||
def addUser(self, name):
|
def addUser(self, name):
|
||||||
item = QtWidgets.QListWidgetItem(name)
|
item = QtWidgets.QListWidgetItem(name)
|
||||||
|
@ -1936,7 +1932,7 @@ class MemoListItem(QtWidgets.QTreeWidgetItem):
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
column = self.treeWidget().sortColumn()
|
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 int(self.text(column)) < int(other.text(column))
|
||||||
return self.text(column) < other.text(column)
|
return self.text(column) < other.text(column)
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ def lexer(string, objlist):
|
||||||
for oType, regexp in objlist:
|
for oType, regexp in objlist:
|
||||||
newstringlist = []
|
newstringlist = []
|
||||||
for stri, s in enumerate(stringlist):
|
for stri, s in enumerate(stringlist):
|
||||||
if type(s) not in [str, str]:
|
if not isinstance(s, str):
|
||||||
newstringlist.append(s)
|
newstringlist.append(s)
|
||||||
continue
|
continue
|
||||||
lasti = 0
|
lasti = 0
|
||||||
|
@ -268,9 +268,8 @@ class mecmd(lexercon.Chunk):
|
||||||
kxpclexer = lexercon.Pesterchum()
|
kxpclexer = lexercon.Pesterchum()
|
||||||
|
|
||||||
|
|
||||||
def kxlexMsg(string):
|
def kxlexMsg(msg: str):
|
||||||
# Do a bit of sanitization.
|
"""Do a bit of sanitization."""
|
||||||
msg = str(string)
|
|
||||||
# TODO: Let people paste line-by-line normally. Maybe have a mass-paste
|
# TODO: Let people paste line-by-line normally. Maybe have a mass-paste
|
||||||
# right-click option?
|
# right-click option?
|
||||||
msg = msg.replace("\n", " ").replace("\r", " ")
|
msg = msg.replace("\n", " ").replace("\r", " ")
|
||||||
|
@ -327,7 +326,7 @@ def balance(lexed):
|
||||||
balanced.append(colorEnd("</c>"))
|
balanced.append(colorEnd("</c>"))
|
||||||
if len(balanced) == 0:
|
if len(balanced) == 0:
|
||||||
balanced.append("")
|
balanced.append("")
|
||||||
if type(balanced[len(balanced) - 1]) not in [str, str]:
|
if not isinstance(balanced[len(balanced) - 1], str):
|
||||||
balanced.append("")
|
balanced.append("")
|
||||||
return balanced
|
return balanced
|
||||||
|
|
||||||
|
@ -336,12 +335,12 @@ def convertTags(lexed, format="html"):
|
||||||
if format not in ["html", "bbcode", "ctag", "text"]:
|
if format not in ["html", "bbcode", "ctag", "text"]:
|
||||||
raise ValueError("Color format not recognized")
|
raise ValueError("Color format not recognized")
|
||||||
|
|
||||||
if type(lexed) in [str, str]:
|
if isinstance(lexed, str):
|
||||||
lexed = lexMessage(lexed)
|
lexed = lexMessage(lexed)
|
||||||
escaped = ""
|
escaped = ""
|
||||||
# firststr = True
|
# firststr = True
|
||||||
for i, o in enumerate(lexed):
|
for i, o in enumerate(lexed):
|
||||||
if type(o) in [str, str]:
|
if isinstance(o, str):
|
||||||
if format == "html":
|
if format == "html":
|
||||||
escaped += (
|
escaped += (
|
||||||
o.replace("&", "&").replace(">", ">").replace("<", "<")
|
o.replace("&", "&").replace(">", ">").replace("<", "<")
|
||||||
|
@ -370,7 +369,7 @@ def _max_msg_len(mask=None, target=None, nick=None, ident=None):
|
||||||
|
|
||||||
if mask is not None:
|
if mask is not None:
|
||||||
# Since this will be included in what we send
|
# Since this will be included in what we send
|
||||||
limit -= len(str(mask))
|
limit -= len(mask)
|
||||||
else:
|
else:
|
||||||
# Since we should always be able to fetch this
|
# Since we should always be able to fetch this
|
||||||
# karxi: ... Which we can't, right now, unlike in the old script.
|
# karxi: ... Which we can't, right now, unlike in the old script.
|
||||||
|
@ -996,9 +995,7 @@ def parseRegexpFunctions(to):
|
||||||
return parsed
|
return parsed
|
||||||
|
|
||||||
|
|
||||||
def img2smiley(string):
|
def img2smiley(string: str):
|
||||||
string = str(string)
|
|
||||||
|
|
||||||
def imagerep(mo):
|
def imagerep(mo):
|
||||||
return reverse_smiley[mo.group(1)]
|
return reverse_smiley[mo.group(1)]
|
||||||
|
|
||||||
|
|
18
pytwmn.py
18
pytwmn.py
|
@ -54,8 +54,8 @@ def init(host="127.0.0.1", port=None):
|
||||||
|
|
||||||
class Notification:
|
class Notification:
|
||||||
def __init__(self, title="", msg="", icon=""):
|
def __init__(self, title="", msg="", icon=""):
|
||||||
self.title = str(title)
|
self.title = title
|
||||||
self.msg = str(msg)
|
self.msg = msg
|
||||||
if icon.startswith("file://"):
|
if icon.startswith("file://"):
|
||||||
icon = icon[7:]
|
icon = icon[7:]
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
|
@ -68,16 +68,16 @@ class Notification:
|
||||||
try:
|
try:
|
||||||
if self.time is None:
|
if self.time is None:
|
||||||
s.send(
|
s.send(
|
||||||
"<root><title>" + self.title + "</title>"
|
f"<root><title>{self.title}</title>"
|
||||||
"<content>" + self.msg + "</content>"
|
f"<content>{self.msg}</content>"
|
||||||
"<icon>" + self.icon + "</icon></root>"
|
f"<icon>{self.icon}</icon></root>"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
s.send(
|
s.send(
|
||||||
"<root><title>" + self.title + "</title>"
|
f"<root><title>{self.title}</title>"
|
||||||
"<content>" + self.msg + "</content>"
|
f"<content>{self.msg}</content>"
|
||||||
"<icon>" + self.icon + "</icon>"
|
f"<icon>{self.icon}</icon>"
|
||||||
"<duration>" + str(self.time) + "</duration></root>"
|
f"<duration>{self.time}</duration></root>"
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
raise TwmnError(TwmnError.NO_TWMND)
|
raise TwmnError(TwmnError.NO_TWMND)
|
||||||
|
|
|
@ -77,6 +77,6 @@ class RandomHandler(QtCore.QObject):
|
||||||
msgbox.setInformativeText("Try again later :(")
|
msgbox.setInformativeText("Try again later :(")
|
||||||
msgbox.exec()
|
msgbox.exec()
|
||||||
return
|
return
|
||||||
name = str(l[1])
|
name = l[1]
|
||||||
PchumLog.info("Random Encounter name is: %s", name)
|
PchumLog.info("Random Encounter name is: %s", name)
|
||||||
self.mainwindow.newConversation(name)
|
self.mainwindow.newConversation(name)
|
||||||
|
|
4
toast.py
4
toast.py
|
@ -303,7 +303,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
|
||||||
self.msg.setText(
|
self.msg.setText(
|
||||||
PesterToast.wrapText(
|
PesterToast.wrapText(
|
||||||
self.msg.font(),
|
self.msg.font(),
|
||||||
str(self.msg.text()),
|
self.msg.text(),
|
||||||
self.parent().theme["toasts/width"],
|
self.parent().theme["toasts/width"],
|
||||||
self.parent().theme["toasts/content/style"],
|
self.parent().theme["toasts/content/style"],
|
||||||
)
|
)
|
||||||
|
@ -328,7 +328,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
|
||||||
def done(self):
|
def done(self):
|
||||||
QtWidgets.QWidget.hide(self)
|
QtWidgets.QWidget.hide(self)
|
||||||
t = self.machine.toasts[0]
|
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.toasts.pop(0)
|
||||||
self.machine.displaying = False
|
self.machine.displaying = False
|
||||||
if self.machine.on:
|
if self.machine.on:
|
||||||
|
|
|
@ -621,7 +621,7 @@ class userProfile:
|
||||||
self.chat = user
|
self.chat = user
|
||||||
self.userprofile = {
|
self.userprofile = {
|
||||||
"handle": user.handle,
|
"handle": user.handle,
|
||||||
"color": str(user.color.name()),
|
"color": user.color.name(),
|
||||||
"quirks": [],
|
"quirks": [],
|
||||||
"theme": "pesterchum",
|
"theme": "pesterchum",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue