home · contact · privacy
Strengthen hierarchical class relations.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 11 Sep 2025 20:40:04 +0000 (22:40 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 11 Sep 2025 20:40:04 +0000 (22:40 +0200)
ircplom/client.py
ircplom/client_tui.py

index bd6ad5bf38d1883a347eb87b052cac28c41074af..d125aa75b68dee5c042cb5ee100eabfc42d0f720 100644 (file)
@@ -298,6 +298,7 @@ class SharedClientDbFields(IrcConnSetup):
     'API for fields shared directly in name and type with TUI.'
     connection_state: str = ''
     isupport: Dict[str]
+    motd: Iterable[str]
     sasl_account: str = ''
     sasl_auth_state: str = ''
 
@@ -317,6 +318,12 @@ class NickUserHost:
         return f'{self.nick}!{self.user}@{self.host}'
 
 
+class User(NickUserHost):
+    'Adds to NickUserHost non-naming-specific attributes.'
+    modes: str = '?'
+    exit_msg: str = ''
+
+
 @dataclass
 class ServerCapability:
     'Public API for CAP data.'
@@ -331,6 +338,12 @@ class Topic:
     who: Optional[NickUserHost] = None
 
 
+class Channel:
+    'Collects .topic, and in .user_ids inhabitant IDs.'
+    topic: Topic
+    user_ids: Iterable[str]
+
+
 class LogScope(Enum):
     'Where log messages should go.'
     ALL = auto()
@@ -385,7 +398,7 @@ class _CompletableTopic(_Completable, Topic):
                                 NickUserHost(copy.nick, copy.user, copy.host))
 
 
-class _Channel:
+class _Channel(Channel):
     user_ids: _CompletableStringsSet
     topic: _CompletableTopic
 
@@ -461,9 +474,7 @@ class _NickUserHost(NickUserHost):
         return name + str(0 if not digits else (int(digits) + 1))
 
 
-class _User(_SetNickuserhostMixin, NickUserHost):
-    modes: str = '?'
-    exit_msg: str = ''
+class _User(_SetNickuserhostMixin, User):
 
     def __init__(self,
                  names_channels_of_user: Callable,
index f1d5e90431802eddf87bc24d67710d75d8876296..fa6b5a41c4d974033383ac1d22c792eea4f7f935 100644 (file)
@@ -8,9 +8,9 @@ from typing import Any, Callable, Optional, Self, Sequence
 from ircplom.tui_base import (BaseTui, PromptWidget, TuiEvent, Window,
                               CMD_SHORTCUTS)
 from ircplom.client import (
-        AutoAttrMixin, Client, ClientQueueMixin, Dict, DictItem,
+        AutoAttrMixin, Channel, Client, ClientQueueMixin, Dict, DictItem,
         IntoEndnodeUpdatesMixin, IrcConnSetup, LogScope, NewClientEvent,
-        NickUserHost, ServerCapability, SharedClientDbFields, Topic)
+        NickUserHost, ServerCapability, SharedClientDbFields, User)
 
 CMD_SHORTCUTS['disconnect'] = 'window.disconnect'
 CMD_SHORTCUTS['join'] = 'window.join'
@@ -215,10 +215,9 @@ class _QueryWindow(_ChatWindow):
     pass
 
 
-class _UpdatingChannel(_UpdatingNode):
-    user_ids: set[str]
-    topic: Topic
+class _UpdatingChannel(_UpdatingNode, Channel):
     log_scopes = {'': LogScope.CHAT}
+    user_ids: set[str]
 
     def _focused_set_and_report_change(
             self, old_value: '_UpdatingNode', update: _Update
@@ -241,11 +240,9 @@ class _UpdatingChannel(_UpdatingNode):
         return None
 
 
-class _UpdatingUser(_UpdatingNode, NickUserHost):
+class _UpdatingUser(_UpdatingNode, User):
     log_scopes = {'nick': LogScope.USER, 'exit_msg': LogScope.USER}
     prev_nick = '?'
-    modes = '?'
-    exit_msg = ''
 
     def _focused_set_and_report_change(
             self, old_value: '_UpdatingNode', update: _Update