emotes

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadEmote

func DownloadEmote(emote Emote, size ImageSize) ([]byte, error)

func DownloadEmoteHalves

func DownloadEmoteHalves(emote Emote, size ImageSize) ([]byte, []byte, error)

func FormatBTTVEmote

func FormatBTTVEmote(id string, size ImageSize) string

func FormatFFZEmote

func FormatFFZEmote(id string, size ImageSize) string

func InitIdealGifFrames

func InitIdealGifFrames(path string)

func ShouldNotCache added in v1.2.0

func ShouldNotCache(emote Emote) bool

Types

type BttvChannelResponse

type BttvChannelResponse struct {
	ChanEmotes   []*BttvEmote `json:"channelEmotes"`
	SharedEmotes []*BttvEmote `json:"sharedEmotes"`
}

type BttvEmote

type BttvEmote struct {
	ID        string `json:"id"`
	Code      string `json:"code"`
	ImageType string `json:"imageType"`
}

func GetChannelBTTVEmotes

func GetChannelBTTVEmotes(channelID string) ([]*BttvEmote, error)

func GetGlobalBTTVEmotes

func GetGlobalBTTVEmotes() ([]*BttvEmote, error)

func GetSpecificBTTVEmote

func GetSpecificBTTVEmote(emoteID string) (*BttvEmote, error)

func (*BttvEmote) EmoteID

func (b *BttvEmote) EmoteID() string

func (*BttvEmote) LetterCode

func (b *BttvEmote) LetterCode() string

func (*BttvEmote) Type

func (b *BttvEmote) Type() string

func (*BttvEmote) TypedName added in v1.2.0

func (b *BttvEmote) TypedName() string

func (*BttvEmote) URL

func (b *BttvEmote) URL(size ImageSize) string

type BttvProvider added in v1.2.0

type BttvProvider struct{}

func (BttvProvider) IdentifierCode added in v1.2.0

func (b BttvProvider) IdentifierCode() rune

func (BttvProvider) LoadChannelEmotes added in v1.2.0

func (b BttvProvider) LoadChannelEmotes(channelID string) ([]Emote, error)

func (BttvProvider) LoadGlobalEmotes added in v1.2.0

func (b BttvProvider) LoadGlobalEmotes() ([]Emote, error)

func (BttvProvider) LoadSpecificEmote added in v1.2.0

func (b BttvProvider) LoadSpecificEmote(emoteID string) (Emote, error)

type Emote

type Emote interface {
	// EmoteID is an identifier string for the emote within its provider's realm.
	EmoteID() string

	// TypedName is the name that people type into Twitch chat.
	TypedName() string

	// URL returns the URL to render the emote for the given size.
	URL(size ImageSize) string

	// LetterCode returns the provider prefix letter code.
	LetterCode() string

	// Type returns the emote type/mimetype of the image.
	Type() string
}

type EmoteStore

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

func NewEmoteStore

func NewEmoteStore() *EmoteStore

func (*EmoteStore) GetChannelEmotes

func (s *EmoteStore) GetChannelEmotes(channelID string) ([]Emote, bool)

func (*EmoteStore) GetEmote added in v1.2.0

func (s *EmoteStore) GetEmote(identifierCode rune, emoteID string) (Emote, bool)

func (*EmoteStore) GetEmoteFromWord

func (s *EmoteStore) GetEmoteFromWord(word, channelID string) (Emote, bool)

func (*EmoteStore) Init

func (s *EmoteStore) Init() error

func (*EmoteStore) Load

func (s *EmoteStore) Load(channelID string) error

func (*EmoteStore) LoadIfNotLoaded

func (s *EmoteStore) LoadIfNotLoaded(channelID string) error

LoadIfNotLoaded loads and caches BTTV and FFZ emotes for a channel

func (*EmoteStore) ProviderFromCode added in v1.2.0

func (s *EmoteStore) ProviderFromCode(identifierCode rune) (Provider, bool)

type FfzEmote

type FfzEmote struct {
	ID     int     `json:"id"`
	Name   string  `json:"name"`
	Images FfzUrls `json:"urls"`
}

func GetChannelFFZEmotes

func GetChannelFFZEmotes(channelID string) ([]*FfzEmote, error)

func GetGlobalFFZEmotes

func GetGlobalFFZEmotes() ([]*FfzEmote, error)

func GetSpecificFFZEmote

func GetSpecificFFZEmote(emoteID string) (*FfzEmote, error)

func (*FfzEmote) EmoteID

func (f *FfzEmote) EmoteID() string

func (*FfzEmote) LetterCode

func (f *FfzEmote) LetterCode() string

func (*FfzEmote) Type

func (f *FfzEmote) Type() string

func (*FfzEmote) TypedName added in v1.2.0

func (f *FfzEmote) TypedName() string

func (*FfzEmote) URL

func (f *FfzEmote) URL(size ImageSize) string

type FfzEmoteContainer

type FfzEmoteContainer struct {
	Emote FfzEmote `json:"emote"`
}

type FfzGlobal

type FfzGlobal struct {
	DefaultSets []int              `json:"default_sets"`
	Sets        map[string]*FfzSet `json:"sets"`
}

type FfzProvider added in v1.2.0

type FfzProvider struct{}

func (FfzProvider) IdentifierCode added in v1.2.0

func (f FfzProvider) IdentifierCode() rune

func (FfzProvider) LoadChannelEmotes added in v1.2.0

