24 lines
566 B
Go
24 lines
566 B
Go
package mdb
|
|
|
|
import (
|
|
"context"
|
|
"kurumibot/laniakea"
|
|
"time"
|
|
)
|
|
|
|
type MessageLogEntry struct {
|
|
MessageID int `bson:"messageId"`
|
|
SenderID int `bson:"senderId"`
|
|
ChatID int `bson:"chatId"`
|
|
Text string `bson:"text"`
|
|
TimeStamp int64 `bson:"timestamp"`
|
|
}
|
|
|
|
func WriteMessageLog(db *laniakea.DatabaseContext, e *MessageLogEntry) error {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
collection := db.MongoDB.Database("kurumi").Collection("msg_logs")
|
|
_, err := collection.InsertOne(ctx, e)
|
|
return err
|
|
}
|