waaa
This commit is contained in:
parent
f99bcf83d9
commit
9f319b7054
2 changed files with 8 additions and 18 deletions
18
irc.py
18
irc.py
|
@ -52,17 +52,6 @@ class ProtectedCommandError(CommandError):
|
||||||
# Python 3
|
# Python 3
|
||||||
QString = str
|
QString = str
|
||||||
|
|
||||||
# Copied from pesterchum.py
|
|
||||||
# CUSTOMBOTS = ["CALSPRITE", "RANDOMENCOUNTER"]
|
|
||||||
# BOTNAMES = ["NICKSERV", "CHANSERV", "MEMOSERV", "OPERSERV", "HELPSERV", "HOSTSERV", "BOTSERV"]
|
|
||||||
# BOTNAMES.extend(CUSTOMBOTS)
|
|
||||||
|
|
||||||
# if ostools.isOSXBundle():
|
|
||||||
# logging.basicConfig(level=logging.WARNING)
|
|
||||||
# else:
|
|
||||||
# # karxi; We do NOT need this set to INFO; it's very, very spammy.
|
|
||||||
# logging.basicConfig(level=logging.WARNING)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import certifi
|
import certifi
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -185,6 +174,7 @@ class PesterIRC(QtCore.QThread):
|
||||||
try:
|
try:
|
||||||
buffer = b""
|
buffer = b""
|
||||||
while not self._end:
|
while not self._end:
|
||||||
|
data = []
|
||||||
try:
|
try:
|
||||||
buffer += self.socket.recv(1024)
|
buffer += self.socket.recv(1024)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
@ -200,6 +190,7 @@ class PesterIRC(QtCore.QThread):
|
||||||
raise OSError("Connection closed")
|
raise OSError("Connection closed")
|
||||||
|
|
||||||
data, buffer = self.parse_buffer(buffer)
|
data, buffer = self.parse_buffer(buffer)
|
||||||
|
print(f"data: {data}")
|
||||||
for line in data:
|
for line in data:
|
||||||
tags, prefix, command, args = self.parse_irc_line(line)
|
tags, prefix, command, args = self.parse_irc_line(line)
|
||||||
# print(tags, prefix, command, args)
|
# print(tags, prefix, command, args)
|
||||||
|
@ -247,14 +238,13 @@ class PesterIRC(QtCore.QThread):
|
||||||
data = decoded_buffer.split("\r\n")
|
data = decoded_buffer.split("\r\n")
|
||||||
if data[-1]:
|
if data[-1]:
|
||||||
# Last entry has incomplete data, add back to buffer
|
# Last entry has incomplete data, add back to buffer
|
||||||
buffer = data[-1].encode("utf-8") + buffer
|
buffer = data[-1].encode(encoding="utf-8")
|
||||||
return data[:-1], buffer
|
return data[:-1], buffer
|
||||||
|
|
||||||
def parse_irc_line(self, line: str):
|
def parse_irc_line(self, line: str):
|
||||||
parts = line.split(" ")
|
parts = line.split(" ")
|
||||||
tags = None
|
tags = None
|
||||||
prefix = None
|
prefix = None
|
||||||
print(line)
|
|
||||||
if parts[0].startswith(":"):
|
if parts[0].startswith(":"):
|
||||||
prefix = parts[0][1:]
|
prefix = parts[0][1:]
|
||||||
command = parts[1]
|
command = parts[1]
|
||||||
|
@ -272,7 +262,7 @@ class PesterIRC(QtCore.QThread):
|
||||||
try:
|
try:
|
||||||
command = numeric_events[command]
|
command = numeric_events[command]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
PchumLog.info("Server send unknown numeric event {command}.")
|
PchumLog.info("Server send unknown numeric event %s.", command)
|
||||||
command = command.lower()
|
command = command.lower()
|
||||||
|
|
||||||
# If ':' is present the subsequent args are one parameter.
|
# If ':' is present the subsequent args are one parameter.
|
||||||
|
|
|
@ -430,7 +430,7 @@ def kxsplitMsg(lexed, ctx, fmt="pchum", maxlen=None, debug=False):
|
||||||
# Maximum number of characters *to* use.
|
# Maximum number of characters *to* use.
|
||||||
if not maxlen:
|
if not maxlen:
|
||||||
maxlen = _max_msg_len(
|
maxlen = _max_msg_len(
|
||||||
None, None, ctx.mainwindow.profile().handle, ctx.mainwindow.irc.cli.realname
|
None, None, ctx.mainwindow.profile().handle, "pcc31"
|
||||||
)
|
)
|
||||||
elif maxlen < 0:
|
elif maxlen < 0:
|
||||||
# Subtract the (negative) length, giving us less leeway in this
|
# Subtract the (negative) length, giving us less leeway in this
|
||||||
|
@ -440,7 +440,7 @@ def kxsplitMsg(lexed, ctx, fmt="pchum", maxlen=None, debug=False):
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
ctx.mainwindow.profile().handle,
|
ctx.mainwindow.profile().handle,
|
||||||
ctx.mainwindow.irc.cli.realname,
|
"pcc31",
|
||||||
)
|
)
|
||||||
+ maxlen
|
+ maxlen
|
||||||
)
|
)
|
||||||
|
@ -806,10 +806,10 @@ def kxhandleInput(ctx, text=None, flavor=None):
|
||||||
|
|
||||||
# Split the messages so we don't go over the buffer and lose text.
|
# Split the messages so we don't go over the buffer and lose text.
|
||||||
maxlen = _max_msg_len(
|
maxlen = _max_msg_len(
|
||||||
None, None, ctx.mainwindow.profile().handle, ctx.mainwindow.irc.cli.realname
|
None, None, ctx.mainwindow.profile().handle, "pcc31"
|
||||||
)
|
)
|
||||||
# ctx.mainwindow.profile().handle ==> Get handle
|
# ctx.mainwindow.profile().handle ==> Get handle
|
||||||
# ctx.mainwindow.irc.cli.realname ==> Get ident (Same as realname in this case.)
|
# "pcc31" ==> Get ident (Same as realname in this case.)
|
||||||
# Since we have to do some post-processing, we need to adjust the maximum
|
# Since we have to do some post-processing, we need to adjust the maximum
|
||||||
# length we can use.
|
# length we can use.
|
||||||
if flavor == "convo":
|
if flavor == "convo":
|
||||||
|
|
Loading…
Reference in a new issue