mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add some comments
This commit is contained in:
parent
f02e88cd32
commit
432edf4e63
5 changed files with 9 additions and 3 deletions
|
@ -17,8 +17,6 @@ func main() {
|
|||
|
||||
conf := config.LoadConfig()
|
||||
|
||||
// db.InsertInitialData()
|
||||
|
||||
nb = &bot.Bot{
|
||||
TwitchClient: twitch.NewClient(conf.Username, conf.Oauth),
|
||||
MongoClient: db.Connect(conf),
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// AddChannel adds a given channel name to the database.
|
||||
func AddChannel(target, channelName string, nb *bot.Bot) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
|
|
@ -11,6 +11,8 @@ import (
|
|||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
// Connect connects the the MongoDB database through a supplied cfg
|
||||
// and returns a *mongo.Client
|
||||
func Connect(cfg *config.Config) *mongo.Client {
|
||||
client, err := mongo.NewClient(options.Client().ApplyURI(cfg.MongoURI))
|
||||
if err != nil {
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// InitialJoin is called everytime the Bot starts and joins the
|
||||
// initial list of twitch channels it should be in.
|
||||
func InitialJoin(nb *bot.Bot) {
|
||||
collection := nb.MongoClient.Database("nourybot").Collection("channels")
|
||||
|
||||
|
@ -31,7 +33,7 @@ func InitialJoin(nb *bot.Bot) {
|
|||
|
||||
for _, ch := range channels {
|
||||
nb.TwitchClient.Join(ch.Name)
|
||||
nb.TwitchClient.Say(ch.Name, "xd")
|
||||
// nb.TwitchClient.Say(ch.Name, "xd")
|
||||
log.Infof("Joined: %s\n", ch.Name)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// PartChannel takes in a target channel and querys the database for
|
||||
// its name. If the channel is found it deletes the channel and returns a
|
||||
// success message. If the channel couldn't be found it will return an error.
|
||||
func PartChannel(target, channelName string, nb *bot.Bot) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
|
Loading…
Reference in a new issue