storage

package
v0.0.0-...-2d94afc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	ID       int
	UserID   int
	ChatID   int
	SentDate time.Time
}

type MessagePicture

type MessagePicture struct {
	ID       int
	UserID   int
	ChatID   int
	SentDate time.Time
	PHash    *goimagehash.ImageHash
	DHash    *goimagehash.ImageHash
}

type MessageVideo

type MessageVideo struct {
	Msg     Message
	PHashes VideoHashes
	DHashes VideoHashes
}

type SimilarMessage

type SimilarMessage struct {
	Msg      *Message
	Distance int
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func New

func New(filepath string) (*Storage, error)

func (*Storage) FindMsgPictureFilter

func (s *Storage) FindMsgPictureFilter(chatID int64, limit int, filter func(msg *MessagePicture) (dist int, ok bool, err error)) ([]*SimilarMessage, error)

FindMsgPictureFilter finds messages in the database and applies a filter to them. The filter function should return the distance between the hashes, whether the message is a match and an error if any. The messages are sorted by distance in descending order. If limit is 0, all matches are returned.

func (*Storage) FindMsgVideoFilter

func (s *Storage) FindMsgVideoFilter(chatID int64, limit int, filter func(msg *MessageVideo) (dist int, ok bool, err error)) ([]*SimilarMessage, error)

func (*Storage) SaveMessagePicture

func (s *Storage) SaveMessagePicture(msg *models.Message, pHash *goimagehash.ImageHash, dHash *goimagehash.ImageHash) error

func (*Storage) SaveMessageVideo

func (s *Storage) SaveMessageVideo(msg *models.Message, pHashes, dHashes *VideoHashes) error

type VideoHashes

type VideoHashes struct {
	FrameA *goimagehash.ImageHash
	FrameB *goimagehash.ImageHash
	FrameC *goimagehash.ImageHash
	FrameD *goimagehash.ImageHash
}

func LoadVideoHashes

func LoadVideoHashes(b io.Reader) (*VideoHashes, error)

LoadVideoHashes method loads a VideoHashes from io.Reader.

func (*VideoHashes) Dump

func (h *VideoHashes) Dump(w io.Writer) error

Dump method writes a binary serialization into w io.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL