This commit is contained in:
Dpeta 2021-03-23 22:40:24 +01:00
parent 19597ff06b
commit fef7db8161
5 changed files with 66 additions and 23 deletions

5
irc.py
View file

@ -340,6 +340,8 @@ class PesterHandler(DefaultCommandHandler):
msg = msg.decode('utf-8')
except UnicodeDecodeError:
msg = msg.decode('iso-8859-1', 'ignore')
nick = nick.decode('utf-8')
chan = chan.decode('utf-8')
handle = nick[0:nick.find("!")]
logging.info("---> recv \"NOTICE %s :%s\"" % (handle, msg))
if handle == "ChanServ" and chan == self.parent.mainwindow.profile().handle and msg[0:2] == "[#":
@ -458,8 +460,9 @@ class PesterHandler(DefaultCommandHandler):
self.parent.mainwindow.randhandler.setRunning(True)
self.parent.moodUpdated.emit(handle, Mood("chummy"))
def mode(self, op, channel, mode, *handles):
channel = channel.decode('utf-8')
if len(handles) <= 0: handles = [""]
opnick = op[0:op.find("!")]
opnick = op.decode('utf-8')[0:op.decode('utf-8').find("!")]
if op == channel or channel == self.parent.mainwindow.profile().handle:
modes = list(self.parent.mainwindow.modes)
if modes and modes[0] == "+": modes = modes[1:]

View file

@ -1737,8 +1737,7 @@ class LoadingScreen(QtWidgets.QDialog):
# Set a timer so that we don't immediately disconnect anyway.
self.cancel.setEnabled(False)
# A few seconds should be enough.
self.timer = QtCore.QTimer.singleShot(2000, self,
QtCore.SLOT('enableQuit()'))
self.timer = QtCore.QTimer.singleShot(2000, self.enableQuit)
def showReconnect(self):
self.ok.show()

View file

@ -66,12 +66,12 @@ class CommandHandler(object):
["command", "sub", "func"].
"""
if isinstance(in_command_parts, (str, bytes)):
in_command_parts = in_command_parts.split(bytes('.', 'ascii'))
in_command_parts = in_command_parts.split('.')
command_parts = in_command_parts[:]
p = self
while command_parts:
cmd = command_parts.pop(0).decode('ascii')
cmd = command_parts.pop(0)
if cmd.startswith('_'):
raise ProtectedCommandError(in_command_parts)

View file

@ -46,8 +46,9 @@ def parse_raw_irc_command(element):
<crlf> ::= CR LF
"""
parts = element.strip().split(bytes(" ", "ascii"))
if parts[0].startswith(bytes(':', 'ascii')):
element = element.decode("utf-8")
parts = element.strip().split(" ")
if parts[0].startswith(':'):
prefix = parts[0][1:]
command = parts[1]
args = parts[2:]
@ -63,12 +64,12 @@ def parse_raw_irc_command(element):
logging.warn('unknown numeric event %s' % command)
command = command.lower()
if args[0].startswith(bytes(':', 'ascii')):
args = [bytes(" ", "ascii").join(args)[1:]]
if args[0].startswith(':'):
args = [" ".join(args)[1:]]
else:
for idx, arg in enumerate(args):
if arg.startswith(bytes(':', 'ascii')):
args = args[:idx] + [bytes(" ", 'ascii').join(args[idx:])[1:]]
for idx, arg in enumerate(args):
if arg.startswith(':'):
args = args[:idx] + [" ".join(args[idx:])[1:]]
break
return (prefix, command, args)

View file

