Documentation ¶
Index ¶
- Variables
- func GetItemMessageText(item db.DictionaryItem) string
- func GetQuizMessageText(quiz db.Quiz) (string, error)
- type Bot
- type Handler
- type ListSettingsHandler
- type QuizHandler
- type QuizReplyHandler
- type SendQuizTypesHandler
- type SetQuizTypesHandler
- type StartHandler
- type TelegramBot
- type WordHandler
Constants ¶
This section is empty.
Variables ¶
var ErrNotEnoughWords = errors.New("not enough words")
ErrNotEnoughWords is returned when there are not enough words in dictionary
Functions ¶
func GetItemMessageText ¶
func GetItemMessageText(item db.DictionaryItem) string
GetItemMessageText executes template with dictionary item data
Types ¶
type Bot ¶
type Bot interface { Send(tgbotapi.Chattable) (tgbotapi.Message, error) SendCallback(tgbotapi.CallbackConfig) (*tgbotapi.APIResponse, error) DB() db.Storage }
Bot describes bot for handlers
type Handler ¶
type Handler interface { Handle(ctx context.Context, b Bot, u tgbotapi.Update) Passthrough(tgbotapi.Update) bool Match(u tgbotapi.Update) bool }
Handler describes a handler for a single update
type ListSettingsHandler ¶
type ListSettingsHandler struct {
// contains filtered or unexported fields
}
ListSettingsHandler handles /settings command
func (ListSettingsHandler) Match ¶
func (h ListSettingsHandler) Match(u tgbotapi.Update) bool
Match returns true if update is /settings command
func (ListSettingsHandler) Passthrough ¶
Passthrough always returns false
type QuizHandler ¶
type QuizHandler struct {
// contains filtered or unexported fields
}
QuizHandler handles quiz command
func (QuizHandler) Match ¶
func (h QuizHandler) Match(u tgbotapi.Update) bool
Match returns true if update is /quiz command
func (QuizHandler) Passthrough ¶
Passthrough always returns false
type QuizReplyHandler ¶
type QuizReplyHandler struct {
// contains filtered or unexported fields
}
QuizReplyHandler handles quiz reply callback
func (QuizReplyHandler) Match ¶
func (h QuizReplyHandler) Match(u tgbotapi.Update) bool
Match returns true if update is quiz reply callback
func (QuizReplyHandler) Passthrough ¶
Passthrough always returns false
type SendQuizTypesHandler ¶
type SendQuizTypesHandler struct {
// contains filtered or unexported fields
}
SendQuizTypesHandler sends available quiz types
func (SendQuizTypesHandler) Match ¶
func (h SendQuizTypesHandler) Match(u tgbotapi.Update) bool
Match returns true if update is quiz settings callback
func (SendQuizTypesHandler) Passthrough ¶
Passthrough always returns false
type SetQuizTypesHandler ¶
type SetQuizTypesHandler struct {
// contains filtered or unexported fields
}
SetQuizTypesHandler saves quiz type to user config
func (SetQuizTypesHandler) Match ¶
func (h SetQuizTypesHandler) Match(u tgbotapi.Update) bool
Match returns true if update is quiz settings callback with picked type
func (SetQuizTypesHandler) Passthrough ¶
Passthrough always returns false
type StartHandler ¶
type StartHandler struct {
// contains filtered or unexported fields
}
StartHandler is a handler for /start command
func (StartHandler) Match ¶
func (h StartHandler) Match(u tgbotapi.Update) bool
Match returns true if update is /start command
func (StartHandler) Passthrough ¶
Passthrough always returns false
type TelegramBot ¶
type TelegramBot struct { UserName string // contains filtered or unexported fields }
TelegramBot handles Telegram API intragration and updates handling
func NewTelegramBot ¶
NewTelegramBot creates a TelegramBot
func (*TelegramBot) SendCallback ¶
func (b *TelegramBot) SendCallback(c tgbotapi.CallbackConfig) (*tgbotapi.APIResponse, error)
SendCallback sends a callback query response
type WordHandler ¶
type WordHandler struct {
// contains filtered or unexported fields
}
WordHandler handles word requests
func NewWordHandler ¶
func NewWordHandler(tranlationsToken string) WordHandler
NewWordHandler creates new word handler
func (WordHandler) Match ¶
func (h WordHandler) Match(u tgbotapi.Update) bool
Match returns true if message is a text
func (WordHandler) Passthrough ¶
Passthrough always returns false