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 TypeMethodDescriptiondefault List<ConfigField> Returns the configurable fields this script exposes.default ScriptUIgetUI()Returns a custom UI for this script, rendered in the Script UI panel.default voidonConfigUpdate(ScriptConfig config) Called when configuration is updated.intonLoop()Called repeatedly while the script is running.voidonStart(ManagementContext ctx) Called once when the script is started.voidonStop()Called once when the script is stopped.
-
Method Details
-
onStart
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
-1to stop
-
onStop
void onStop()Called once when the script is stopped. -
getConfigFields
Returns the configurable fields this script exposes. -
onConfigUpdate
Called when configuration is updated. -
getUI
Returns a custom UI for this script, rendered in the Script UI panel.
-