From 3da33468fe6369acbd725c3178dfaed31a9e0b0f Mon Sep 17 00:00:00 2001 From: lyx0 Date: Wed, 13 Oct 2021 21:30:31 +0200 Subject: [PATCH] idk --- bot/bot.go | 26 ++++++++++++++++++++++++++ config/config.go | 29 +++++++++++++++++++++++++++++ go.mod | 8 ++++++++ go.sum | 14 ++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 bot/bot.go create mode 100644 config/config.go create mode 100644 go.sum diff --git a/bot/bot.go b/bot/bot.go new file mode 100644 index 0000000..5a608bd --- /dev/null +++ b/bot/bot.go @@ -0,0 +1,26 @@ +package bot + +import ( + twitch "github.com/gempir/go-twitch-irc/v2" + cfg "github.com/lyx0/nourybot/config" + log "github.com/sirupsen/logrus" +) + +type Bot struct { + twitchClient *twitch.Client + cfg *cfg.Config + log *log.Logger +} + +func (b *Bot) newTwitchClient() *twitch.Client { + twitchClient := twitch.NewClient(b.cfg.Username, b.cfg.Oauth) + return twitchClient +} + +func NewBot(cfg *cfg.Config, log *log.Logger, twitchClient *twitch.Client) *Bot { + return &Bot{ + cfg: cfg, + twitchClient: twitchClient, + log: log, + } +} diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..f43aa23 --- /dev/null +++ b/config/config.go @@ -0,0 +1,29 @@ +package config + +import ( + "os" + + "github.com/joho/godotenv" + log "github.com/sirupsen/logrus" +) + +type Config struct { + Username string + Oauth string +} + +func LoadConfig() *Config { + err := godotenv.Load() + if err != nil { + log.Fatal("Error loading .env") + } + + cfg := &Config{ + Username: os.Getenv("TWITCH_USER"), + Oauth: os.Getenv("TWITCH_PASS"), + } + log.Info("Config loaded succesfully") + + return cfg + +} diff --git a/go.mod b/go.mod index 92f84d7..5768914 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,11 @@ module github.com/lyx0/nourybot go 1.17 + +require ( + github.com/gempir/go-twitch-irc/v2 v2.5.0 + github.com/joho/godotenv v1.4.0 + github.com/sirupsen/logrus v1.8.1 +) + +require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..66b746c --- /dev/null +++ b/go.sum @@ -0,0 +1,14 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gempir/go-twitch-irc/v2 v2.5.0 h1:aybXNoyDNQaa4vHhXb0UpIDmspqutQUmXIYUFsjgecU= +github.com/gempir/go-twitch-irc/v2 v2.5.0/go.mod h1:120d2SdlRYg8tRnZwsyNPeS+mWPn+YmNEzB7Bv/CDGE= +github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= +github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=