From fd7a843576b70c9fe55e6d54674c96cc0938befb Mon Sep 17 00:00:00 2001 From: eccentric Date: Mon, 11 Dec 2023 00:06:41 +0000 Subject: [PATCH] update some things --- aid/aid.go | 11 +++++++++++ main.go | 6 +++++- person/person.go | 6 +++++- person/snapshot.go | 1 + storage/tables.go | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/aid/aid.go b/aid/aid.go index e205e50..fb42a88 100644 --- a/aid/aid.go +++ b/aid/aid.go @@ -1,6 +1,7 @@ package aid import ( + "math/rand" "os" "os/signal" "syscall" @@ -23,4 +24,14 @@ func JSONParse(input string) interface{} { var output interface{} json.Unmarshal([]byte(input), &output) return output +} + +func RandomString(n int) string { + var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + + s := make([]rune, n) + for i := range s { + s[i] = letters[rand.Intn(len(letters))] + } + return string(s) } \ No newline at end of file diff --git a/main.go b/main.go index 87591c9..e74f38b 100644 --- a/main.go +++ b/main.go @@ -41,7 +41,11 @@ func init() { fortnite.GenerateRandomStorefront() if aid.Config.Database.DropAllTables { - fortnite.NewFortnitePerson("ac", "1") + username := aid.RandomString(6) + password := aid.RandomString(10) + fortnite.NewFortnitePerson(username, password) + + aid.Print("Admin Credentials: username", username, "password", password) } fortnite.GeneratePlaylistImages() diff --git a/person/person.go b/person/person.go index 4a88c72..03f53ce 100644 --- a/person/person.go +++ b/person/person.go @@ -15,6 +15,7 @@ type Person struct { Profile0Profile *Profile CollectionsProfile *Profile CreativeProfile *Profile + DiscordID string Discord *storage.DB_DiscordPerson } @@ -142,10 +143,10 @@ func findHelper(databasePerson *storage.DB_Person) *Person { CollectionsProfile: collectionsProfile, CreativeProfile: creativeProfile, Discord: &databasePerson.Discord, + DiscordID: databasePerson.DiscordID, } cache.SavePerson(person) - return person } @@ -201,7 +202,9 @@ func (p *Person) ToDatabase() *storage.DB_Person { ID: p.ID, DisplayName: p.DisplayName, Profiles: []storage.DB_Profile{}, + Stats: []storage.DB_SeasonStat{}, AccessKey: p.AccessKey, + DiscordID: p.DiscordID, } if p.Discord != nil { @@ -285,5 +288,6 @@ func (p *Person) Snapshot() *PersonSnapshot { CollectionsProfile: *p.CollectionsProfile.Snapshot(), CreativeProfile: *p.CreativeProfile.Snapshot(), Discord: *p.Discord, + DiscordID: p.DiscordID, } } \ No newline at end of file diff --git a/person/snapshot.go b/person/snapshot.go index e00de9b..da024ae 100644 --- a/person/snapshot.go +++ b/person/snapshot.go @@ -12,6 +12,7 @@ type PersonSnapshot struct { CollectionsProfile ProfileSnapshot CreativeProfile ProfileSnapshot Discord storage.DB_DiscordPerson + DiscordID string } type ProfileSnapshot struct { diff --git a/storage/tables.go b/storage/tables.go index bfbc304..b66b3b6 100644 --- a/storage/tables.go +++ b/storage/tables.go @@ -12,6 +12,7 @@ type DB_Person struct { AccessKey string Profiles []DB_Profile `gorm:"foreignkey:PersonID"` Stats []DB_SeasonStat `gorm:"foreignkey:PersonID"` + DiscordID string Discord DB_DiscordPerson `gorm:"foreignkey:PersonID"` }