session_context

Base session context for telnet client connections.

class TelnetSessionContext(raw_mode=None, ascii_eol=False, input_filter=None, autoreply_engine=None, autoreply_wait_fn=None, typescript_file=None, gmcp_data=None)[source]

Base session context for telnet client connections.

Holds per-connection state that the shell layer needs. Subclass this to add application-specific attributes (e.g. MUD client state, macros, room graphs).

A default instance is created for every TelnetWriter; applications may replace it with a subclass via writer.ctx = MyCtx().

Parameters:
  • raw_mode (Optional[bool]) – Terminal raw mode override. None = auto-detect from server negotiation, True = force raw, False = force line mode.

  • ascii_eol (bool) – When True, translate ATASCII CR/LF glyphs to ASCII \r / \n.

  • input_filter (Optional[Any]) – Optional InputFilter for translating raw keyboard bytes (e.g. arrow keys for ATASCII/PETSCII).

  • autoreply_engine (Optional[Any]) – Optional autoreply engine (e.g. a MUD macro engine) that receives server output via engine.feed(text) and can send replies.

  • autoreply_wait_fn (Optional[Callable[..., Awaitable[None]]]) – Async callable installed by the shell to gate autoreply sends on GA/EOR prompt signals; set automatically during shell startup.

  • typescript_file (Optional[IO[str]]) – When set, all server output is appended to this file (like the POSIX typescript command).

  • gmcp_data (Optional[dict[str, Any]]) – Initial GMCP module data mapping; defaults to an empty dict.

Initialize session context with default attribute values.