store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	JID             string     `json:"jid"`
	Name            *string    `json:"name,omitempty"`
	IsGroup         bool       `json:"is_group"`
	LastMessageTime *time.Time `json:"last_message_time,omitempty"`
	LastMessage     *string    `json:"last_message,omitempty"`
	LastSender      *string    `json:"last_sender,omitempty"`
	LastIsFromMe    *bool      `json:"last_is_from_me,omitempty"`
}

Chat represents a WhatsApp chat (direct message or group).

type ChatWithRecent

type ChatWithRecent struct {
	Chat           Chat      `json:"chat"`
	RecentMessages []Message `json:"recent_messages"`
}

ChatWithRecent represents a chat with its recent messages.

type ConnectionStatus

type ConnectionStatus struct {
	Connected bool        `json:"connected"`
	LoggedIn  bool        `json:"logged_in"`
	Device    *DeviceInfo `json:"device,omitempty"`
	Database  *DBStats    `json:"database,omitempty"`
}

ConnectionStatus represents the WhatsApp connection status.

type Contact

type Contact struct {
	JID   string  `json:"jid"`
	Phone string  `json:"phone_number"`
	Name  *string `json:"name,omitempty"`
}

Contact represents a WhatsApp contact.

type ContextResult

type ContextResult struct {
	Connection  *ConnectionStatus `json:"connection"`
	RecentChats []ChatWithRecent  `json:"recent_chats"`
}

ContextResult represents aggregated context for LLMs.

type DB

type DB struct {
	Messages *sql.DB
}

DB wraps the messages database connection.

func Open

func Open(dbPath string) (*DB, error)

Open opens the messages database at the given path.

func (*DB) Close

func (d *DB) Close() error

Close closes all database connections.

func (*DB) CloseQuietly

func (d *DB) CloseQuietly()

CloseQuietly closes all database connections, ignoring any errors.

func (*DB) CountChats

func (d *DB) CountChats(query string) (int, error)

CountChats returns the total number of chats matching the query.

func (*DB) CountMessages

func (d *DB) CountMessages() (int, error)

CountMessages returns the total number of messages.

func (*DB) GetChatName

func (d *DB) GetChatName(jid string) string

GetChatName returns the name of a chat by JID.

func (*DB) GetLIDMapping

func (d *DB) GetLIDMapping(lid string) (phone, name string, found bool)

GetLIDMapping retrieves a LID mapping.

func (*DB) GetLastSyncTime added in v0.2.0

func (d *DB) GetLastSyncTime() (time.Time, error)

GetLastSyncTime returns the last sync time, or zero time if never synced.

func (*DB) ListChats

func (d *DB) ListChats(opts ListChatsOptions) ([]Chat, error)

ListChats returns chats matching the given options.

func (*DB) ListMessages

func (d *DB) ListMessages(opts ListMessagesOptions) ([]Message, error)

ListMessages returns messages matching the given options.

func (*DB) ResolveSenderName

func (d *DB) ResolveSenderName(sender string) string

ResolveSenderName tries to resolve a sender identifier to a display name.

func (*DB) SearchMessages

func (d *DB) SearchMessages(opts SearchMessagesOptions) ([]Message, error)

SearchMessages performs full-text search on messages.

func (*DB) SetLastSyncTime added in v0.2.0

func (d *DB) SetLastSyncTime(t time.Time) error

SetLastSyncTime stores the last sync time.

func (*DB) StoreLIDMapping

func (d *DB) StoreLIDMapping(lid, phone, name string) error

StoreLIDMapping stores a LID -> phone/name mapping.

type DBStats

type DBStats struct {
	Chats    int `json:"chats"`
	Messages int `json:"messages"`
}

DBStats contains database statistics.

type DeviceInfo

type DeviceInfo struct {
	User   string `json:"user"`
	Device uint16 `json:"device"`
}

DeviceInfo contains device information.

type DownloadResult

type DownloadResult struct {
	Filename string `json:"filename"`
	Path     string `json:"path"`
}

DownloadResult represents the result of downloading media.

type GroupInfo

type GroupInfo struct {
	JID          string        `json:"jid"`
	Name         string        `json:"name"`
	Topic        string        `json:"topic,omitempty"`
	Created      time.Time     `json:"created"`
	CreatorJID   string        `json:"creator_jid,omitempty"`
	Participants []Participant `json:"participants,omitempty"`
}

GroupInfo represents WhatsApp group information.

type ListChatsOptions

type ListChatsOptions struct {
	Query      string
	OnlyGroups bool
	Limit      int
	Page       int
}

ListChatsOptions contains options for listing chats.

type ListMessagesOptions

type ListMessagesOptions struct {
	After     string
	Before    string
	Timeframe string
	ChatJID   string
	Type      string
	Limit     int
	Page      int
}

ListMessagesOptions contains options for listing messages.

type Message

type Message struct {
	ID         string    `json:"id"`
	ChatJID    string    `json:"chat_jid"`
	Sender     string    `json:"sender"`
	SenderName *string   `json:"sender_name,omitempty"`
	Content    *string   `json:"content,omitempty"`
	Timestamp  time.Time `json:"timestamp"`
	IsFromMe   bool      `json:"is_from_me"`
	MediaType  *string   `json:"media_type,omitempty"`
	Filename   *string   `json:"filename,omitempty"`
	ChatName   *string   `json:"chat_name,omitempty"`
}

Message represents a WhatsApp message.

type Participant

type Participant struct {
	JID     string  `json:"jid"`
	LID     *string `json:"lid,omitempty"`
	Phone   *string `json:"phone,omitempty"`
	IsAdmin bool    `json:"is_admin"`
	Name    string  `json:"name,omitempty"`
}

Participant represents a group participant.

type SearchMessagesOptions

type SearchMessagesOptions struct {
	Query     string
	ChatJID   string
	FromJID   string
	After     string
	Before    string
	Timeframe string
	Type      string
	Limit     int
	Page      int
}

SearchMessagesOptions contains options for searching messages.

type SendResult

type SendResult struct {
	MessageID string `json:"message_id"`
	ChatJID   string `json:"chat_jid"`
	Timestamp string `json:"timestamp"`
}

SendResult represents the result of sending a message.

Jump to

Keyboard shortcuts

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