diff --git a/README.md b/README.md index 54f8429..a42286e 100644 --- a/README.md +++ b/README.md @@ -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? diff --git a/hippolyzer/lib/proxy/addons.py b/hippolyzer/lib/proxy/addons.py index eff63fe..f090343 100644 --- a/hippolyzer/lib/proxy/addons.py +++ b/hippolyzer/lib/proxy/addons.py @@ -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, diff --git a/static/repl_screenshot.png b/static/repl_screenshot.png new file mode 100644 index 0000000..9448186 Binary files /dev/null and b/static/repl_screenshot.png differ