msgconv

package
v0.11.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const FailedMediaField = "fi.mau.whatsapp.failed_media"
View Source
const GroupInviteMetaField = "fi.mau.whatsapp.invite"

Variables

View Source
var URLRegex = regexp.MustCompile(`https?://[^\s/_*]+(?:/\S*)?`)

Functions

func KeyToMessageID added in v0.11.1

func KeyToMessageID(client *whatsmeow.Client, chat, sender types.JID, key *waCommon.MessageKey) networkid.MessageID

Types

type AnimatedStickerConfig

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

type FailedMediaKeys

type FailedMediaKeys struct {
	Key        []byte              `json:"key"`
	Length     uint64              `json:"length"`
	Type       whatsmeow.MediaType `json:"type"`
	SHA256     []byte              `json:"sha256"`
	EncSHA256  []byte              `json:"enc_sha256"`
	DirectPath string              `json:"direct_path,omitempty"`
}

func (*FailedMediaKeys) GetDirectPath

func (f *FailedMediaKeys) GetDirectPath() string

func (*FailedMediaKeys) GetFileEncSHA256

func (f *FailedMediaKeys) GetFileEncSHA256() []byte

func (*FailedMediaKeys) GetFileLength

func (f *FailedMediaKeys) GetFileLength() uint64

func (*FailedMediaKeys) GetFileSHA256

func (f *FailedMediaKeys) GetFileSHA256() []byte

func (*FailedMediaKeys) GetMediaKey

func (f *FailedMediaKeys) GetMediaKey() []byte

func (*FailedMediaKeys) GetMediaType

func (f *FailedMediaKeys) GetMediaType() whatsmeow.MediaType

type MediaMessage

type MediaMessage interface {
	whatsmeow.DownloadableMessage
	GetContextInfo() *waE2E.ContextInfo
	GetFileLength() uint64
	GetMimetype() string
}

type MediaMessageWithCaption

type MediaMessageWithCaption interface {
	MediaMessage
	GetCaption() string
}

type MediaMessageWithDimensions

type MediaMessageWithDimensions interface {
	MediaMessage
	GetHeight() uint32
	GetWidth() uint32
}

type MediaMessageWithDuration

type MediaMessageWithDuration interface {
	MediaMessage
	GetSeconds() uint32
}

type MediaMessageWithFileName

type MediaMessageWithFileName interface {
	MediaMessage
	GetFileName() string
}

type MediaMessageWithThumbnail

type MediaMessageWithThumbnail interface {
	MediaMessage
	GetJPEGThumbnail() []byte
}

type MessageConverter

type MessageConverter struct {
	Bridge                *bridgev2.Bridge
	DB                    *wadb.Database
	MaxFileSize           int64
	HTMLParser            *format.HTMLParser
	AnimatedStickerConfig AnimatedStickerConfig
	FetchURLPreviews      bool
	ExtEvPolls            bool
	DisableViewOnce       bool
	DirectMedia           bool
	OldMediaSuffix        string
}

func New

func (*MessageConverter) MediaRetryToMatrix

func (mc *MessageConverter) MediaRetryToMatrix(
	ctx context.Context,
	part *PreparedMedia,
	client *whatsmeow.Client,
	intent bridgev2.MatrixAPI,
	portal *bridgev2.Portal,
	existingPart *database.Message,
) *bridgev2.ConvertedEdit

func (*MessageConverter) PollStartToWhatsApp

func (mc *MessageConverter) PollStartToWhatsApp(
	ctx context.Context,
	content *event.PollStartEventContent,
	replyTo *database.Message,
	portal *bridgev2.Portal,
) (*waE2E.Message, map[[32]byte]string, error)

func (*MessageConverter) PollVoteToWhatsApp

func (mc *MessageConverter) PollVoteToWhatsApp(
	ctx context.Context,
	client *whatsmeow.Client,
	content *event.PollResponseEventContent,
	pollMsg *database.Message,
) (*waE2E.Message, error)

func (*MessageConverter) ToMatrix

func (mc *MessageConverter) ToMatrix(
	ctx context.Context,
	portal *bridgev2.Portal,
	client *whatsmeow.Client,
	intent bridgev2.MatrixAPI,
	waMsg *waE2E.Message,
	info *types.MessageInfo,
	isViewOnce bool,
	previouslyConvertedPart *bridgev2.ConvertedMessagePart,
) *bridgev2.ConvertedMessage

func (*MessageConverter) ToWhatsApp

func (mc *MessageConverter) ToWhatsApp(
	ctx context.Context,
	client *whatsmeow.Client,
	evt *event.Event,
	content *event.MessageEventContent,
	replyTo *database.Message,
	portal *bridgev2.Portal,
) (*waE2E.Message, error)

type PaddedImage

type PaddedImage struct {
	image.Image
	Size    int
	OffsetX int
	OffsetY int
}

func (*PaddedImage) At

func (img *PaddedImage) At(x, y int) color.Color

func (*PaddedImage) Bounds

func (img *PaddedImage) Bounds() image.Rectangle

type PreparedMedia

type PreparedMedia struct {
	Type                       event.Type `json:"type"`
	*event.MessageEventContent `json:"content"`
	Extra                      map[string]any     `json:"extra"`
	FailedKeys                 *FailedMediaKeys   `json:"whatsapp_media"`          // only for failed media
	MentionedJID               []string           `json:"mentioned_jid,omitempty"` // only for failed media
	TypeDescription            string             `json:"type_description"`
	ContextInfo                *waE2E.ContextInfo `json:"-"`
}

func (*PreparedMedia) FillFileName added in v0.11.1

func (pm *PreparedMedia) FillFileName() *PreparedMedia

Jump to

Keyboard shortcuts

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