mudpuppy_core
The mudpuppy_core
module offers low-level access to Mudpuppy.
A MudpuppyCore
instance for interacting with the client.
It is automatically set up when Mudpuppy is running and has loaded your scripts.
You will typically want to call functions on the mudpuppy_core.mudpuppy_core
instance to interact with the client. For example,
from mudpuppy_core import mudpuppy_core
version = mudpuppy_core.version()
print(f"running {version}")
An EventHandlers
instance for registering EventHandler
instances
with the client.
It is automatically set up when Mudpuppy is running and has loaded your scripts.
You will typically want to use the mudpuppy
decorators (e.g. mudpuppy.on_event()
)
instead of directly interacting with the EventHandlers
.
To manually register an EventHandler
, you can use EventHandlers.add_handler()
:
from mudpuppy_core import mudpuppy_core, event_handlers, Event, EventType
async def on_gmcp_enabled(event: Event):
print(f"GMCP enabled for session {event.id}")
await mudpuppy_core.gmcp_register(event.id, "Char")
event_handlers.add_handler(EventType.GmcpEnabled, on_gmcp_enabled, __name__)
Returns a Config
instance.
Note that when the configuration changes old Config
instances
are not automatically updated. You should use a
EventType.ConfigReloaded
event handler to respond to updates
to Config
.
Returns the path to the Mudpuppy configuration directory.
This is the place where you should place .py
scripts to be
automatically loaded, and the default location for the Config
file.
Returns the path to the Mudpuppy data directory.
This is the place where Mudpuppy writes its logfile.
Outputs each line of the rendered arguments as debug output items in the currently active mudpuppy session (if any).
The arguments and behaviour match that of builtins.print
.
For more control over output, use MudpuppyCore.add_output()
instead.
Returns the ID of the currently active session, or None
if no session
is active.
Returns a list of SessionInfo
instances for all sessions.
Returns a SessionInfo
instance for the given session ID.
Returns connection Status
information for the given session ID.
Returns the Mud
configuration for the given session ID, if it exists.
Sends a line of text to the given session ID as if it were input sent by the user.
The input will be marked as "scripted" to differentiate it from true user input typed at the keyboard.
Command splitting works the same as for normal user input.
Unlike true user input, aliases are not evaluated for send_line()
input. This also means it isn't possible to send slash
command
input in this manner.
Prefer using MudpuppyCore.send_lines()
for sending multiple lines.
Example:
from mudpuppy_core import mudpuppy_core
session_id = ...
mudpuppy_core.send_line(session_id, "hello") # Sends 'hello'
mudpuppy_core.send_line(session_id, "hello;;wave") # Sends 'hello' and then 'wave'
Sends a list of lines of text to the given session ID as if they were input sent by the user.
The input will be marked as "scripted" to differentiate it from true user input typed at the keyboard.
Prefer using MudpuppyCore.send_line()
for sending a single line.
Connects the given session ID if it isn't already connected.
You can use MudpuppyCore.status()
to determine a session's connection Status
before calling connect()
.
A EventType.Connection
event will be emitted with the new Status
.
Disconnects the given session ID if it isn't already disconnected.
You can use MudpuppyCore.status()
to determine a session's connection Status
before calling connect()
.
A EventType.Connection
event will be emitted with the new Status
.
Requests that the MUD server enable a telnet option for the given session ID.
If the option is enabled by the server a EventType.OptionEnabled
event will be
emitted with the same session ID.
Requests that the MUD server disable a telnet option for the given session ID.
If the option is disabled by the server a EventType.OptionDisabled
event will be
emitted with the same session ID.
Sends a telnet subnegotiation to the given session.
The data should be the raw bytes of the subnegotiation payload for the given option code.
Creates a new trigger for the given session ID for the given TriggerConfig
.
Returns an int
trigger ID that can be used with MudpuppyCore.get_trigger()
,
MudpuppyCore.disable_trigger()
and MudpuppyCore.remove_trigger()
.
The module
str is used to associate the trigger with a specific Python module that created
it so that if the module is reloaded, the trigger will be deleted first to avoid duplicates
when the module re-creates it at load.
Returns the Trigger
for the given trigger ID if it exists for the provided session ID.
See MudpuppyCore.new_trigger()
for creating triggers.
Disables the trigger with the given trigger ID for the given session ID if it is currently enabled.
The trigger will no longer be evaluated when new input is received, even if it matches the trigger's pattern.
You can use MudpuppyCore.get_trigger()
to get a Trigger
to determine if
it is currently enabled or disabled. Use MudpuppyCore.enable_trigger()
to
enable the trigger again.
Enables the trigger with the given trigger ID for the given session ID if it was previously disabled.
You can use MudpuppyCore.get_trigger()
to get a Trigger
to determine if
it is currently enabled or disabled. Use MudpuppyCore.disable_trigger()
to
disable the trigger again.
Removes the trigger with the given trigger ID for the given session ID if it exists.
The trigger will be deleted and its trigger ID will no longer be valid. You
will need to recreate it with MudpuppyCore.new_trigger()
if you want to
restore the TriggerConfig
.
Prefer MudpuppyCore.disable_trigger()
if you think you'll want the trigger
to be used again in the future.
Removes all triggers created by the given module for the given session ID.
This is useful when a module is reloaded and triggers need to be recreated to avoid duplicates.
Returns a list of Trigger
instances for the given session ID.
Creates a new Alias
for the given session ID for the given AliasConfig
.
Returns an int
alias ID that can be used with MudpuppyCore.get_alias()
,
MudpuppyCore.disable_alias()
and MudpuppyCore.remove_alias()
.
The module
str is used to associate the alias with a specific Python module that created
it so that if the module is reloaded, the alias will be deleted first to avoid duplicates
when the module re-creates it at load.
Returns the Alias
for the given alias ID if it exists for the provided session ID.
See MudpuppyCore.new_alias()
for creating aliases.
Disables the alias with the given alias ID for the given session if it is currently enabled.
The alias will no longer be evaluated when new input is received, even if it matches the alias's pattern.
You can use MudpuppyCore.get_alias()
to get a Alias
to determine if
it is currently enabled or disabled. Use MudpuppyCore.enable_alias()
to
enable the alias again.
Enables the alias with the given alias ID for the given session ID if it was previously disabled.
You can use MudpuppyCore.get_alias()
to get a Alias
to determine if
it is currently enabled or disabled. Use MudpuppyCore.disable_alias()
to
disable the alias again.
Removes the alias with the given alias ID for the given session ID if it exists.
The alias will be deleted and its alias ID will no longer be valid. You
will need to recreate it with MudpuppyCore.new_alias()
if you want to
restore the AliasConfig
.
Prefer MudpuppyCore.disable_alias()
if you think you'll want the alias
to be used again in the future.
Removes all aliases created by the given module for the given session ID.
This is useful when a module is reloaded and aliases need to be recreated to avoid duplicates.
Returns a list of Alias
instances for the given session ID.
Creates a new Timer
configured with the given TimerConfig
.
Returns an int
timer ID that can be used with MudpuppyCore.get_timer()
,
MudpuppyCore.stop_timer()
and MudpuppyCore.remove_timer()
.
The module
str is used to associate the timer with a specific Python module that created
it so that if the module is reloaded, the timer will be deleted first to avoid duplicates
when the module re-creates it at load.
Returns the Timer
for the given timer ID if it exists.
See MudpuppyCore.new_timer()
for creating timers.
Disables the timer with the given timer ID if it is currently enabled.
The timer will no longer be evaluated when the timer interval elapses.
You can use MudpuppyCore.get_timer()
to get a Timer
to determine if
it is currently enabled or disabled. Use MudpuppyCore.enable_timer()
to
enable the timer again.
Starts a timer with the given timer ID if it was previously stopped.
You can use MudpuppyCore.get_timer()
to get a Timer
to determine if
it is currently enabled or disabled. Use MudpuppyCore.disable_timer()
to
disable the timer again.
Removes the timer with the given timer ID if it exists.
The timer will be deleted and its timer ID will no longer be valid. You
will need to recreate it with MudpuppyCore.new_timer()
if you want to
restore the TimerConfig
.
Prefer MudpuppyCore.disable_timer()
if you think you'll want the timer
to be used again in the future.
Removes all timers created by the given module.
This is useful when a module is reloaded and timers need to be recreated to avoid duplicates.
Adds an OutputItem
to the main output buffer for the given session ID.
This is the primary mechanism of displaying data to the user.
Use MudpuppyCore.add_outputs()
if you have a list[OutputItem]
to add.
Adds a list of OutputItem
instances to the main output buffer for the given session ID.
USe MudpuppyCore.add_output()
if you only have one OutputItem
to add.
Returns the width and height of the output area for the given session ID.
Note that this is not the overall width/height of the window, but just the area just to display output from the MUD. These dimensions match the dimensions sent to the MUD using the Telnet NAWS option if supported.
See also EventType.BufferResized
.
Returns the root LayoutNode
for the given session ID.
The layout tree describes how the output area is divided into regions and how each region is filled with content.
Use LayoutNode
methods to navigate the tree and manipulate the layout.
Creates a new ExtraBuffer
for the given session ID with the given BufferConfig
.
Returns an int
buffer ID that can be used with MudpuppyCore.get_buffer()
,
MudpuppyCore.remove_buffer()
.
Once retrieving the ExtraBuffer
with MudpuppyCore.get_buffer()
, you can
use the ExtraBuffer
methods to manipulate the buffer, add output, etc.
Returns the ExtraBuffer
for the given buffer ID if it exists for the provided session ID.
See MudpuppyCore.new_buffer()
for creating buffers.
Returns a list of ExtraBuffer
instances for the given session ID.
Removes the buffer with the given buffer ID for the given session ID if it exists.
The buffer will be deleted and its buffer ID will no longer be valid. You
will need to recreate it with MudpuppyCore.new_buffer()
if you want to
restore the BufferConfig
.
Returns True
if negotiation has completed and GMCP is enabled for the given
session ID, False
otherwise.
Sends a GMCP package to the MUD for the given session ID.
The module
is the GMCP module name and the json
is the JSON-encoded
data to send. You must json.dumps()
your data to create the json_data
string you provide this function.
Use MudpuppyCore.gmcp_enabled()
to verify GMCP is enabled for a session
before sending GMCP messages.
Use MudpuppyCore.gmcp_register()
to register the module
if required.
Registers the given GMCP package
with the MUD for the given session ID.
This lets the MUD know you support GMCP messages for the package
.
Use MudpuppyCore.gmcp_enabled()
to verify GMCP is enabled for a session
before sending GMCP messages.
For example, you may wish to gmcp_register(id, "Char")
to receive Char.*
package messages as events.
Unregisters the given GMCP package
with the MUD for the given session ID.
This lets the MUD know you no longer want GMCP messages for the package
.
Use MudpuppyCore.gmcp_enabled()
to verify GMCP is enabled for a session
before sending GMCP messages.
For example, you may wish to gmcp_unregister(id, "Char")
to stop receiving Char.*
package messages as events.
Emits a custom event with the given custom_type
and data
for the given session ID.
If id
is None
, the event is emitted for all sessions.
The event will be produced as an EventType.Python
event.
This can be helpful for coordinating between your Python scripts. One can emit a custom event and another can register a listener for it.
Reloads all Python scripts.
Before the reload occurs already loaded scripts will have their on_reload()
function called (if it exists) before the reload happens. Similarly,
MudpuppyCore.remove_module_aliases()
,MudpuppyCore.remove_module_triggers()
, and
MudpuppyCore.remove_module_timers()
will be called for each of the reloaded modules.
Remember that events that already occurred (e.g. EventType.NewSession
) will not
be re-emitted. Your scripts should be written to pick up where they left off from
before the reload without requiring extra events beyond EventType.PythonReloaded
.
Read-only access to the Mudpuppy config.
Accessed by calling MudpuppyCore.config()
.
Return the Mud
configuration for the given mud_name
, or None
if no
configuration exists for the given mud_name
.
Return the Mud
configuration for the given mud_name
, or raise an
exception if no configuration exists for the given mud_name
.
Information about a session.
Typically retrieved using MudpuppyCore.session_info()
with an int
session ID,
or for all sessions, MudpuppyCore.sessions()
.
Information about a MUD and its configuration.
Name of the MUD.
Used as the label for the session tab, and for listing the MUD on the connection screen.
This is the identifier you will use with decorators like mudpuppy.trigger
for the
mud_name
parameter.
Host address of the MUD.
This is typically a domain name like "dunemud.net"
or an IP address like 8.8.8.8
or
2607:f8b0:400b:803::200e
.
The port
number is specified separately and not included here.
Describes whether/how TLS should be used when connecting to a Mud
.
TLS should be used, but certificate errors should be ignored.
This is generally unsafe but may be required if the server is misconfigured or if you're using self-signed test certificates.
A key press event.
A mouse event.
An enum describing possible MouseEvent
types.
The left mouse button was pressed.
The right mouse button was pressed.
The middle mouse button was pressed.
Read-only Key binding configuration.
See Config
for more information.
Returns a dictionary of all the key bindings for the given mode. If no mode is specified a default of "mudsession" is used.
Raises an exception if mode is not a known input mode.
Use modes
for a list of all available modes.
A line received from a MUD.
The raw bytes received from the game.
For regular lines this will be the content without the trailing newline indicator
(\r\n
) that terminated the line.
If ANSI colours are used, the control codes will be present in raw
unaltered.
Whether or not the line was considered a prompt.
Prompt lines are typically terminated explicitly, or flushed from the connection
buffer after a certain timeout without receiving a normal \r\n
line ending.
Converts self.raw
to a UTF8-encoded string and returns it.
If the content is not UTF8 unknown characters will be replaced with U+FFFD
,
the unicode "replacement character".
Returns self.raw
after converting to UTF-8 using to_str()
and then
stripping ANSI control sequences.
A line of input that was transmitted to the MUD.
The scripted
property is True
when the input wasn't sent by a human
entering it with the keyboard but was instead sent programmatically by a
script.
A EventType.NewSession
event. This is produced when the user
selects a MUD from the MUD list and an initial session ID is
assigned.
An EvenType.Connection
event. This is produced when the
Status
of the session's connection changes.
An EventType.Prompt
event. This is produced when a prompt
is received from the MUD.
The prompt MudLine
that was received.
The MudLine.prompt
value will always be true
for MudLine
s received
as part of a Prompt
event.
An EventType.Iac
event. This is produced when a Telnet IAC
option is received.
An EventType.OptionEnabled
event. This is produced when a
Telnet option is enabled. Typically in response to a
MudpuppyCore.request_enable_option()
call.
An EventType.OptionDisabled
event. This is produced when a
Telnet option is disabled. Typically in response to a
MudpuppyCore.request_disable_option()
call.
An EventType.Subnegotiation
event. This is produced when a
Telnet subnegotiation is received.
An EventType.BufferResized
event. This is produced when the MUD
output buffer is resized.
The dimensions included in the event describe the new size of the MUD output area (e.g. not the entire Mudpuppy window - just the area where MUD output is displayed).
An EventType.InputLine
event. This is produced after a line of input
is sent to the MUD.
An EventType.Shortcut
event. This is produced when a recognized
keyboard shortcut is input.
An EventType.KeyPress
event. This is produced when a keyboard key
is pressed.
An EventType.Mouse
event. This is produced when there is mouse activity and the Mudpuppy config has
mouse_enabled
set to true
.
An EventType.GmcpEnabled
event. This is produced when GMCP is enabled for a session
after successfully negotiating the telnet option with the MUD server.
An EventType.GmcpDisabled
event. This is produced when GMCP is disabled for a session.
An EventType.GmcpMessage
event. This is produced when a GMCP message is received.
Typically this happens for module
's that have been registered with
MudpuppyCore.gmcp_register()
. To stop receiving message events for a module
, try
MudpuppyCore.gmcp_unregister()
.
An EventType.Python
event. This is produced when a custom event is emitted
with MudpuppyCore.emit_event()
.
An EventType.ConfigReloaded
event. This is produced when the Config
has been reloaded.
This happens when the config file on disk has been edited, or a setting was changed.
You should call MudpuppyCore.config()
after receiving this event to get a copy of
the latest Config
.
An EventType.PythonReloaded
event. This is produced when Python code has been reloaded.
This is emitted after MudpuppyCore.reload()
has been called, and the reload process
completed.
An EventType.ResumeSession
event. This is produced for each session ID after a
PythonReloaded
event.
An enum describing possible Event
types.
You will typically specify an EventType
when registering event handlers that will
later be called with an Event
instance matching that event type.
An event emitted when a new session ID is created after connecting to a Mud
.
An event emitted when the connection for a session ID changes Status
.
An event emitted when the Config
has been reloaded.
This happens when the config file on disk has been edited, or a setting was changed.
An event emitted when Python code has been reloaded.
This is emitted after MudpuppyCore.reload()
has been called, and the reload process
completed.
An event emitted when a Telnet option was enabled. Typically in response
to a MudpuppyCore.request_enable_option()
call.
An event emitted when a Telnet option was disabled. Typically in response
to a MudpuppyCore.request_disable_option()
call.
An event emitted when a Telnet subnegotiation was received.
An event emitted when the MUD output buffer is resized. Typically this happens when the overall window has been resized, or layout element changes have occurred.
An event emitted after a line of input was sent to the MUD.
An event emitted when a recognized keyboard shortcut was input.
An event emitted when GMCP is enabled for a session.
See also MudpuppyCore.gmcp_enabled()
.
An event emitted when GMCP is disabled for a session.
See also MudpuppyCore.gmcp_enabled()
.
An event emitted when a GMCP message is received.
An event emitted for each session ID after a PythonReloaded
event.
An async function that handles a mudpuppy_core.Event
object as its sole argument.
Example:
async def my_event_handler(event: mudpuppy_core.Event):
print(f"my_event_handler received event {event}")
A collection of event handlers that will be invoked for specific registered
EventType
s.
Adds a new event handler for the given EventType
.
The async handler
will be invoked when an event of the given type is emitted.
The module
string is used to associate the handler with a specific Python
module so that when the module is reloaded, the handler can be removed to
avoid duplicates.
The handler
should have a signature like:
async def handler(event: Event):
...
Returns a list of handlers for the given EventType
if any are registered.
A AliasConfig
associated with a int
alias ID after being created with MudpuppyCore.new_alias()
Whether the Alias
is currently enabled.
Mutate using MudpuppyCore.enable_alias()
and MudpuppyCore.disable_alias()
.
The module that created the Alias
.
Used in association with MudpuppyCore.remove_module_aliases()
.
An async function that is called when input sent to a MUD matches an alias pattern.
Typically you will assign an AliasCallable
to the callback
property of an AliasConfig
.
Alternatively, see mudpuppy.alias()
for a simple @alias()
decorator.
The handler is called with:
- the
int
session ID of the session that received the input - the
int
alias ID of theAlias
that matched. - the
str
input that matched the alias pattern, and - a
list[str]
of captured groups from the alias pattern (if any).
Example:
from mudpuppy_core import mudpuppy_core, Alias
async def my_alias_handler(session_id: int, alias_id: int, line: str, _groups: list[str]):
alias: Alias = await mudpuppy_core.get_alias(session_id, alias_id)
print(f"alias {alias.config.name} has matched input: {line}")
print(f"this alias has matched input {alias.config.hits} times so far")
Configuration for an Alias
.
You can create a new AliasConfig
by specifying a regexp pattern
and a name
:
alias_config = AliasConfig(r"^hello$", "hello trigger")
alias_config.expansion = "say HELLO!"
Create a new AliasConfig
with a pattern
and a name
.
You can optionally provide a callback
and an expansion
string.
An optional async AliasCallable
to invoke when the alias matches.
An optional string that will be expanded into an InputLine
sent to the MUD whenever the
alias matches if it is non-empty.
This value will become the InputLine.sent
value sent to the game, and the
line that was matched by the alias will be set to the InputLine.original
value.
The sent InputLine.scripted
property will be set to True
.
A TriggerConfig
associated with a int
trigger ID after being created with MudpuppyCore.new_trigger()
The module that created the Trigger
.
Used in association with MudpuppyCore.remove_module_triggers()
.
An async function that is called when output sent from a MUD matches a trigger pattern.
Typically assigned to a TriggerConfig
's callback
property, alternatively see
mudpuppy.trigger()
for a simple @trigger()
decorator.
The handler is called with:
- the
int
session ID of the session that received the output - the
int
trigger ID of themudpuppy_core.Trigger
that matched. - the
str
output that matched the trigger pattern, and - a
list[str]
of captured groups from the trigger pattern (if any).
Example:
from mudpuppy_core import mudpuppy_core
async def my_trigger_handler(
session_id: int,
trigger_id: int,
line: str,
_groups: list[str]
):
trigger: Trigger = await mudpuppy_core.get_trigger(session_id, trigger_id)
print(f"trigger {trigger.config.name} has matched output: {line}")
print(f"this trigger has matched output {trigger.config.hits} times so far")
A non-async function that is called when a line of output from the MUD matches a
highlight pattern. Typically assigned to a TriggerConfig
's highlight
property.
Alternatively see mudpuppy.highlight()
for a simple @highlight()
decorator.
The handler is called with:
- a
MudLine
object representing the line of output from the MUD - a
list[str]
of captured groups from the highlight pattern (if any)
It must return a MudLine
to display. This can be the same line
object passed in, or a new line object.
Unlike AliasCallable
, TriggerCallable
, and most other callables
mudpuppy_core
uses this callable is not async. This is because the handler is expected to mutate
the MudLine
object in place to apply the desired highlighting. This
also means you can not await
other mudpuppy_core
functions from within a highlight
and should prefer using TriggerCallable()
handlers for those tasks.
For example, you could use MudLine.set_line()
to mutate the provided
line
to add ANSI colours using cformat
:
from cformat import cformat
# Note: **not async**!
def example_highlight_callable(line: MudLine, groups):
assert len(groups) == 1
new_line = line.__str__().replace(
groups[0], cformat(f"<bold><cyan>{groups[0]}<reset>")
)
line.set(new_line)
return line
Configuration for a Trigger
.
You can create a new TriggerConfig
by specifying a regexp pattern
and a name
:
trigger_config = TriggerConfig(r".*Hello.*", "hello trigger")
trigger_config.gag = True
Create a new TriggerConfig
with a pattern
and a name
.
Optionally you may specify strip_ansi
, prompt
, gag
, callback
, highlight
, and expansion
.
Whether or not the MudLine
is required to have MudLine.prompt
be equal to True
in
addition to the pattern
matching for the trigger to fire.
Set this to True
if you only want the trigger to match lines that generate a EventType.Prompt
event.
Whether or not MudLine
s matched by this trigger should be gagged (e.g. not displayed).
Set this to True
to suppress (gag) matched lines.
An optional async TriggerCallable
to invoke when the trigger matches.
An optional synchronous HighlightCallable
to invoke when the pattern
matches
to provide a new MudLine
to display.
The MudLine
returned by the callback function will replace the matched MudLine
allowing you to (for example) add ANSI highlights colours.
An optional string that will be expanded into an InputLine
sent to the MUD whenever the
trigger matches if it is non-empty.
The sent MudLine
will have MudLine.scripted
set to True
to differentiate
it from human input.
The expansion will be used after both the optional callback
and highlight
functions
have been called.
Configuration for a Timer
.
You can create a new TimerConfig
by specifying a name
, a duration_ms
, a callback
and optionally an int
session ID:
timer_config = TimerConfig("Test Timer", 1000, my_timer_callback, None)
Create a new TimerConfig
with a name
that will be run every duration_ms
milliseconds, invoking callback
. The timer may optionally be associated
with an int
session ID.
An async function that receives an int
timer ID and optionally an int
session ID when the timer fires.
Your timer callback function should have a signature like:
async def my_timer_callback(timer_id: int, sesh: Optional[int]):
...
An optional int
session ID that the timer is associated with. Can be both read and set.
An optional maximum number of times the callback
should be invoked before
the timer is automatically removed. Can be both read and set.
A TimerConfig
associated with an int
timer ID after being created with MudpuppyCore.new_timer()
Whether the Timer
is currently running.
Mutate using MudpuppyCore.start_timer()
and MudpuppyCore.stop_timer()
.
The module that created the Timer
.
Used in association with MudpuppyCore.remove_module_timers()
.
A recognized keyboard shortcut.
A shortcut to swap the current tab with the tab to the left.
A shortcut to swap the current tab with the tab to the right.
A shortcut to select the next MUD from the MUD list.
A shortcut to select the previous MUD from the MUD list.
A shortcut to connect to the selected MUD from the MUD list.
A shortcut to toggle line wrapping in the output area.
A shortcut to toggle whether InputLine
s are displayed in the output buffer.
A shortcut to navigate to the next line in the input history.
A shortcut to navigate to the previous line in the input history.
A shortcut to scroll the output buffer to the bottom.
Describes a possible way of signalling the a partial line is a prompt and not part of a line waiting for the other part with the line terminator to be received.
Prompts are signalled by the telnet end of record (EOR) IAC signal.
Prompts are signalled by the telnet go ahead (GA) IAC signal.
The mode the MUD is using for handling prompt lines.
The MUD explicitly signals prompt lines using a specified PromptSignal
.
Connection status information.
Typically retrieved using MudpuppyCore.status()
with an int
session ID.
The session is not connected.
The session is in the process of connecting.
The session is connected and info
holds the StreamInfo
describing
the server the stream is connected to.
The StreamInfo
for the connected stream.
This will be a StreamInfo.Tcp
or StreamInfo.Tls
instance depending
on the Mud
that was used to create the stream.
Information about a connection stream.
A normal Telnet TCP stream without any encryption or authentication.
A TLS encrypted stream.
The IP address the stream is connected to, in string format.
This may be an IPv4 or IPv6 address.
Whether the TLS certificate verification was skipped.
When verify_skipped
is True
, the stream was configured to ignore
any certificate errors (dangerous!).
An item to be displayed in the output area of a session.
Construct a Mud
OutputItem
with the given MudLine
.
Construct a CommandResult
OutputItem
with the given msg
.
The CommandResult.error
will be False
. For a failed command
result output item, use failed_command_result()
.
Construct a failed CommandResult
OutputItem
with the given msg
.
The CommandResult.error
will be True
.
Construct a PreviousSession
OutputItem
with the given line
.
A line of text from the MUD.
A line of text from the user.
A prompt line.
A prompt line that has been held at the bottom of the MUD buffer for consistent display as output scrolls.
A connection event to be displayed in the output buffer.
A command result to be displayed in the output buffer.
A message loaded from a previous session log.
A debug message to be displayed in the output buffer.
A collection of OutputItem
instances displayed in an ExtraBuffer
.
Appends an OutputItem
to the collection.
The BufferConfig.direction
will determine whether items added at the end
of the collection are rendered first, or last.
Sets the collection of OutputItem
instances to items
.
Replaces the existing content with the items
list.
The input area of the client window.
Adds the provided ansi_markup as a decoration to the input area at the given index.
The echo state for an InputLine
Telnet echo was disabled because the InputLine
was a password.
It should be displayed masked (e.g. *****
)
Each layout node describes a section in the layout tree.
The list of sub-sections (if any). Can be both read and set.
Each sub-section is described as a Tuple
holding a Constraint
and a LayoutNode
.
Adds a LayoutNode
as a child section of this node, with size described by
the given constraint
.
Returns the Constraint
and LayoutNode
for the section with the given name
.
Raises an exception if name
is not a known section name under the LayoutNode
.
Returns a dictionary of all the LayoutNode
instances in the layout tree,
keyed by their section name.
A LayoutNode
constraint.
Creates a new Constraint
with a percentage constraint.
Creates a new Constraint
with a ratio constraint.
Creates a new Constraint
with a length constraint.
A direction to use when creating new layout nodes.
Configuration for an ExtraBuffer
.
See MudpuppyCore.new_buffer()
for more information.
The name of the layout section that the buffer should be displayed in.
See layout.LayoutManager
for more information.
The BufferDirection
that the content of the ExtraBuffer
should be displayed in.
Describes what direction an ExtraBuffer
should render its contents.
The default direction, and the way the standard MUD output buffer works.
Newer items should be rendered first, at the bottom of the buffer. Older items will be rendered afterwards towards the top of the buffer.
Older items should be rendered first, at the top of the buffer. Newer items will be rendered afterwards, towards the bottom of the buffer.
A BufferConfig
associated with an int
buffer ID after being created with MudpuppyCore.new_buffer()
An extra buffer for displaying output. Typically created by and used by scripts.
A gauge widget that can be created with MudpuppyCore.new_gauge()
.
A button widget that can be created with MudpuppyCore.new_button()
.
An async function that is called when a button is clicked.
Typically assigned to a Button
's callback
property.
The callable is called with:
- the
int
session ID of the session that owns the button that was clicked. - the
int
button ID of the button that was clicked.