diff --git a/osuapi/beatmapsets.go b/osuapi/beatmapsets.go index 49547d6..f52ed4a 100644 --- a/osuapi/beatmapsets.go +++ b/osuapi/beatmapsets.go @@ -68,3 +68,28 @@ func (api *Osuapi) BeatmapsetDownload(beatmapSetId int) (path string, err error) path = file.Name() return } + +type GetBeatmapsetEventsOptions struct { + User string + Types []string +} + +func (api *Osuapi) GetBeatmapsetEvents(opts *GetBeatmapsetEventsOptions) (events []BeatmapsetEvent, err error) { + values := url.Values{} + values.Set("user", opts.User) + query := values.Encode() + for _, t := range opts.Types { + query += "&types[]=" + t + } + url := "/beatmapsets/events?" + query + fmt.Println("URL IS", url) + + var reply BeatmapsetEvents + err = api.Request("GET", url, &reply) + if err != nil { + return + } + + events = reply.Events + return +} diff --git a/osuapi/models.go b/osuapi/models.go index acf6182..7eb03b2 100644 --- a/osuapi/models.go +++ b/osuapi/models.go @@ -63,3 +63,14 @@ type EventUser struct { type BeatmapSearch struct { Beatmapsets []Beatmapset `json:"beatmapsets"` } + +type BeatmapsetEvents struct { + Events []BeatmapsetEvent `json:"events"` +} + +type BeatmapsetEvent struct { + ID int `json:"id"` + Type string `json:"type"` + Beatmapset Beatmapset `json:"beatmapset"` + UserID int `json:"user_id"` +} diff --git a/scrape/nominated.go b/scrape/nominated.go index 8868090..c50c703 100644 --- a/scrape/nominated.go +++ b/scrape/nominated.go @@ -1,5 +1,16 @@ package scrape -func (s *Scraper) scrapeNominatedMaps() { +import ( + "fmt" + "subscribe-bot/osuapi" +) +func (s *Scraper) scrapeNominatedMaps() { + events, _ := s.api.GetBeatmapsetEvents(&osuapi.GetBeatmapsetEventsOptions{ + Types: []string{"nominate", "qualify"}, + }) + + for _, event := range events { + fmt.Println(event) + } }