Documentation ¶
Index ¶
- Constants
- func CallbackQueryHandler(reqenv *base.RequestEnv, query *tgbotapi.CallbackQuery, ...)
- func PopulateWizardDescriptors(handlers []base.MessageHandler) bool
- type Field
- type FieldDescriptor
- type FieldExtractor
- type FieldType
- type FieldValidator
- type Fields
- type File
- type Form
- func (form *Form) AddEmptyField(name string, fieldType FieldType)
- func (form *Form) AddPrefilledField(name string, value interface{})
- func (form *Form) DoAction(reqenv *base.RequestEnv, msg *tgbotapi.Message)
- func (form *Form) PopulateRestored(msg *tgbotapi.Message, storage StateStorage)
- func (form *Form) ProcessNextField(reqenv *base.RequestEnv, msg *tgbotapi.Message)
- type FormAction
- type FormDescriptor
- type InlineButtonCustomizer
- type RedisStateStorage
- type ReplyKeyboardBuilder
- type SkipCondition
- type SkipOnFieldValue
- type StateStorage
- type Wizard
- type WizardMessageHandler
Constants ¶
View Source
const ( InvalidFieldValueErrorTr = "wizard.errors.field.invalid.value" InvalidFieldValueTypeErrorTr = "wizard.errors.field.invalid.type" MissingStateErrorTr = "wizard.errors.state.missing" )
View Source
const (
CallbackDataFieldPrefix = "field" + callbackDataSep
)
View Source
const ValidErrNotInListTr = "errors.validation.option.not.in.list"
Variables ¶
This section is empty.
Functions ¶
func CallbackQueryHandler ¶ added in v0.2.0
func CallbackQueryHandler(reqenv *base.RequestEnv, query *tgbotapi.CallbackQuery, stateStorage StateStorage)
func PopulateWizardDescriptors ¶
func PopulateWizardDescriptors(handlers []base.MessageHandler) bool
Types ¶
type FieldDescriptor ¶
type FieldDescriptor struct { Validator FieldValidator SkipIf SkipCondition ReplyKeyboardBuilder ReplyKeyboardBuilder InlineKeyboardAnswers []string DisableKeyboardValidation bool // contains filtered or unexported fields }
func (*FieldDescriptor) InlineButtonCustomizer ¶ added in v0.2.2
func (descriptor *FieldDescriptor) InlineButtonCustomizer(option string, customizer InlineButtonCustomizer) bool
type FieldExtractor ¶
type Form ¶
type Form struct { Fields Fields `json:"fields"` Index int `json:"index"` WizardType string `json:"wizardType"` // contains filtered or unexported fields }
func (*Form) AddEmptyField ¶
func (*Form) AddPrefilledField ¶
func (*Form) PopulateRestored ¶
func (form *Form) PopulateRestored(msg *tgbotapi.Message, storage StateStorage)
func (*Form) ProcessNextField ¶
func (form *Form) ProcessNextField(reqenv *base.RequestEnv, msg *tgbotapi.Message)
type FormAction ¶
type FormAction func(reqenv *base.RequestEnv, msg *tgbotapi.Message, fields Fields)
type FormDescriptor ¶
type FormDescriptor struct {
// contains filtered or unexported fields
}
func NewWizardDescriptor ¶
func NewWizardDescriptor(action FormAction) *FormDescriptor
func (*FormDescriptor) AddField ¶
func (descriptor *FormDescriptor) AddField(name, promptDescriptionOrTrKey string) *FieldDescriptor
type InlineButtonCustomizer ¶ added in v0.2.2
type InlineButtonCustomizer func(btn *tgbotapi.InlineKeyboardButton, f *Field)
type RedisStateStorage ¶
type RedisStateStorage struct {
// contains filtered or unexported fields
}
func ConnectToRedis ¶
func ConnectToRedis(ctx context.Context, ttl time.Duration, options *redis.Options) RedisStateStorage
func (RedisStateStorage) Close ¶
func (rss RedisStateStorage) Close() error
func (RedisStateStorage) DeleteState ¶
func (rss RedisStateStorage) DeleteState(uid int64) error
func (RedisStateStorage) GetCurrentState ¶
func (rss RedisStateStorage) GetCurrentState(uid int64, dest Wizard) error
type ReplyKeyboardBuilder ¶ added in v0.2.2
type ReplyKeyboardBuilder func(reqenv *base.RequestEnv, msg *tgbotapi.Message) []string
type SkipCondition ¶
type SkipOnFieldValue ¶
func (SkipOnFieldValue) ShouldBeSkipped ¶
func (s SkipOnFieldValue) ShouldBeSkipped(form *Form) bool
type StateStorage ¶
type Wizard ¶
type Wizard interface { AddEmptyField(name string, fieldType FieldType) AddPrefilledField(name string, value interface{}) ProcessNextField(reqenv *base.RequestEnv, msg *tgbotapi.Message) DoAction(reqenv *base.RequestEnv, msg *tgbotapi.Message) PopulateRestored(msg *tgbotapi.Message, storage StateStorage) }
func NewWizard ¶
func NewWizard(handler WizardMessageHandler, fields int) Wizard
type WizardMessageHandler ¶
type WizardMessageHandler interface { base.MessageHandler GetWizardName() string GetWizardStateStorage() StateStorage GetWizardDescriptor() *FormDescriptor }
Click to show internal directories.
Click to hide internal directories.