@ -1286,7 +1286,7 @@ class PesterWindow(MovingWindow):
# Fuck you some more OSX leopard! >:(
if not ostools.isOSXLeopard():
QtCore.QTimer.singleShot(1000, self, QtCore.SLOT('mspacheck()'))
QtCore.QTimer.singleShot(1000, self.mspacheck)
self.pcUpdate['QString', 'QString'].connect(self.updateMsg)
@ -3051,7 +3051,7 @@ class MainProgram(QtCore.QObject):
self.trayicon.setContextMenu(self.traymenu)
self.trayicon.show()
self.trayicon.activated[QSystemTrayIcon.ActivationReason].connect(self.widget.systemTrayActivated)
self.trayicon.activated[QtWidgets.QSystemTrayIcon.ActivationReason].connect(self.widget.systemTrayActivated)
self.widget.trayIconSignal[int].connect(self.trayicon.changeTrayIcon)
self.widget.closeToTraySignal.connect(self.trayiconShow)
self.widget.closeSignal.connect(self.trayicon.mainWindowClosed)
@ -3064,7 +3064,7 @@ class MainProgram(QtCore.QObject):
self.irc = PesterIRC(self.widget.config, self.widget, self.server)
self.connectWidgets(self.irc, self.widget)
self.widget.gainAttention[QWidget].connect(self.alertWindow)
self.widget.gainAttention[QtWidgets.QWidget].connect(self.alertWindow)
# This doesn't know as far as I'm aware, so it's commented out for now.
@ -3195,18 +3195,58 @@ Click this message to never see this again.")
('quirkDisable(QString, QString, QString)',
'quirkDisable(QString, QString, QString)')
]
def ircQtConnections(self, irc, widget):
# IRC --> Main window
return ((widget.sendMessage, irc.sendMessage),
(widget.sendNotice, irc.sendNotice),
(widget.newConvoStarted, irc.startConvo),
(widget.convoClosed, irc.endConvo),
(widget.profileChanged, irc.updateProfile),
(widget.moodRequest, irc.getMood),
(widget.moodsRequest, irc.getMoods),
(widget.moodUpdated, irc.updateMood),
(widget.mycolorUpdated, irc.updateColor),
(widget.blockedChum, irc.blockedChum),
(widget.unblockedChum, irc.unblockedChum),
(widget.requestNames, irc.requestNames),
(widget.requestChannelList, irc.requestChannelList),
(widget.joinChannel, irc.joinChannel),
(widget.leftChannel, irc.leftChannel),
(widget.kickUser, irc.kickUser),
(widget.setChannelMode, irc.setChannelMode),
(widget.channelNames, irc.channelNames),
(widget.inviteChum, irc.inviteChum),
(widget.pingServer, irc.pingServer),
(widget.setAway, irc.setAway),
(widget.killSomeQuirks, irc.killSomeQuirks),
(widget.reconnectIRC, irc.reconnectIRC),
# Main window --> IRC
(irc.connected, widget.connected),
(irc.moodUpdated, widget.updateMoodSlot),
(irc.messageReceived, widget.deliverMessage),
(irc.memoReceived, widget.deliverMemo),
(irc.noticeReceived, widget.deliverNotice),
(irc.inviteReceived, widget.deliverInvite),
(irc.nickCollision, widget.nickCollision),
(irc.myHandleChanged, widget.myHandleChanged),
(irc.namesReceived, widget.updateNames),
(irc.userPresentUpdate, widget.userPresentUpdate),
(irc.channelListReceived, widget.updateChannelList),
(irc.timeCommand, widget.timeCommand),
(irc.chanInviteOnly, widget.chanInviteOnly),
(irc.modesUpdated, widget.modesUpdated),
(irc.cannotSendToChan, widget.cannotSendToChan),
(irc.tooManyPeeps, widget.tooManyPeeps),
(irc.quirkDisable, widget.quirkDisable))
def connectWidgets(self, irc, widget):
irc.finished.connect(self.restartIRC)
irc.connected.connect(self.connected)
for c in self.widget2irc:
widget.c[0].connect(irc.c[1])
for c in self.irc2widget:
irc.c[0].connect(widget.c[1])
for sig, slot in self.ircQtConnections(irc, widget):
sig.connect(slot)
def disconnectWidgets(self, irc, widget):
for c in self.widget2irc:
widget.c[0].disconnect(irc.c[1])
for c in self.irc2widget:
irc.c[0].disconnect(widget.c[1])
for sig, slot in self.ircQtConnections(irc, widget):
sig.disconnect(slot)
irc.connected.disconnect(self.connected)
self.irc.finished.disconnect(self.restartIRC)