DefaultFindDispatcherStrategy

class DefaultFindDispatcherStrategy(dispatchers: List<StateDispatcher<out State>>, botUsername: String? = null) : FindDispatcherStrategy

Routes on the two things that can start a flow — a command and a callback — and on the conversation's current state for everything else.

That "everything else" is the load-bearing part, and it is why adding an Input type is not a change here. A photo, a document, a contact, a location or a type a bot declared itself all reach the dispatcher that owns the current state, which is what a wizard step wants: the step asked for something, and whatever arrived is the answer to it. Only a command and a callback carry routing information of their own, because only they can arrive with no state to belong to.

Parameters

botUsername

the bot's own @name, without the @. Telegram appends @botname to a command whenever more than one bot can see the chat, and that suffix is the only thing saying which bot was meant. Left null — the default, because telek cannot know the name on its own — a command addressed to any bot is handled, which is right in a private chat and in a group with one bot, and wrong in a group with two: this bot would answer commands meant for the other. Pass the name and a command addressed elsewhere stops being a command here; it reaches the current state's dispatcher as the ordinary message it is, rather than vanishing.

Constructors

Link copied to clipboard
constructor(dispatchers: List<StateDispatcher<out State>>, botUsername: String? = null)

Functions

Link copied to clipboard
open override fun findDispatcher(state: State?, input: Input? = null): StateDispatcher<out State>?