tock / ai.tock.bot.definition / StoryHandlerBase

StoryHandlerBase

abstract class StoryHandlerBase<out T : StoryHandlerDefinition> : StoryHandler, I18nKeyProvider, IntentAware (source)

Base implementation of StoryHandler. Provides also a convenient implementation of I18nKeyProvider to support i18n.

Constructors

<init>

Base implementation of StoryHandler. Provides also a convenient implementation of I18nKeyProvider to support i18n.

StoryHandlerBase(mainIntentName: String? = null, i18nNamespace: String = defaultNamespace, breath: Long = defaultBreath)

Properties

breath

Convenient value to wait before next answer sentence.

val breath: Long

Functions

checkPreconditions

Checks preconditions - if BotBus.end is called, StoryHandlerDefinition.handle is not called and the handling of bot answer is over.

open fun checkPreconditions(): BotBus.() -> Any?

findStoryDefinition

Finds the story definition of this handler.

open fun findStoryDefinition(bus: BotBus): StoryDefinition?

handle

Receive a message from the bus.

fun handle(bus: BotBus): Unit

handleAndSwitchStory

Handles the action and switches the context to the underlying story definition.

fun handleAndSwitchStory(bus: BotBus): Unit

i18n

open fun i18n(defaultLabel: CharSequence, args: List<Any?>): I18nLabelValue

i18nKey

Gets an i18n label with the specified key. Current namespace is used for the categorization.

fun i18nKey(key: String, defaultLabel: CharSequence, vararg args: Any?): I18nLabelValue

newHandlerDefinition

Instantiates new instance of T.

abstract fun newHandlerDefinition(bus: BotBus, data: Any? = null): T

selectStepFromStoryHandlerAndData

Selects step from HandlerDef, optional data and StoryDefinition.

fun <T : StoryHandlerDefinition> selectStepFromStoryHandlerAndData(def: T, data: Any?, storyDefinition: StoryDefinition?): StoryStep<*>?

support

What is the probability of bot support for the current request?

open fun support(bus: BotBus): Double

wrappedIntent

open fun wrappedIntent(): Intent

Inheritors

ConfigurableStoryHandler

A story handler that can be fully configured. Advanced usage only.

open class ConfigurableStoryHandler<out T : StoryHandlerDefinition> : StoryHandlerBase<T>

SimpleStoryHandlerBase

For simple stories that do not use custom StoryHandlerDefinition.

abstract class SimpleStoryHandlerBase : StoryHandlerBase<StoryHandlerDefinition>