add even more shit shit

This commit is contained in:
Fijxu 2025-01-08 23:52:14 -03:00
parent db4c3881d9
commit 4c3b9a5b05
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
3 changed files with 229 additions and 118 deletions

View file

@ -10,8 +10,8 @@ func root(w http.ResponseWriter, r *http.Request) {
} }
func getAllBadges(w http.ResponseWriter, r *http.Request) { func getAllBadges(w http.ResponseWriter, r *http.Request) {
parseAllBadges() asd := parseAllBadges()
io.WriteString(w, "test") io.WriteString(w, asd)
} }
// func sevenTvPaints(w http.ResponseWriter, r *http.Request) { // func sevenTvPaints(w http.ResponseWriter, r *http.Request) {

View file

@ -2,21 +2,80 @@ package main
import "encoding/json" import "encoding/json"
type Parser struct { type _Chatterino struct {
SevenTV string `json:"SevenTV"` Badges []struct {
Bttv string `json:"BTTV"` Name string `json:"name"`
Ffz string `json:"FFZ"` Url string `json:"url"`
Chatterino string `json:"Chatterino"` Users []string `json:"users"`
Chatty string `json:"Chatty"` } `json:"badges"`
Homies string `json:"Homies"`
Ptv string `json:"PurpleTV"`
} }
func parseAllBadges() { type _FrankerFz struct {
stv := &SevenTv{} Badges []struct {
stv.getBadges() Name string `json:"name"`
json, _ := json.Marshal(stv.Badges) Url string `json:"url"`
logger.Trace().Msg(string(json)) Users []string `json:"users"`
} `json:"badges"`
}
type _SevenTv struct {
Badges []struct {
Name string `json:"name"`
Url string `json:"url"`
Users []string `json:"users"`
} `json:"badges"`
Paints []struct {
}
}
type Format struct {
Chatterino _Chatterino `json:"chatterino"`
SevenTv _SevenTv `json:"7tv"`
Ffz _FrankerFz `json:"ffz"`
}
func parseChatterino(format *Format) {
chatterino := &Chatterino{}
chatterino.getBadges()
for _, badge := range chatterino.Badges {
format.Chatterino.Badges = append(format.Chatterino.Badges, struct {
Name string `json:"name"`
Url string `json:"url"`
Users []string `json:"users"`
}{
Name: badge.Tooltip,
Url: badge.Image3,
Users: badge.Users,
})
}
}
func parseSevenTv(format *Format) {
sevenTv := &Chatterino{}
sevenTv.getBadges()
for _, badge := range sevenTv.Badges {
format.Chatterino.Badges = append(format.Chatterino.Badges, struct {
Name string `json:"name"`
Url string `json:"url"`
Users []string `json:"users"`
}{
Name: badge.Tooltip,
Url: badge.Image3,
Users: badge.Users,
})
}
}
func parseAllBadges() string {
format := &Format{}
parseChatterino(format)
json, _ := json.Marshal(format)
return string(json)
// bttv := &Bttv{} // bttv := &Bttv{}
// ffz := &FrankerFz{} // ffz := &FrankerFz{}
// chatterino := &Chatterino{} // chatterino := &Chatterino{}

View file

@ -18,6 +18,7 @@ type GqlQuery struct {
type SevenTv struct { type SevenTv struct {
Query GqlQuery `json:"query"` Query GqlQuery `json:"query"`
UserID string
Badges struct { Badges struct {
Data struct { Data struct {
Cosmetics struct { Cosmetics struct {
@ -35,11 +36,41 @@ type SevenTv struct {
} `json:"sevenTvBadges"` } `json:"sevenTvBadges"`
} }
type Chatterino struct {
Badges []struct {
Tooltip string `json:"tooltip"`
Image1 string `json:"image1"`
Image2 string `json:"image2"`
Image3 string `json:"image3"`
Users []string `json:"users"`
} `json:"badges"`
}
type Bttv struct{} type Bttv struct{}
type FrankerFz struct{}
type Chatterino struct{} type FrankerFz struct {
Badge struct {
ID int64 `json:"id"`
Name string `json:"name"`
Title string `json:"title"`
Slot int64 `json:"slot"`
Replaces *string `json:"replaces"`
Color string `json:"color"`
Image string `json:"image"`
Urls map[string]string `json:"urls"`
CSS interface{} `json:"css"`
} `json:"badges"`
Users map[string][]int64 `json:"users"`
}
type Chatty struct{} type Chatty struct{}
type DankChat struct{}
type DankChat struct {
Type string `json:"type"`
URL string `json:"url"`
Users []string `json:"users"`
}
type Homies struct{} type Homies struct{}
type PurpleTV struct{} type PurpleTV struct{}
@ -75,9 +106,9 @@ func doPostRequest(url string, data []byte) []byte {
return body return body
} }
func (s *SevenTv) getUserID(userId string) []byte { func (s *SevenTv) getUserID(userId string) (string, error) {
req := doGetRequest("https://7tv.io/v3/users/twitch/" + userId) req := doGetRequest("https://7tv.io/v3/users/twitch/" + userId)
return req return string(req), nil
} }
func (s *SevenTv) getBadges() *SevenTv { func (s *SevenTv) getBadges() *SevenTv {
@ -101,16 +132,15 @@ func (s *SevenTv) getBadges() *SevenTv {
Query: query, Query: query,
} }
data, _ := json.Marshal(s.Query) data, err := json.Marshal(s.Query)
// if err != nil { if err != nil {
// return "", err logger.Error().Msg(err.Error())
// } }
res := doPostRequest("https://7tv.io/v3/gql", data) res := doPostRequest("https://7tv.io/v3/gql", data)
logger.Trace().Msg(string(res))
logger.Info().Msg(string(res)) err = json.Unmarshal(res, &s.Badges)
err := json.Unmarshal(res, &s.Badges)
if err != nil { if err != nil {
logger.Error().Msg(err.Error()) logger.Error().Msg(err.Error())
} }
@ -118,106 +148,128 @@ func (s *SevenTv) getBadges() *SevenTv {
return s return s
} }
// func (s *SevenTv) getPaints() (string, error) { func (s *SevenTv) getPaints() (string, error) {
// query := ` query := `
// query GetCosmestics($list: [ObjectID!]) { query GetCosmestics($list: [ObjectID!]) {
// cosmetics(list: $list) { cosmetics(list: $list) {
// paints { paints {
// id id
// kind kind
// name name
// function function
// color color
// angle angle
// shape shape
// image_url image_url
// repeat repeat
// stops { stops {
// at at
// color color
// __typename __typename
// } }
// shadows { shadows {
// x_offset x_offset
// y_offset y_offset
// radius radius
// color color
// __typename __typename
// } }
// __typename __typename
// } }
// } }
// }` }`
// s.Query = GqlQuery{ s.Query = GqlQuery{
// OperationName: "GetCosmestics", OperationName: "GetCosmestics",
// Query: query, Query: query,
// } }
// data, err := json.Marshal(s.Query) data, err := json.Marshal(s.Query)
// if err != nil { if err != nil {
// return "", err return "", err
// } }
// logger.Trace().Msg(string(data)) logger.Trace().Msg(string(data))
// res := doPostRequest("https://7tv.io/v3/gql", data) res := doPostRequest("https://7tv.io/v3/gql", data)
// return res, nil return string(res), nil
// } }
// func (s *SevenTv) getUserCosmetics(userId string) (string, error) { // Returns the costmetrics that a user has.
// query := ` // userId, needs to be a 7TV ULID, call getUserID first.
// query GetUserCosmetics($id: ObjectID!) { func (s *SevenTv) getUserCosmetics(userId string) (string, error) {
// user(id: $id) { query := `
// id query GetUserCosmetics($id: ObjectID!) {
// cosmetics { user(id: $id) {
// id id
// kind cosmetics {
// selected id
// __typename kind
// } selected
// __typename __typename
// } }
// }` __typename
}
}`
// s.Query = GqlQuery{ s.Query = GqlQuery{
// OperationName: "GetUserCosmetics", OperationName: "GetUserCosmetics",
// Variables: Variables{ Variables: Variables{
// ID: userId, ID: userId,
// }, },
// Query: query, Query: query,
// } }
// data, err := json.Marshal(s.Query) data, err := json.Marshal(s.Query)
// if err != nil { if err != nil {
// return "", err return "", err
// } }
// logger.Trace().Msg(string(data)) logger.Trace().Msg(string(data))
// res := doPostRequest("https://7tv.io/v3/gql", data) res := doPostRequest("https://7tv.io/v3/gql", data)
// return res, nil return string(res), nil
// } }
// func (s *Bttv) getBadges() string { func (s *Chatterino) getBadges() *Chatterino {
// req := doGetRequest("https://api.betterttv.net/3/cached/badges/twitch") res := doGetRequest("https://api.chatterino.com/badges")
// return req err := json.Unmarshal(res, &s)
// } if err != nil {
logger.Error().Msg(err.Error())
}
return s
}
// func (s *FrankerFz) getBadges() string { func (s *Bttv) getBadges() *Bttv {
// req := doGetRequest("https://api.frankerfacez.com/v1/badges/ids") res := doGetRequest("https://api.betterttv.net/3/cached/badges/twitch")
// return req err := json.Unmarshal(res, &s)
// } if err != nil {
logger.Error().Msg(err.Error())
}
return s
}
// func (s *Chatty) getBadges() string { func (s *FrankerFz) getBadges() *FrankerFz {
// req := doGetRequest("https://api.betterttv.net/3/cached/badges/twitch") res := doGetRequest("https://api.frankerfacez.com/v1/badges/ids")
// return req err := json.Unmarshal(res, &s)
// } if err != nil {
logger.Error().Msg(err.Error())
}
return s
}
// func (s *DankChat) getBadges() string { func (s *Chatty) getBadges() *Chatty {
// req := doGetRequest("https://flxrs.com/api/badges") res := doGetRequest("https://tduva.com/res/badges")
// return req err := json.Unmarshal(res, &s)
// } if err != nil {
logger.Error().Msg(err.Error())
}
return s
}
// func (s *Chatterino) getBadges() string { func (s *DankChat) getBadges() *DankChat {
// req := doGetRequest("https://api.chatterino.com/badges") res := doGetRequest("https://flxrs.com/api/badges")
// return req err := json.Unmarshal(res, &s)
// } if err != nil {
logger.Error().Msg(err.Error())
}
return s
}