0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2025-01-08 13:50:05 -05:00
safetwitch-backend/extractor/twitch/emoteHandler.go
2023-06-17 21:14:28 -04:00

61 lines
1.3 KiB
Go

package twitch
import (
"fmt"
"safetwitch-backend/extractor/structs"
)
type Emote struct {
Name string `json:"name"`
Urls map[string]string `json:"urls"`
}
func ParseFfzEmotes(emotes structs.FfzData) []Emote {
setId := emotes.Room.Set
sets := emotes.Sets[fmt.Sprint(setId)]
parsedEmotes := []Emote{}
for _, emote := range sets.Emoticons {
parsedEmotes = append(parsedEmotes, Emote{
Name: emote.Name,
Urls: emote.Urls,
})
}
return parsedEmotes
}
func generateBttvEmotesUrls(id string) map[string]string {
url := "https://cdn.betterttv.net/emote/"
createdUrls := map[string]string{}
for i := 1; i < 4; i++ {
createdUrls[fmt.Sprint(i)] = url + id + "/" + fmt.Sprint(i) + "x"
}
return createdUrls
}
func ParseBttvEmotes(emoteData []structs.BttvEmoteData) []Emote {
parsedEmotes := []Emote{}
for _, emote := range emoteData {
parsedEmotes = append(parsedEmotes, Emote{
Name: emote.Code,
Urls: generateBttvEmotesUrls(emote.Id),
})
}
return parsedEmotes
}
func ParseBttvGlobalEmotes(emoteData []structs.BttvGlobalEmoteData) []Emote {
parsedEmotes := []Emote{}
for _, emote := range emoteData {
parsedEmotes = append(parsedEmotes, Emote{
Name: emote.Code,
Urls: generateBttvEmotesUrls(emote.Id),
})
}
return parsedEmotes
}