home · contact · privacy
Handle QUIT message, at least inside of channels.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 19 Aug 2025 02:46:47 +0000 (04:46 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 19 Aug 2025 02:46:47 +0000 (04:46 +0200)
ircplom/client.py

index 0c2a923106becfb2a784286338cc4d3a305e900c..df2fc7d1bac9a06e6e21791489429eef74e68fc1 100644 (file)
@@ -67,6 +67,7 @@ _EXPECTATIONS: dict[str, _MsgParseExpectation] = {
    'PART': _MsgParseExpectation(1, 2),
    'PING': _MsgParseExpectation(1, source=''),
    'PRIVMSG': _MsgParseExpectation(2),
+   'QUIT': _MsgParseExpectation(1),
 }
 
 
@@ -658,6 +659,14 @@ class Client(ABC, ClientQueueMixin):
                         'users', msg.nick_from_source, stay_complete=True)
         elif msg.match('PING'):
             self.send(IrcMessage(verb='PONG', params=(msg.params[0],)))
+        elif msg.match('QUIT'):
+            user = msg.nick_from_source
+            for chan_name in self._db.chan_names:
+                chan = self._db.chan(chan_name)
+                if user in chan.users:
+                    chan.remove_completable('users', user, stay_complete=True)
+                    self._log(f'{user} quits: {msg.params[0]}',
+                              scope=LogScope.CHAT, target=chan_name)
         else:
             self._log(f'PLEASE IMPLEMENT HANDLER FOR: {msg.raw}')