Skip to content

Commit

Permalink
Add game country
Browse files Browse the repository at this point in the history
  • Loading branch information
klipach committed Jan 15, 2025
1 parent e23b5ff commit bb7bf02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func Bot(w http.ResponseWriter, r *http.Request) {
GameStartingAt: gg.StartingAt,
GameLeague: gg.League,
Season: gg.Season,
Country: gg.League,
Country: gg.Country,
})
if err != nil {
logger.Printf("error while executing mainPrompt: %v", err)
Expand Down Expand Up @@ -174,7 +174,7 @@ func Bot(w http.ResponseWriter, r *http.Request) {
GameStartingAt: gg.StartingAt,
GameLeague: gg.League,
Season: gg.Season,
Country: gg.League,
Country: gg.Country,
})

if err != nil {
Expand Down Expand Up @@ -303,7 +303,7 @@ func Bot(w http.ResponseWriter, r *http.Request) {

// allow only tags that are supported by app
policy := bluemonday.NewPolicy()
policy.AllowElements("br", "s", "i", "b")
policy.AllowElements("br", "s", "i", "b", "a")

safeHTML := policy.SanitizeBytes(unsafeHTML)
response = string(safeHTML)
Expand Down
9 changes: 7 additions & 2 deletions game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Game struct {
StartingAt time.Time
League string
Season string
Country string
}

type FixtureResponse struct {
Expand All @@ -24,7 +25,10 @@ type FixtureResponse struct {
Name string `json:"name"`
StartingAtTimestamp int64 `json:"starting_at_timestamp"`
League struct {
Name string `json:"name"`
Name string `json:"name"`
Country struct {
Name string `json:"name"`
} `json:"country"`
} `json:"league"`
Season struct {
Name string `json:"name"`
Expand All @@ -43,7 +47,7 @@ func Fetch(ctx context.Context, gameID int) (*Game, error) {
req, err := http.NewRequestWithContext(
ctx,
http.MethodGet,
sportmonksBaseURL+fmt.Sprintf("/v3/football/fixtures/%d/?include=league:name,image_path;season:name;round:name;participants.country:name;scores;venue;lineups.player;statistics;referees.referee;state", gameID),
sportmonksBaseURL+fmt.Sprintf("/v3/football/fixtures/%d/?include=league:name;season:name;round:name;league.country;participants.country:name,image_path;scores;venue;lineups.player;referees.referee;state", gameID),
http.NoBody,
)
if err != nil {
Expand Down Expand Up @@ -79,5 +83,6 @@ func Fetch(ctx context.Context, gameID int) (*Game, error) {
StartingAt: time.Unix(fixture.Data.StartingAtTimestamp, 0),
League: fixture.Data.League.Name,
Season: fixture.Data.Season.Name,
Country: fixture.Data.League.Country.Name,
}, nil
}

0 comments on commit bb7bf02

Please sign in to comment.