mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
use twitch id instead of twitch username
This commit is contained in:
parent
bab41a15af
commit
9896d07dd7
|
@ -103,12 +103,14 @@ func (app *Application) SetUserLocation(message twitch.PrivateMessage) {
|
||||||
// handlers as the `location` part of the command.
|
// handlers as the `location` part of the command.
|
||||||
location := message.Message[snipLength:len(message.Message)]
|
location := message.Message[snipLength:len(message.Message)]
|
||||||
login := message.User.Name
|
login := message.User.Name
|
||||||
|
twitchId := message.User.ID
|
||||||
|
|
||||||
app.Logger.Infow("SetUserLocation",
|
app.Logger.Infow("SetUserLocation",
|
||||||
"location", location,
|
"location", location,
|
||||||
"login", login,
|
"login", login,
|
||||||
|
"twitchId", message.User.ID,
|
||||||
)
|
)
|
||||||
err := app.Models.Users.SetLocation(login, location)
|
err := app.Models.Users.SetLocation(twitchId, location)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), app.TwitchClient)
|
common.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), app.TwitchClient)
|
||||||
app.Logger.Error(err)
|
app.Logger.Error(err)
|
||||||
|
|
|
@ -53,13 +53,13 @@ func (u UserModel) Insert(login, twitchId string) error {
|
||||||
|
|
||||||
// SetLocation searches the database for a record with the provided login value
|
// SetLocation searches the database for a record with the provided login value
|
||||||
// and if that exists sets the location to the supplied
|
// and if that exists sets the location to the supplied
|
||||||
func (u UserModel) SetLocation(login, location string) error {
|
func (u UserModel) SetLocation(twitchId, location string) error {
|
||||||
query := `
|
query := `
|
||||||
UPDATE users
|
UPDATE users
|
||||||
SET location = $2
|
SET location = $2
|
||||||
WHERE login = $1`
|
WHERE twitchId = $1`
|
||||||
|
|
||||||
result, err := u.DB.Exec(query, login, location)
|
result, err := u.DB.Exec(query, twitchId, location)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue