Documentation
¶
Overview ¶
Package files provides file processing utilities for Telegram messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ProcessedFile ¶
type ProcessedFile struct {
// LLMParts contains the file data formatted for OpenRouter API
// (ImagePart, FilePart, TextPart from openrouter package)
LLMParts []interface{}
// Instruction is the localized LLM instruction for this file type
// (e.g., "Quote the transcription..." for voice messages)
Instruction string
// FileType indicates the type of file
FileType FileType
// FileID is the Telegram file ID
FileID string
// FileName is the original file name (if available)
FileName string
// MimeType is the MIME type of the file
MimeType string
// Size is the file size in bytes
Size int64
// Duration is the download time (for metrics)
Duration time.Duration
}
ProcessedFile represents a processed file ready for LLM consumption.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor handles file downloads and processing from Telegram messages.
func NewProcessor ¶
func NewProcessor( downloader telegram.FileDownloader, translator *i18n.Translator, language string, logger *slog.Logger, ) *Processor
NewProcessor creates a new file processor.
func (*Processor) ProcessMessage ¶
func (p *Processor) ProcessMessage(ctx context.Context, msg *telegram.Message, userID int64) ([]*ProcessedFile, error)
ProcessMessage extracts and processes the file from a message. A Telegram message contains at most one file (photo OR document OR voice). Individual file errors are logged as warnings and nil is returned for that file. Returns a slice with 0 or 1 successfully processed files.
Click to show internal directories.
Click to hide internal directories.