package emote import ( "io" "github.com/go-json-experiment/json" ) // seventvUser has the fields of a 7TV user model which are relevant to Kaiyan. type seventvUser struct { EmoteSet emoteSet `json:"emote_set"` } type emoteSet struct { Emotes []seventvEmote `json:"emotes"` } type seventvEmote struct { ID string `json:"id"` Name string `json:"name"` // 7TV provides the CDN URL as well, but it's nested in further objects, // not a complete URL, and it's also trivially derivable from the ID. } // SevenTVv3 parses the emotes from a 7TV v3/users/{platform}/{platform_id} // response body. func SevenTVv3(r io.Reader) ([]Emote, error) { var u seventvUser if err := json.UnmarshalRead(r, &u); err != nil { return nil, err } ems := make([]Emote, 0, len(u.EmoteSet.Emotes)) for _, em := range u.EmoteSet.Emotes { v := Emote{ ID: em.ID, Name: em.Name, Source: "7TV", Link: "https://7tv.app/emotes/" + em.ID, Image: "https://cdn.7tv.app/emote/" + em.ID + "/4x.webp", } ems = append(ems, v) } return ems, nil }