mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2025-01-24 05:08:45 -05:00
62 lines
1.3 KiB
Go
62 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
|
||
|
}
|