Documentation
¶
Index ¶
- func FormatSize(bytes int64) string
- type Manager
- func (m *Manager) CleanupOldDownloads(maxAge time.Duration) error
- func (m *Manager) DownloadAndReply(ctx *interfaces.CommandContext) error
- func (m *Manager) DownloadMedia(ctx context.Context, msg *interfaces.MessageEvent) (string, error)
- func (m *Manager) GetDownloadDir() string
- func (m *Manager) SendDocument(ctx context.Context, chatID int64, path string, caption string) error
- func (m *Manager) SendFile(ctx context.Context, chatID int64, path string, caption string, replyTo int) error
- func (m *Manager) SendPhoto(ctx context.Context, chatID int64, path string, caption string) error
- func (m *Manager) SetDownloadDir(dir string) error
- func (m *Manager) UploadFile(ctx context.Context, chatID int64, path string) (tg.InputMediaClass, error)
- type MediaInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatSize ¶
FormatSize formats bytes to human readable string.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles media upload/download operations.
func NewManager ¶
func NewManager(api *tg.Client, resolver interfaces.PeerResolver, downloadDir string) *Manager
NewManager creates a media manager.
func (*Manager) CleanupOldDownloads ¶
CleanupOldDownloads removes files older than maxAge.
func (*Manager) DownloadAndReply ¶
func (m *Manager) DownloadAndReply(ctx *interfaces.CommandContext) error
DownloadAndReply downloads media from message and sends back as file.
func (*Manager) DownloadMedia ¶
func (m *Manager) DownloadMedia(ctx context.Context, msg *interfaces.MessageEvent) (string, error)
DownloadMedia downloads media from a message to local file.
func (*Manager) GetDownloadDir ¶
GetDownloadDir returns the download directory.
func (*Manager) SendDocument ¶
func (m *Manager) SendDocument(ctx context.Context, chatID int64, path string, caption string) error
SendDocument sends a document from local path.
func (*Manager) SendFile ¶
func (m *Manager) SendFile(ctx context.Context, chatID int64, path string, caption string, replyTo int) error
SendFile sends a local file to a chat.
func (*Manager) SetDownloadDir ¶
SetDownloadDir changes the download directory.
func (*Manager) UploadFile ¶
func (m *Manager) UploadFile(ctx context.Context, chatID int64, path string) (tg.InputMediaClass, error)
UploadFile uploads a local file and returns InputMedia for sending.
type MediaInfo ¶
type MediaInfo struct {
Type string // photo, document, video, audio, voice, sticker, etc.
MIMEType string
FileName string
FileSize int64
Width int
Height int
Duration int
IsAnimated bool
}
MediaInfo holds extracted media metadata.
func ExtractInfo ¶
func ExtractInfo(media tg.MessageMediaClass) *MediaInfo
ExtractInfo extracts metadata from message media.