Lauriethefish / ModsBeforeFriday

Beat Saber Mods Before Friday
GNU Affero General Public License v3.0
90 stars 16 forks source link

MBF Agent Wrapper for CLI Usage #35

Closed AdalynBlack closed 2 months ago

AdalynBlack commented 2 months ago

A simple python script to easily interface with the MBF Agent directly, as an alternative to the web interface

screenshot-2024-09-02-01-47-11 screenshot-2024-09-02-01-48-07

While it may be a bit overly verbose at times, everything possible in the web interface should be possible with it. All dependencies are internal python packages, so no external packages are required

Lauriethefish commented 2 months ago

This definitely looks like a great start for a backend wrapper!

Before I merge, I will need to reference the wrapper in the main README and perhaps add a README in the wrapper folder just to explain what it's good for.

The implementation for checking the agent hash seems satisfactory - MBF does store the SHA1 of the agent server side in agent_manifest.ts but because the typescript is compiled and then minimized, this is very difficult to extract. It might make sense to serve a JSON file containing this information so it can be easily fetched, but right now the current implementation is OK.

Lauriethefish commented 2 months ago

Another thing it might be worth noting, although there isn't much you can do about it. The Core Mod property for mods is only set if the request that you're making actually involves the core mod index, so e.g. GetModStatus.

If you're setting mod statuses, this doesn't inherently require information about core mods so the backend won't set the property as it never needs to fetch the index for anything else.

Maybe possible to "fix" by not displaying the Core Mod property if it's false for all mods, but don't worry too much about it.

Lauriethefish commented 2 months ago

For the future, it's a little annoying to PR from your main branch to the main main branch - it's always best to create a different branch e.g. agent-wrapper, but don't worry about it this time around.

Lauriethefish commented 2 months ago

Another note: Right now running the python script with no arguments gives an error/backtrace instead of showing the help message, which probably makes more sense.

In interactive mode, keyboard interrupts could be gracefully handled but this is low priority.