mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
additionally add message context to each logged sent_message_logs in the database
This commit is contained in:
parent
8744951554
commit
801853cdb3
|
@ -40,11 +40,11 @@ func (app *application) AddCommand(name string, message twitch.PrivateMessage) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err)
|
reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Successfully added command: %s", name)
|
reply := fmt.Sprintf("Successfully added command: %s", name)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,19 +126,19 @@ func (app *application) EditCommandLevel(name, lvl string, message twitch.Privat
|
||||||
level, err := strconv.Atoi(lvl)
|
level, err := strconv.Atoi(lvl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrCommandLevelNotInteger))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrCommandLevelNotInteger), message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Models.Commands.SetLevel(name, level)
|
err = app.Models.Commands.SetLevel(name, level)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Updated command %s to level %v", name, level)
|
reply := fmt.Sprintf("Updated command %s to level %v", name, level)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,12 +149,12 @@ func (app *application) EditCommandCategory(name, category string, message twitc
|
||||||
err := app.Models.Commands.SetCategory(name, category)
|
err := app.Models.Commands.SetCategory(name, category)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Updated command %s to category %v", name, category)
|
reply := fmt.Sprintf("Updated command %s to category %v", name, category)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ func (app *application) DebugCommand(name string, message twitch.PrivateMessage)
|
||||||
cmd, err := app.Models.Commands.Get(name)
|
cmd, err := app.Models.Commands.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err)
|
reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("id=%v\nname=%v\nlevel=%v\ncategory=%v\ntext=%v\nhelp=%v\n",
|
reply := fmt.Sprintf("id=%v\nname=%v\nlevel=%v\ncategory=%v\ntext=%v\nhelp=%v\n",
|
||||||
|
@ -182,10 +182,10 @@ func (app *application) DebugCommand(name string, message twitch.PrivateMessage)
|
||||||
resp, err := app.uploadPaste(reply)
|
resp, err := app.uploadPaste(reply)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln("Could not upload paste:", err)
|
app.Log.Errorln("Could not upload paste:", err)
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload), message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Send(message.Channel, resp)
|
app.Send(message.Channel, resp, message)
|
||||||
//app.SendEmail(fmt.Sprintf("DEBUG for command %s", name), reply)
|
//app.SendEmail(fmt.Sprintf("DEBUG for command %s", name), reply)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -213,12 +213,12 @@ func (app *application) EditCommandHelp(name string, message twitch.PrivateMessa
|
||||||
err := app.Models.Commands.SetHelp(name, text)
|
err := app.Models.Commands.SetHelp(name, text)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Updated help text for command %s to: %v", name, text)
|
reply := fmt.Sprintf("Updated help text for command %s to: %v", name, text)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,13 +227,13 @@ func (app *application) EditCommandHelp(name string, message twitch.PrivateMessa
|
||||||
func (app *application) DeleteCommand(name string, message twitch.PrivateMessage) {
|
func (app *application) DeleteCommand(name string, message twitch.PrivateMessage) {
|
||||||
err := app.Models.Commands.Delete(name)
|
err := app.Models.Commands.Delete(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, "Something went wrong FeelsBadMan")
|
app.Send(message.Channel, "Something went wrong FeelsBadMan", message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reply := fmt.Sprintf("Deleted command %s", name)
|
reply := fmt.Sprintf("Deleted command %s", name)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) LogCommand(msg twitch.PrivateMessage, commandName string, userLevel int) {
|
func (app *application) LogCommand(msg twitch.PrivateMessage, commandName string, userLevel int) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
|
|
||||||
case "help":
|
case "help":
|
||||||
if msgLen > 1 {
|
if msgLen > 1 {
|
||||||
app.commandHelp(target, cmdParams[1], message.User.Name)
|
app.commandHelp(target, cmdParams[1], message.User.Name, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "nourybot":
|
case "nourybot":
|
||||||
|
@ -245,7 +245,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
reply = r
|
reply = r
|
||||||
}
|
}
|
||||||
if reply != "" {
|
if reply != "" {
|
||||||
go app.Send(target, reply)
|
go app.Send(target, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ var helpText = map[string]string{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help checks if a help text for a given command exists and replies with it.
|
// Help checks if a help text for a given command exists and replies with it.
|
||||||
func (app *application) commandHelp(target, name, username string) {
|
func (app *application) commandHelp(target, name, username string, message twitch.PrivateMessage) {
|
||||||
// Check if the `helpText` map has an entry for `name`. If it does return it's value entry
|
// Check if the `helpText` map has an entry for `name`. If it does return it's value entry
|
||||||
// and send that as a reply.
|
// and send that as a reply.
|
||||||
i, ok := helpText[name]
|
i, ok := helpText[name]
|
||||||
|
@ -291,9 +291,9 @@ func (app *application) commandHelp(target, name, username string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Send(target, c)
|
app.Send(target, c, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Send(target, i)
|
app.Send(target, i, message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,51 +22,51 @@ func (app *application) NewDownload(destination, target, link string, msg twitch
|
||||||
link,
|
link,
|
||||||
identifier,
|
identifier,
|
||||||
)
|
)
|
||||||
app.Send(target, "xd")
|
app.Send(target, "xd", msg)
|
||||||
|
|
||||||
switch destination {
|
switch destination {
|
||||||
case "catbox":
|
case "catbox":
|
||||||
app.CatboxDownload(target, link, identifier)
|
app.CatboxDownload(target, link, identifier, msg)
|
||||||
case "yaf":
|
case "yaf":
|
||||||
app.YafDownload(target, link, identifier)
|
app.YafDownload(target, link, identifier, msg)
|
||||||
case "kappa":
|
case "kappa":
|
||||||
app.KappaDownload(target, link, identifier)
|
app.KappaDownload(target, link, identifier, msg)
|
||||||
case "gofile":
|
case "gofile":
|
||||||
app.GofileDownload(target, link, identifier)
|
app.GofileDownload(target, link, identifier, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) YafDownload(target, link, identifier string) {
|
func (app *application) YafDownload(target, link, identifier string, msg twitch.PrivateMessage) {
|
||||||
goutubedl.Path = "yt-dlp"
|
goutubedl.Path = "yt-dlp"
|
||||||
|
|
||||||
app.Send(target, "Downloading... dankCircle")
|
app.Send(target, "Downloading... dankCircle", msg)
|
||||||
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rExt := result.Info.Ext
|
rExt := result.Info.Ext
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Send(target, "Downloaded.")
|
app.Send(target, "Downloaded.", msg)
|
||||||
fileName := fmt.Sprintf("%s.%s", identifier, rExt)
|
fileName := fmt.Sprintf("%s.%s", identifier, rExt)
|
||||||
f, err := os.Create(fileName)
|
f, err := os.Create(fileName)
|
||||||
app.Send(target, fmt.Sprintf("Filename: %s", fileName))
|
app.Send(target, fmt.Sprintf("Filename: %s", fileName), msg)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if _, err = io.Copy(f, downloadResult); err != nil {
|
if _, err = io.Copy(f, downloadResult); err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,41 +76,41 @@ func (app *application) YafDownload(target, link, identifier string) {
|
||||||
// dl.twitchClient.Say(target, "ResidentSleeper ..")
|
// dl.twitchClient.Say(target, "ResidentSleeper ..")
|
||||||
// time.Sleep(duration)
|
// time.Sleep(duration)
|
||||||
|
|
||||||
go app.NewUpload("yaf", fileName, target, identifier)
|
go app.NewUpload("yaf", fileName, target, identifier, msg)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) KappaDownload(target, link, identifier string) {
|
func (app *application) KappaDownload(target, link, identifier string, msg twitch.PrivateMessage) {
|
||||||
goutubedl.Path = "yt-dlp"
|
goutubedl.Path = "yt-dlp"
|
||||||
|
|
||||||
app.Send(target, "Downloading... dankCircle")
|
app.Send(target, "Downloading... dankCircle", msg)
|
||||||
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rExt := result.Info.Ext
|
rExt := result.Info.Ext
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Send(target, "Downloaded.")
|
app.Send(target, "Downloaded.", msg)
|
||||||
fileName := fmt.Sprintf("%s.%s", identifier, rExt)
|
fileName := fmt.Sprintf("%s.%s", identifier, rExt)
|
||||||
f, err := os.Create(fileName)
|
f, err := os.Create(fileName)
|
||||||
app.Send(target, fmt.Sprintf("Filename: %s", fileName))
|
app.Send(target, fmt.Sprintf("Filename: %s", fileName), msg)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if _, err = io.Copy(f, downloadResult); err != nil {
|
if _, err = io.Copy(f, downloadResult); err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,18 +120,18 @@ func (app *application) KappaDownload(target, link, identifier string) {
|
||||||
// dl.twitchClient.Say(target, "ResidentSleeper ..")
|
// dl.twitchClient.Say(target, "ResidentSleeper ..")
|
||||||
// time.Sleep(duration)
|
// time.Sleep(duration)
|
||||||
|
|
||||||
go app.NewUpload("kappa", fileName, target, identifier)
|
go app.NewUpload("kappa", fileName, target, identifier, msg)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) GofileDownload(target, link, identifier string) {
|
func (app *application) GofileDownload(target, link, identifier string, msg twitch.PrivateMessage) {
|
||||||
goutubedl.Path = "yt-dlp"
|
goutubedl.Path = "yt-dlp"
|
||||||
|
|
||||||
app.Send(target, "Downloading... dankCircle")
|
app.Send(target, "Downloading... dankCircle", msg)
|
||||||
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
safeFilename := fmt.Sprintf("download_%s", result.Info.Title)
|
safeFilename := fmt.Sprintf("download_%s", result.Info.Title)
|
||||||
|
@ -139,23 +139,23 @@ func (app *application) GofileDownload(target, link, identifier string) {
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Send(target, "Downloaded.")
|
app.Send(target, "Downloaded.", msg)
|
||||||
fileName := fmt.Sprintf("%s.%s", safeFilename, rExt)
|
fileName := fmt.Sprintf("%s.%s", safeFilename, rExt)
|
||||||
f, err := os.Create(fileName)
|
f, err := os.Create(fileName)
|
||||||
app.Send(target, fmt.Sprintf("Filename: %s", fileName))
|
app.Send(target, fmt.Sprintf("Filename: %s", fileName), msg)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if _, err = io.Copy(f, downloadResult); err != nil {
|
if _, err = io.Copy(f, downloadResult); err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,19 +165,19 @@ func (app *application) GofileDownload(target, link, identifier string) {
|
||||||
// dl.twitchClient.Say(target, "ResidentSleeper ..")
|
// dl.twitchClient.Say(target, "ResidentSleeper ..")
|
||||||
// time.Sleep(duration)
|
// time.Sleep(duration)
|
||||||
|
|
||||||
go app.NewUpload("gofile", fileName, target, identifier)
|
go app.NewUpload("gofile", fileName, target, identifier, msg)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) CatboxDownload(target, link, identifier string) {
|
func (app *application) CatboxDownload(target, link, identifier string, msg twitch.PrivateMessage) {
|
||||||
goutubedl.Path = "yt-dlp"
|
goutubedl.Path = "yt-dlp"
|
||||||
var fileName string
|
var fileName string
|
||||||
|
|
||||||
app.Send(target, "Downloading... dankCircle")
|
app.Send(target, "Downloading... dankCircle", msg)
|
||||||
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
result, err := goutubedl.New(context.Background(), link, goutubedl.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,28 +190,28 @@ func (app *application) CatboxDownload(target, link, identifier string) {
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Send(target, "Downloaded.")
|
app.Send(target, "Downloaded.", msg)
|
||||||
fileName = fmt.Sprintf("%s.%s", identifier, rExt)
|
fileName = fmt.Sprintf("%s.%s", identifier, rExt)
|
||||||
f, err := os.Create(fileName)
|
f, err := os.Create(fileName)
|
||||||
app.Send(target, fmt.Sprintf("Filename: %s", fileName))
|
app.Send(target, fmt.Sprintf("Filename: %s", fileName), msg)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if _, err = io.Copy(f, downloadResult); err != nil {
|
if _, err = io.Copy(f, downloadResult); err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadResult.Close()
|
downloadResult.Close()
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
go app.NewUpload("catbox", fileName, target, identifier)
|
go app.NewUpload("catbox", fileName, target, identifier, msg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ func main() {
|
||||||
|
|
||||||
// Special rule for #pajlada.
|
// Special rule for #pajlada.
|
||||||
if message.Message == "!nourybot" {
|
if message.Message == "!nourybot" {
|
||||||
app.Send(message.Channel, "Lidl Twitch bot made by @nourylul. Prefix: ()")
|
app.Send(message.Channel, "Lidl Twitch bot made by @nourylul. Prefix: ()", message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -172,8 +172,8 @@ func main() {
|
||||||
|
|
||||||
app.TwitchClient.Join("nourylul")
|
app.TwitchClient.Join("nourylul")
|
||||||
app.TwitchClient.Join("nourybot")
|
app.TwitchClient.Join("nourybot")
|
||||||
app.Send("nourylul", "xD!")
|
app.TwitchClient.Say("nourylul", "xD!")
|
||||||
app.Send("nourybot", "gopherDance")
|
app.TwitchClient.Say("nourybot", "gopherDance")
|
||||||
|
|
||||||
// Successfully connected to Twitch
|
// Successfully connected to Twitch
|
||||||
app.Log.Infow("Successfully connected to Twitch Servers",
|
app.Log.Infow("Successfully connected to Twitch Servers",
|
||||||
|
|
|
@ -6,7 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gempir/go-twitch-irc/v4"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,14 +82,70 @@ func (app *application) checkMessage(text string) (bool, string) {
|
||||||
|
|
||||||
// Send is used to send twitch replies and contains the necessary
|
// Send is used to send twitch replies and contains the necessary
|
||||||
// safeguards and logic for that.
|
// safeguards and logic for that.
|
||||||
func (app *application) Send(target, message string) {
|
func (app *application) SendNoContext(target, message string) {
|
||||||
// Message we are trying to send is empty.
|
// Message we are trying to send is empty.
|
||||||
if len(message) == 0 {
|
if len(message) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
identifier := uuid.NewString()
|
identifier := uuid.NewString()
|
||||||
go app.Models.SentMessagesLogs.Insert(target, message, identifier)
|
go app.Models.SentMessagesLogs.Insert(target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")
|
||||||
|
|
||||||
|
// Since messages starting with `.` or `/` are used for special actions
|
||||||
|
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
||||||
|
// the actions wouldn't execute. `!` and `$` are common bot prefixes so we
|
||||||
|
// don't allow them either.
|
||||||
|
if message[0] == '.' || message[0] == '/' || message[0] == '!' || message[0] == '$' {
|
||||||
|
message = ":tf: " + message
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the message for bad words before we say it
|
||||||
|
messageBanned, banReason := app.checkMessage(message)
|
||||||
|
if !messageBanned {
|
||||||
|
// In case the message we are trying to send is longer than the
|
||||||
|
// maximum allowed message length on twitch we split the message in two parts.
|
||||||
|
// Twitch has a maximum length for messages of 510 characters so to be safe
|
||||||
|
// we split and check at 500 characters.
|
||||||
|
// https://discuss.dev.twitch.tv/t/missing-client-side-message-length-check/21316
|
||||||
|
// TODO: Make it so it splits at a space instead and not in the middle of a word.
|
||||||
|
if len(message) > 500 {
|
||||||
|
firstMessage := message[0:499]
|
||||||
|
secondMessage := message[499:]
|
||||||
|
|
||||||
|
app.TwitchClient.Say(target, firstMessage)
|
||||||
|
app.TwitchClient.Say(target, secondMessage)
|
||||||
|
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
// Message was fine.
|
||||||
|
go app.TwitchClient.Say(target, message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Bad message, replace message and log it.
|
||||||
|
app.TwitchClient.Say(target, "[BANPHRASED] monkaS")
|
||||||
|
app.Log.Infow("banned message detected",
|
||||||
|
"target channel", target,
|
||||||
|
"message", message,
|
||||||
|
"ban reason", banReason,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send is used to send twitch replies and contains the necessary
|
||||||
|
// safeguards and logic for that.
|
||||||
|
func (app *application) Send(target, message string, msgContext twitch.PrivateMessage) {
|
||||||
|
// Message we are trying to send is empty.
|
||||||
|
if len(message) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
commandName := strings.ToLower(strings.SplitN(msgContext.Message, " ", 3)[0][2:])
|
||||||
|
identifier := uuid.NewString()
|
||||||
|
app.Log.Info("xd xd")
|
||||||
|
go app.Models.SentMessagesLogs.Insert(target, message, commandName, msgContext.User.Name, msgContext.User.ID, msgContext.Message, identifier, msgContext.Raw)
|
||||||
|
|
||||||
// Since messages starting with `.` or `/` are used for special actions
|
// Since messages starting with `.` or `/` are used for special actions
|
||||||
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
||||||
|
@ -141,7 +199,7 @@ func (app *application) SendNoBanphrase(target, message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
identifier := uuid.NewString()
|
identifier := uuid.NewString()
|
||||||
go app.Models.SentMessagesLogs.Insert(target, message, identifier)
|
go app.Models.SentMessagesLogs.Insert(target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")
|
||||||
|
|
||||||
// Since messages starting with `.` or `/` are used for special actions
|
// Since messages starting with `.` or `/` are used for special actions
|
||||||
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
// (ban, whisper, timeout) and so on, we place an emote infront of it so
|
||||||
|
@ -194,7 +252,7 @@ func (app *application) SendNoLimit(target, message string) {
|
||||||
// TODO: Make it so it splits at a space instead and not in the middle of a word.
|
// TODO: Make it so it splits at a space instead and not in the middle of a word.
|
||||||
// Message was fine.
|
// Message was fine.
|
||||||
identifier := uuid.NewString()
|
identifier := uuid.NewString()
|
||||||
go app.Models.SentMessagesLogs.Insert(target, message, identifier)
|
go app.Models.SentMessagesLogs.Insert(target, message, "unavailable", "unavailable", "unavailable", "unavailable", identifier, "unavailable")
|
||||||
go app.TwitchClient.Say(target, message)
|
go app.TwitchClient.Say(target, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (app *application) AddTimer(name, repeat string, message twitch.PrivateMess
|
||||||
)
|
)
|
||||||
|
|
||||||
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
// cronName is the internal, unique tag/name for the timer.
|
// cronName is the internal, unique tag/name for the timer.
|
||||||
|
@ -84,7 +84,7 @@ func (app *application) AddTimer(name, repeat string, message twitch.PrivateMess
|
||||||
)
|
)
|
||||||
|
|
||||||
reply := fmt.Sprintf("Successfully added timer %s repeating every %s", name, repeat)
|
reply := fmt.Sprintf("Successfully added timer %s repeating every %s", name, repeat)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,7 +93,7 @@ func (app *application) AddTimer(name, repeat string, message twitch.PrivateMess
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
reply := "Something went wrong FeelsBadMan received wrong time format. Allowed formats: 30m, 10h, 10h30m"
|
reply := "Something went wrong FeelsBadMan received wrong time format. Allowed formats: 30m, 10h, 10h30m"
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ func (app *application) EditTimer(name, repeat string, message twitch.PrivateMes
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
reply := "Something went wrong FeelsBadMan"
|
reply := "Something went wrong FeelsBadMan"
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ func (app *application) EditTimer(name, repeat string, message twitch.PrivateMes
|
||||||
)
|
)
|
||||||
|
|
||||||
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ func (app *application) EditTimer(name, repeat string, message twitch.PrivateMes
|
||||||
)
|
)
|
||||||
|
|
||||||
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
} else { // this is a bit scuffed. The else here is the end of a successful call.
|
} else { // this is a bit scuffed. The else here is the end of a successful call.
|
||||||
// cronName is the internal, unique tag/name for the timer.
|
// cronName is the internal, unique tag/name for the timer.
|
||||||
|
@ -211,7 +211,7 @@ func (app *application) EditTimer(name, repeat string, message twitch.PrivateMes
|
||||||
)
|
)
|
||||||
|
|
||||||
reply := fmt.Sprintf("Successfully updated timer %s", name)
|
reply := fmt.Sprintf("Successfully updated timer %s", name)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -220,7 +220,7 @@ func (app *application) EditTimer(name, repeat string, message twitch.PrivateMes
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
reply := "Something went wrong FeelsBadMan received wrong time format. Allowed formats: 30s, 30m, 10h, 10h30m"
|
reply := "Something went wrong FeelsBadMan received wrong time format. Allowed formats: 30s, 30m, 10h, 10h30m"
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ func (app *application) InitialTimers() {
|
||||||
// newPrivateMessageTimer is a helper function to set timers
|
// newPrivateMessageTimer is a helper function to set timers
|
||||||
// which trigger into sending a twitch PrivateMessage.
|
// which trigger into sending a twitch PrivateMessage.
|
||||||
func (app *application) newPrivateMessageTimer(channel, text string) {
|
func (app *application) newPrivateMessageTimer(channel, text string) {
|
||||||
app.Send(channel, text)
|
app.SendNoContext(channel, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteTimer takes in the name of a timer and tries to delete the timer from the database.
|
// DeleteTimer takes in the name of a timer and tries to delete the timer from the database.
|
||||||
|
@ -346,10 +346,10 @@ func (app *application) DeleteTimer(name string, message twitch.PrivateMessage)
|
||||||
)
|
)
|
||||||
|
|
||||||
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
reply := fmt.Sprintln("Something went wrong FeelsBadMan")
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reply := fmt.Sprintf("Deleted timer with name %s", name)
|
reply := fmt.Sprintf("Deleted timer with name %s", name)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gempir/go-twitch-irc/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -27,30 +29,30 @@ const (
|
||||||
YAF_ENDPOINT = "https://i.yaf.ee/upload"
|
YAF_ENDPOINT = "https://i.yaf.ee/upload"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (app *application) NewUpload(destination, fileName, target, identifier string) {
|
func (app *application) NewUpload(destination, fileName, target, identifier string, msg twitch.PrivateMessage) {
|
||||||
|
|
||||||
switch destination {
|
switch destination {
|
||||||
case "catbox":
|
case "catbox":
|
||||||
go app.CatboxUpload(target, fileName, identifier)
|
go app.CatboxUpload(target, fileName, identifier, msg)
|
||||||
case "yaf":
|
case "yaf":
|
||||||
go app.YafUpload(target, fileName, identifier)
|
go app.YafUpload(target, fileName, identifier, msg)
|
||||||
case "kappa":
|
case "kappa":
|
||||||
go app.KappaUpload(target, fileName, identifier)
|
go app.KappaUpload(target, fileName, identifier, msg)
|
||||||
case "gofile":
|
case "gofile":
|
||||||
go app.GofileUpload(target, fileName, identifier)
|
go app.GofileUpload(target, fileName, identifier, msg)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) CatboxUpload(target, fileName, identifier string) {
|
func (app *application) CatboxUpload(target, fileName, identifier string, msg twitch.PrivateMessage) {
|
||||||
defer os.Remove(fileName)
|
defer os.Remove(fileName)
|
||||||
file, err := os.Open(fileName)
|
file, err := os.Open(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
app.Send(target, "Uploading to catbox.moe... dankCircle")
|
app.Send(target, "Uploading to catbox.moe... dankCircle", msg)
|
||||||
|
|
||||||
// if size := helper.FileSize(fileName); size > 209715200 {
|
// if size := helper.FileSize(fileName); size > 209715200 {
|
||||||
// return "", fmt.Errorf("file too large, size: %d MB", size/1024/1024)
|
// return "", fmt.Errorf("file too large, size: %d MB", size/1024/1024)
|
||||||
|
@ -67,7 +69,7 @@ func (app *application) CatboxUpload(target, fileName, identifier string) {
|
||||||
m.WriteField("time", "24h")
|
m.WriteField("time", "24h")
|
||||||
part, err := m.CreateFormFile("fileToUpload", filepath.Base(file.Name()))
|
part, err := m.CreateFormFile("fileToUpload", filepath.Base(file.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,26 +87,26 @@ func (app *application) CatboxUpload(target, fileName, identifier string) {
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reply := string(body)
|
reply := string(body)
|
||||||
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
||||||
app.Send(target, fmt.Sprintf("Removing file: %s", fileName))
|
app.Send(target, fmt.Sprintf("Removing file: %s", fileName), msg)
|
||||||
app.Send(target, reply)
|
app.Send(target, reply, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) GofileUpload(target, path, identifier string) {
|
func (app *application) GofileUpload(target, path, identifier string, msg twitch.PrivateMessage) {
|
||||||
defer os.Remove(path)
|
defer os.Remove(path)
|
||||||
app.Send(target, "Uploading to gofile.io... dankCircle")
|
app.Send(target, "Uploading to gofile.io... dankCircle", msg)
|
||||||
pr, pw := io.Pipe()
|
pr, pw := io.Pipe()
|
||||||
form := multipart.NewWriter(pw)
|
form := multipart.NewWriter(pw)
|
||||||
|
|
||||||
|
@ -127,21 +129,21 @@ func (app *application) GofileUpload(target, path, identifier string) {
|
||||||
|
|
||||||
file, err := os.Open(path) // path to image file
|
file, err := os.Open(path) // path to image file
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w, err := form.CreateFormFile("file", path)
|
w, err := form.CreateFormFile("file", path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = io.Copy(w, file)
|
_, err = io.Copy(w, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -151,7 +153,7 @@ func (app *application) GofileUpload(target, path, identifier string) {
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, GOFILE_ENDPOINT, pr)
|
req, err := http.NewRequest(http.MethodPost, GOFILE_ENDPOINT, pr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -162,18 +164,18 @@ func (app *application) GofileUpload(target, path, identifier string) {
|
||||||
}
|
}
|
||||||
resp, err := httpClient.Do(req)
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
app.Log.Errorln("Error while sending HTTP request:", err)
|
app.Log.Errorln("Error while sending HTTP request:", err)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
app.Send(target, "Uploaded PogChamp")
|
app.Send(target, "Uploaded PogChamp", msg)
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
app.Log.Errorln("Error while reading response:", err)
|
app.Log.Errorln("Error while reading response:", err)
|
||||||
return
|
return
|
||||||
|
@ -181,7 +183,7 @@ func (app *application) GofileUpload(target, path, identifier string) {
|
||||||
|
|
||||||
jsonResponse := new(gofileResponse)
|
jsonResponse := new(gofileResponse)
|
||||||
if err := json.Unmarshal(body, jsonResponse); err != nil {
|
if err := json.Unmarshal(body, jsonResponse); err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
app.Log.Errorln("Error while unmarshalling JSON response:", err)
|
app.Log.Errorln("Error while unmarshalling JSON response:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -189,13 +191,13 @@ func (app *application) GofileUpload(target, path, identifier string) {
|
||||||
var reply = jsonResponse.Data.DownloadPage
|
var reply = jsonResponse.Data.DownloadPage
|
||||||
|
|
||||||
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
||||||
app.Send(target, fmt.Sprintf("Removing file: %s", path))
|
app.Send(target, fmt.Sprintf("Removing file: %s", path), msg)
|
||||||
app.Send(target, reply)
|
app.Send(target, reply, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) KappaUpload(target, path, identifier string) {
|
func (app *application) KappaUpload(target, path, identifier string, msg twitch.PrivateMessage) {
|
||||||
defer os.Remove(path)
|
defer os.Remove(path)
|
||||||
app.Send(target, "Uploading to kappa.lol... dankCircle")
|
app.Send(target, "Uploading to kappa.lol... dankCircle", msg)
|
||||||
pr, pw := io.Pipe()
|
pr, pw := io.Pipe()
|
||||||
form := multipart.NewWriter(pw)
|
form := multipart.NewWriter(pw)
|
||||||
|
|
||||||
|
@ -208,28 +210,28 @@ func (app *application) KappaUpload(target, path, identifier string) {
|
||||||
|
|
||||||
err := form.WriteField("name", "xd")
|
err := form.WriteField("name", "xd")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := os.Open(path) // path to image file
|
file, err := os.Open(path) // path to image file
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w, err := form.CreateFormFile("file", path)
|
w, err := form.CreateFormFile("file", path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = io.Copy(w, file)
|
_, err = io.Copy(w, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -239,7 +241,7 @@ func (app *application) KappaUpload(target, path, identifier string) {
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, KAPPA_ENDPOINT, pr)
|
req, err := http.NewRequest(http.MethodPost, KAPPA_ENDPOINT, pr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -250,18 +252,18 @@ func (app *application) KappaUpload(target, path, identifier string) {
|
||||||
}
|
}
|
||||||
resp, err := httpClient.Do(req)
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
app.Log.Errorln("Error while sending HTTP request:", err)
|
app.Log.Errorln("Error while sending HTTP request:", err)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
app.Send(target, "Uploaded PogChamp")
|
app.Send(target, "Uploaded PogChamp", msg)
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
app.Log.Errorln("Error while reading response:", err)
|
app.Log.Errorln("Error while reading response:", err)
|
||||||
return
|
return
|
||||||
|
@ -269,7 +271,7 @@ func (app *application) KappaUpload(target, path, identifier string) {
|
||||||
|
|
||||||
jsonResponse := new(kappaResponse)
|
jsonResponse := new(kappaResponse)
|
||||||
if err := json.Unmarshal(body, jsonResponse); err != nil {
|
if err := json.Unmarshal(body, jsonResponse); err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
app.Log.Errorln("Error while unmarshalling JSON response:", err)
|
app.Log.Errorln("Error while unmarshalling JSON response:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -277,13 +279,13 @@ func (app *application) KappaUpload(target, path, identifier string) {
|
||||||
var reply = jsonResponse.Link
|
var reply = jsonResponse.Link
|
||||||
|
|
||||||
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
||||||
app.Send(target, fmt.Sprintf("Removing file: %s", path))
|
app.Send(target, fmt.Sprintf("Removing file: %s", path), msg)
|
||||||
app.Send(target, reply)
|
app.Send(target, reply, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) YafUpload(target, path, identifier string) {
|
func (app *application) YafUpload(target, path, identifier string, msg twitch.PrivateMessage) {
|
||||||
defer os.Remove(path)
|
defer os.Remove(path)
|
||||||
app.Send(target, "Uploading to yaf.ee... dankCircle")
|
app.Send(target, "Uploading to yaf.ee... dankCircle", msg)
|
||||||
pr, pw := io.Pipe()
|
pr, pw := io.Pipe()
|
||||||
form := multipart.NewWriter(pw)
|
form := multipart.NewWriter(pw)
|
||||||
|
|
||||||
|
@ -292,28 +294,28 @@ func (app *application) YafUpload(target, path, identifier string) {
|
||||||
|
|
||||||
err := form.WriteField("name", "xd")
|
err := form.WriteField("name", "xd")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := os.Open(path) // path to image file
|
file, err := os.Open(path) // path to image file
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w, err := form.CreateFormFile("file", path)
|
w, err := form.CreateFormFile("file", path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = io.Copy(w, file)
|
_, err = io.Copy(w, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -323,7 +325,7 @@ func (app *application) YafUpload(target, path, identifier string) {
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, YAF_ENDPOINT, pr)
|
req, err := http.NewRequest(http.MethodPost, YAF_ENDPOINT, pr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -334,7 +336,7 @@ func (app *application) YafUpload(target, path, identifier string) {
|
||||||
}
|
}
|
||||||
resp, err := httpClient.Do(req)
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
app.Log.Errorln("Error while sending HTTP request:", err)
|
app.Log.Errorln("Error while sending HTTP request:", err)
|
||||||
|
|
||||||
|
@ -344,7 +346,7 @@ func (app *application) YafUpload(target, path, identifier string) {
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err))
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
app.Log.Errorln("Error while reading response:", err)
|
app.Log.Errorln("Error while reading response:", err)
|
||||||
return
|
return
|
||||||
|
@ -353,6 +355,6 @@ func (app *application) YafUpload(target, path, identifier string) {
|
||||||
var reply = string(body[:])
|
var reply = string(body[:])
|
||||||
|
|
||||||
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
go app.Models.Uploads.UpdateUploadURL(identifier, reply)
|
||||||
app.Send(target, fmt.Sprintf("Removing file: %s", path))
|
app.Send(target, fmt.Sprintf("Removing file: %s", path), msg)
|
||||||
app.Send(target, reply)
|
app.Send(target, reply, msg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (app *application) DebugUser(login string, message twitch.PrivateMessage) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err)
|
reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
// subject := fmt.Sprintf("DEBUG for user %v", login)
|
// subject := fmt.Sprintf("DEBUG for user %v", login)
|
||||||
|
@ -42,10 +42,10 @@ func (app *application) DebugUser(login string, message twitch.PrivateMessage) {
|
||||||
resp, err := app.uploadPaste(body)
|
resp, err := app.uploadPaste(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln("Could not upload paste:", err)
|
app.Log.Errorln("Could not upload paste:", err)
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload), message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Send(message.Channel, resp)
|
app.Send(message.Channel, resp, message)
|
||||||
// app.SendEmail(subject, body)
|
// app.SendEmail(subject, body)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -56,13 +56,13 @@ func (app *application) DebugUser(login string, message twitch.PrivateMessage) {
|
||||||
func (app *application) DeleteUser(login string, message twitch.PrivateMessage) {
|
func (app *application) DeleteUser(login string, message twitch.PrivateMessage) {
|
||||||
err := app.Models.Users.Delete(login)
|
err := app.Models.Users.Delete(login)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, "Something went wrong FeelsBadMan")
|
app.Send(message.Channel, "Something went wrong FeelsBadMan", message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reply := fmt.Sprintf("Deleted user %s", login)
|
reply := fmt.Sprintf("Deleted user %s", login)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditUserLevel tries to update the database record for the supplied
|
// EditUserLevel tries to update the database record for the supplied
|
||||||
|
@ -73,18 +73,18 @@ func (app *application) EditUserLevel(login, lvl string, message twitch.PrivateM
|
||||||
level, err := strconv.Atoi(lvl)
|
level, err := strconv.Atoi(lvl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrUserLevelNotInteger))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrUserLevelNotInteger), message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Models.Users.SetLevel(login, level)
|
err = app.Models.Users.SetLevel(login, level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Updated user %s to level %v", login, level)
|
reply := fmt.Sprintf("Updated user %s to level %v", login, level)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,12 +106,12 @@ func (app *application) SetUserLocation(message twitch.PrivateMessage) {
|
||||||
|
|
||||||
err := app.Models.Users.SetLocation(twitchId, location)
|
err := app.Models.Users.SetLocation(twitchId, location)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Successfully set your location to %v", location)
|
reply := fmt.Sprintf("Successfully set your location to %v", location)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,12 @@ func (app *application) SetUserLastFM(lastfmUser string, message twitch.PrivateM
|
||||||
|
|
||||||
err := app.Models.Users.SetLastFM(login, lastfmUser)
|
err := app.Models.Users.SetLastFM(login, lastfmUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound))
|
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), message)
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
reply := fmt.Sprintf("Successfully set your lastfm username to %v", lastfmUser)
|
reply := fmt.Sprintf("Successfully set your lastfm username to %v", lastfmUser)
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,12 +157,12 @@ func (app *application) UserCheckWeather(message twitch.PrivateMessage) {
|
||||||
"twitchId:", twitchId,
|
"twitchId:", twitchId,
|
||||||
)
|
)
|
||||||
reply := "No location for your account set in my database. Use ()set location <location> to register. Otherwise use ()weather <location> without registering."
|
reply := "No location for your account set in my database. Use ()set location <location> to register. Otherwise use ()weather <location> without registering."
|
||||||
app.Send(message.Channel, reply)
|
app.Send(message.Channel, reply, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reply, _ := commands.Weather(location)
|
reply, _ := commands.Weather(location)
|
||||||
app.Send(target, reply)
|
app.Send(target, reply, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) UserCheckLastFM(message twitch.PrivateMessage) string {
|
func (app *application) UserCheckLastFM(message twitch.PrivateMessage) string {
|
||||||
|
|
|
@ -61,7 +61,7 @@ type Models struct {
|
||||||
Insert(twitchLogin, twitchId, twitchChannel, twitchMessage, commandName string, uLvl int, identifier, rawMsg string)
|
Insert(twitchLogin, twitchId, twitchChannel, twitchMessage, commandName string, uLvl int, identifier, rawMsg string)
|
||||||
}
|
}
|
||||||
SentMessagesLogs interface {
|
SentMessagesLogs interface {
|
||||||
Insert(twitchChannel, twitchMessage, identifier string)
|
Insert(twitchChannel, twitchMessage, ctxCommandName, ctxUser, ctxUserID, ctxMsg, identifier, ctxRaw string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,12 @@ type SentMessagesLog struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
TwitchChannel string `json:"twitch_channel,omitempty"`
|
TwitchChannel string `json:"twitch_channel,omitempty"`
|
||||||
TwitchMessage string `json:"twitch_message,omitempty"`
|
TwitchMessage string `json:"twitch_message,omitempty"`
|
||||||
|
ContextCommandName string `json:"context_command_name"`
|
||||||
|
ContextUsername string `json:"context_user"`
|
||||||
|
ContextMessage string `json:"context_message"`
|
||||||
|
ContextUserID string `json:"context_user_id"`
|
||||||
Identifier string `json:"identifier,omitempty"`
|
Identifier string `json:"identifier,omitempty"`
|
||||||
|
ContextRawMsg string `json:"context_raw"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SentMessagesLogModel struct {
|
type SentMessagesLogModel struct {
|
||||||
|
@ -16,14 +21,14 @@ type SentMessagesLogModel struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get tries to find a command in the database with the provided name.
|
// Get tries to find a command in the database with the provided name.
|
||||||
func (s SentMessagesLogModel) Insert(twitchChannel, twitchMessage, identifier string) {
|
func (s SentMessagesLogModel) Insert(twitchChannel, twitchMessage, ctxCommandName, ctxUser, ctxUserID, ctxMsg, identifier, ctxRaw string) {
|
||||||
query := `
|
query := `
|
||||||
INSERT into sent_messages_logs(twitch_channel, twitch_message, identifier)
|
INSERT into sent_messages_logs(twitch_channel, twitch_message, context_command_name, context_username, context_user_id, context_message, identifier, context_raw)
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||||
RETURNING id;
|
RETURNING id;
|
||||||
`
|
`
|
||||||
|
|
||||||
args := []interface{}{twitchChannel, twitchMessage, identifier}
|
args := []interface{}{twitchChannel, twitchMessage, ctxCommandName, ctxUser, ctxUserID, ctxMsg, identifier, ctxRaw}
|
||||||
|
|
||||||
result, err := s.DB.Exec(query, args...)
|
result, err := s.DB.Exec(query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,8 +3,13 @@ CREATE TABLE IF NOT EXISTS sent_messages_logs (
|
||||||
added_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
|
added_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
|
||||||
twitch_channel text NOT NULL,
|
twitch_channel text NOT NULL,
|
||||||
twitch_message text NOT NULL,
|
twitch_message text NOT NULL,
|
||||||
identifier text NOT NULL
|
context_command_name text,
|
||||||
|
context_username text,
|
||||||
|
context_message text,
|
||||||
|
context_user_id text,
|
||||||
|
identifier text,
|
||||||
|
context_raw text
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO sent_messages_logs (added_at,twitch_channel,twitch_message,identifier) VALUES
|
INSERT INTO sent_messages_logs (added_at,twitch_channel,twitch_message,context_command_name,context_username,context_message,context_user_id,identifier,context_raw) VALUES
|
||||||
(NOW(),'nourybot','Weather for Vilnius, LT: Feels like: 9.3°C. Currently 10.85°C with a high of 12.07°C and a low of 10.49°C, humidity: 50%, wind: 2.57m/s.','04fbd9c0-47da-466f-b966-44d1d04de11c');
|
(NOW(),'nourybot','Weather for Vilnius, LT: Feels like: 8.07°C. Currently 8.65°C with a high of 9.29°C and a low of 8.49°C, humidity: 66%, wind: 1.54m/s.','weather','nourylul','()weather Vilnius','31437432','654f9761-b2d4-4975-a4fd-84c6ec7f2eb8','@badge-info=;badges=moderator/1,game-developer/1;color=#00F2FB;display-name=nourylul;emotes=;first-msg=0;flags=;id=357d94a4-024e-49ea-ab3d-d97286cd0492;mod=1;returning-chatter=0;room-id=596581605;subscriber=0;tmi-sent-ts=1696952295788;turbo=0;user-id=31437432;user-type=mod :nourylul!nourylul@nourylul.tmi.twitch.tv PRIVMSG #nourybot :()weather Vilnius');
|
||||||
|
|
Loading…
Reference in a new issue