Beispiel #1
0
// Get Returns template with gien name
func (u Utemplates) Get(templateName string) *UserTemplate {
	templ := &UserTemplate{}
	err := boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).Get(templateName, templ)
	if err != nil {
		log.Println("Can't load user template:", err)
		return nil
	}
	return templ
}
Beispiel #2
0
// GetAll Get all tamplates with their names
func (u Utemplates) GetAll() (map[string]UserTemplate, error) {
	templs := map[string]UserTemplate{}

	ut, err := boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).GetAll(&UserTemplate{})
	if err != nil {
		return templs, err
	}

	for k, v := range ut {
		templs[k] = *v.(*UserTemplate)
	}
	return templs, nil
}
Beispiel #3
0
//Delete Deletes template from db
func (u Utemplates) Delete(templateName string) {
	boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).Delete(templateName)
}
Beispiel #4
0
// Set Creates new or update entry for template
func (u Utemplates) Set(templateName string, templ UserTemplate) {
	boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).Set(templateName, templ)
}