mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add mail functionality to replace twitch whispers
This commit is contained in:
parent
9825967182
commit
14162e006a
|
@ -81,6 +81,9 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
reply, _ = commands.Currency(cmdParams[1], cmdParams[2], cmdParams[4])
|
reply, _ = commands.Currency(cmdParams[1], cmdParams[2], cmdParams[4])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "mail":
|
||||||
|
app.SendEmail()
|
||||||
|
|
||||||
case "lastfm":
|
case "lastfm":
|
||||||
if msgLen == 1 {
|
if msgLen == 1 {
|
||||||
reply = app.UserCheckLastFM(message)
|
reply = app.UserCheckLastFM(message)
|
||||||
|
|
34
cmd/nourybot/email.go
Normal file
34
cmd/nourybot/email.go
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
"gopkg.in/gomail.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Thanks to Twitch moving whispers again I just use email now.
|
||||||
|
func (app *application) SendEmail() {
|
||||||
|
err := godotenv.Load()
|
||||||
|
if err != nil {
|
||||||
|
app.Log.Fatal("Error loading .env")
|
||||||
|
}
|
||||||
|
hostname := os.Getenv("EMAIL_HOST")
|
||||||
|
login := os.Getenv("EMAIL_LOGIN")
|
||||||
|
password := os.Getenv("EMAIL_PASS")
|
||||||
|
emailFrom := os.Getenv("EMAIL_FROM")
|
||||||
|
emailTo := os.Getenv("EMAIL_TO")
|
||||||
|
d := gomail.NewDialer(hostname, 587, login, password)
|
||||||
|
|
||||||
|
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
m := gomail.NewMessage()
|
||||||
|
m.SetHeader("From", emailFrom)
|
||||||
|
m.SetHeader("To", emailTo)
|
||||||
|
m.SetHeader("Subject", "Test Email!")
|
||||||
|
m.SetBody("text/plain", "Hello!")
|
||||||
|
|
||||||
|
if err := d.DialAndSend(m); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
2
go.mod
2
go.mod
|
@ -15,6 +15,8 @@ require (
|
||||||
require (
|
require (
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.uber.org/atomic v1.7.0 // indirect
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
go.uber.org/multierr v1.6.0 // indirect
|
||||||
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -47,4 +47,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||||
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||||
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
||||||
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|
Loading…
Reference in a new issue