Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotState ¶
type BotState interface { RemoveConverastionState(conversationID int64) error // removes record about a current conversation. Should be called after a high-level handler is done LoadState() error // Load state from a file Close() error // Forbid furter savings GetConversationIDs() []int64 // get list of conversationsIDs, if several IDs have the same ChatID, only the latest conversationID will be listed GetConversatonFirstUpdate(conversationID int64) *tgbotapi.Update // get first update of the conversation GetConversationStepAndData(conversationID int64) (int, interface{}) // get data and state of the conversation GetConversationChatID(conversationID int64) int64 // get ChatID of the conversation StartConversationWithUpdate(conversationID int64, chatID int64, firstUpdate *tgbotapi.Update) error // create state for a conversation with first update SaveConversationStepAndData(conversationID int64, step int, data interface{}) error // save new conversation step and data, save all states to a file }
BotState is an interface for object that records current state of all ongoing conversations
func NewBotState ¶
NewBotState method constructs a new BotState object
type ConversationState ¶
type ConversationState struct { FirstUpdate *tgbotapi.Update `json:"first_update"` // initial message for a handler Step int `json:"step"` // the index of the stap that should be processed Data interface{} `json:"data"` // user-data ChatID int64 `json:"chat_id"` // chat_id of the conversation }
ConversationState reflects the current state of a conversation handler with "step" granularity. The exact handler should be deduced from the firstMessage
Click to show internal directories.
Click to hide internal directories.