home · contact · privacy
Use space rather than colon as "impossible" meta character for server query, move...
authorChristian Heller <c.heller@plomlompom.de>
Mon, 22 Sep 2025 07:15:25 +0000 (09:15 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 22 Sep 2025 07:15:25 +0000 (09:15 +0200)
ircplom/client.py
ircplom/msg_parse_expectations.py
test.txt

index fe8479c813fb4cf8247f00f62ed161d3c3396f91..eeb1708b5c79adec4551ca2b5db14e84d0d5a675 100644 (file)
@@ -436,9 +436,11 @@ class _Channel(Channel):
 
 class _ChatMessage(ChatMessage):
 
-    def __init__(self, sender: str = '', db: Optional['_ClientDb'] = None
+    def __init__(self,
+                 sender: str | NickUserHost = '',
+                 db: Optional['_ClientDb'] = None
                  ) -> None:
-        self.sender = sender
+        self.sender = sender if isinstance(sender, str) else sender.nick
         self._db = db
 
     def to(self, target: str) -> Self:
@@ -671,8 +673,7 @@ class _ClientDb(_Clearable, _UpdatingAttrsMixin, SharedClientDbFields):
 
     def messaging(self, src: str | NickUserHost) -> ChatMessage:
         'Start input chain for chat message data.'
-        return _ChatMessage(sender=f':{src}' if isinstance(src, str)
-                            else src.nick, db=self)
+        return _ChatMessage(sender=src, db=self)
 
     def into_endnode_updates(self, path: tuple[str, ...]
                              ) -> list[tuple[tuple[str, ...], Any]]:
index 71755a9198a22cf981faefd07b91747f5662a4ec..84478b4589d4ad615626bb3a81acb0107ccf483c 100644 (file)
@@ -492,12 +492,12 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [
         'NOTICE',
         _MsgTok.SERVER,
         ('*',
-         (_MsgTok.ANY, 'setattr_db.messaging.server.to.:notice'))),
+         (_MsgTok.ANY, 'setattr_db.messaging. server.to.:notice'))),
     _MsgParseExpectation(
         'NOTICE',
         _MsgTok.SERVER,
         ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'),
-         (_MsgTok.ANY, 'setattr_db.messaging.server.to.:notice'))),
+         (_MsgTok.ANY, 'setattr_db.messaging. server.to.:notice'))),
 
     _MsgParseExpectation(
         'NOTICE',
index 0ab00d395181e7188aeacb3dac08bed5a7c01994..352fac78daf8ce8a0ab87afb54b2b3b53f0afdde 100644 (file)
--- a/test.txt
+++ b/test.txt
 
 # expect some NOTICE and PING to process/reply during initiation
 0:2 < :*.?.net NOTICE * :*** Looking up your ident...
-1,2 $ message set to: [N :server  :*** Looking up your ident...]
-3 <<< [:server] *** Looking up your ident...
+1,2 $ message set to: [N  server  :*** Looking up your ident...]
+3 <<< [ server] *** Looking up your ident...
 1,2 $ message set to: [P   :]
 0:2 < :*.?.net NOTICE * :*** Looking up your hostname...
-1,2 $ message set to: [N :server  :*** Looking up your hostname...]
-3 <<< [:server] *** Looking up your hostname...
+1,2 $ message set to: [N  server  :*** Looking up your hostname...]
+3 <<< [ server] *** Looking up your hostname...
 1,2 $ message set to: [P   :]
 0:2 < :*.?.net NOTICE * :*** Found your hostname (baz.bar.foo)
-1,2 $ message set to: [N :server  :*** Found your hostname (baz.bar.foo)]
-3 <<< [:server] *** Found your hostname (baz.bar.foo)
+1,2 $ message set to: [N  server  :*** Found your hostname (baz.bar.foo)]
+3 <<< [ server] *** Found your hostname (baz.bar.foo)
 1,2 $ message set to: [P   :]
 0:2 < PING :?
 2 > PONG :?
 0 #   0) :start
 0 #   1) foo.bar.baz :DEBUG
 0 #   2) foo.bar.baz :RAW
-0 #   3) foo.bar.baz :server
+0 #   3) foo.bar.baz  server
 0 #   4) foo.bar.baz SaslServ
 > /window 1
 > /help