diff --git a/cmd/bot/commands.go b/cmd/bot/commands.go index 09cd72e..f5b7e13 100644 --- a/cmd/bot/commands.go +++ b/cmd/bot/commands.go @@ -154,7 +154,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) { } case "lastfm": if msgLen == 1 { - app.CheckLastFM(message) + app.UserCheckLastFM(message) return } else if cmdParams[1] == "artist" && cmdParams[2] == "top" { commands.LastFmArtistTop(target, message, app.TwitchClient) @@ -251,7 +251,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) { if msgLen == 1 { // Default to first argument supplied being the name // of the user to look up recently played. - app.CheckWeather(message) + app.UserCheckWeather(message) return } else if msgLen < 2 { common.Send(target, "Not enough arguments provided.", app.TwitchClient) diff --git a/cmd/bot/lastfm.go b/cmd/bot/lastfm.go deleted file mode 100644 index 8ff1e65..0000000 --- a/cmd/bot/lastfm.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "github.com/gempir/go-twitch-irc/v3" - "github.com/lyx0/nourybot/internal/commands" - "github.com/lyx0/nourybot/internal/common" - "go.uber.org/zap" -) - -func (app *Application) CheckLastFM(message twitch.PrivateMessage) { - sugar := zap.NewExample().Sugar() - defer sugar.Sync() - - twitchLogin := message.User.Name - sugar.Infow("Twitchlogin: ", - "twitchLogin:", twitchLogin, - ) - lastfmUser, err := app.Models.Users.GetLastFM(twitchLogin) - if err != nil { - sugar.Errorw("No LastFM account registered for: ", - "twitchLogin:", twitchLogin, - ) - reply := "No lastfm account registered in my database. Use ()register lastfm to register. (Not yet implemented) Otherwise use ()lastfm without registering." - common.Send(message.Channel, reply, app.TwitchClient) - return - } - - target := message.Channel - sugar.Infow("Twitchlogin: ", - "twitchLogin:", twitchLogin, - "user:", lastfmUser, - ) - - commands.LastFmUserRecent(target, lastfmUser, app.TwitchClient) -} - -//func (app *Application) SetLastFMUser(lastfmUser string, message twitch.PrivateMessage) { -// sugar := zap.NewExample().Sugar() -// defer sugar.Sync() -// -// user := &data.LastFMUser{ -// TwitchLogin: message.User.Name, -// TwitchID: message.User.ID, -// LastFMUser: lastfmUser, -// } -// sugar.Infow("User:: ", -// "user:", user, -// ) -// -// err := app.Models.LastFMUsers.Insert(user) -// if err != nil { -// if err != nil { -// reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err) -// common.Send(message.Channel, reply, app.TwitchClient) -// return -// } -// } else { -// reply := fmt.Sprintf("Successfully set your lastfm account as %v", lastfmUser) -// common.Send(message.Channel, reply, app.TwitchClient) -// return -// } -//} -// diff --git a/cmd/bot/user.go b/cmd/bot/user.go index 6fc9941..5477829 100644 --- a/cmd/bot/user.go +++ b/cmd/bot/user.go @@ -159,7 +159,7 @@ func (app *Application) GetUserLevel(login string) int { } } -func (app *Application) CheckWeather(message twitch.PrivateMessage) { +func (app *Application) UserCheckWeather(message twitch.PrivateMessage) { sugar := zap.NewExample().Sugar() defer sugar.Sync() @@ -185,3 +185,30 @@ func (app *Application) CheckWeather(message twitch.PrivateMessage) { commands.Weather(target, location, app.TwitchClient) } + +func (app *Application) UserCheckLastFM(message twitch.PrivateMessage) { + sugar := zap.NewExample().Sugar() + defer sugar.Sync() + + twitchLogin := message.User.Name + sugar.Infow("Twitchlogin: ", + "twitchLogin:", twitchLogin, + ) + lastfmUser, err := app.Models.Users.GetLastFM(twitchLogin) + if err != nil { + sugar.Errorw("No LastFM account registered for: ", + "twitchLogin:", twitchLogin, + ) + reply := "No lastfm account registered in my database. Use ()register lastfm to register. (Not yet implemented) Otherwise use ()lastfm without registering." + common.Send(message.Channel, reply, app.TwitchClient) + return + } + + target := message.Channel + sugar.Infow("Twitchlogin: ", + "twitchLogin:", twitchLogin, + "user:", lastfmUser, + ) + + commands.LastFmUserRecent(target, lastfmUser, app.TwitchClient) +}