Documentation ¶
Index ¶
- func AskGenericMessageReplyWithValidation(ctx context.Context, conversation BotConversation, message tgbotapi.Chattable, ...) (*tgbotapi.Update, bool, error)
- func RequestUserContact(ctx context.Context, conversation BotConversation, message string, ...) (tgbotapi.Contact, bool, error)
- type BotConversation
- type BotUpdateValidator
- type CalendarMode
- type InputTextValidation
- type ListItem
- type UserImageAndDataReply
- type UserIndexDataReply
- type UserSelectedIndecesReply
- type UserSelectedListReply
- type UserTextAndDataReply
- func AskOnlyButtonReply(ctx context.Context, conversation BotConversation, message tgbotapi.Chattable, ...) (UserTextAndDataReply, error)
- func AskReplyEmail(ctx context.Context, conversation BotConversation, message string, ...) (UserTextAndDataReply, error)
- func AskTextMessageReplyWithValidation(ctx context.Context, conversation BotConversation, message string, ...) (UserTextAndDataReply, error)
- func ParseUserTextAndDataReply(update *tgbotapi.Update, exit bool) UserTextAndDataReply
- func ParseUserTextDataAndErrorReply(update *tgbotapi.Update, exit bool, err error) (UserTextAndDataReply, error)
- func ReadRawTextAndDataResult(ctx context.Context, conversation BotConversation) UserTextAndDataReply
- func SelectItemFromList(ctx context.Context, conversation BotConversation, text string, ...) (UserTextAndDataReply, error)
- type UserTimeAndDataReply
- func AskReplyCalendarDate(ctx context.Context, conversation BotConversation, text string, ...) (UserTimeAndDataReply, error)
- func AskReplyCalendarDateWithAvailability(ctx context.Context, conversation BotConversation, text string, ...) (UserTimeAndDataReply, error)
- func AskReplyCalendarDateWithAvailableList(ctx context.Context, conversation BotConversation, text string, ...) (UserTimeAndDataReply, error)
- func AskReplyCalendarDateWithUnavailableList(ctx context.Context, conversation BotConversation, text string, ...) (UserTimeAndDataReply, error)
- func AskReplyDate(ctx context.Context, conversation BotConversation, message string, ...) (UserTimeAndDataReply, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskGenericMessageReplyWithValidation ¶
func AskGenericMessageReplyWithValidation(ctx context.Context, conversation BotConversation, message tgbotapi.Chattable, bs buttons.ButtonSet, validator BotUpdateValidator, repeatOriginalOnIncorrect bool) (*tgbotapi.Update, bool, error)
AskGenericMessageReplyWithValidation continuously asks a user for reply until reply passes validation functor
Types ¶
type BotConversation ¶
type BotConversation interface { ChatID() int64 // get current chatID ConversationID() int64 // get conversation object ID GetUpdateFromUser(ctx context.Context) (*tgbotapi.Update, bool) // read update from a user (will hang until a user sends new mupdate, or conversation is closed) GetFile(fileID string) ([]byte, error) // get file from Telegram server GetFileInfo(fileID string) (tgbotapi.File, error) // get file info from Telegram server NewPhotoUpload(fileData []byte, caption string) tgbotapi.PhotoConfig // create a message with a Photo that uploads to the telegram an caption NewDocumentUpload(fileData []byte, caption string, filename string) tgbotapi.DocumentConfig // create a message with a Document that uploads to the telegram an caption NewMessage(text string) tgbotapi.MessageConfig // Create a new Text message with HTML parsing NewMessagef(text string, args ...interface{}) tgbotapi.MessageConfig // Create a new Text message with HTML parsing from text and parameters SendGeneralMessage(msg tgbotapi.Chattable) (int, error) // send general message to a user. This method is not safe, so use it as less as possible SendGeneralMessageWithKeyboardRemoveOnExit(msg tgbotapi.Chattable) (int, error) // send general message and ask conversation object to remove reply markup from this message in case of cancel event. the remove will be applied only to the latest message SendText(text string) (int, error) // send text with HTML parsing SendTextf(text string, args ...interface{}) (int, error) // send text and parameters with HTML parsing ReplyWithText(text string, messageID int) (int, error) // reply with text message to the existing message AnswerButton(callbackQueryID string) error // record answer to an inline button press DeleteMessage(messageID int) error // delete an existing message RemoveReplyMarkup(messageID int) error // remove reply markup from the existing message EditReplyMarkup(messageID int, markup tgbotapi.InlineKeyboardMarkup) error // replace reply markup in the existing message EditMessageText(messageID int, text string) error // replace text in the existing message EditMessageTextAndInlineMarkup(messageID int, text string, markup tgbotapi.InlineKeyboardMarkup) error // replace both text and reply markup in the existing message GlobalKeyboard() interface{} // get global keybard for the conversation user }
BotConversation implements interface for reading and writing messages from the bot side
type BotUpdateValidator ¶
BotUpdateValidator validates an update recieved from a user. If the update does not pass the criteria, the validator can return a string with the clarification
type InputTextValidation ¶
InputTextValidation is a type for function that validates messaged recieved from a user
type UserImageAndDataReply ¶
UserImageAndDataReply contains image input from a user
type UserIndexDataReply ¶ added in v0.16.4
UserIndexDataReply contains information about selected index (-1 if nothing selected)
func SelectIndexFromList ¶ added in v0.16.4
func SelectIndexFromList( ctx context.Context, conversation BotConversation, text string, items []string, pageSize int, navigation buttons.ButtonSet, prevPageText string, nextPageText string, filterText string, removeFilterText string) (UserIndexDataReply, error)
SelectIndexFromList asks a user to select one item from the list of strings and returns selected index
type UserSelectedIndecesReply ¶ added in v0.17.1
SelectItemFromList asks a user to select one or more items from the list of strings and returns indeces of selected items
func MultySelectIndecesFromList ¶ added in v0.17.1
func MultySelectIndecesFromList( ctx context.Context, conversation BotConversation, text string, items []string, selectedIndeces []int, pageSize int, selectedText string, removeSelectedText string, navigation buttons.ButtonSet, prevPageText string, nextPageText string, filterText string, removeFilterText string) (UserSelectedIndecesReply, error)
MultySelectIndecesFromList returns indeces of selected items from list.
type UserSelectedListReply ¶
UserSelectedListReply contains a list of user-selected items
func MultySelectItemFromList ¶
func MultySelectItemFromList( ctx context.Context, conversation BotConversation, text string, items []ListItem, selectedItems []ListItem, pageSize int, selectedText string, removeSelectedText string, navigation buttons.ButtonSet, prevPageText string, nextPageText string, filterText string, removeFilterText string) (UserSelectedListReply, error)
MultySelectItemFromList asks a user to select several items from the list
type UserTextAndDataReply ¶
type UserTextAndDataReply struct { MessageID int CallbackQueryID string Text string Data string Exit bool }
UserTextAndDataReply handles simplified information from the update
func AskOnlyButtonReply ¶
func AskOnlyButtonReply(ctx context.Context, conversation BotConversation, message tgbotapi.Chattable, bs buttons.ButtonSet, messageOnText string) (UserTextAndDataReply, error)
AskOnlyButtonReply sends message to a user and accepts only buttons
func AskReplyEmail ¶
func AskReplyEmail(ctx context.Context, conversation BotConversation, message string, bs buttons.ButtonSet, messageOnIncorrectInput string) (UserTextAndDataReply, error)
AskReplyEmail asks user to enter a vaid email address
func AskTextMessageReplyWithValidation ¶
func AskTextMessageReplyWithValidation(ctx context.Context, conversation BotConversation, message string, bs buttons.ButtonSet, validator InputTextValidation, messageOnIncorrect string) (UserTextAndDataReply, error)
AskTextMessageReplyWithValidation is a complex conversation that keep asking a question to user until they give information that pass the validation or press a button
func ParseUserTextAndDataReply ¶
func ParseUserTextAndDataReply(update *tgbotapi.Update, exit bool) UserTextAndDataReply
ParseUserTextAndDataReply parses text message and button data from the user's input
func ParseUserTextDataAndErrorReply ¶
func ParseUserTextDataAndErrorReply(update *tgbotapi.Update, exit bool, err error) (UserTextAndDataReply, error)
ParseUserTextDataAndErrorReply creates pair (UserTextAndDataReply, error) from triple (update *tgbotapi.Update, exit bool, err error)
func ReadRawTextAndDataResult ¶
func ReadRawTextAndDataResult(ctx context.Context, conversation BotConversation) UserTextAndDataReply
ReadRawTextAndDataResult waits for an update fro a user, and parses the update to UserTextAndDataReply struct
func SelectItemFromList ¶
func SelectItemFromList( ctx context.Context, conversation BotConversation, text string, items []ListItem, pageSize int, navigation buttons.ButtonSet, prevPageText string, nextPageText string, filterText string, removeFilterText string) (UserTextAndDataReply, error)
SelectItemFromList asks user to select an item from the list
type UserTimeAndDataReply ¶
type UserTimeAndDataReply struct { MessageID int CallbackQueryID string Time time.Time Data string Exit bool }
UserTimeAndDataReply handles user input a Time (or Date)
func AskReplyCalendarDate ¶
func AskReplyCalendarDate(ctx context.Context, conversation BotConversation, text string, minDate time.Time, maxDate time.Time, currentDate time.Time, calendarMode CalendarMode, navigation buttons.ButtonSet, months [12]string, weekDays [7]string, prevPageText string, nextPageText string, location *time.Location) (UserTimeAndDataReply, error)
func AskReplyCalendarDateWithAvailability ¶ added in v0.16.3
func AskReplyCalendarDateWithAvailability(ctx context.Context, conversation BotConversation, text string, minDate time.Time, maxDate time.Time, currentDate time.Time, calendarMode CalendarMode, navigation buttons.ButtonSet, months [12]string, weekDays [7]string, prevPageText string, nextPageText string, isDateAvailable func(day time.Time) bool, location *time.Location) (UserTimeAndDataReply, error)
AskReplyCalendarDateWithAvailability asks a user to select date between minDate and maxDate in calendar widget
func AskReplyCalendarDateWithAvailableList ¶ added in v0.16.3
func AskReplyCalendarDateWithAvailableList(ctx context.Context, conversation BotConversation, text string, minDate time.Time, maxDate time.Time, currentDate time.Time, calendarMode CalendarMode, navigation buttons.ButtonSet, months [12]string, weekDays [7]string, prevPageText string, nextPageText string, availableDates []time.Time, location *time.Location) (UserTimeAndDataReply, error)
func AskReplyCalendarDateWithUnavailableList ¶ added in v0.16.3
func AskReplyCalendarDateWithUnavailableList(ctx context.Context, conversation BotConversation, text string, minDate time.Time, maxDate time.Time, currentDate time.Time, calendarMode CalendarMode, navigation buttons.ButtonSet, months [12]string, weekDays [7]string, prevPageText string, nextPageText string, unavailableDates []time.Time, location *time.Location) (UserTimeAndDataReply, error)
func AskReplyDate ¶
func AskReplyDate(ctx context.Context, conversation BotConversation, message string, bs buttons.ButtonSet, messageOnIncorrectInput string, location *time.Location) (UserTimeAndDataReply, error)
AskReplyDate asks a user to enter date in format dd.mm.yyyy