mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
idk
This commit is contained in:
parent
ce9522c9cd
commit
3da33468fe
26
bot/bot.go
Normal file
26
bot/bot.go
Normal file
|
@ -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,
|
||||||
|
}
|
||||||
|
}
|
29
config/config.go
Normal file
29
config/config.go
Normal file
|
@ -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
|
||||||
|
|
||||||
|
}
|
8
go.mod
8
go.mod
|
@ -1,3 +1,11 @@
|
||||||
module github.com/lyx0/nourybot
|
module github.com/lyx0/nourybot
|
||||||
|
|
||||||
go 1.17
|
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
|
||||||
|
|
14
go.sum
Normal file
14
go.sum
Normal file
|
@ -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=
|
Loading…
Reference in a new issue