msgconv

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedMsgType  = errors.New("unsupported msgtype")
	ErrMediaDownloadFailed = errors.New("failed to download media")
	ErrMediaDecryptFailed  = errors.New("failed to decrypt media")
	ErrMediaConvertFailed  = errors.New("failed to convert")
	ErrMediaUploadFailed   = errors.New("failed to upload media")
	ErrInvalidGeoURI       = errors.New("invalid `geo:` URI in message")
	ErrURLNotFound         = errors.New("url not found")
)
View Source
var BypassOnionForMedia bool
View Source
var ErrTooLargeFile = errors.New("too large file")
View Source
var MediaReferer string

Functions

func DownloadMedia

func DownloadMedia(ctx context.Context, mime, url string, maxSize int64) ([]byte, error)

func UpdateAvatar

func UpdateAvatar(
	ctx context.Context,
	newAvatarURL string,
	avatarID *string, avatarSet *bool, avatarURL *id.ContentURI,
	uploadAvatar func(context.Context, []byte, string) (*mautrix.RespMediaUpload, error),
	setAvatar func(context.Context, id.ContentURI) error,
) bool

Types

type AttachmentMessage

type AttachmentMessage[Integral MediaTransportContainer, Ancillary any, Transport AttachmentTransport[Integral, Ancillary]] interface {
	Decode() (Transport, error)
}

type AttachmentMessageWithCaption

type AttachmentMessageWithCaption[Integral MediaTransportContainer, Ancillary any, Transport AttachmentTransport[Integral, Ancillary]] interface {
	GetCaption() *waCommon.MessageText
}

type AttachmentTransport

type AttachmentTransport[Integral MediaTransportContainer, Ancillary any] interface {
	GetIntegral() Integral
	GetAncillary() Ancillary
}

type ConvertedMessage

type ConvertedMessage struct {
	Parts []*ConvertedMessagePart
}

func (*ConvertedMessage) MergeCaption

func (cm *ConvertedMessage) MergeCaption()

type ConvertedMessagePart

type ConvertedMessagePart struct {
	Type    event.Type
	Content *event.MessageEventContent
	Extra   map[string]any
}

type MediaTransportContainer

type MediaTransportContainer interface {
	GetTransport() *waMediaTransport.WAMediaTransport
}

type MessageConverter

type MessageConverter struct {
	PortalMethods

	ConvertVoiceMessages bool
	ConvertGIFToAPNG     bool
	MaxFileSize          int64
	AsyncFiles           bool
}

func (*MessageConverter) IsPrivateChat

func (mc *MessageConverter) IsPrivateChat(ctx context.Context) bool

func (*MessageConverter) TextToWhatsApp

func (mc *MessageConverter) TextToWhatsApp(content *event.MessageEventContent) *waCommon.MessageText

func (*MessageConverter) ToMatrix

func (*MessageConverter) ToMeta

func (mc *MessageConverter) ToMeta(ctx context.Context, evt *event.Event, content *event.MessageEventContent, relaybotFormatted bool) ([]socket.Task, int64, error)

func (*MessageConverter) ToWhatsApp

func (*MessageConverter) WhatsAppTextToMatrix

func (mc *MessageConverter) WhatsAppTextToMatrix(ctx context.Context, text *waCommon.MessageText) *ConvertedMessagePart

func (*MessageConverter) WhatsAppToMatrix

func (mc *MessageConverter) WhatsAppToMatrix(ctx context.Context, evt *events.FBMessage) *ConvertedMessage

type PortalMethods

type PortalMethods interface {
	UploadMatrixMedia(ctx context.Context, data []byte, fileName, contentType string) (id.ContentURIString, error)
	DownloadMatrixMedia(ctx context.Context, uri id.ContentURIString) ([]byte, error)
	GetMatrixReply(ctx context.Context, messageID string, replyToUser int64) (replyTo id.EventID, replyTargetSender id.UserID)
	GetMetaReply(ctx context.Context, content *event.MessageEventContent) *socket.ReplyMetaData
	GetUserMXID(ctx context.Context, userID int64) id.UserID
	ShouldFetchXMA(ctx context.Context) bool
	GetThreadURL(ctx context.Context) (string, string)

	GetClient(ctx context.Context) *messagix.Client
	GetE2EEClient(ctx context.Context) *whatsmeow.Client
	GetData(ctx context.Context) *database.Portal
}

type UTF16String

type UTF16String []uint16

func NewUTF16String

func NewUTF16String(s string) UTF16String

func (UTF16String) String

func (u UTF16String) String() string

Jump to

Keyboard shortcuts

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