helper

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 18 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanConvertTgsToX added in v1.18.1

func CanConvertTgsToX() error

CanConvertTgsToX Checks whether the external command necessary for ConvertTgsToX works.

func ClipMessage added in v1.11.1

func ClipMessage(text string, length int) string

ClipMessage trims a message to the specified length if it exceeds it and adds a warning to the message in case it does so.

func ConvertTgsToX added in v1.18.1

func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) error

ConvertTgsToWebP convert input data (which should be tgs format) to WebP format This relies on an external command, which is ugly, but works.

func ConvertWebPToPNG added in v1.14.0

func ConvertWebPToPNG(data *[]byte) error

ConvertWebPToPNG converts input data (which should be WebP format) to PNG format

func DownloadFile

func DownloadFile(url string) (*[]byte, error)

DownloadFile downloads the given non-authenticated URL.

func DownloadFileAuth added in v1.9.0

func DownloadFileAuth(url string, auth string) (*[]byte, error)

DownloadFileAuth downloads the given URL using the specified authentication token.

func GetAvatar added in v1.8.0

func GetAvatar(av map[string]string, userid string, general *config.Protocol) string

GetAvatar constructs a URL for a given user-avatar if it is available in the cache.

func GetSubLines added in v1.12.0

func GetSubLines(message string, maxLineLength int) []string

GetSubLines splits messages in newline-delimited lines. If maxLineLength is specified as non-zero GetSubLines will also clip long lines to the maximum length and insert a warning marker that the line was clipped.

TODO: The current implementation has the inconvenient that it disregards word boundaries when splitting but this is hard to solve without potentially breaking formatting and other stylistic effects.

func HandleDownloadData added in v1.9.0

func HandleDownloadData(logger *logrus.Entry, msg *config.Message, name, comment, url string, data *[]byte, general *config.Protocol)

HandleDownloadData adds the data for a remote file into a Matterbridge gateway message.

func HandleDownloadSize added in v1.9.0

func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string, size int64, general *config.Protocol) error

HandleDownloadSize checks a specified filename against the configured download blacklist and checks a specified file-size against the configure limit.

func HandleExtra added in v1.8.0

func HandleExtra(msg *config.Message, general *config.Protocol) []config.Message

HandleExtra manages the supplementary details stored inside a message's 'Extra' field map.

func ParseMarkdown added in v1.13.0

func ParseMarkdown(input string) string

ParseMarkdown takes in an input string as markdown and parses it to html

func RemoveEmptyNewLines added in v1.9.1

func RemoveEmptyNewLines(msg string) string

RemoveEmptyNewLines collapses consecutive newline characters into a single one and trims any preceding or trailing newline characters as well.

Types

This section is empty.

Jump to

Keyboard shortcuts

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