mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add debug user command that sends user information to my email
This commit is contained in:
parent
14162e006a
commit
dabbce14fe
|
@ -82,7 +82,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
|||
}
|
||||
|
||||
case "mail":
|
||||
app.SendEmail()
|
||||
app.SendEmail("Test command used!", "This is an email test")
|
||||
|
||||
case "lastfm":
|
||||
if msgLen == 1 {
|
||||
|
@ -136,6 +136,12 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
|||
app.DeleteTimer(cmdParams[2], message)
|
||||
}
|
||||
|
||||
case "debug":
|
||||
switch cmdParams[1] {
|
||||
case "user":
|
||||
app.DebugUser(cmdParams[2], message)
|
||||
}
|
||||
|
||||
case "command":
|
||||
switch cmdParams[1] {
|
||||
case "add":
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
// Thanks to Twitch moving whispers again I just use email now.
|
||||
func (app *application) SendEmail() {
|
||||
func (app *application) SendEmail(subject, body string) {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
app.Log.Fatal("Error loading .env")
|
||||
|
@ -25,8 +25,8 @@ func (app *application) SendEmail() {
|
|||
m := gomail.NewMessage()
|
||||
m.SetHeader("From", emailFrom)
|
||||
m.SetHeader("To", emailTo)
|
||||
m.SetHeader("Subject", "Test Email!")
|
||||
m.SetBody("text/plain", "Hello!")
|
||||
m.SetHeader("Subject", subject)
|
||||
m.SetBody("text/plain", body)
|
||||
|
||||
if err := d.DialAndSend(m); err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -30,9 +30,10 @@ func (app *application) DebugUser(login string, message twitch.PrivateMessage) {
|
|||
app.Send(message.Channel, reply)
|
||||
return
|
||||
} else {
|
||||
reply := fmt.Sprintf("User %v: ID %v, Login: %s, TwitchID: %v, Level: %v", login, user.ID, user.Login, user.TwitchID, user.Level)
|
||||
app.Send(message.Channel, reply)
|
||||
//app.TwitchClient.Whisper(message.User.Name, reply)
|
||||
subject := fmt.Sprintf("DEBUG for %v", login)
|
||||
body := fmt.Sprintf("DEBUG information for user %v\n\nid=%v \nlogin=%v \nlevel=%v \nlocation=%v \nlastfm=%v", login, user.TwitchID, user.Login, user.Level, user.Location, user.LastFMUsername)
|
||||
|
||||
app.SendEmail(subject, body)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ func (u UserModel) SetLevel(login string, level int) error {
|
|||
// Get searches the database for a login name and returns the user struct on success.
|
||||
func (u UserModel) Get(login string) (*User, error) {
|
||||
query := `
|
||||
SELECT id, added_at, login, twitchid, level, location
|
||||
SELECT id, added_at, login, twitchid, level, location, lastfm_username
|
||||
FROM users
|
||||
WHERE login = $1`
|
||||
|
||||
|
@ -227,6 +227,7 @@ func (u UserModel) Get(login string) (*User, error) {
|
|||
&user.TwitchID,
|
||||
&user.Level,
|
||||
&user.Location,
|
||||
&user.LastFMUsername,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue