Auto-load certain symbols in REPL, add docs for REPL

This commit is contained in:
Salad Dais
2022-06-27 01:49:27 +00:00
parent d07a0df0fd
commit 03a56c9982
3 changed files with 18 additions and 0 deletions

View File

@@ -333,6 +333,13 @@ If you are a viewer developer, please put them in a viewer.
apply the mesh to the local mesh target. It works on attachments too. Useful for testing rigs before a
final, real upload.
## REPL
A quick and dirty REPL is also included for when you want to do ad-hoc introspection of proxy state.
It can be launched at any time by typing `/524 spawn_repl` in chat.
![Screenshot of REPL](https://github.com/SaladDais/Hippolyzer/blob/master/static/repl_screenshot.png?raw=true)
## Potential Changes
* AISv3 wrapper?

View File

@@ -58,6 +58,14 @@ class BaseInteractionManager:
return None
# Used to initialize a REPL environment with commonly desired helpers
REPL_INITIALIZER = r"""
from hippolyzer.lib.base.datatypes import *
from hippolyzer.lib.base.message.message import Block, Message, Direction
from hippolyzer.lib.proxy.addon_utils import send_chat, show_message
"""
class AddonManager:
COMMAND_CHANNEL = 524
@@ -133,6 +141,9 @@ class AddonManager:
if _locals is None:
_locals = stack.frame.f_locals
_globals = dict(_globals)
exec(REPL_INITIALIZER, _globals, None)
async def _wrapper():
coro: Coroutine = ptpython.repl.embed( # noqa: the type signature lies
globals=_globals,

BIN
static/repl_screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB