diff --git a/cmd/bot/bot.go b/cmd/bot/bot.go index ca8e8c9..191c065 100644 --- a/cmd/bot/bot.go +++ b/cmd/bot/bot.go @@ -4,11 +4,13 @@ import ( "time" twitch "github.com/gempir/go-twitch-irc/v2" + "github.com/nicklaw5/helix" "go.mongodb.org/mongo-driver/mongo" ) type Bot struct { TwitchClient *twitch.Client + HelixClient *helix.Client MongoClient *mongo.Client Uptime time.Time } diff --git a/cmd/main.go b/cmd/main.go index 02d9c5f..4818d02 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -10,6 +10,7 @@ import ( "github.com/lyx0/nourybot/pkg/config" "github.com/lyx0/nourybot/pkg/db" "github.com/lyx0/nourybot/pkg/handlers" + "github.com/nicklaw5/helix" log "github.com/sirupsen/logrus" ) @@ -24,8 +25,17 @@ func main() { conf := config.LoadConfig() + helixClient, err := helix.NewClient(&helix.Options{ + ClientID: conf.ClientId, + ClientSecret: conf.ClientSecret, + }) + if err != nil { + log.Fatalf("Error creating helix client: %s", err) + } + nb = &bot.Bot{ TwitchClient: twitch.NewClient(conf.Username, conf.Oauth), + HelixClient: helixClient, MongoClient: db.Connect(conf), Uptime: time.Now(), } diff --git a/go.mod b/go.mod index c08b916..99e9489 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,10 @@ require ( require ( github.com/go-stack/stack v1.8.0 // indirect + github.com/golang-jwt/jwt v3.2.1+incompatible // indirect github.com/golang/snappy v0.0.1 // indirect github.com/klauspost/compress v1.13.6 // indirect + github.com/nicklaw5/helix v1.25.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.0.2 // indirect diff --git a/go.sum b/go.sum index 0b36145..31dc50e 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,8 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +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/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= @@ -52,6 +54,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +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/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/pkg/config/config.go b/pkg/config/config.go index 4538075..1432880 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -8,10 +8,12 @@ import ( ) type Config struct { - Username string - Oauth string - BotUserId string - MongoURI string + Username string + Oauth string + ClientId string + ClientSecret string + BotUserId string + MongoURI string } func LoadConfig() *Config { @@ -22,10 +24,12 @@ func LoadConfig() *Config { } cfg := &Config{ - Username: os.Getenv("TWITCH_USER"), - Oauth: os.Getenv("TWITCH_PASS"), - BotUserId: os.Getenv("BOT_USER_ID"), - MongoURI: os.Getenv("MONGO_URI"), + Username: os.Getenv("TWITCH_USER"), + Oauth: os.Getenv("TWITCH_PASS"), + ClientId: os.Getenv("CLIENT_ID"), + ClientSecret: os.Getenv("CLIENT_SECRET"), + BotUserId: os.Getenv("BOT_USER_ID"), + MongoURI: os.Getenv("MONGO_URI"), } log.Info("Config loaded succesfully")