home · contact · privacy
Move part of 433 handling into MSG_EXPECTATIONS, improve messaging.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 30 Sep 2025 18:14:39 +0000 (20:14 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 30 Sep 2025 18:14:39 +0000 (20:14 +0200)
src/ircplom/client.py
src/ircplom/msg_parse_expectations.py
src/tests/test.txt

index 3ebbc111559132b5a044e8e5cf81358d4c3f8439..d8e59b7a71e247b8a201463a75aadd5c6427c09d 100644 (file)
@@ -951,11 +951,9 @@ class Client(ABC, ClientQueueMixin):
         elif ret['_verb'] == '401':  # ERR_NOSUCHNICK
             raise TargetUserOffline(ret['missing'])
         elif ret['_verb'] == '432':  # ERR_ERRONEOUSNICKNAME
-            alert = 'nickname refused for bad format'
-            if 'nick' not in ret:
-                alert += ', giving up'
-                self.close()
-            self._alert(alert)
+            self._alert('nickname refused for bad format, '
+                        + ('keeping current one' if 'nick' in ret
+                           else 'giving up'))
         elif ret['_verb'] == '433':  # ERR_NICKNAMEINUSE
             self._alert('nickname already in use, trying increment')
             self.send('NICK', _NickUserHost(nick=ret['used']).incremented)
index 95fbc5f6ae836bb066fd62b5504a02665bde1b4a..158154f8bf10467f343002770136f4cdf2fb2a8c 100644 (file)
@@ -401,7 +401,8 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [
         _MsgTok.SERVER,
         ('*',
          _MsgTok.ANY,  # bad one probably fails our NICKNAME tests
-         _MsgTok.ANY)),  # comment
+         _MsgTok.ANY),  # comment
+        bonus_tasks=('do_close:',)),
     _MsgParseExpectation(
         '432',  # ERR_ERRONEOUSNICKNAME
         _MsgTok.SERVER,
index 10ae008127273f0939309227285aa4a756bab530..10109422d1d0e2bbd90ecfbd742a18b38519c683 100644 (file)
 > /nick @foo
 1 .> NICK :@foo
 0:1 .< :*.?.net 432 foo1 @foo :Erroneous nickname
-1 .!$ nickname refused for bad format
+1 .!$ nickname refused for bad format, keeping current one
 
 # join channel, collect topic, residents; update me:user from JOIN message; ensure topic.who not affecting users DB
 > /join #test