Add force prefix option
This commit is contained in:
parent
938cf69b85
commit
3f7caf73b2
8 changed files with 82 additions and 18 deletions
7
convo.py
7
convo.py
|
@ -1096,7 +1096,12 @@ class PesterConvo(QtWidgets.QFrame):
|
||||||
text = self.textInput.text()
|
text = self.textInput.text()
|
||||||
text = str(self.textInput.text())
|
text = str(self.textInput.text())
|
||||||
|
|
||||||
return parsetools.kxhandleInput(self, text, flavor="convo", irc_compatible=self.mainwindow.config.irc_compatibility_mode())
|
return parsetools.kxhandleInput(
|
||||||
|
self,
|
||||||
|
text,
|
||||||
|
flavor="convo",
|
||||||
|
irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
|
||||||
|
)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def addThisChum(self):
|
def addThisChum(self):
|
||||||
|
|
|
@ -321,7 +321,7 @@ class PesterProfile:
|
||||||
|
|
||||||
def colorcmd(self):
|
def colorcmd(self):
|
||||||
if self.color:
|
if self.color:
|
||||||
(r, g, b, _) = self.color.getRgb()
|
(r, g, b, _a) = self.color.getRgb()
|
||||||
return "%d,%d,%d" % (r, g, b)
|
return "%d,%d,%d" % (r, g, b)
|
||||||
else:
|
else:
|
||||||
return "0,0,0"
|
return "0,0,0"
|
||||||
|
|
42
memos.py
42
memos.py
|
@ -20,13 +20,16 @@ from parsetools import (
|
||||||
timeProtocol,
|
timeProtocol,
|
||||||
lexMessage,
|
lexMessage,
|
||||||
colorBegin,
|
colorBegin,
|
||||||
|
addTimeInitial,
|
||||||
mecmd,
|
mecmd,
|
||||||
smiledict,
|
smiledict,
|
||||||
)
|
)
|
||||||
from logviewer import PesterLogViewer
|
from logviewer import PesterLogViewer
|
||||||
|
|
||||||
PchumLog = logging.getLogger("pchumLogger")
|
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
|
# Python 3
|
||||||
QString = str
|
QString = str
|
||||||
|
|
||||||
|
@ -356,14 +359,36 @@ class MemoText(PesterText):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addMessage(self, msg, chum):
|
def make_valid(self, msg, chum, parent, window, me):
|
||||||
if isinstance(msg, str):
|
"""Adds initials and color to a message if they're missing."""
|
||||||
lexmsg = lexMessage(msg)
|
if not re.match(_valid_memo_msg_start, msg):
|
||||||
|
if chum is me:
|
||||||
|
initials = me.initials()
|
||||||
|
color = me.colorcmd()
|
||||||
|
msg = f"<c={color}>{initials}: {msg}</c>"
|
||||||
|
msg = addTimeInitial(msg, parent.time.getGrammar())
|
||||||
else:
|
else:
|
||||||
lexmsg = msg
|
color = window.chumdb.getColor(chum.handle)
|
||||||
|
if color:
|
||||||
|
(r, g, b, _a) = color.getRgb()
|
||||||
|
color = f"{r},{g},{b}"
|
||||||
|
else:
|
||||||
|
color = "0,0,0"
|
||||||
|
initials = chum.initials()
|
||||||
|
msg = f"<c={color}>{initials}: {msg}</c>"
|
||||||
|
msg = addTimeInitial(msg, parent.times[chum.handle].getGrammar())
|
||||||
|
return msg
|
||||||
|
|
||||||
|
def addMessage(self, msg, chum):
|
||||||
parent = self.parent()
|
parent = self.parent()
|
||||||
window = parent.mainwindow
|
window = parent.mainwindow
|
||||||
me = window.profile()
|
me = window.profile()
|
||||||
|
if isinstance(msg, str):
|
||||||
|
if self.mainwindow.config.force_prefix():
|
||||||
|
msg = self.make_valid(msg, chum, parent, window, me)
|
||||||
|
lexmsg = lexMessage(msg)
|
||||||
|
else:
|
||||||
|
lexmsg = msg
|
||||||
if self.mainwindow.config.animations():
|
if self.mainwindow.config.animations():
|
||||||
for m in self.urls:
|
for m in self.urls:
|
||||||
if convertTags(lexmsg).find(self.urls[m].toString()) != -1:
|
if convertTags(lexmsg).find(self.urls[m].toString()) != -1:
|
||||||
|
@ -1400,7 +1425,12 @@ class PesterMemo(PesterConvo):
|
||||||
def sentMessage(self):
|
def sentMessage(self):
|
||||||
text = str(self.textInput.text())
|
text = str(self.textInput.text())
|
||||||
|
|
||||||
return parsetools.kxhandleInput(self, text, flavor="memos", irc_compatible=self.mainwindow.config.irc_compatibility_mode())
|
return parsetools.kxhandleInput(
|
||||||
|
self,
|
||||||
|
text,
|
||||||
|
flavor="memos",
|
||||||
|
irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
|
||||||
|
)
|
||||||
|
|
||||||
@QtCore.pyqtSlot(QString)
|
@QtCore.pyqtSlot(QString)
|
||||||
def namesUpdated(self, channel):
|
def namesUpdated(self, channel):
|
||||||
|
|
25
menus.py
25
menus.py
|
@ -323,7 +323,12 @@ class QuirkTesterWindow(QtWidgets.QDialog):
|
||||||
def sentMessage(self):
|
def sentMessage(self):
|
||||||
text = str(self.textInput.text())
|
text = str(self.textInput.text())
|
||||||
|
|
||||||
return parsetools.kxhandleInput(self, text, "menus", irc_compatible=self.mainwindow.config.irc_compatibility_mode())
|
return parsetools.kxhandleInput(
|
||||||
|
self,
|
||||||
|
text,
|
||||||
|
"menus",
|
||||||
|
irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
|
||||||
|
)
|
||||||
|
|
||||||
def addMessage(self, msg, me=True):
|
def addMessage(self, msg, me=True):
|
||||||
if isinstance(msg, str):
|
if isinstance(msg, str):
|
||||||
|
@ -1238,17 +1243,29 @@ class PesterOptions(QtWidgets.QDialog):
|
||||||
self.irc_mode_check.setChecked(True)
|
self.irc_mode_check.setChecked(True)
|
||||||
bandwidthLabel = QtWidgets.QLabel(
|
bandwidthLabel = QtWidgets.QLabel(
|
||||||
"Enable this if you're planning on using Pesterchum on a server with normal IRC clients."
|
"Enable this if you're planning on using Pesterchum on a server with normal IRC clients."
|
||||||
"\nDisables at least the following features:"
|
"\nStops the client from sending or requesting:"
|
||||||
"\n - Moods (#pesterchum MOODs and METADATA moods)"
|
"\n - Moods (#pesterchum MOODs and METADATA moods)"
|
||||||
"\n - Message colors (COLOR > and METADATA color)"
|
"\n - Message colors (COLOR > and METADATA color)"
|
||||||
"\n - Message color tags (<c=0,0,0>)"
|
"\n - Message color tags (<c=0,0,0>)"
|
||||||
"\n - Timelines (PESTERCHUM:CURRENT, etc.)"
|
"\n - Timelines (PESTERCHUM:CURRENT, etc.)"
|
||||||
"\n - PESTERCHUM:X commands (BEGIN, CEASE, BLOCK, IDLE, etc.)"
|
"\n - Misc. PESTERCHUM:X commands (BEGIN, CEASE, BLOCK, IDLE, etc.)"
|
||||||
)
|
)
|
||||||
font = bandwidthLabel.font()
|
font = bandwidthLabel.font()
|
||||||
font.setPointSize(8)
|
font.setPointSize(8)
|
||||||
bandwidthLabel.setFont(font)
|
bandwidthLabel.setFont(font)
|
||||||
|
|
||||||
|
self.force_prefix_check = QtWidgets.QCheckBox(
|
||||||
|
"Add initials to memo messages without initials", self
|
||||||
|
)
|
||||||
|
if self.config.force_prefix():
|
||||||
|
self.force_prefix_check.setChecked(True)
|
||||||
|
initials_label = QtWidgets.QLabel(
|
||||||
|
"Enable this when chatting with normal IRC users or to forcibly un-scratch Doc Scratch."
|
||||||
|
)
|
||||||
|
font = initials_label.font()
|
||||||
|
font.setPointSize(8)
|
||||||
|
initials_label.setFont(font)
|
||||||
|
|
||||||
self.autonickserv = QtWidgets.QCheckBox("Auto-Identify with NickServ", self)
|
self.autonickserv = QtWidgets.QCheckBox("Auto-Identify with NickServ", self)
|
||||||
self.autonickserv.setChecked(parent.userprofile.getAutoIdentify())
|
self.autonickserv.setChecked(parent.userprofile.getAutoIdentify())
|
||||||
self.autonickserv.stateChanged[int].connect(self.autoNickServChange)
|
self.autonickserv.stateChanged[int].connect(self.autoNickServChange)
|
||||||
|
@ -1624,6 +1641,8 @@ class PesterOptions(QtWidgets.QDialog):
|
||||||
layout_connect.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
layout_connect.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
||||||
layout_connect.addWidget(self.irc_mode_check)
|
layout_connect.addWidget(self.irc_mode_check)
|
||||||
layout_connect.addWidget(bandwidthLabel)
|
layout_connect.addWidget(bandwidthLabel)
|
||||||
|
layout_connect.addWidget(self.force_prefix_check)
|
||||||
|
layout_connect.addWidget(initials_label)
|
||||||
layout_connect.addWidget(self.autonickserv)
|
layout_connect.addWidget(self.autonickserv)
|
||||||
layout_indent = QtWidgets.QVBoxLayout()
|
layout_indent = QtWidgets.QVBoxLayout()
|
||||||
layout_indent.addWidget(self.nickservpass)
|
layout_indent.addWidget(self.nickservpass)
|
||||||
|
|
|
@ -283,6 +283,7 @@ def kxlexMsg(string):
|
||||||
# ...and that's it for this.
|
# ...and that's it for this.
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
def lexMessage(string: str):
|
def lexMessage(string: str):
|
||||||
lexlist = [
|
lexlist = [
|
||||||
(mecmd, _mecmdre),
|
(mecmd, _mecmdre),
|
||||||
|
@ -305,6 +306,7 @@ def lexMessage(string: str):
|
||||||
lexed = lexer(string, lexlist)
|
lexed = lexer(string, lexlist)
|
||||||
return balance(lexed)
|
return balance(lexed)
|
||||||
|
|
||||||
|
|
||||||
def balance(lexed):
|
def balance(lexed):
|
||||||
balanced = []
|
balanced = []
|
||||||
beginc = 0
|
beginc = 0
|
||||||
|
|
|
@ -1897,8 +1897,9 @@ class PesterWindow(MovingWindow):
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
def newMessage(self, handle, msg):
|
def newMessage(self, handle, msg):
|
||||||
if not self.config.irc_compatibility_mode() and handle in self.config.getBlocklist():
|
if handle in self.config.getBlocklist():
|
||||||
# yeah suck on this
|
# yeah suck on this
|
||||||
|
if not self.config.irc_compatibility_mode():
|
||||||
self.sendMessage.emit("PESTERCHUM:BLOCKED", handle)
|
self.sendMessage.emit("PESTERCHUM:BLOCKED", handle)
|
||||||
return
|
return
|
||||||
# notify
|
# notify
|
||||||
|
@ -1951,7 +1952,6 @@ class PesterWindow(MovingWindow):
|
||||||
# TODO: This is really bad practice. Fix it later.
|
# TODO: This is really bad practice. Fix it later.
|
||||||
return
|
return
|
||||||
memo = self.memos[chan]
|
memo = self.memos[chan]
|
||||||
msg = str(msg)
|
|
||||||
if handle not in memo.times:
|
if handle not in memo.times:
|
||||||
# new chum! time current
|
# new chum! time current
|
||||||
newtime = datetime.timedelta(0)
|
newtime = datetime.timedelta(0)
|
||||||
|
@ -3442,15 +3442,20 @@ class PesterWindow(MovingWindow):
|
||||||
curnotify = self.config.notifyOptions()
|
curnotify = self.config.notifyOptions()
|
||||||
if notifysetting != curnotify:
|
if notifysetting != curnotify:
|
||||||
self.config.set("notifyOptions", notifysetting)
|
self.config.set("notifyOptions", notifysetting)
|
||||||
# low bandwidth
|
# IRC compatibility (previously low bandwidth)
|
||||||
irc_mode_setting = self.optionmenu.irc_mode_check.isChecked()
|
irc_mode_setting = self.optionmenu.irc_mode_check.isChecked()
|
||||||
curbandwidth = self.config.irc_compatibility_mode()
|
current_irc_mode = self.config.irc_compatibility_mode()
|
||||||
if irc_mode_setting != curbandwidth:
|
if irc_mode_setting != current_irc_mode:
|
||||||
self.config.set("irc_compatibility_mode", irc_mode_setting)
|
self.config.set("irc_compatibility_mode", irc_mode_setting)
|
||||||
if irc_mode_setting:
|
if irc_mode_setting:
|
||||||
self.leftChannel.emit("#pesterchum")
|
self.leftChannel.emit("#pesterchum")
|
||||||
else:
|
else:
|
||||||
self.joinChannel.emit("#pesterchum")
|
self.joinChannel.emit("#pesterchum")
|
||||||
|
# Force prefix
|
||||||
|
force_prefix_setting = self.optionmenu.force_prefix_check.isChecked()
|
||||||
|
current_prefix_setting = self.config.force_prefix()
|
||||||
|
if force_prefix_setting != current_prefix_setting:
|
||||||
|
self.config.set("force_prefix", force_prefix_setting)
|
||||||
# nickserv
|
# nickserv
|
||||||
autoidentify = self.optionmenu.autonickserv.isChecked()
|
autoidentify = self.optionmenu.autonickserv.isChecked()
|
||||||
nickservpass = self.optionmenu.nickservpass.text()
|
nickservpass = self.optionmenu.nickservpass.text()
|
||||||
|
|
|
@ -361,6 +361,9 @@ with a backup from: <a href='%s'>%s</a></h3></html>"
|
||||||
def irc_compatibility_mode(self):
|
def irc_compatibility_mode(self):
|
||||||
return self.config.get("irc_compatibility_mode", False)
|
return self.config.get("irc_compatibility_mode", False)
|
||||||
|
|
||||||
|
def force_prefix(self):
|
||||||
|
return self.config.get("force_prefix", False)
|
||||||
|
|
||||||
def ghostchum(self):
|
def ghostchum(self):
|
||||||
return self.config.get("ghostchum", False)
|
return self.config.get("ghostchum", False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue