feat(parser): Add chatty support for badges
This commit is contained in:
parent
53344090f2
commit
d4d90c317c
1 changed files with 31 additions and 17 deletions
|
@ -32,7 +32,13 @@ type _FrankerFz struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
type _Chatty struct{}
|
type _Chatty struct {
|
||||||
|
Badges []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
Users []string `json:"users"`
|
||||||
|
} `json:"badges"`
|
||||||
|
}
|
||||||
|
|
||||||
type _DankChat struct {
|
type _DankChat struct {
|
||||||
Badges []struct {
|
Badges []struct {
|
||||||
|
@ -129,7 +135,7 @@ func formatFfz(format *Format) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// TODO
|
||||||
func formatBttv(format *Format) {
|
func formatBttv(format *Format) {
|
||||||
defer format.wg.Done()
|
defer format.wg.Done()
|
||||||
data := &Bttv{}
|
data := &Bttv{}
|
||||||
|
@ -209,26 +215,31 @@ func formatPurpleTv(format *Format) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO: Replace the data from the Chatty struct in place to use less memory.
|
||||||
func formatChatty(format *Format) {
|
func formatChatty(format *Format) {
|
||||||
defer format.wg.Done()
|
defer format.wg.Done()
|
||||||
data := &Chatty{}
|
data := &Chatty{}
|
||||||
|
newData := Chatty{}
|
||||||
data.getBadges()
|
data.getBadges()
|
||||||
|
|
||||||
// var users []string
|
// Removes the elements containing "ffz" or "ffzap" in the ID.
|
||||||
// for _, user := range data.Users {
|
for _, element := range *data {
|
||||||
// users = append(users, user.UserName)
|
if (element.ID != "ffz") && (element.ID != "ffzap") {
|
||||||
// }
|
newData = append(newData, element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// format.PurpleTv.Badges = append(format.PurpleTv.Badges, struct {
|
for _, badge := range newData {
|
||||||
// Name string `json:"name"`
|
format.Chatty.Badges = append(format.Chatty.Badges, struct {
|
||||||
// Url string `json:"url"`
|
Name string `json:"name"`
|
||||||
// Users []string `json:"users"`
|
Url string `json:"url"`
|
||||||
// }{
|
Users []string `json:"users"`
|
||||||
// Name: "PurpleTV Supporter",
|
}{
|
||||||
// Url: data.DefaultBadgeURL,
|
Name: badge.MetaTitle,
|
||||||
// Users: users,
|
Url: badge.ImageURL4,
|
||||||
// })
|
Users: badge.Usernames,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatSevenTvBadges() string {
|
func formatSevenTvBadges() string {
|
||||||
|
@ -278,6 +289,9 @@ func formatAllBadges() string {
|
||||||
|
|
||||||
format.wg.Wait()
|
format.wg.Wait()
|
||||||
|
|
||||||
json, _ := json.Marshal(format)
|
json, err := json.Marshal(format)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error().Msg("Failed to json.Marshal badges: " + err.Error())
|
||||||
|
}
|
||||||
return string(json)
|
return string(json)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue