From eabf16899e2a76a484ae15c2173e5349802cadfa Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 12 Oct 2020 09:35:51 -0500 Subject: [PATCH] BREAKING CHANGE: store repos under a subdir of the mapper id --- discord/bot.go | 6 +++--- osuapi/models.go | 2 +- scrape/scrape.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/discord/bot.go b/discord/bot.go index cae0089..be031d3 100644 --- a/discord/bot.go +++ b/discord/bot.go @@ -100,7 +100,7 @@ func (bot *Bot) NotifyNewBeatmap(channels []string, newMaps []osuapi.Beatmapset) // try to open a repo for this beatmap var repo *git.Repository - repoDir := path.Join(bot.config.Repos, strconv.Itoa(beatmapSet.ID)) + repoDir := path.Join(bot.config.Repos, strconv.Itoa(beatmapSet.UserID), strconv.Itoa(beatmapSet.ID)) if _, err := os.Stat(repoDir); os.IsNotExist(err) { os.MkdirAll(repoDir, 0777) } @@ -181,11 +181,11 @@ func (bot *Bot) NotifyNewBeatmap(channels []string, newMaps []osuapi.Beatmapset) Title: fmt.Sprintf("Update: %s - %s", beatmapSet.Artist, beatmapSet.Title), Timestamp: eventTime.Format(time.RFC3339), Author: &discordgo.MessageEmbedAuthor{ - URL: "https://osu.ppy.sh/u/" + strconv.Itoa(beatmapSet.UserId), + URL: "https://osu.ppy.sh/u/" + strconv.Itoa(beatmapSet.UserID), Name: beatmapSet.Creator, IconURL: fmt.Sprintf( "https://a.ppy.sh/%d?%d.png", - beatmapSet.UserId, + beatmapSet.UserID, time.Now().Unix(), ), }, diff --git a/osuapi/models.go b/osuapi/models.go index 5c7514f..acf6182 100644 --- a/osuapi/models.go +++ b/osuapi/models.go @@ -14,7 +14,7 @@ type Beatmapset struct { Title string `json:"title"` TitleUnicode string `json:"title_unicode"` Creator string `json:"creator"` - UserId int `json:"user_id"` + UserID int `json:"user_id"` Covers BeatmapCovers `json:"covers"` Beatmaps []Beatmap `json:"beatmaps,omitempty"` diff --git a/scrape/scrape.go b/scrape/scrape.go index 752df4c..ad107a4 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -50,7 +50,7 @@ func RunScraper(config *config.Config, bot *discord.Bot, db *db.Db, api *osuapi. break } - mapperId := beatmapSet.UserId + mapperId := beatmapSet.UserID if _, ok := trackedMappers[mapperId]; ok { if _, ok2 := allNewMaps[mapperId]; !ok2 { allNewMaps[mapperId] = make([]osuapi.Beatmapset, 0)