hook.shell¶
- class immp.hook.shell.ShellHook(name, config, host)¶
Bases:
ResourceHookHook to start a Python shell when a message is received.
- async on_receive(sent, source, primary)¶
Handle an incoming message received by any plug.
- Parameters:
sent (.SentMessage) – Raw message received from another plug.
source (.Message) – Original message data used to generate the raw message, if sent via the plug (e.g. from another hook), equivalent to
msgif the source is otherwise unknown.primary (bool) –
Falsefor supplementary messages if the source message required multiple raw messages in order to represent it (e.g. messages with multiple attachments where the underlying network doesn’t support it), otherwiseTrue.
- class immp.hook.shell.AsyncShellHook(name, config, host)¶
Bases:
ResourceHookHook to launch an asynchonous console alongside a
Hostinstance.- buffer¶
Queue of recent messages, the length defined by the
bufferconfig entry.- Type:
- async start()¶
Perform any underlying operations needed to ready this resource for use, such as opening connections to an external network or API.
If using an event-driven framework that yields and runs in the background, you should use a signal of some form (e.g.
asyncio.Condition) to block this method until the framework is ready for use.
- async stop()¶
Perform any underlying operations needed to stop using this resource and tidy up, such as terminating open network connections.
Like with
start(), this should block as needed to wait for other frameworks – this method should return only when ready to be started again.
- async on_receive(sent, source, primary)¶
Handle an incoming message received by any plug.
- Parameters:
sent (.SentMessage) – Raw message received from another plug.
source (.Message) – Original message data used to generate the raw message, if sent via the plug (e.g. from another hook), equivalent to
msgif the source is otherwise unknown.primary (bool) –
Falsefor supplementary messages if the source message required multiple raw messages in order to represent it (e.g. messages with multiple attachments where the underlying network doesn’t support it), otherwiseTrue.