log middleware

This commit is contained in:
2025-09-29 09:14:39 +03:00
parent 49ffe9ae03
commit e15d56196d
27 changed files with 641 additions and 164 deletions

23
database/mdb/logs.go Normal file
View 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
}