media

package
v0.0.0-...-14802c6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(bytes int64) string

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

func (m *Manager) CleanupOldDownloads(maxAge time.Duration) error

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

func (m *Manager) GetDownloadDir() string

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) SendPhoto

func (m *Manager) SendPhoto(ctx context.Context, chatID int64, path string, caption string) error

SendPhoto sends a photo from local path.

func (*Manager) SetDownloadDir

func (m *Manager) SetDownloadDir(dir string) error

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.

Jump to

Keyboard shortcuts

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