Botmation Documentation

Aborting

Aborting

AbortLine Signal

Sometimes it's necessary to abort an assembly line(s) of BotAction's. Perhaps something is removed from a web page or a condition wasn't met that subsequent BotAction's rely on. When this happens, a BotAction returns an AbortLineSignal.

type AbortLineSignal = {
brand: 'Abort_Signal',
assembledLines: number,
pipeValue?: PipeValue
}

AbortLine signals are safely created with the createAbortLineSignal() helper. It's a simple JSON object with potentially two to three properties.

Assembled Lines Count

An AbortLine signal's important property is called assembledLines. It informs the assembler how many lines of assembly to break. One is one line, two is two, three is three and so forth.

The default count of assembledLines is one for both the abort() BotAction and the createAbortLineSignal() helper. It can be any positive number, including zero.

Infinity AbortLine Signal

It's possible to abort all lines of assembly without knowing how many there are by returning an Infinity AbortLine signal.

Infinity AbortLine signals have assembledLines set to 0. When an assembler processes an Infinity AbortLine signal, it aborts what it's doing and returns the same signal without change.

Optional Pipe Value

AbortLineSignal has an optional param called pipeValue that carries a PipeValue back to the final aborted assembler for return.

The optional pipeValue param does not get returned by a Chain, when it's the final assembler to process an AbortLine signal.

Process AbortLine Signal

Almost every assembler processes an AbortLine signal with the processAbortLineSignal() helper. It supports all main use-cases of assembledLines: 0, 1, and 2+.

Here is a table for the default assemblers' aborting behavior:

assembledLineseffect
0Infinity AbortLine Signal aborts every BotAction and returns itself without change on each abort
1Default AbortLine Signal aborts only one line of assembled BotActions and returns the abortLineSignal.pipeValue
2+Level specific AbortLine Signal aborts one line of assembled BotActions at a time while reducing its assembledLines count to 1 for final abort

Each assembler will detect the value returned by the resolved BotAction for an AbortLine signal. If it is one, it processes it to the effect listed above.

This is the default aborting behavior. There are exceptions for some BotAction's such as the Loops, Branching, Switch Pipe, and Pipe Case(s), which implement their own unique aborting behavior.

Unique Aborting behavior

Switch Pipe implements its own AbortLine signal behavior in order to support its own unique functionality. When it hasn't received a CasesSignal with its condition passed, it ignores default AbortLine signals. That's because abort() is treated like break; from the traditional switch(){} code block, inside a Switch Pipe.

Some BotActions have unique AbortLine signal behavior for aborting parts of the unique assemblers. For example, a For All BotAction's loop iteration (runs an assembled line of BotActions) can abort out of its loop iteration with a default AbortLine signal or abort the entire loop with two or more assembledLines.

BotAction's with unique aborting behavior have their aborting functionality explained in their documentation, listed under API in the sidebar.

Edit this page on GitHub
Baby Bot