From dda26a8e49a5a4e01304fa73383f322676ba7ef8 Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:03:13 +0200 Subject: [PATCH] cleanup warnings --- cmd/nourybot/send.go | 6 ++++-- cmd/nourybot/upload.go | 12 ++++++++++-- cmd/nourybot/user.go | 2 +- internal/data/uploads.go | 2 -- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/nourybot/send.go b/cmd/nourybot/send.go index f2b8f5c..744242c 100644 --- a/cmd/nourybot/send.go +++ b/cmd/nourybot/send.go @@ -63,7 +63,10 @@ func (app *application) checkMessage(text string) (bool, string) { } var responseObject banphraseResponse - json.Unmarshal(body, &responseObject) + if err := json.Unmarshal(body, &responseObject); err != nil { + app.Log.Error(err) + return true, "could not check banphrase api" + } // Bad Message // @@ -144,7 +147,6 @@ func (app *application) Send(target, message string, msgContext twitch.PrivateMe 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 diff --git a/cmd/nourybot/upload.go b/cmd/nourybot/upload.go index 3cf62ee..edcc890 100644 --- a/cmd/nourybot/upload.go +++ b/cmd/nourybot/upload.go @@ -65,8 +65,16 @@ func (app *application) CatboxUpload(target, fileName, identifier string, msg tw defer w.Close() defer m.Close() - m.WriteField("reqtype", "fileupload") - m.WriteField("time", "24h") + err := m.WriteField("reqtype", "fileupload") + if err != nil { + app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg) + return + } + err = m.WriteField("time", "24h") + if err != nil { + app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg) + return + } part, err := m.CreateFormFile("fileToUpload", filepath.Base(file.Name())) if err != nil { app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg) diff --git a/cmd/nourybot/user.go b/cmd/nourybot/user.go index 29d7d5e..b26f5ff 100644 --- a/cmd/nourybot/user.go +++ b/cmd/nourybot/user.go @@ -14,7 +14,7 @@ func (app *application) InitUser(login, twitchId string) { _, err := app.Models.Users.Check(twitchId) //app.Log.Error(err) if err != nil { - app.Models.Users.Insert(login, twitchId) + go app.Models.Users.Insert(login, twitchId) return } diff --git a/internal/data/uploads.go b/internal/data/uploads.go index 115edea..5efcae2 100644 --- a/internal/data/uploads.go +++ b/internal/data/uploads.go @@ -81,6 +81,4 @@ func (u UploadModel) UpdateUploadURL(identifier, uploadURL string) { return } } - - return }