media

package
v0.0.0-...-7bda4f7 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnimatedStickerConfig

type AnimatedStickerConfig struct {
	Target          string `yaml:"target"`
	ConvertFromWebm bool   `yaml:"convert_from_webm"`
	Args            struct {
		Width  int `yaml:"width"`
		Height int `yaml:"height"`
		FPS    int `yaml:"fps"`
	} `yaml:"args"`
}

type ConvertedSticker

type ConvertedSticker struct {
	DataWriter        io.Reader
	MIMEType          string
	ThumbnailData     []byte
	ThumbnailMIMEType string
	Width             int
	Height            int
	Size              int
}

type ReadyTransferer

type ReadyTransferer struct {
	// contains filtered or unexported fields
}

func (*ReadyTransferer) DirectDownloadURL

func (t *ReadyTransferer) DirectDownloadURL(ctx context.Context, loggedInUserID int64, portal *bridgev2.Portal, msgID int, thumbnail bool, telegramMediaID int64) (id.ContentURIString, *event.FileInfo, error)

DirectDownloadURL returns the direct download URL for the media.

func (*ReadyTransferer) DownloadBytes

func (t *ReadyTransferer) DownloadBytes(ctx context.Context) ([]byte, error)

DownloadBytes downloads the media from Telegram to a byte buffer.

func (*ReadyTransferer) Stream

func (t *ReadyTransferer) Stream(ctx context.Context) (r io.Reader, mimeType string, fileSize int, err error)

Stream streams the media from Telegram to an io.Reader.

func (*ReadyTransferer) Transfer

func (t *ReadyTransferer) Transfer(ctx context.Context, store *store.Container, intent bridgev2.MatrixAPI) (mxc id.ContentURIString, encryptedFileInfo *event.EncryptedFileInfo, outFileInfo *event.FileInfo, err error)

Transfer downloads the media from Telegram and uploads it to Matrix.

If the file is already in the database, the MXC URI will be reused. The file's MXC URI will only be cached if the room ID is unset or if the room is not encrypted.

If there is a sticker config on the Transferer, this function converts animated stickers to the target format specified by the specified AnimatedStickerConfig.

type Transferer

type Transferer struct {
	// contains filtered or unexported fields
}

Transferer is a utility for downloading media from Telegram and uploading it to Matrix.

func NewTransferer

func NewTransferer(client downloader.Client) *Transferer

NewTransferer creates a new Transferer with the given downloader.Client. The client is used to download the media from Telegram.

func (*Transferer) WithChannelPhoto

func (t *Transferer) WithChannelPhoto(channelID, accessHash, photoID int64) *ReadyTransferer

WithChannelPhoto transforms a Transferer to a ReadyTransferer by setting the given chat photo as the location that will be downloaded by the ReadyTransferer.

func (*Transferer) WithDocument

func (t *Transferer) WithDocument(doc tg.DocumentClass, thumbnail bool) *ReadyTransferer

WithDocument transforms a Transferer to a ReadyTransferer by setting the given document as the location that will be downloaded by the ReadyTransferer.

func (*Transferer) WithFilename

func (t *Transferer) WithFilename(filename string) *Transferer

WithFilename sets the filename for the Transferer.

func (*Transferer) WithImageSize

func (t *Transferer) WithImageSize(attr *tg.DocumentAttributeImageSize) *Transferer

func (*Transferer) WithPhoto

func (t *Transferer) WithPhoto(pc tg.PhotoClass) *ReadyTransferer

WithPhoto transforms a Transferer to a ReadyTransferer by setting the given photo as the location that will be downloaded by the ReadyTransferer.

func (*Transferer) WithRoomID

func (t *Transferer) WithRoomID(roomID id.RoomID) *Transferer

WithRoomID sets the room ID for the Transferer.

func (*Transferer) WithStickerConfig

func (t *Transferer) WithStickerConfig(cfg AnimatedStickerConfig) *Transferer

WithStickerConfig sets the animated sticker config for the Transferer.

func (*Transferer) WithThumbnail

func (t *Transferer) WithThumbnail(uri id.ContentURIString, file *event.EncryptedFileInfo, info *event.FileInfo) *Transferer

func (*Transferer) WithUserPhoto

func (t *Transferer) WithUserPhoto(ctx context.Context, store *store.ScopedStore, user *tg.User, photoID int64) (*ReadyTransferer, error)

WithUser transforms a Transferer to a ReadyTransferer by setting the given user's photo as the location that will be downloaded by the ReadyTransferer.

func (*Transferer) WithVideo

func (t *Transferer) WithVideo(attr *tg.DocumentAttributeVideo) *Transferer

Jump to

Keyboard shortcuts

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