all repos — paprika @ lastfm

go rewrite of taigabot

plugins/listenbrainz/db.go (view raw)

 1package listenbrainz
 2
 3import (
 4	"fmt"
 5
 6	"git.icyphox.sh/paprika/database"
 7)
 8
 9// Store the Listenbrainz username against the nick.
10func Setup(lbzUser, nick string) error {
11	err := database.DB.Set(
12		[]byte(fmt.Sprintf("lbz/%s", nick)),
13		[]byte(lbzUser),
14	)
15	return err
16}
17
18// Gets the Listenbrainz username from the DB.
19func GetUser(nick string) (string, error) {
20	nick = fmt.Sprintf("lbz/%s", nick)
21	user, err := database.DB.Get([]byte(nick))
22	if err != nil {
23		return "", err
24	}
25	return string(user), nil
26}