mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
part works
This commit is contained in:
parent
cb0181c01f
commit
4171d11dae
32
pkg/db/partchannel.go
Normal file
32
pkg/db/partchannel.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func PartChannel(channelName string) {
|
||||
// Interact with data
|
||||
|
||||
client := Connect()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
/*
|
||||
Get my collection instance
|
||||
*/
|
||||
collection := client.Database("nourybot").Collection("channels")
|
||||
|
||||
// Channel
|
||||
chnl := Channel{channelName, true}
|
||||
|
||||
res, insertErr := collection.DeleteOne(ctx, chnl)
|
||||
if insertErr != nil {
|
||||
log.Error(insertErr)
|
||||
}
|
||||
log.Info(res)
|
||||
|
||||
}
|
|
@ -144,6 +144,11 @@ func Command(message twitch.PrivateMessage, nb *bot.Bot) {
|
|||
case "join":
|
||||
db.AddChannel(cmdParams[1])
|
||||
nb.Send(message.Channel, "Joined")
|
||||
return
|
||||
|
||||
case "part":
|
||||
db.PartChannel(cmdParams[1])
|
||||
nb.Send(message.Channel, "Parted")
|
||||
|
||||
case "firstline":
|
||||
if msgLen == 1 {
|
||||
|
|
Loading…
Reference in a new issue