Documentation ¶
Overview ¶
Package factoids implemets a simple factoid get/set system for the bot
Index ¶
- Constants
- Variables
- func Delete(key, substr string) error
- func Lastfact() fullfactoid
- func List(start string) (string, error)
- func Lookup(ctx context.Context, nick, msg string) (string, bool)
- func NewReplyString(ctx *context.Context, msg string) string
- func RandomKey() string
- func SaveToFile(filename string, c Config) error
- func Search(rex string, maxresults int) ([]string, error)
- func Store(msg string, from string) string
- type Config
- type FactoidSet
Constants ¶
View Source
const ( DefaultConfFile = "conf/factoids.yml" DefaultDBPath = "db/factoids.yml" )
Variables ¶
View Source
var ErrAmbiguousKey = errors.New("ambiguous key")
View Source
var ErrFactAlreadyExists = errors.New("fact already exists")
View Source
var ErrInvalidUTF8 = errors.New("invalid UTF-8")
View Source
var ErrNoSuchFact = errors.New("factoid not found")
Functions ¶
func Delete ¶
Delete removes a value from a key matching substring `substr`. If more than one match, return error
func Lookup ¶
Lookup returns a string to output to the channel, and a bool indicating if it's an action ('/me blabla'). Nick is the nickname of the asker.
func NewReplyString ¶
NewReplyString adds a custom reply string to the list of reply strings TODO: generalize config file read/write/parse TODO: switch to toml for config
func SaveToFile ¶
Types ¶
type Config ¶
type Config struct { DatabaseFile string `yaml:"database"` ReplyStrings helpers.StringSlice `yaml:"replystrings"` }
func FromContext ¶
func ParseConfFile ¶
ParseConfFile parses configuration in `filename` and returns a configuration and an error
type FactoidSet ¶
type FactoidSet map[string]factoid
func NewFactoidSet ¶
func NewFactoidSet(values ...factoid) FactoidSet
func (FactoidSet) Add ¶
func (f FactoidSet) Add(values ...factoid)
func (FactoidSet) Delete ¶
func (f FactoidSet) Delete(val string)
Remove removes a value from the set.
func (FactoidSet) Exists ¶
func (f FactoidSet) Exists(value factoid) bool
func (FactoidSet) Random ¶
func (f FactoidSet) Random() factoid
func (FactoidSet) Slice ¶
func (f FactoidSet) Slice() []factoid
Slice returns the values of the set as a slice.
func (FactoidSet) StringSlice ¶
func (f FactoidSet) StringSlice() []string
Slice returns the values of the set as a slice.
Click to show internal directories.
Click to hide internal directories.