mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
check if a user was registered in the database if no argument for lastfm command is provided
This commit is contained in:
parent
ea6fcbe416
commit
eb692020f7
|
@ -152,10 +152,9 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
||||||
commands.FirstLine(target, cmdParams[1], cmdParams[2], app.TwitchClient)
|
commands.FirstLine(target, cmdParams[1], cmdParams[2], app.TwitchClient)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case "lastfm":
|
case "lastfm":
|
||||||
if msgLen == 1 {
|
if msgLen == 1 {
|
||||||
common.Send(target, "Usage: ()firstline <channel> <user>", app.TwitchClient)
|
app.CheckLastFM(message)
|
||||||
return
|
return
|
||||||
} else if cmdParams[1] == "artist" && cmdParams[2] == "top" {
|
} else if cmdParams[1] == "artist" && cmdParams[2] == "top" {
|
||||||
commands.LastFmArtistTop(target, message, app.TwitchClient)
|
commands.LastFmArtistTop(target, message, app.TwitchClient)
|
||||||
|
@ -508,12 +507,11 @@ func (app *Application) commandHelp(target, name, username string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reply := fmt.Sprintf(c)
|
reply := fmt.Sprint(c)
|
||||||
common.Send(target, reply, app.TwitchClient)
|
common.Send(target, reply, app.TwitchClient)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reply := fmt.Sprintf("%s", i)
|
reply := fmt.Sprint(i)
|
||||||
common.Send(target, reply, app.TwitchClient)
|
common.Send(target, reply, app.TwitchClient)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
36
cmd/bot/lastfm.go
Normal file
36
cmd/bot/lastfm.go
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
u, err := app.Models.LastFMUsers.Get(twitchLogin)
|
||||||
|
if err != nil {
|
||||||
|
sugar.Errorw("No LastFM account registered for: ",
|
||||||
|
"twitchLogin:", twitchLogin,
|
||||||
|
)
|
||||||
|
reply := "No lastfm account registered in my database. Use ()register lastfm <username> to register. (Not yet implemented) Otherwise use ()lastfm <username> without registering."
|
||||||
|
common.Send(message.Channel, reply, app.TwitchClient)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
target := message.Channel
|
||||||
|
user := u.LastFMUser
|
||||||
|
sugar.Infow("Twitchlogin: ",
|
||||||
|
"twitchLogin:", twitchLogin,
|
||||||
|
"user:", user,
|
||||||
|
)
|
||||||
|
|
||||||
|
commands.LastFmUserRecent(target, user, app.TwitchClient)
|
||||||
|
}
|
Loading…
Reference in a new issue