log middleware
This commit is contained in:
23
database/mdb/logs.go
Normal file
23
database/mdb/logs.go
Normal file
@@ -0,0 +1,23 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user