Documentation
¶
Index ¶
- Constants
- func LogFatal(err error, message string)
- func LogPrint(err error, message string)
- func LogPrintf(err error, message string, args ...interface{})
- type Activity
- type Category
- type Config
- type DBService
- type Database
- type HTTPService
- type Language
- type LogFormatter
- type Row
- type StatRow
- type State
- type Statistics
- type Update
- type User
Constants ¶
View Source
const ModePicking = "picking"
ModePicking constant for user "picking" mode
View Source
const ModeTyping = "typing"
ModeTyping constant for user "typing" mode
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Env string `json:"env"`
Database Database `json:"database"`
DefaultLanguage string `json:"default_language"`
}
Config ...
func ConfigFromEnv ¶
func ConfigFromEnv() *Config
ConfigFromEnv returns config based on environment variables
type DBService ¶
type DBService interface {
RandomQuestion(category string) (Row, error)
RandomAnswers(q Row, limit int) ([]Row, error)
SetState(State) error
GetState(string) (State, error)
ResetState(string) error
InsertWord(Row) error
InsertUser(user User) error
UpdateUser(user User) error
ExistUser(user User) (bool, error)
GetUser(userID string) (User, error)
SetUserMode(userID string, mode string) error
GetCategories(userID string) ([]Category, error)
SetUserCategory(userID string, category string) error
DeleteWordsByCategory(userID string, category string) error
InsertActivity(activity Activity) error
GetStatistics(userID string, year int, month int, week int, day int) (Statistics, error)
Close()
}
DBService ...
type Database ¶
type Database struct {
Host string `json:"host"`
Port string `json:"port"`
User string `json:"user"`
Name string `json:"name"`
Password string `json:"password"`
Delay int `json:"delay"`
}
Database ...
type HTTPService ¶
type HTTPService interface {
Send(update *Update, message string, keyboard string) error
Parse(r *http.Request) (*Update, error)
}
HTTPService represents interface for dealing with sending and parsing http requests
type Language ¶
Language represents collection of phrases by certain language used in application
func GetLanguage ¶
GetLanguage returns language object with phrases
type State ¶
type State struct {
UserKey string
Question Row
Answers []Row
Mode string
Category string
Timestamp int64
}
State represents last user state by saving question and answers in db. When user answers we get last state and compare text user send with state answer
type Statistics ¶
type Statistics struct {
Today StatRow `json:"today"`
Week StatRow `json:"week"`
Month StatRow `json:"month"`
}
Statistics represents group of periods.
Click to show internal directories.
Click to hide internal directories.