Documentation ¶
Index ¶
- Constants
- Variables
- func MessageCommandInfo(c Command) (Text, Parse string)
- func MessageMissingContent() (Text, Parse string)
- func MessageMissingName() (Text, Parse string)
- func MessageSavedCommand(c Command) (Text, Parse string)
- type Answer
- type Command
- type Database
- func (db Database) Close()
- func (db Database) FindCommand(pack, name string, numParams int) (Command, error)
- func (db Database) FindPack(chat int64) (string, error)
- func (db Database) FindState(chat int64, user int) (State, error)
- func (db Database) RemoveState(chat int64, user int) error
- func (db Database) UpsertCommand(c Command) error
- func (db Database) UpsertState(s State) error
- type Pack
- type State
- type WaitingState
Constants ¶
View Source
const ( ParseMarkdown = "Markdown" ParseHTML = "HTML" )
Variables ¶
View Source
var (
ErrNotFound = errors.New("Not found")
)
Functions ¶
func MessageCommandInfo ¶
func MessageMissingContent ¶
func MessageMissingContent() (Text, Parse string)
func MessageMissingName ¶
func MessageMissingName() (Text, Parse string)
func MessageSavedCommand ¶
Types ¶
type Answer ¶
type Answer struct { Text string `bson:"text,omitempty"` NumParams int `bson:"numParams"` Parse string `bson:"parseMode,omitempty"` Sticker string `bson:"sticker,omitempty"` }
Answer holds the possible messages the bot can send
type Command ¶
type Command struct { Pack string `bson:"pack"` Name string `bson:"name"` Answer Answer `bson:"answer"` Time time.Time `bson:"time"` Creator string `bson:"creator,omitempty"` NumChanged int `bson:"numChanged,omitempty"` }
Command holds the data about for persistent commands
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database holds the necessary data for all persistent data operations
func NewDatabase ¶
NewDatabase returns a new database connected through the connURI
func (Database) FindCommand ¶
FindCommand returns the one command filtered by the pack, name and numParams, or an error if not found
func (Database) UpsertCommand ¶
UpsertCommand updates or inserts the given command
func (Database) UpsertState ¶
type State ¶
type State struct { Chat int64 `bson:"chat"` User int `bson:"user"` Waiting WaitingState `bson:"waiting,omitempty"` LastUpdate time.Time `bson:"lastUpdate"` }
func NewWaitingState ¶
func NewWaitingState(chat int64, user int, w WaitingState) State
type WaitingState ¶
Click to show internal directories.
Click to hide internal directories.