imgstore

package
v0.0.0-...-d931726 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ImgUrlSRx = regexp.MustCompile(`^https?:\/\/([\w-]+\.)+([\w-]+)(\/[\w-]+)*.*\.(png|jpg|jpeg|gif|ico|tiff|img|bmp|mp4)$`)
)

Functions

func ExtractFromMessage

func ExtractFromMessage(text string, attachments []*discordgo.MessageAttachment) (resText, imgLink string)

ExtractFromMessage tries to extract an image URL from the passed text or message attachments and returns the text of the message excluding the matched link and the image link.

func GetLink(ident, publicAddr string) string

GetLink returns the publicly accessable link for an image resource by passed ident and publicAddr.

Types

type Image

type Image struct {
	ID       snowflake.ID
	MimeType string
	Data     []byte
	Size     int
}

Image wraps metadata and data of an image.

func DownloadFromURL

func DownloadFromURL(url string) (img *Image, err error)

DownloadFromURL tries to GET an image from the passed resource URL, downloading it and returning the metadata and data of the image as well as occured errors.

func (*Image) GenerateID

func (img *Image) GenerateID()

Jump to

Keyboard shortcuts

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