mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
join/say works
This commit is contained in:
parent
95e8fe0ade
commit
ff135f615b
|
@ -18,7 +18,6 @@ func main() {
|
||||||
conf := config.LoadConfig()
|
conf := config.LoadConfig()
|
||||||
|
|
||||||
// db.InsertInitialData()
|
// db.InsertInitialData()
|
||||||
db.ListChannels()
|
|
||||||
|
|
||||||
nb = &bot.Bot{
|
nb = &bot.Bot{
|
||||||
TwitchClient: twitch.NewClient(conf.Username, conf.Oauth),
|
TwitchClient: twitch.NewClient(conf.Username, conf.Oauth),
|
||||||
|
@ -43,7 +42,8 @@ func main() {
|
||||||
handlers.PrivateMessage(message, nb)
|
handlers.PrivateMessage(message, nb)
|
||||||
})
|
})
|
||||||
|
|
||||||
nb.TwitchClient.Join("nouryqt", "nourybot")
|
// nb.TwitchClient.Join("nouryqt", "nourybot")
|
||||||
nb.Send("nourybot", "HeyGuys")
|
db.ListChannels(nb)
|
||||||
|
// nb.Send("nourybot", "HeyGuys")
|
||||||
nb.TwitchClient.Connect()
|
nb.TwitchClient.Connect()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/lyx0/nourybot/cmd/bot"
|
||||||
"github.com/lyx0/nourybot/pkg/config"
|
"github.com/lyx0/nourybot/pkg/config"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
@ -67,14 +68,14 @@ func InsertInitialData() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListChannels() {
|
func ListChannels(nb *bot.Bot) {
|
||||||
client := Connect()
|
client := Connect()
|
||||||
|
|
||||||
collection := client.Database("nourybot").Collection("channels")
|
collection := client.Database("nourybot").Collection("channels")
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer client.Disconnect(ctx)
|
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 {
|
if currErr != nil {
|
||||||
panic(currErr)
|
panic(currErr)
|
||||||
|
@ -87,7 +88,9 @@ func ListChannels() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ch := range channels {
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue