Interface ManagementScript


public interface ManagementScript
Service Provider Interface for independent management scripts.

Management scripts are not tied to any single client. They run independently and coordinate across clients using the ClientOrchestrator and ClientProvider.

Use these for orchestration tasks such as:

  • Starting/stopping scripts across groups of clients
  • Monitoring and reacting to cross-client state
  • Rotating scripts based on schedules or conditions
  • Coordinating multi-account workflows

Implementations are discovered at runtime via ServiceLoader. Each script JAR must declare provides com.botwithus.bot.api.script.ManagementScript with <ClassName> in its module-info.java.

Annotate implementations with ScriptManifest to declare metadata.

Quick start

@ScriptManifest(name = "GroupRotator", version = "1.0",
        description = "Rotates scripts across client groups")
public class GroupRotator implements ManagementScript {

    private ClientOrchestrator orchestrator;

    @Override
    public void onStart(ManagementContext ctx) {
        orchestrator = ctx.getOrchestrator();
        orchestrator.createGroup("skillers", "Skilling accounts");
    }

    @Override
    public int onLoop() {
        orchestrator.startScriptOnGroup("skillers", "Woodcutter");
        return 60_000; // check every minute
    }

    @Override
    public void onStop() {
        orchestrator.stopAllScriptsOnAll();
    }
}
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default List<ConfigField>
    Returns the configurable fields this script exposes.
    default ScriptUI
    Returns a custom UI for this script, rendered in the Script UI panel.
    default void
    Called when configuration is updated.
    int
    Called repeatedly while the script is running.
    void
    Called once when the script is started.
    void
    Called once when the script is stopped.
  • Method Details

    • onStart

      void onStart(ManagementContext ctx)
      Called once when the script is started.
      Parameters:
      ctx - the management context providing cross-client access
    • onLoop

      int onLoop()
      Called repeatedly while the script is running.
      Returns:
      delay in milliseconds before the next loop, or -1 to stop
    • onStop

      void onStop()
      Called once when the script is stopped.
    • getConfigFields

      default List<ConfigField> getConfigFields()
      Returns the configurable fields this script exposes.
    • onConfigUpdate

      default void onConfigUpdate(ScriptConfig config)
      Called when configuration is updated.
    • getUI

      default ScriptUI getUI()
      Returns a custom UI for this script, rendered in the Script UI panel.