tock / ai.tock.bot.definition / StoryDataStepBase

StoryDataStepBase

abstract class StoryDataStepBase<T : StoryHandlerDefinition, TD, D> : StoryDataStep<T, TD, D> (source)

Base class for StoryDataStep implementations.

Parameters

T - the StoryDef

TD - the StoryDef data

D - the step data

Constructors

<init>

Base class for StoryDataStep implementations.

StoryDataStepBase(select: TD.(T) -> Boolean = { false }, setup: T.(TD) -> D = { @Suppress("UNCHECKED_CAST") EmptyData as D }, reply: T.(D) -> Any?)

Properties

name

The name of the step.

open val name: String

Functions

checkPreconditions

Checks preconditions - if BotBus.end is called, StoryHandlerDefinition.handle is not called and the handling of bot answer is over. Returned data is used in subsequent call of handler if not null

fun checkPreconditions(): T.(TD?) -> D?

execute

fun execute(storyDef: T, configuration: TD): Any?

handler

The custom handler for this step. When returning a null value, it means that the step is not able to answer to the current request.

fun handler(): T.(D?) -> Any?

reply

fun reply(): T.(D) -> Any?

select

fun select(): TD.(T) -> Boolean

selectFromBusAndData

Does this Step has to be selected from the Bus? This method is called if StoryHandlerBase.checkPreconditions does not call BotBus.end. If this functions returns true, the step is selected and remaining steps are not tested.

fun selectFromBusAndData(): T.(TD?) -> Boolean

setup

fun setup(): T.(TD) -> D