From ff135f615b705db3302e3ce43db6d18652c2d0cb Mon Sep 17 00:00:00 2001 From: lyx0 Date: Wed, 27 Oct 2021 19:41:42 +0200 Subject: [PATCH] join/say works --- cmd/main.go | 6 +++--- pkg/db/connect.go | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 4fe4359..ce8bea5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -18,7 +18,6 @@ func main() { conf := config.LoadConfig() // db.InsertInitialData() - db.ListChannels() nb = &bot.Bot{ TwitchClient: twitch.NewClient(conf.Username, conf.Oauth), @@ -43,7 +42,8 @@ func main() { handlers.PrivateMessage(message, nb) }) - nb.TwitchClient.Join("nouryqt", "nourybot") - nb.Send("nourybot", "HeyGuys") + // nb.TwitchClient.Join("nouryqt", "nourybot") + db.ListChannels(nb) + // nb.Send("nourybot", "HeyGuys") nb.TwitchClient.Connect() } diff --git a/pkg/db/connect.go b/pkg/db/connect.go index f55e953..6496604 100644 --- a/pkg/db/connect.go +++ b/pkg/db/connect.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/lyx0/nourybot/cmd/bot" "github.com/lyx0/nourybot/pkg/config" log "github.com/sirupsen/logrus" "go.mongodb.org/mongo-driver/bson" @@ -67,14 +68,14 @@ func InsertInitialData() { } -func ListChannels() { +func ListChannels(nb *bot.Bot) { client := Connect() collection := client.Database("nourybot").Collection("channels") ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) defer client.Disconnect(ctx) - cur, currErr := collection.Find(ctx, bson.D{{Key: "connect", Value: true}}) + cur, currErr := collection.Find(ctx, bson.D{}) if currErr != nil { panic(currErr) @@ -87,7 +88,9 @@ func ListChannels() { } for _, ch := range channels { - fmt.Printf("%v", ch.Name) + nb.TwitchClient.Join(ch.Name) + nb.TwitchClient.Say(ch.Name, "xd") + // fmt.Printf("%v\n", ch.Name) } }