join/say works

This commit is contained in:
lyx0 2021-10-27 19:41:42 +02:00
parent 95e8fe0ade
commit ff135f615b
2 changed files with 9 additions and 6 deletions

View file

@ -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()
}

View file

@ -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)
}
}