diff --git a/cmd/main.go b/cmd/main.go index 6ca2609..9e1304e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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), diff --git a/pkg/db/addchannel.go b/pkg/db/addchannel.go index 5ad3079..332c42c 100644 --- a/pkg/db/addchannel.go +++ b/pkg/db/addchannel.go @@ -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() diff --git a/pkg/db/connect.go b/pkg/db/connect.go index a3833d1..89be5e6 100644 --- a/pkg/db/connect.go +++ b/pkg/db/connect.go @@ -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 { diff --git a/pkg/db/initialjoin.go b/pkg/db/initialjoin.go index aa85336..1678182 100644 --- a/pkg/db/initialjoin.go +++ b/pkg/db/initialjoin.go @@ -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) } diff --git a/pkg/db/partchannel.go b/pkg/db/partchannel.go index 911c4c5..ea020c6 100644 --- a/pkg/db/partchannel.go +++ b/pkg/db/partchannel.go @@ -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()