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