Documentation
¶
Index ¶
- type Chat
- type ChatWithRecent
- type ConnectionStatus
- type Contact
- type ContextResult
- type DB
- func (d *DB) Close() error
- func (d *DB) CloseQuietly()
- func (d *DB) CountChats(query string) (int, error)
- func (d *DB) CountMessages() (int, error)
- func (d *DB) GetChatName(jid string) string
- func (d *DB) GetLIDMapping(lid string) (phone, name string, found bool)
- func (d *DB) GetLastSyncTime() (time.Time, error)
- func (d *DB) ListChats(opts ListChatsOptions) ([]Chat, error)
- func (d *DB) ListMessages(opts ListMessagesOptions) ([]Message, error)
- func (d *DB) ResolveSenderName(sender string) string
- func (d *DB) SearchMessages(opts SearchMessagesOptions) ([]Message, error)
- func (d *DB) SetLastSyncTime(t time.Time) error
- func (d *DB) StoreLIDMapping(lid, phone, name string) error
- type DBStats
- type DeviceInfo
- type DownloadResult
- type GroupInfo
- type ListChatsOptions
- type ListMessagesOptions
- type Message
- type Participant
- type SearchMessagesOptions
- type SendResult
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 ¶
DB wraps the messages database connection.
func (*DB) CloseQuietly ¶
func (d *DB) CloseQuietly()
CloseQuietly closes all database connections, ignoring any errors.
func (*DB) CountChats ¶
CountChats returns the total number of chats matching the query.
func (*DB) CountMessages ¶
CountMessages returns the total number of messages.
func (*DB) GetChatName ¶
GetChatName returns the name of a chat by JID.
func (*DB) GetLIDMapping ¶
GetLIDMapping retrieves a LID mapping.
func (*DB) GetLastSyncTime ¶ added in v0.2.0
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 ¶
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
SetLastSyncTime stores the last sync time.
func (*DB) StoreLIDMapping ¶
StoreLIDMapping stores a LID -> phone/name mapping.
type DeviceInfo ¶
DeviceInfo contains device information.
type DownloadResult ¶
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 ¶
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.