func (f FfzProvider) LoadChannelEmotes(channelID string) ([]Emote, error)

func (FfzProvider) LoadGlobalEmotes added in v1.2.0

func (f FfzProvider) LoadGlobalEmotes() ([]Emote, error)

func (FfzProvider) LoadSpecificEmote added in v1.2.0

func (f FfzProvider) LoadSpecificEmote(emoteID string) (Emote, error)

type FfzRoom

type FfzRoom struct {
	RoomInfo FfzRoomInfo        `json:"room"`
	Sets     map[string]*FfzSet `json:"sets"`
}

type FfzRoomInfo

type FfzRoomInfo struct {
	Set int `json:"set"`
}

type FfzSet

type FfzSet struct {
	Emoticons []*FfzEmote `json:"emoticons"`
}

type FfzUrls

type FfzUrls struct {
	One  string `json:"1"`
	Two  string `json:"2"`
	Four string `json:"4"`
}

type ImageFileCache

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

func NewImageFileCache

func NewImageFileCache(basePath string, expiration time.Duration, cleanOnIndex bool) *ImageFileCache

func (*ImageFileCache) AutoEvict

func (c *ImageFileCache) AutoEvict(ctx context.Context)

func (*ImageFileCache) DownloadToCache

func (c *ImageFileCache) DownloadToCache(emote Emote, size ImageSize) error

func (*ImageFileCache) DownloadVirtualToCache

func (c *ImageFileCache) DownloadVirtualToCache(emote Emote, size ImageSize) error

func (*ImageFileCache) Evict

func (c *ImageFileCache) Evict() (int, error)

func (*ImageFileCache) GetCachedOrDownload

func (c *ImageFileCache) GetCachedOrDownload(emote Emote, size ImageSize, writer io.Writer) error

func (*ImageFileCache) GetCachedOrDownloadHalf

func (c *ImageFileCache) GetCachedOrDownloadHalf(emote Emote, size ImageSize, half VirtualHalf, writer io.Writer) error

func (*ImageFileCache) GetEmoteAspectRatio

func (c *ImageFileCache) GetEmoteAspectRatio(emote Emote) (float64, error)

func (*ImageFileCache) Index

func (c *ImageFileCache) Index() error

func (*ImageFileCache) Purge

func (c *ImageFileCache) Purge() error

type ImageSize

type ImageSize int
const (
	ImageSizeSmall ImageSize = iota
	ImageSizeMedium
	ImageSizeLarge
)

func (ImageSize) BttvString

func (s ImageSize) BttvString() string

func (ImageSize) FfzString

func (s ImageSize) FfzString() string

func (ImageSize) SevenTVString added in v1.2.0

func (s ImageSize) SevenTVString() string

type Provider added in v1.2.0

type Provider interface {
	IdentifierCode() rune
	LoadGlobalEmotes() ([]Emote, error)
	LoadChannelEmotes(channelID string) ([]Emote, error)
	LoadSpecificEmote(emoteID string) (Emote, error)
}

type ProviderEmotes added in v1.2.0

type ProviderEmotes map[rune][]Emote

type SevenTVEmote added in v1.2.0

type SevenTVEmote struct {
	ID       string      `json:"id"`
	Name     string      `json:"name"`
	MimeType string      `json:"mime"`
	URLs     [][2]string `json:"urls"`

	Widths  []int `json:"width"`
	Heights []int `json:"height"`
}

func GetChannelSevenTVEmotes added in v1.2.0

func GetChannelSevenTVEmotes(channelID string) ([]*SevenTVEmote, error)

func GetGlobalSevenTVEmotes added in v1.2.0

func GetGlobalSevenTVEmotes() ([]*SevenTVEmote, error)

func GetSpecificSevenTVEmote added in v1.2.0

func GetSpecificSevenTVEmote(emoteID string) (*SevenTVEmote, error)

func (*SevenTVEmote) EmoteID added in v1.2.0

func (s *SevenTVEmote) EmoteID() string

func (*SevenTVEmote) LetterCode added in v1.2.0

func (s *SevenTVEmote) LetterCode() string

func (*SevenTVEmote) Type added in v1.2.0

func (s *SevenTVEmote) Type() string

func (*SevenTVEmote) TypedName added in v1.2.0

func (s *SevenTVEmote) TypedName() string

func (*SevenTVEmote) URL added in v1.2.0

func (s *SevenTVEmote) URL(size ImageSize) string

type SevenTVProvider added in v1.2.0

type SevenTVProvider struct{}

func (SevenTVProvider) IdentifierCode added in v1.2.0

func (s SevenTVProvider) IdentifierCode() rune

func (SevenTVProvider) LoadChannelEmotes added in v1.2.0

func (s SevenTVProvider) LoadChannelEmotes(channelID string) ([]Emote, error)

func (SevenTVProvider) LoadGlobalEmotes added in v1.2.0

func (s SevenTVProvider) LoadGlobalEmotes() ([]Emote, error)

func (SevenTVProvider) LoadSpecificEmote added in v1.2.0

func (s SevenTVProvider) LoadSpecificEmote(emoteID string) (Emote, error)

type VirtualHalf

type VirtualHalf int
const (
	LeftHalf VirtualHalf = iota
	RightHalf
)

func (VirtualHalf) LetterCode

func (h VirtualHalf) LetterCode() string

type WordMap

type WordMap map[string]Emote

Jump to

Keyboard shortcuts

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