Commit 5dac3729 authored by Mike Jones's avatar Mike Jones 🌶

Let people other than me set/unset their Last.fm username

parent 394ef84d
......@@ -7,7 +7,7 @@ import (
"github.com/n7st/lastfm-go/lastfm"
)
func (f *Fn) ArtistInfo(artist string) string {
func (f *Fn) ArtistInfo(artist string, nickname string) string {
artistInfo, err := f.getArtistInfo(artist)
if err != nil {
......@@ -19,7 +19,7 @@ func (f *Fn) ArtistInfo(artist string) string {
// returns a comma separated list of tags, e.g.:
// death metal, old school death metal, danish, breakbeat, seen live
func (f *Fn) GetArtistTags(artist string) string {
func (f *Fn) GetArtistTags(artist string, nickname string) string {
var tags = "no tags"
res, err := f.getArtistInfo(artist)
......
......@@ -12,7 +12,7 @@ import (
type (
FnCommand func(message string, username string) string
OpenFnCommand func(message string) string
OpenFnCommand func(message string, nickname string) string
)
type Fn struct {
......
......@@ -14,18 +14,22 @@ const (
noTopArtistsForPeriodF = "%s has no listening data for this period"
)
func (f *Fn) SetUser(message string) string {
func (f *Fn) SetUser(message string, nickname string) string {
var err error
if message == "" {
err = f.Store.RemoveAssociatedUser("Mike")
err = f.Store.RemoveAssociatedUser(nickname)
if err != nil {
return fmtError(err)
}
return "Last.fm username unset"
}
args := strings.Split(message, " ")
err = f.Store.SetAssociatedUser("Mike", args[0])
err = f.Store.SetAssociatedUser(nickname, args[0])
if err != nil {
return fmtError(err)
......
......@@ -69,7 +69,7 @@ func Run(nickname string, message string, db *store.BoltStore) string {
openFnCommand := openCommands[arguments[0]]
if openFnCommand != nil {
return openFnCommand(strings.Join(arguments[1:], " "))
return openFnCommand(strings.Join(arguments[1:], " "), nickname)
}
return ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment