diff --git a/cmd/nourybot/channel.go b/cmd/nourybot/channel.go index 96e517e..e04adf7 100644 --- a/cmd/nourybot/channel.go +++ b/cmd/nourybot/channel.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/gempir/go-twitch-irc/v4" - "github.com/lyx0/nourybot/internal/ivr" + "github.com/lyx0/nourybot/pkg/ivr" ) // AddChannel takes in a channel name, then calls GetIdByLogin for the diff --git a/cmd/nourybot/commands.go b/cmd/nourybot/commands.go index 9ad146e..07d78a6 100644 --- a/cmd/nourybot/commands.go +++ b/cmd/nourybot/commands.go @@ -6,7 +6,9 @@ import ( "github.com/gempir/go-twitch-irc/v4" "github.com/lyx0/nourybot/internal/commands" "github.com/lyx0/nourybot/internal/common" - "github.com/lyx0/nourybot/internal/ivr" + "github.com/lyx0/nourybot/pkg/ivr" + "github.com/lyx0/nourybot/pkg/lastfm" + "github.com/lyx0/nourybot/pkg/owm" ) // handleCommand takes in a twitch.PrivateMessage and then routes the message to @@ -129,7 +131,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) { } else { // Default to first argument supplied being the name // of the user to look up recently played. - reply = commands.LastFmUserRecent(target, cmdParams[1]) + reply = lastfm.LastFmUserRecent(target, cmdParams[1]) } case "help": @@ -157,7 +159,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) { } else if msgLen < 2 { reply = "Not enough arguments provided." } else { - reply, _ = commands.Weather(message.Message[10:len(message.Message)]) + reply, _ = owm.Weather(message.Message[10:len(message.Message)]) } case "rxkcd": diff --git a/cmd/nourybot/user.go b/cmd/nourybot/user.go index b26f5ff..3f036c7 100644 --- a/cmd/nourybot/user.go +++ b/cmd/nourybot/user.go @@ -5,7 +5,8 @@ import ( "strconv" "github.com/gempir/go-twitch-irc/v4" - "github.com/lyx0/nourybot/internal/commands" + "github.com/lyx0/nourybot/pkg/lastfm" + "github.com/lyx0/nourybot/pkg/owm" ) // AddUser calls GetIdByLogin to get the twitch id of the login name and then adds @@ -161,7 +162,7 @@ func (app *application) UserCheckWeather(message twitch.PrivateMessage) { return } - reply, _ := commands.Weather(location) + reply, _ := owm.Weather(location) app.Send(target, reply, message) } @@ -178,6 +179,6 @@ func (app *application) UserCheckLastFM(message twitch.PrivateMessage) string { return reply } - reply := commands.LastFmUserRecent(target, lastfmUser) + reply := lastfm.LastFmUserRecent(target, lastfmUser) return reply } diff --git a/go.mod b/go.mod index 6d4e08e..a543cd5 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/google/uuid v1.3.1 github.com/jakecoffman/cron v0.0.0-20190106200828-7e2009c226a5 github.com/lib/pq v1.10.9 + github.com/nicklaw5/helix/v2 v2.25.1 github.com/rs/zerolog v1.29.1 github.com/shkh/lastfm-go v0.0.0-20191215035245-89a801c244e0 github.com/wader/goutubedl v0.0.0-20230924165737-427b7fa536e6 @@ -16,7 +17,6 @@ require ( require ( github.com/golang-jwt/jwt/v4 v4.0.0 // indirect - github.com/nicklaw5/helix/v2 v2.25.1 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect @@ -25,9 +25,8 @@ require ( require ( github.com/briandowns/openweathermap v0.19.0 github.com/dustin/go-humanize v1.0.1 - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect github.com/joho/godotenv v1.5.1 github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect - golang.org/x/sys v0.8.0 // indirect + golang.org/x/sys v0.11.0 // indirect ) diff --git a/go.sum b/go.sum index cb05f7a..0e0cbc9 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,6 @@ github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu github.com/gempir/go-twitch-irc/v4 v4.0.0 h1:sHVIvbWOv9nHXGEErilclxASv0AaQEr/r/f9C0B9aO8= github.com/gempir/go-twitch-irc/v4 v4.0.0/go.mod h1:QsOMMAk470uxQ7EYD9GJBGAVqM/jDrXBNbuePfTauzg= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.0.0 h1:RAqyYixv1p7uEnocuy8P1nru5wprCh/MH2BIlW5z5/o= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= @@ -28,8 +26,6 @@ github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZb github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/nicklaw5/helix v1.25.0 h1:Mrz537izZVsGdM3I46uGAAlslj61frgkhS/9xQqyT/M= -github.com/nicklaw5/helix v1.25.0/go.mod h1:yvXZFapT6afIoxnAvlWiJiUMsYnoHl7tNs+t0bloAMw= github.com/nicklaw5/helix/v2 v2.25.1 h1:hccFfWf1kdPKeC/Zp8jNbOvqV0f6ya12hdeNHuQa5wg= github.com/nicklaw5/helix/v2 v2.25.1/go.mod h1:zZcKsyyBWDli34x3QleYsVMiiNGMXPAEU5NjsiZDtvY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -57,8 +53,8 @@ go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.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= diff --git a/internal/commands/ping.go b/internal/commands/ping.go index bf092ac..ec5a6a5 100644 --- a/internal/commands/ping.go +++ b/internal/commands/ping.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/lyx0/nourybot/internal/common" - "github.com/lyx0/nourybot/internal/humanize" + "github.com/lyx0/nourybot/pkg/humanize" ) func Ping() string { diff --git a/internal/humanize/time.go b/pkg/humanize/time.go similarity index 100% rename from internal/humanize/time.go rename to pkg/humanize/time.go diff --git a/internal/ivr/user.go b/pkg/ivr/user.go similarity index 100% rename from internal/ivr/user.go rename to pkg/ivr/user.go diff --git a/internal/commands/lastfm.go b/pkg/lastfm/lastfm.go similarity index 98% rename from internal/commands/lastfm.go rename to pkg/lastfm/lastfm.go index 978e2ec..cbd7bad 100644 --- a/internal/commands/lastfm.go +++ b/pkg/lastfm/lastfm.go @@ -1,4 +1,4 @@ -package commands +package lastfm import ( "fmt" diff --git a/internal/commands/weather.go b/pkg/owm/weather.go similarity index 88% rename from internal/commands/weather.go rename to pkg/owm/weather.go index 6f20017..f241936 100644 --- a/internal/commands/weather.go +++ b/pkg/owm/weather.go @@ -1,6 +1,7 @@ -package commands +package owm import ( + "errors" "fmt" "os" @@ -8,6 +9,11 @@ import ( "github.com/joho/godotenv" ) +var ( + ErrInternalServerError = errors.New("internal server error") + ErrWeatherLocationNotFound = errors.New("location not found") +) + // Weather queries the OpenWeatherMap Api for the given location and sends the // current weather response to the target twitch chat. func Weather(location string) (string, error) {