Add documentation to IRC slots

This commit is contained in:
Dpeta 2023-02-12 00:54:11 +01:00
parent 1d4d1dbab6
commit 8d91b18369
No known key found for this signature in database
GPG key ID: 51227517CEA0030C

23
irc.py
View file

@ -331,10 +331,12 @@ class PesterIRC(QtCore.QThread):
@QtCore.pyqtSlot(PesterList) @QtCore.pyqtSlot(PesterList)
def getMoods(self, chums): def getMoods(self, chums):
"""Get mood, slot is called from main thread."""
self.getMood(*chums) self.getMood(*chums)
@QtCore.pyqtSlot(str, str) @QtCore.pyqtSlot(str, str)
def sendNotice(self, text, handle): def sendNotice(self, text, handle):
"""Send notice, slot is called from main thread."""
self._send_irc.notice(handle, text) self._send_irc.notice(handle, text)
@QtCore.pyqtSlot(str, str) @QtCore.pyqtSlot(str, str)
@ -375,7 +377,6 @@ class PesterIRC(QtCore.QThread):
b = c + b b = c + b
if b: # len > 0 if b: # len > 0
return [a] + splittext([b]) return [a] + splittext([b])
else:
return [a] return [a]
else: else:
return l return l
@ -386,20 +387,24 @@ class PesterIRC(QtCore.QThread):
@QtCore.pyqtSlot(str, str) @QtCore.pyqtSlot(str, str)
def sendCTCP(self, handle, text): def sendCTCP(self, handle, text):
"""Send CTCP message, slot is called from main thread."""
self._send_irc.ctcp(handle, text) self._send_irc.ctcp(handle, text)
@QtCore.pyqtSlot(str, bool) @QtCore.pyqtSlot(str, bool)
def startConvo(self, handle, initiated): def startConvo(self, handle, initiated):
"""Send convo begin message and color, slot is called from main thread."""
self._send_irc.privmsg(handle, f"COLOR >{self.mainwindow.profile().colorcmd()}") self._send_irc.privmsg(handle, f"COLOR >{self.mainwindow.profile().colorcmd()}")
if initiated: if initiated:
self._send_irc.privmsg(handle, "PESTERCHUM:BEGIN") self._send_irc.privmsg(handle, "PESTERCHUM:BEGIN")
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def endConvo(self, handle): def endConvo(self, handle):
"""Send convo cease message, slot is called from main thread."""
self._send_irc.privmsg(handle, "PESTERCHUM:CEASE") self._send_irc.privmsg(handle, "PESTERCHUM:CEASE")
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def updateProfile(self): def updateProfile(self):
"""....update profile? this shouldn't be a thing."""
self._send_irc.nick(self.mainwindow.profile().handle) self._send_irc.nick(self.mainwindow.profile().handle)
self.mainwindow.closeConversations(True) self.mainwindow.closeConversations(True)
self.mainwindow.doAutoIdentify() self.mainwindow.doAutoIdentify()
@ -409,6 +414,7 @@ class PesterIRC(QtCore.QThread):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def updateMood(self): def updateMood(self):
"""Update and send mood, slot is called from main thread."""
mood = self.mainwindow.profile().mood.value_str() mood = self.mainwindow.profile().mood.value_str()
# Moods via metadata # Moods via metadata
self._send_irc.metadata("*", "set", "mood", mood) self._send_irc.metadata("*", "set", "mood", mood)
@ -417,6 +423,7 @@ class PesterIRC(QtCore.QThread):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def updateColor(self): def updateColor(self):
"""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", str(color.name()))
@ -429,51 +436,63 @@ class PesterIRC(QtCore.QThread):
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def blockedChum(self, handle): def blockedChum(self, handle):
"""Send block message, slot is called from main thread."""
self._send_irc.privmsg(handle, "PESTERCHUM:BLOCK") self._send_irc.privmsg(handle, "PESTERCHUM:BLOCK")
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def unblockedChum(self, handle): def unblockedChum(self, handle):
"""Send unblock message, slot is called from main thread."""
self._send_irc.privmsg(handle, "PESTERCHUM:UNBLOCK") self._send_irc.privmsg(handle, "PESTERCHUM:UNBLOCK")
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def requestNames(self, channel): def requestNames(self, channel):
"""Send NAMES to request channel members, slot is called from main thread."""
self._send_irc.names(channel) self._send_irc.names(channel)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def requestChannelList(self): def requestChannelList(self):
"""Send LIST to request list of channels, slot is called from main thread."""
self._send_irc.list() self._send_irc.list()
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def joinChannel(self, channel): def joinChannel(self, channel):
"""Send JOIN and MODE to join channel and get modes, slot is called from main thread."""
self._send_irc.join(channel) self._send_irc.join(channel)
self._send_irc.mode(channel) self._send_irc.mode(channel)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def leftChannel(self, channel): def leftChannel(self, channel):
"""Send PART to leave channel, slot is called from main thread."""
self._send_irc.part(channel) self._send_irc.part(channel)
@QtCore.pyqtSlot(str, str, str) @QtCore.pyqtSlot(str, str, str)
def kickUser(self, channel, user, reason=""): def kickUser(self, channel, user, reason=""):
"""Send KICK message to kick user from channel, slot is called from main thread."""
self._send_irc.kick(channel, user, reason) self._send_irc.kick(channel, user, reason)
@QtCore.pyqtSlot(str, str, str) @QtCore.pyqtSlot(str, str, str)
def setChannelMode(self, channel, mode, command): def setChannelMode(self, channel, mode, command):
"""Send MODE to set channel mode, slot is called from main thread."""
self._send_irc.mode(channel, mode, command) self._send_irc.mode(channel, mode, command)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def channelNames(self, channel): def channelNames(self, channel):
"""Send block message, slot is called from main thread."""
self._send_irc.names(channel) self._send_irc.names(channel)
@QtCore.pyqtSlot(str, str) @QtCore.pyqtSlot(str, str)
def inviteChum(self, handle, channel): def inviteChum(self, handle, channel):
"""Send INVITE message to invite someone to a channel, slot is called from main thread."""
self._send_irc.invite(handle, channel) self._send_irc.invite(handle, channel)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def pingServer(self): def pingServer(self):
"""Send PING to server to verify connectivity, slot is called from main thread."""
self._send_irc.ping("B33") self._send_irc.ping("B33")
@QtCore.pyqtSlot(bool) @QtCore.pyqtSlot(bool)
def setAway(self, away=True): def setAway(self, away=True):
"""Send AWAY to update away status, slot is called from main thread."""
if away: if away:
self.away("Idle") self.away("Idle")
else: else:
@ -481,10 +500,12 @@ class PesterIRC(QtCore.QThread):
@QtCore.pyqtSlot(str, str) @QtCore.pyqtSlot(str, str)
def killSomeQuirks(self, channel, handle): def killSomeQuirks(self, channel, handle):
"""Send NOQUIRKS ctcp message, disables quirks. Slot is called from main thread."""
self._send_irc.ctcp(channel, "NOQUIRKS", handle) self._send_irc.ctcp(channel, "NOQUIRKS", handle)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def disconnectIRC(self): def disconnectIRC(self):
"""Send QUIT and close connection, slot is called from main thread."""
self._send_irc.quit(f"{_pcVersion} <3") self._send_irc.quit(f"{_pcVersion} <3")
self._end = True self._end = True
self._close() self._close()