mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
switch from twitch usernames to twitch userid
This commit is contained in:
parent
8a7057f2d4
commit
777329897a
|
@ -43,7 +43,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
// 500 = mod
|
||||
// 250 = vip
|
||||
// 100 = normal
|
||||
// If the level returned is 0 then the user was not found in the database.
|
||||
// If the level returned is -1 then the user was not found in the database.
|
||||
userLevel := app.GetUserLevel(message.User.ID)
|
||||
|
||||
app.Logger.Infow("Command received",
|
||||
|
|
|
@ -158,13 +158,16 @@ func (app *Application) UserCheckWeather(message twitch.PrivateMessage) {
|
|||
defer sugar.Sync()
|
||||
|
||||
twitchLogin := message.User.Name
|
||||
sugar.Infow("Twitchlogin: ",
|
||||
twitchId := message.User.ID
|
||||
sugar.Infow("UserCheckWeather: ",
|
||||
"twitchLogin:", twitchLogin,
|
||||
"twitchId:", twitchId,
|
||||
)
|
||||
location, err := app.Models.Users.GetLocation(twitchLogin)
|
||||
location, err := app.Models.Users.GetLocation(twitchId)
|
||||
if err != nil {
|
||||
sugar.Errorw("No LastFM account registered for: ",
|
||||
sugar.Errorw("No location data registered for: ",
|
||||
"twitchLogin:", twitchLogin,
|
||||
"twitchId:", twitchId,
|
||||
)
|
||||
reply := "No location for your account set in my database. Use ()set location <location> to register. Otherwise use ()weather <location> without registering."
|
||||
common.Send(message.Channel, reply, app.TwitchClient)
|
||||
|
|
|
@ -80,15 +80,15 @@ func (u UserModel) SetLocation(login, location string) error {
|
|||
|
||||
// SetLocation searches the database for a record with the provided login value
|
||||
// and if that exists sets the location to the supplied
|
||||
func (u UserModel) GetLocation(login string) (string, error) {
|
||||
func (u UserModel) GetLocation(twitchId string) (string, error) {
|
||||
query := `
|
||||
SELECT location
|
||||
FROM users
|
||||
WHERE login = $1`
|
||||
WHERE twitchid = $1`
|
||||
|
||||
var user User
|
||||
|
||||
err := u.DB.QueryRow(query, login).Scan(
|
||||
err := u.DB.QueryRow(query, twitchId).Scan(
|
||||
&user.Location,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue