class _Dict(Dict[DictItem]):
- _defaults: dict[str, DictItem]
-
- def __init__(self, **kwargs) -> None:
- super().__init__(**kwargs)
- self._defaults = {}
-
- def __getitem__(self, key: str) -> DictItem:
- if key not in self._dict and key in self._defaults:
- return self._defaults[key]
- return super().__getitem__(key)
def __setitem__(self, key: str, val: DictItem) -> None:
assert isinstance(val, self._item_cls)
channel.remove_user(user)
+class _UpdatingIsupportDict(_UpdatingDict[str]):
+
+ def __init__(self, **kwargs) -> None:
+ super().__init__(**kwargs)
+ self._set_defaults()
+
+ def _set_defaults(self):
+ for key, value in ISUPPORT_DEFAULTS.items():
+ self._dict[key] = value
+
+ def __delitem__(self, key: str) -> None:
+ if key in ISUPPORT_DEFAULTS:
+ self[key] = ISUPPORT_DEFAULTS[key]
+ else:
+ super().__delitem__(key)
+
+ def clear(self) -> None:
+ super().clear()
+ self._set_defaults()
+
+
class _ClientDb(_Clearable, _UpdatingAttrsMixin, SharedClientDbFields):
_keep_on_clear = set(IrcConnSetup.__annotations__.keys())
caps: _UpdatingDict[_UpdatingServerCapability]
channels: _UpdatingChannelsDict
- isupport: _UpdatingDict[str]
+ isupport: _UpdatingIsupportDict
motd: _UpdatingCompletableStringsOrdered
users: _UpdatingUsersDict
def __getattribute__(self, key: str):
attr = super().__getattribute__(key)
- if key == 'isupport' and not attr._defaults:
- attr._defaults = ISUPPORT_DEFAULTS
- elif key == 'channels' and attr._create_if_none is None\
+ if key == 'channels' and attr._create_if_none is None\
and super().__getattribute__('users'
)._create_if_none is not None:
attr._create_if_none = {
2 < :*.?.net NOTICE * :*** Found your hostname (baz.bar.foo)
1,2 $$$ *** Found your hostname (baz.bar.foo)
2 < :*.?.net CAP * LS : foo bar sasl=PLAIN,EXTERNAL baz
-1,2 $ isupport cleared
+1,2 $ isupport:CHANTYPES set to: [#&]
+1,2 $ isupport:PREFIX set to: [(ov)@+]
2 > CAP REQ :sasl
2 > CAP :LIST
2 < PING :?
2 < :foo.bar.baz 903 foo :SASL authentication successful
1,2 $ sasl_auth_state set to: [SASL authentication successful]
2 > CAP :END
+2 < :foo.bar.baz 001 foo :Welcome to the foo.bar.baz network
+2 < :foo.bar.baz 002 foo :Your host is foo.bar.baz
+2 < :foo.bar.baz 003 foo :This server was created Jan 1 2020
+2 < :foo.bar.baz 004 foo foo.bar.baz ircserver-1.0 abc def ghi
+2 < :foo.bar.baz 005 foo ABC=DEF GHI=JKL :are supported by this server
+1,2 $ isupport:ABC set to: [DEF]
+1,2 $ isupport:GHI set to: [JKL]
+2 < :foo.bar.baz 005 foo MNO=PQR STU=VWX Y=Z :are supported by this server
+1,2 $ isupport:MNO set to: [PQR]
+1,2 $ isupport:STU set to: [VWX]
+1,2 $ isupport:Y set to: [Z]
+2 < :foo.bar.baz 251 foo :There are 10 users and 1000 invisible on 5 servers
+2 < :foo.bar.baz 252 foo 7 :IRC Operators online
+2 < :foo.bar.baz 253 foo 4 :unknown connection(s)
+2 < :foo.bar.baz 254 foo 800 :channels formed
+2 < :foo.bar.baz 255 foo :I have 100 clients and 1 serveres
+2 < :foo.bar.baz 265 foo 100 150 :Current local users 100, max 150
+2 < :foo.bar.baz 266 foo 1010 1050 :Current global users 1010, max 1050
+2 < :foo.bar.baz 250 foo :Highest connection count: 151 (150 clients) (1080 connections received)
+2 < :foo.bar.baz 375 foo :- foo.bar.baz Message of the Day -
+2 < :foo.bar.baz 372 foo :- Howdy! -
+2 < :foo.bar.baz 372 foo :- Welcome! -
+2 < :foo.bar.baz 372 foo :- (to this server) -
+2 < :foo.bar.baz 376 foo :End of /MOTD command
+1,2 $ motd set to:
+1,2 $ - Howdy! -
+1,2 $ - Welcome! -
+1,2 $ - (to this server) -
+2 < :foo MODE foo :+Ziw
+1,2 $ users:me:modes set to: [+Ziw]
+2 < :SaslServ!SaslServ@services.bar.baz NOTICE foo :Last login from ~plom@foo.bar.baz on Jan 1 22:00:00 2021 +0000.
+3 <<< [SaslServ] Last login from ~plom@foo.bar.baz on Jan 1 22:00:00 2021 +0000.
+> /disconnect
+0 !# invalid prompt command: /disconnect unknown
+> /list
+0 # windows available via /window:
+0 # 0) :start
+0 # 1) foo.bar.baz :SERVER
+0 # 2) foo.bar.baz :RAW
+0 # 3) foo.bar.baz SaslServ
+> /window 1
+> /disconnect
+1,2 $ requesting disconnect …
+2 > QUIT :ircplom says bye
> /quit
0 <