From 796e25482134bf392ebb667919b8beb44c82551e Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 13:04:21 +0900 Subject: [PATCH 01/36] Added Link to Information struct / Modified both Characters and Guilds / Add test for information on characters test --- src/TibiaCharactersCharacter.go | 1 + src/TibiaCharactersCharacter_test.go | 3 +++ src/TibiaGuildsGuild.go | 1 + src/webserver.go | 1 + 4 files changed, 6 insertions(+) diff --git a/src/TibiaCharactersCharacter.go b/src/TibiaCharactersCharacter.go index b6e70431..0ac7a0eb 100644 --- a/src/TibiaCharactersCharacter.go +++ b/src/TibiaCharactersCharacter.go @@ -725,6 +725,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string) (CharacterResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=characters&name=" + TibiaDataQueryEscapeString(CharacterInfoData.Name), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCharactersCharacter_test.go b/src/TibiaCharactersCharacter_test.go index 87f1660e..61c7e96a 100644 --- a/src/TibiaCharactersCharacter_test.go +++ b/src/TibiaCharactersCharacter_test.go @@ -33,6 +33,7 @@ func TestNumber1(t *testing.T) { assert := assert.New(t) character := characterJson.Character.CharacterInfo + information := characterJson.Information assert.Equal("Darkside Rafa", character.Name) assert.Nil(character.FormerNames) @@ -54,6 +55,8 @@ func TestNumber1(t *testing.T) { assert.Equal("2022-01-05T21:23:32Z", character.LastLogin) assert.Equal("Premium Account", character.AccountStatus) assert.Empty(character.Comment) + + assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.Link) } func TestNumber2(t *testing.T) { diff --git a/src/TibiaGuildsGuild.go b/src/TibiaGuildsGuild.go index 1f2d0c10..926a6575 100644 --- a/src/TibiaGuildsGuild.go +++ b/src/TibiaGuildsGuild.go @@ -282,6 +282,7 @@ func TibiaGuildsGuildImpl(guild string, BoxContentHTML string) (GuildResponse, e Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=" + TibiaDataQueryEscapeString(guildName), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/webserver.go b/src/webserver.go index 1f060063..0d431045 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -47,6 +47,7 @@ type OutInformation struct { type Information struct { APIDetails APIDetails `json:"api"` // The API details. Timestamp string `json:"timestamp"` // The timestamp from when the data was processed. + Link string `json:"link"` // The link to the source of the data. Status Status `json:"status"` // The response status information. } From 7e108587046a7f36333b98c1193fdf271bb6ef7c Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 13:11:24 +0900 Subject: [PATCH 02/36] Tibia Guild Test Case with Link on information --- src/TibiaGuildsGuild_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/TibiaGuildsGuild_test.go b/src/TibiaGuildsGuild_test.go index 9cd42cd5..eeeef2e7 100644 --- a/src/TibiaGuildsGuild_test.go +++ b/src/TibiaGuildsGuild_test.go @@ -27,6 +27,7 @@ func TestOrderofGlory(t *testing.T) { assert := assert.New(t) guild := orderOfGloryJson.Guild + information := orderOfGloryJson.Information assert.Equal("Order of Glory", guild.Name) assert.Equal("Premia", guild.World) @@ -56,6 +57,8 @@ func TestOrderofGlory(t *testing.T) { assert.Equal("online", guildLeader.Status) assert.Nil(guild.Invited) + + // assert.Equal("Order of Glory") } func TestElysium(t *testing.T) { From b6b7e2a8038c34990e2fd7793ef373f7d74ac355 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 13:21:30 +0900 Subject: [PATCH 03/36] Added link to guilds/:world endpoint and tests for both guild/:guild and guilds/:world endpoints --- src/TibiaGuildsGuild_test.go | 2 +- src/TibiaGuildsOverview.go | 2 +- src/TibiaGuildsOverview_test.go | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TibiaGuildsGuild_test.go b/src/TibiaGuildsGuild_test.go index eeeef2e7..7aa51892 100644 --- a/src/TibiaGuildsGuild_test.go +++ b/src/TibiaGuildsGuild_test.go @@ -58,7 +58,7 @@ func TestOrderofGlory(t *testing.T) { assert.Nil(guild.Invited) - // assert.Equal("Order of Glory") + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Order+of+Glory", information.Link) } func TestElysium(t *testing.T) { diff --git a/src/TibiaGuildsOverview.go b/src/TibiaGuildsOverview.go index c5918388..f33d6288 100644 --- a/src/TibiaGuildsOverview.go +++ b/src/TibiaGuildsOverview.go @@ -48,7 +48,6 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string) (GuildsOvervie tableName := s.Nodes[0].FirstChild.Data if strings.Contains(tableName, "Active Guilds") { GuildCategory = "active" - } else if strings.Contains(tableName, "Guilds in Course of Formation") { GuildCategory = "formation" } @@ -96,6 +95,7 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string) (GuildsOvervie Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=guilds&world=" + world, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsOverview_test.go b/src/TibiaGuildsOverview_test.go index dc2bd8ec..c2377880 100644 --- a/src/TibiaGuildsOverview_test.go +++ b/src/TibiaGuildsOverview_test.go @@ -27,6 +27,8 @@ func TestPremia(t *testing.T) { assert := assert.New(t) + information := premiaGuildsJson.Information + assert.Equal("Premia", premiaGuildsJson.Guilds.World) assert.Equal(38, len(premiaGuildsJson.Guilds.Active)) assert.Equal(3, len(premiaGuildsJson.Guilds.Formation)) @@ -40,4 +42,6 @@ func TestPremia(t *testing.T) { assert.Equal("Konungen", secondGuildInFormation.Name) assert.Equal("https://static.tibia.com/images/community/default_logo.gif", secondGuildInFormation.LogoURL) assert.Empty(secondGuildInFormation.Description) + + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&world=Premia", information.Link) } From e58723eefb66da2d0f5512c64917b060444cabd6 Mon Sep 17 00:00:00 2001 From: Kai-Animator Date: Tue, 15 Oct 2024 13:39:50 +0900 Subject: [PATCH 04/36] Adjust test for existing guild --- src/TibiaGuildsGuild_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TibiaGuildsGuild_test.go b/src/TibiaGuildsGuild_test.go index 7aa51892..e0dc17bc 100644 --- a/src/TibiaGuildsGuild_test.go +++ b/src/TibiaGuildsGuild_test.go @@ -27,7 +27,6 @@ func TestOrderofGlory(t *testing.T) { assert := assert.New(t) guild := orderOfGloryJson.Guild - information := orderOfGloryJson.Information assert.Equal("Order of Glory", guild.Name) assert.Equal("Premia", guild.World) @@ -57,8 +56,6 @@ func TestOrderofGlory(t *testing.T) { assert.Equal("online", guildLeader.Status) assert.Nil(guild.Invited) - - assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Order+of+Glory", information.Link) } func TestElysium(t *testing.T) { @@ -151,6 +148,9 @@ func TestMercenarys(t *testing.T) { assert.False(guild.InWar) assert.Equal("2023-02-07", guild.DisbandedDate) assert.Equal("if there are still less than four vice leaders or an insufficient amount of premium accounts in the leading ranks by then", guild.DisbandedCondition) + + information := mercenarysJson.Information + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys", information.Link) } func TestKotkiAntica(t *testing.T) { From be8a2ff68b843a0c35af7c9f9279a0450b50bce1 Mon Sep 17 00:00:00 2001 From: Kai-Animator Date: Tue, 15 Oct 2024 13:57:40 +0900 Subject: [PATCH 05/36] Link added to fansites --- src/TibiaFansites.go | 1 + src/TibiaFansites_test.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/TibiaFansites.go b/src/TibiaFansites.go index 8646faf2..d0369c21 100644 --- a/src/TibiaFansites.go +++ b/src/TibiaFansites.go @@ -97,6 +97,7 @@ func TibiaFansitesImpl(BoxContentHTML string) (FansitesResponse, error) { Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=fansites", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaFansites_test.go b/src/TibiaFansites_test.go index d8c45ccd..746c53c5 100644 --- a/src/TibiaFansites_test.go +++ b/src/TibiaFansites_test.go @@ -86,4 +86,7 @@ func TestFansites(t *testing.T) { assert.Equal("Upload, browse, like and share pictures.", tibiaGalleryFansite.Specials[0]) assert.True(tibiaGalleryFansite.FansiteItem) assert.Equal("https://static.tibia.com/images/community/fansiteitems/TibiaGallery.com.gif", tibiaGalleryFansite.FansiteItemURL) + + information := fansitesJson.Information + assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.Link) } From 0aab6ece761ed384eb84c7881d3e3b765878cc72 Mon Sep 17 00:00:00 2001 From: Kai-Animator Date: Tue, 15 Oct 2024 14:04:54 +0900 Subject: [PATCH 06/36] Added Link to Boostable bosses && Test --- src/TibiaBoostableBossesOverview.go | 1 + src/TibiaBoostableBossesOverview_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/TibiaBoostableBossesOverview.go b/src/TibiaBoostableBossesOverview.go index 55eebd2f..aaf2e5ad 100644 --- a/src/TibiaBoostableBossesOverview.go +++ b/src/TibiaBoostableBossesOverview.go @@ -151,6 +151,7 @@ func TibiaBoostableBossesOverviewImpl(BoxContentHTML string) (BoostableBossesOve Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/library/?subtopic=boostablebosses", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaBoostableBossesOverview_test.go b/src/TibiaBoostableBossesOverview_test.go index ffea85ce..8128f929 100644 --- a/src/TibiaBoostableBossesOverview_test.go +++ b/src/TibiaBoostableBossesOverview_test.go @@ -24,7 +24,9 @@ func TestBoostableBossesOverview(t *testing.T) { assert := assert.New(t) boosted := boostableBossesJson.BoostableBosses.Boosted bosses := boostableBossesJson.BoostableBosses.BoostableBosses + information := boostableBossesJson.Information + assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.Link) assert.Equal(95, len(bosses)) assert.Equal("Ragiaz", boosted.Name) assert.Equal( From 0643725c48e0a1f238a4e33faf000f52c69b05cf Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 20:40:27 +0900 Subject: [PATCH 07/36] Add Creature Link and Creature Test --- src/TibiaCreaturesCreature.go | 5 +++-- src/TibiaCreaturesCreature_test.go | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index 3ba8ccc0..673a3519 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -54,7 +54,7 @@ var ( func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureResponse, error) { // local strings used in this function - var localDamageString = " damage" + localDamageString := " damage" // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) @@ -79,7 +79,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes CreatureBeParalysed, CreatureBeSummoned, CreatureBeConvinced, CreatureSeeInvisible, CreatureIsLootable, CreatureIsBoosted bool ) - //Find boosted creature + // Find boosted creature boostedMonsterTitle, boostedCreatureFound := ReaderHTML.Find("#Monster").First().Attr("title") if boostedCreatureFound { @@ -192,6 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/library/?subtopic=creatures", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesCreature_test.go b/src/TibiaCreaturesCreature_test.go index 60a4770c..e834f8ba 100644 --- a/src/TibiaCreaturesCreature_test.go +++ b/src/TibiaCreaturesCreature_test.go @@ -26,7 +26,9 @@ func TestDemon(t *testing.T) { } assert := assert.New(t) + information := demonJson.Information + assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.Link) assert.Equal("Demons", demonJson.Creature.Name) assert.Equal("Demon", demonJson.Creature.Race) assert.Equal("https://static.tibia.com/images/library/demon.gif", demonJson.Creature.ImageURL) From 5efdbfabd29f159fb48b69da87c0b973b5c84de5 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 21:12:53 +0900 Subject: [PATCH 08/36] CreaturesOverall test and Link implementation --- src/TibiaCreaturesOverview.go | 5 ++--- src/TibiaCreaturesOverview_test.go | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/TibiaCreaturesOverview.go b/src/TibiaCreaturesOverview.go index 98665daa..0f753568 100644 --- a/src/TibiaCreaturesOverview.go +++ b/src/TibiaCreaturesOverview.go @@ -36,9 +36,7 @@ var ( ) func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewResponse, error) { - var ( - BoostedCreatureName, BoostedCreatureRace, BoostedCreatureImage string - ) + var BoostedCreatureName, BoostedCreatureRace, BoostedCreatureImage string // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) @@ -127,6 +125,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewRespons Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/library/?subtopic=creatures&race=" + TibiaDataSanitizeEscapedString(BoostedCreatureName), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesOverview_test.go b/src/TibiaCreaturesOverview_test.go index 791becf0..df9e04f4 100644 --- a/src/TibiaCreaturesOverview_test.go +++ b/src/TibiaCreaturesOverview_test.go @@ -26,7 +26,9 @@ func TestOverview(t *testing.T) { } assert := assert.New(t) + information := creaturesJson.Information + assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=Minotaur+Amazon", information.Link) assert.Equal("Minotaur Amazon", creaturesJson.Creatures.Boosted.Name) assert.Equal("minotauramazon", creaturesJson.Creatures.Boosted.Race) assert.Equal("https://static.tibia.com/images/global/header/monsters/minotauramazon.gif", creaturesJson.Creatures.Boosted.ImageURL) From 17304b900064476644f783ef35fc16c22ed655ef Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 21:34:32 +0900 Subject: [PATCH 09/36] Highscores link implementation & test --- src/TibiaHighscores.go | 1 + src/TibiaHighscores_test.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/TibiaHighscores.go b/src/TibiaHighscores.go index 3a22058c..7fe52c09 100644 --- a/src/TibiaHighscores.go +++ b/src/TibiaHighscores.go @@ -177,6 +177,7 @@ func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vo Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=highscores&world=" + cases.Title(language.English).String(world) + "&category=" + categoryString + "&profession=" + TibiaDataQueryEscapeString(vocationName) + "¤tpage=" + string(currentPage), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHighscores_test.go b/src/TibiaHighscores_test.go index aba2b396..e42c437c 100644 --- a/src/TibiaHighscores_test.go +++ b/src/TibiaHighscores_test.go @@ -27,8 +27,12 @@ func TestHighscoresAll(t *testing.T) { } assert := assert.New(t) + information := highscoresJson.Information + + assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.Link) assert.Empty(highscoresJson.Highscores.World) + assert.Equal("experience", highscoresJson.Highscores.Category) assert.Equal("all", highscoresJson.Highscores.Vocation) assert.Equal(12, highscoresJson.Highscores.HighscoreAge) From 4057c05425291972a1af50bcce1ede06cb3762bd Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 22:10:40 +0900 Subject: [PATCH 10/36] Fix Creature Links --- src/TibiaCreaturesCreature.go | 2 +- src/TibiaCreaturesOverview.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index 673a3519..f8d0b90c 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -192,7 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=creatures", + Link: "https://www.tibia.com/library/?subtopic=creatures&race=" + TibiaDataSanitizeEscapedString(CreatureName), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesOverview.go b/src/TibiaCreaturesOverview.go index 0f753568..023a278b 100644 --- a/src/TibiaCreaturesOverview.go +++ b/src/TibiaCreaturesOverview.go @@ -125,7 +125,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewRespons Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=creatures&race=" + TibiaDataSanitizeEscapedString(BoostedCreatureName), + Link: "https://www.tibia.com/library/?subtopic=creatures", Status: Status{ HTTPCode: http.StatusOK, }, From 56afabe561dda54972f324f02557430523d0c5e7 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 22:20:23 +0900 Subject: [PATCH 11/36] Fix link on creature single | swap name for race --- src/TibiaCreaturesCreature.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index f8d0b90c..55635c49 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -192,7 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=creatures&race=" + TibiaDataSanitizeEscapedString(CreatureName), + Link: "https://www.tibia.com/library/?subtopic=creatures&race=" + race, Status: Status{ HTTPCode: http.StatusOK, }, From 9c6612b7697f16d2755d868912022744c191b432 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 22:28:00 +0900 Subject: [PATCH 12/36] Highscores adjust --- src/TibiaHighscores.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TibiaHighscores.go b/src/TibiaHighscores.go index 7fe52c09..0cbaf376 100644 --- a/src/TibiaHighscores.go +++ b/src/TibiaHighscores.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "regexp" + "strconv" "strings" "github.com/PuerkitoBio/goquery" @@ -177,7 +178,7 @@ func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vo Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=highscores&world=" + cases.Title(language.English).String(world) + "&category=" + categoryString + "&profession=" + TibiaDataQueryEscapeString(vocationName) + "¤tpage=" + string(currentPage), + Link: "https://www.tibia.com/community/?subtopic=highscores&world=" + cases.Title(language.English).String(world) + "&category=" + categoryString + "&profession=" + TibiaDataQueryEscapeString(vocationName) + "¤tpage=" + strconv.Itoa(currentPage), Status: Status{ HTTPCode: http.StatusOK, }, From f99daa93c5bdb970e879fafbd35199eea2faad4a Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 22:41:13 +0900 Subject: [PATCH 13/36] Houses link implementation & Test --- src/TibiaHousesHouse.go | 2 ++ src/TibiaHousesHouse_test.go | 3 +++ src/TibiaHousesOverview.go | 8 ++++---- src/TibiaHousesOverview_test.go | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/TibiaHousesHouse.go b/src/TibiaHousesHouse.go index 682855fb..8da25d59 100644 --- a/src/TibiaHousesHouse.go +++ b/src/TibiaHousesHouse.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "regexp" + "strconv" "strings" "github.com/PuerkitoBio/goquery" @@ -170,6 +171,7 @@ func TibiaHousesHouseImpl(houseid int, BoxContentHTML string) (HouseResponse, er Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=houses&page=view&world=" + HouseData.World + "&houseid=" + strconv.Itoa(HouseData.Houseid), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesHouse_test.go b/src/TibiaHousesHouse_test.go index 0fc8d0ce..899c809e 100644 --- a/src/TibiaHousesHouse_test.go +++ b/src/TibiaHousesHouse_test.go @@ -26,6 +26,9 @@ func TestCormaya10(t *testing.T) { } assert := assert.New(t) + information := houseJson.Information + + assert.Equal("https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025", information.Link) assert.Equal(54025, houseJson.House.Houseid) assert.Equal("Premia", houseJson.House.World) diff --git a/src/TibiaHousesOverview.go b/src/TibiaHousesOverview.go index 75287dc3..a3f44e32 100644 --- a/src/TibiaHousesOverview.go +++ b/src/TibiaHousesOverview.go @@ -50,10 +50,9 @@ var ( // TibiaHousesOverview func func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlDataCollector func(TibiaDataRequestStruct) (string, error)) (HousesOverviewResponse, error) { - var ( - // Creating empty vars - HouseData, GuildhallData []HousesHouse - ) + + // Creating empty vars + var HouseData, GuildhallData []HousesHouse // list of different fansite types HouseTypes := []string{"houses", "guildhalls"} @@ -84,6 +83,7 @@ func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlData Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=houses&world=" + TibiaDataQueryEscapeString(world) + "&town=" + TibiaDataQueryEscapeString(town), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesOverview_test.go b/src/TibiaHousesOverview_test.go index c306e8db..a1b78174 100644 --- a/src/TibiaHousesOverview_test.go +++ b/src/TibiaHousesOverview_test.go @@ -48,6 +48,9 @@ func TestAnticaThaisHousesOverview(t *testing.T) { } assert := assert.New(t) + information := housesJson.Information + + assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais", information.Link) assert.Equal("Antica", housesJson.Houses.World) assert.Equal("Thais", housesJson.Houses.Town) From 00495022904f56f185a1efd97cab1bb9f4a54e75 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Tue, 15 Oct 2024 23:59:04 +0900 Subject: [PATCH 14/36] Implement Killstatistics, TibiaNews, Spells and SpellsOverview With Tests --- src/TibiaKillstatistics.go | 1 + src/TibiaKillstatistics_test.go | 3 +++ src/TibiaNews.go | 3 ++- src/TibiaNews_test.go | 3 +++ src/TibiaNewslist.go | 1 + src/TibiaSpellsOverview.go | 3 ++- src/TibiaSpellsOverview_test.go | 3 +++ src/TibiaSpellsSpell.go | 3 ++- src/TibiaSpellsSpell_test.go | 3 +++ 9 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/TibiaKillstatistics.go b/src/TibiaKillstatistics.go index 747761e8..e4d6b7fc 100644 --- a/src/TibiaKillstatistics.go +++ b/src/TibiaKillstatistics.go @@ -90,6 +90,7 @@ func TibiaKillstatisticsImpl(world string, BoxContentHTML string) (KillStatistic Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=killstatistics&world=" + TibiaDataQueryEscapeString(world), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaKillstatistics_test.go b/src/TibiaKillstatistics_test.go index 49c236d8..aa29541c 100644 --- a/src/TibiaKillstatistics_test.go +++ b/src/TibiaKillstatistics_test.go @@ -26,6 +26,9 @@ func TestAntica(t *testing.T) { } assert := assert.New(t) + information := anticaJson.Information + + assert.Equal("https://www.tibia.com/community/?subtopic=killstatistics&world=Antica", information.Link) assert.Equal("Antica", anticaJson.KillStatistics.World) assert.Equal(1159, len(anticaJson.KillStatistics.Entries)) diff --git a/src/TibiaNews.go b/src/TibiaNews.go index 85e8112d..cbee6fe9 100644 --- a/src/TibiaNews.go +++ b/src/TibiaNews.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "regexp" + "strconv" "strings" "github.com/PuerkitoBio/goquery" @@ -51,7 +52,6 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon // getting category by image src CategoryImg, _ := s.Find("img").Attr("src") NewsData.Category = TibiaDataGetNewsCategory(CategoryImg) - // getting date from headline tmp1 = s.Find(".NewsHeadlineDate") tmp2, err = tmp1.Html() @@ -142,6 +142,7 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/news/?subtopic=newsarchive&id=" + strconv.Itoa(NewsID), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNews_test.go b/src/TibiaNews_test.go index 62f9b152..678eec56 100644 --- a/src/TibiaNews_test.go +++ b/src/TibiaNews_test.go @@ -26,6 +26,9 @@ func TestNewsById(t *testing.T) { } assert := assert.New(t) + information := newsArticleJson.Information + + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", information.Link) assert.Equal(6529, newsArticleJson.News.ID) assert.Equal("2022-01-12", newsArticleJson.News.Date) diff --git a/src/TibiaNewslist.go b/src/TibiaNewslist.go index 79d328b4..8af1eb4d 100644 --- a/src/TibiaNewslist.go +++ b/src/TibiaNewslist.go @@ -86,6 +86,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string) (NewsListResponse, error Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsOverview.go b/src/TibiaSpellsOverview.go index f4793814..f12b64ed 100644 --- a/src/TibiaSpellsOverview.go +++ b/src/TibiaSpellsOverview.go @@ -48,7 +48,7 @@ func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string) (Spells // Running query over each div ReaderHTML.Find(".Table3 table.TableContent tr").Each(func(index int, s *goquery.Selection) { - //Skip header row + // Skip header row if index == 0 { return } @@ -122,6 +122,7 @@ func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string) (Spells Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/library/?subtopic=spells", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsOverview_test.go b/src/TibiaSpellsOverview_test.go index 57930e6b..65c53440 100644 --- a/src/TibiaSpellsOverview_test.go +++ b/src/TibiaSpellsOverview_test.go @@ -26,6 +26,9 @@ func TestOverviewAll(t *testing.T) { } assert := assert.New(t) + information := spellsOverviewJson.Information + + assert.Equal("https://www.tibia.com/library/?subtopic=spells", information.Link) assert.Equal(152, len(spellsOverviewJson.Spells.Spells)) diff --git a/src/TibiaSpellsSpell.go b/src/TibiaSpellsSpell.go index 5fb3a4a7..46f138de 100644 --- a/src/TibiaSpellsSpell.go +++ b/src/TibiaSpellsSpell.go @@ -68,7 +68,7 @@ var ( // TibiaSpellsSpell func func TibiaSpellsSpellImpl(spell string, BoxContentHTML string) (SpellInformationResponse, error) { - //TODO: There is currently a bug with description, it always comes back empty + // TODO: There is currently a bug with description, it always comes back empty // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) @@ -313,6 +313,7 @@ func TibiaSpellsSpellImpl(spell string, BoxContentHTML string) (SpellInformation Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/library/?subtopic=spells&spell=" + SpellID, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsSpell_test.go b/src/TibiaSpellsSpell_test.go index 0ba0dc33..cb468693 100644 --- a/src/TibiaSpellsSpell_test.go +++ b/src/TibiaSpellsSpell_test.go @@ -27,6 +27,9 @@ func TestFindPerson(t *testing.T) { assert := assert.New(t) spell := findPersonJson.Spell + information := findPersonJson.Information + + assert.Equal("https://www.tibia.com/library/?subtopic=spells&spell=findperson", information.Link) assert.Empty(spell.Description) assert.Equal("Find Person", spell.Name) From 51c896984cbef8d10af157adca198df6f601f163 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 00:05:19 +0900 Subject: [PATCH 15/36] Tibia Worlds link with tests --- src/TibiaWorldsOverview.go | 1 + src/TibiaWorldsOverview_test.go | 3 +++ src/TibiaWorldsWorld.go | 3 ++- src/TibiaWorldsWorld_test.go | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/TibiaWorldsOverview.go b/src/TibiaWorldsOverview.go index 4b3e81b7..61fcd71a 100644 --- a/src/TibiaWorldsOverview.go +++ b/src/TibiaWorldsOverview.go @@ -206,6 +206,7 @@ func TibiaWorldsOverviewImpl(BoxContentHTML string) (WorldsOverviewResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=worlds", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsOverview_test.go b/src/TibiaWorldsOverview_test.go index ca7befa6..555666ca 100644 --- a/src/TibiaWorldsOverview_test.go +++ b/src/TibiaWorldsOverview_test.go @@ -26,6 +26,9 @@ func TestWorlds(t *testing.T) { } assert := assert.New(t) + information := worldsJson.Information + + assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.Link) assert.Equal(8720, worldsJson.Worlds.PlayersOnline) assert.Equal(64028, worldsJson.Worlds.RecordPlayers) diff --git a/src/TibiaWorldsWorld.go b/src/TibiaWorldsWorld.go index ae6896f7..7041c2fe 100644 --- a/src/TibiaWorldsWorld.go +++ b/src/TibiaWorldsWorld.go @@ -51,7 +51,7 @@ var ( // TibiaWorldsWorld func func TibiaWorldsWorldImpl(world string, BoxContentHTML string) (WorldResponse, error) { - //TODO: We need to read the world name from the response rather than pass it into this func + // TODO: We need to read the world name from the response rather than pass it into this func // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) @@ -230,6 +230,7 @@ func TibiaWorldsWorldImpl(world string, BoxContentHTML string) (WorldResponse, e Information: Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "https://www.tibia.com/community/?subtopic=worlds&world=" + world, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsWorld_test.go b/src/TibiaWorldsWorld_test.go index b0f6d50e..997a9b68 100644 --- a/src/TibiaWorldsWorld_test.go +++ b/src/TibiaWorldsWorld_test.go @@ -27,6 +27,9 @@ func TestWorldEndebra(t *testing.T) { assert := assert.New(t) world := worldJson.World + information := worldJson.Information + + assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.Link) assert.Equal("Endebra", world.Name) assert.Equal("online", world.Status) @@ -87,6 +90,7 @@ func TestWorldPremia(t *testing.T) { assert.Empty(world.TournamentWorldType) assert.Equal(0, len(world.OnlinePlayers)) } + func TestWorldWintera(t *testing.T) { file, err := static.TestFiles.Open("testdata/worlds/world/Wintera.html") if err != nil { From 627ab139411cd21e1d91cd9a47344c381976279d Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 00:31:21 +0900 Subject: [PATCH 16/36] Newslist and webserver Changes --- src/TibiaNewslist.go | 2 +- src/webserver.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TibiaNewslist.go b/src/TibiaNewslist.go index 8af1eb4d..296f4b76 100644 --- a/src/TibiaNewslist.go +++ b/src/TibiaNewslist.go @@ -86,7 +86,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string) (NewsListResponse, error Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "", + Link: "https://www.tibia.com/news/?subtopic=newsarchive", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/webserver.go b/src/webserver.go index 0d431045..c28661cc 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -122,6 +122,7 @@ func runWebServer() { data := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "-", Status: Status{ HTTPCode: http.StatusOK, Message: "pong", @@ -1090,6 +1091,7 @@ func TibiaDataErrorHandler(c *gin.Context, err error, httpCode int) { info := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), + Link: "-", Status: Status{ HTTPCode: httpCode, }, From c43bd2fea6aba49c4c149b1f0aaef42c1839996a Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 00:32:39 +0900 Subject: [PATCH 17/36] Tests for newslist --- src/TibiaNewslist_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/TibiaNewslist_test.go b/src/TibiaNewslist_test.go index f036b4fe..37f48d1c 100644 --- a/src/TibiaNewslist_test.go +++ b/src/TibiaNewslist_test.go @@ -28,6 +28,9 @@ func TestNewsList(t *testing.T) { } assert := assert.New(t) + information := newsListJson.Information + + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive", information.Link) assert.Equal(50, len(newsListJson.News)) From c9dcf716055b9e1290b3d45928edef29f4b015db Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 01:37:03 +0900 Subject: [PATCH 18/36] Swap Creature tests --- src/TibiaCreaturesCreature_test.go | 2 +- src/TibiaCreaturesOverview_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TibiaCreaturesCreature_test.go b/src/TibiaCreaturesCreature_test.go index e834f8ba..2ea6cd92 100644 --- a/src/TibiaCreaturesCreature_test.go +++ b/src/TibiaCreaturesCreature_test.go @@ -28,7 +28,7 @@ func TestDemon(t *testing.T) { assert := assert.New(t) information := demonJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.Link) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.Link) assert.Equal("Demons", demonJson.Creature.Name) assert.Equal("Demon", demonJson.Creature.Race) assert.Equal("https://static.tibia.com/images/library/demon.gif", demonJson.Creature.ImageURL) diff --git a/src/TibiaCreaturesOverview_test.go b/src/TibiaCreaturesOverview_test.go index df9e04f4..121589d7 100644 --- a/src/TibiaCreaturesOverview_test.go +++ b/src/TibiaCreaturesOverview_test.go @@ -28,7 +28,7 @@ func TestOverview(t *testing.T) { assert := assert.New(t) information := creaturesJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=Minotaur+Amazon", information.Link) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.Link) assert.Equal("Minotaur Amazon", creaturesJson.Creatures.Boosted.Name) assert.Equal("minotauramazon", creaturesJson.Creatures.Boosted.Race) assert.Equal("https://static.tibia.com/images/global/header/monsters/minotauramazon.gif", creaturesJson.Creatures.Boosted.ImageURL) From 7b9e9311be52ff8e677cd7faf70cc93d6a853743 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 16:20:34 +0900 Subject: [PATCH 19/36] Replace Link to TibiaURL --- src/TibiaBoostableBossesOverview.go | 2 +- src/TibiaBoostableBossesOverview_test.go | 2 +- src/TibiaCharactersCharacter.go | 2 +- src/TibiaCharactersCharacter_test.go | 2 +- src/TibiaCreaturesCreature.go | 2 +- src/TibiaCreaturesCreature_test.go | 2 +- src/TibiaCreaturesOverview.go | 2 +- src/TibiaCreaturesOverview_test.go | 2 +- src/TibiaFansites.go | 2 +- src/TibiaFansites_test.go | 2 +- src/TibiaGuildsGuild.go | 2 +- src/TibiaGuildsGuild_test.go | 2 +- src/TibiaGuildsOverview.go | 2 +- src/TibiaGuildsOverview_test.go | 2 +- src/TibiaHighscores.go | 2 +- src/TibiaHighscores_test.go | 2 +- src/TibiaHousesHouse.go | 2 +- src/TibiaHousesHouse_test.go | 2 +- src/TibiaHousesOverview.go | 2 +- src/TibiaHousesOverview_test.go | 2 +- src/TibiaKillstatistics.go | 2 +- src/TibiaKillstatistics_test.go | 2 +- src/TibiaNews.go | 2 +- src/TibiaNews_test.go | 2 +- src/TibiaNewslist.go | 2 +- src/TibiaNewslist_test.go | 2 +- src/TibiaSpellsOverview.go | 2 +- src/TibiaSpellsOverview_test.go | 2 +- src/TibiaSpellsSpell.go | 2 +- src/TibiaSpellsSpell_test.go | 2 +- src/TibiaWorldsOverview.go | 2 +- src/TibiaWorldsOverview_test.go | 2 +- src/TibiaWorldsWorld.go | 2 +- src/TibiaWorldsWorld_test.go | 2 +- src/webserver.go | 6 +++--- 35 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/TibiaBoostableBossesOverview.go b/src/TibiaBoostableBossesOverview.go index aaf2e5ad..39ea827f 100644 --- a/src/TibiaBoostableBossesOverview.go +++ b/src/TibiaBoostableBossesOverview.go @@ -151,7 +151,7 @@ func TibiaBoostableBossesOverviewImpl(BoxContentHTML string) (BoostableBossesOve Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=boostablebosses", + TibiaURL: "https://www.tibia.com/library/?subtopic=boostablebosses", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaBoostableBossesOverview_test.go b/src/TibiaBoostableBossesOverview_test.go index 8128f929..73c9f051 100644 --- a/src/TibiaBoostableBossesOverview_test.go +++ b/src/TibiaBoostableBossesOverview_test.go @@ -26,7 +26,7 @@ func TestBoostableBossesOverview(t *testing.T) { bosses := boostableBossesJson.BoostableBosses.BoostableBosses information := boostableBossesJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.Link) + assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.TibiaURL) assert.Equal(95, len(bosses)) assert.Equal("Ragiaz", boosted.Name) assert.Equal( diff --git a/src/TibiaCharactersCharacter.go b/src/TibiaCharactersCharacter.go index 0ac7a0eb..f422bb05 100644 --- a/src/TibiaCharactersCharacter.go +++ b/src/TibiaCharactersCharacter.go @@ -725,7 +725,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string) (CharacterResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=characters&name=" + TibiaDataQueryEscapeString(CharacterInfoData.Name), + TibiaURL: "https://www.tibia.com/community/?subtopic=characters&name=" + TibiaDataQueryEscapeString(CharacterInfoData.Name), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCharactersCharacter_test.go b/src/TibiaCharactersCharacter_test.go index 61c7e96a..ee1b4cf6 100644 --- a/src/TibiaCharactersCharacter_test.go +++ b/src/TibiaCharactersCharacter_test.go @@ -56,7 +56,7 @@ func TestNumber1(t *testing.T) { assert.Equal("Premium Account", character.AccountStatus) assert.Empty(character.Comment) - assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.TibiaURL) } func TestNumber2(t *testing.T) { diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index 55635c49..61eb12d6 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -192,7 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=creatures&race=" + race, + TibiaURL: "https://www.tibia.com/library/?subtopic=creatures&race=" + race, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesCreature_test.go b/src/TibiaCreaturesCreature_test.go index 2ea6cd92..6c87f3cb 100644 --- a/src/TibiaCreaturesCreature_test.go +++ b/src/TibiaCreaturesCreature_test.go @@ -28,7 +28,7 @@ func TestDemon(t *testing.T) { assert := assert.New(t) information := demonJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.Link) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.TibiaURL) assert.Equal("Demons", demonJson.Creature.Name) assert.Equal("Demon", demonJson.Creature.Race) assert.Equal("https://static.tibia.com/images/library/demon.gif", demonJson.Creature.ImageURL) diff --git a/src/TibiaCreaturesOverview.go b/src/TibiaCreaturesOverview.go index 023a278b..b3cdd688 100644 --- a/src/TibiaCreaturesOverview.go +++ b/src/TibiaCreaturesOverview.go @@ -125,7 +125,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewRespons Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=creatures", + TibiaURL: "https://www.tibia.com/library/?subtopic=creatures", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesOverview_test.go b/src/TibiaCreaturesOverview_test.go index 121589d7..b9c65886 100644 --- a/src/TibiaCreaturesOverview_test.go +++ b/src/TibiaCreaturesOverview_test.go @@ -28,7 +28,7 @@ func TestOverview(t *testing.T) { assert := assert.New(t) information := creaturesJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.Link) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.TibiaURL) assert.Equal("Minotaur Amazon", creaturesJson.Creatures.Boosted.Name) assert.Equal("minotauramazon", creaturesJson.Creatures.Boosted.Race) assert.Equal("https://static.tibia.com/images/global/header/monsters/minotauramazon.gif", creaturesJson.Creatures.Boosted.ImageURL) diff --git a/src/TibiaFansites.go b/src/TibiaFansites.go index d0369c21..47980db9 100644 --- a/src/TibiaFansites.go +++ b/src/TibiaFansites.go @@ -97,7 +97,7 @@ func TibiaFansitesImpl(BoxContentHTML string) (FansitesResponse, error) { Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=fansites", + TibiaURL: "https://www.tibia.com/community/?subtopic=fansites", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaFansites_test.go b/src/TibiaFansites_test.go index 746c53c5..244ab69c 100644 --- a/src/TibiaFansites_test.go +++ b/src/TibiaFansites_test.go @@ -88,5 +88,5 @@ func TestFansites(t *testing.T) { assert.Equal("https://static.tibia.com/images/community/fansiteitems/TibiaGallery.com.gif", tibiaGalleryFansite.FansiteItemURL) information := fansitesJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.TibiaURL) } diff --git a/src/TibiaGuildsGuild.go b/src/TibiaGuildsGuild.go index 926a6575..72227d18 100644 --- a/src/TibiaGuildsGuild.go +++ b/src/TibiaGuildsGuild.go @@ -282,7 +282,7 @@ func TibiaGuildsGuildImpl(guild string, BoxContentHTML string) (GuildResponse, e Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=" + TibiaDataQueryEscapeString(guildName), + TibiaURL: "https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=" + TibiaDataQueryEscapeString(guildName), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsGuild_test.go b/src/TibiaGuildsGuild_test.go index e0dc17bc..f57ff7aa 100644 --- a/src/TibiaGuildsGuild_test.go +++ b/src/TibiaGuildsGuild_test.go @@ -150,7 +150,7 @@ func TestMercenarys(t *testing.T) { assert.Equal("if there are still less than four vice leaders or an insufficient amount of premium accounts in the leading ranks by then", guild.DisbandedCondition) information := mercenarysJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys", information.TibiaURL) } func TestKotkiAntica(t *testing.T) { diff --git a/src/TibiaGuildsOverview.go b/src/TibiaGuildsOverview.go index f33d6288..1a7cc2be 100644 --- a/src/TibiaGuildsOverview.go +++ b/src/TibiaGuildsOverview.go @@ -95,7 +95,7 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string) (GuildsOvervie Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=guilds&world=" + world, + TibiaURL: "https://www.tibia.com/community/?subtopic=guilds&world=" + world, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsOverview_test.go b/src/TibiaGuildsOverview_test.go index c2377880..7b64b644 100644 --- a/src/TibiaGuildsOverview_test.go +++ b/src/TibiaGuildsOverview_test.go @@ -43,5 +43,5 @@ func TestPremia(t *testing.T) { assert.Equal("https://static.tibia.com/images/community/default_logo.gif", secondGuildInFormation.LogoURL) assert.Empty(secondGuildInFormation.Description) - assert.Equal("https://www.tibia.com/community/?subtopic=guilds&world=Premia", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&world=Premia", information.TibiaURL) } diff --git a/src/TibiaHighscores.go b/src/TibiaHighscores.go index 0cbaf376..ab53720e 100644 --- a/src/TibiaHighscores.go +++ b/src/TibiaHighscores.go @@ -178,7 +178,7 @@ func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vo Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=highscores&world=" + cases.Title(language.English).String(world) + "&category=" + categoryString + "&profession=" + TibiaDataQueryEscapeString(vocationName) + "¤tpage=" + strconv.Itoa(currentPage), + TibiaURL: "https://www.tibia.com/community/?subtopic=highscores&world=" + cases.Title(language.English).String(world) + "&category=" + categoryString + "&profession=" + TibiaDataQueryEscapeString(vocationName) + "¤tpage=" + strconv.Itoa(currentPage), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHighscores_test.go b/src/TibiaHighscores_test.go index e42c437c..b4dd7ec3 100644 --- a/src/TibiaHighscores_test.go +++ b/src/TibiaHighscores_test.go @@ -29,7 +29,7 @@ func TestHighscoresAll(t *testing.T) { assert := assert.New(t) information := highscoresJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.TibiaURL) assert.Empty(highscoresJson.Highscores.World) diff --git a/src/TibiaHousesHouse.go b/src/TibiaHousesHouse.go index 8da25d59..0f3df96e 100644 --- a/src/TibiaHousesHouse.go +++ b/src/TibiaHousesHouse.go @@ -171,7 +171,7 @@ func TibiaHousesHouseImpl(houseid int, BoxContentHTML string) (HouseResponse, er Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=houses&page=view&world=" + HouseData.World + "&houseid=" + strconv.Itoa(HouseData.Houseid), + TibiaURL: "https://www.tibia.com/community/?subtopic=houses&page=view&world=" + HouseData.World + "&houseid=" + strconv.Itoa(HouseData.Houseid), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesHouse_test.go b/src/TibiaHousesHouse_test.go index 899c809e..224c0b20 100644 --- a/src/TibiaHousesHouse_test.go +++ b/src/TibiaHousesHouse_test.go @@ -28,7 +28,7 @@ func TestCormaya10(t *testing.T) { assert := assert.New(t) information := houseJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025", information.TibiaURL) assert.Equal(54025, houseJson.House.Houseid) assert.Equal("Premia", houseJson.House.World) diff --git a/src/TibiaHousesOverview.go b/src/TibiaHousesOverview.go index a3f44e32..069d03f8 100644 --- a/src/TibiaHousesOverview.go +++ b/src/TibiaHousesOverview.go @@ -83,7 +83,7 @@ func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlData Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=houses&world=" + TibiaDataQueryEscapeString(world) + "&town=" + TibiaDataQueryEscapeString(town), + TibiaURL: "https://www.tibia.com/community/?subtopic=houses&world=" + TibiaDataQueryEscapeString(world) + "&town=" + TibiaDataQueryEscapeString(town), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesOverview_test.go b/src/TibiaHousesOverview_test.go index a1b78174..bc877b05 100644 --- a/src/TibiaHousesOverview_test.go +++ b/src/TibiaHousesOverview_test.go @@ -50,7 +50,7 @@ func TestAnticaThaisHousesOverview(t *testing.T) { assert := assert.New(t) information := housesJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais", information.TibiaURL) assert.Equal("Antica", housesJson.Houses.World) assert.Equal("Thais", housesJson.Houses.Town) diff --git a/src/TibiaKillstatistics.go b/src/TibiaKillstatistics.go index e4d6b7fc..37d9a1f7 100644 --- a/src/TibiaKillstatistics.go +++ b/src/TibiaKillstatistics.go @@ -90,7 +90,7 @@ func TibiaKillstatisticsImpl(world string, BoxContentHTML string) (KillStatistic Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=killstatistics&world=" + TibiaDataQueryEscapeString(world), + TibiaURL: "https://www.tibia.com/community/?subtopic=killstatistics&world=" + TibiaDataQueryEscapeString(world), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaKillstatistics_test.go b/src/TibiaKillstatistics_test.go index aa29541c..6f3bca8b 100644 --- a/src/TibiaKillstatistics_test.go +++ b/src/TibiaKillstatistics_test.go @@ -28,7 +28,7 @@ func TestAntica(t *testing.T) { assert := assert.New(t) information := anticaJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=killstatistics&world=Antica", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=killstatistics&world=Antica", information.TibiaURL) assert.Equal("Antica", anticaJson.KillStatistics.World) assert.Equal(1159, len(anticaJson.KillStatistics.Entries)) diff --git a/src/TibiaNews.go b/src/TibiaNews.go index cbee6fe9..7bec2fe7 100644 --- a/src/TibiaNews.go +++ b/src/TibiaNews.go @@ -142,7 +142,7 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/news/?subtopic=newsarchive&id=" + strconv.Itoa(NewsID), + TibiaURL: "https://www.tibia.com/news/?subtopic=newsarchive&id=" + strconv.Itoa(NewsID), Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNews_test.go b/src/TibiaNews_test.go index 678eec56..89712a48 100644 --- a/src/TibiaNews_test.go +++ b/src/TibiaNews_test.go @@ -28,7 +28,7 @@ func TestNewsById(t *testing.T) { assert := assert.New(t) information := newsArticleJson.Information - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", information.Link) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", information.TibiaURL) assert.Equal(6529, newsArticleJson.News.ID) assert.Equal("2022-01-12", newsArticleJson.News.Date) diff --git a/src/TibiaNewslist.go b/src/TibiaNewslist.go index 296f4b76..3a9f9782 100644 --- a/src/TibiaNewslist.go +++ b/src/TibiaNewslist.go @@ -86,7 +86,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string) (NewsListResponse, error Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/news/?subtopic=newsarchive", + TibiaURL: "https://www.tibia.com/news/?subtopic=newsarchive", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNewslist_test.go b/src/TibiaNewslist_test.go index 37f48d1c..7d1440c6 100644 --- a/src/TibiaNewslist_test.go +++ b/src/TibiaNewslist_test.go @@ -30,7 +30,7 @@ func TestNewsList(t *testing.T) { assert := assert.New(t) information := newsListJson.Information - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive", information.Link) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive", information.TibiaURL) assert.Equal(50, len(newsListJson.News)) diff --git a/src/TibiaSpellsOverview.go b/src/TibiaSpellsOverview.go index f12b64ed..8c5fa78a 100644 --- a/src/TibiaSpellsOverview.go +++ b/src/TibiaSpellsOverview.go @@ -122,7 +122,7 @@ func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string) (Spells Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=spells", + TibiaURL: "https://www.tibia.com/library/?subtopic=spells", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsOverview_test.go b/src/TibiaSpellsOverview_test.go index 65c53440..1fee3e2e 100644 --- a/src/TibiaSpellsOverview_test.go +++ b/src/TibiaSpellsOverview_test.go @@ -28,7 +28,7 @@ func TestOverviewAll(t *testing.T) { assert := assert.New(t) information := spellsOverviewJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=spells", information.Link) + assert.Equal("https://www.tibia.com/library/?subtopic=spells", information.TibiaURL) assert.Equal(152, len(spellsOverviewJson.Spells.Spells)) diff --git a/src/TibiaSpellsSpell.go b/src/TibiaSpellsSpell.go index 46f138de..f8b20bb4 100644 --- a/src/TibiaSpellsSpell.go +++ b/src/TibiaSpellsSpell.go @@ -313,7 +313,7 @@ func TibiaSpellsSpellImpl(spell string, BoxContentHTML string) (SpellInformation Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/library/?subtopic=spells&spell=" + SpellID, + TibiaURL: "https://www.tibia.com/library/?subtopic=spells&spell=" + SpellID, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsSpell_test.go b/src/TibiaSpellsSpell_test.go index cb468693..7b2153ac 100644 --- a/src/TibiaSpellsSpell_test.go +++ b/src/TibiaSpellsSpell_test.go @@ -29,7 +29,7 @@ func TestFindPerson(t *testing.T) { spell := findPersonJson.Spell information := findPersonJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=spells&spell=findperson", information.Link) + assert.Equal("https://www.tibia.com/library/?subtopic=spells&spell=findperson", information.TibiaURL) assert.Empty(spell.Description) assert.Equal("Find Person", spell.Name) diff --git a/src/TibiaWorldsOverview.go b/src/TibiaWorldsOverview.go index 61fcd71a..ab4084c8 100644 --- a/src/TibiaWorldsOverview.go +++ b/src/TibiaWorldsOverview.go @@ -206,7 +206,7 @@ func TibiaWorldsOverviewImpl(BoxContentHTML string) (WorldsOverviewResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=worlds", + TibiaURL: "https://www.tibia.com/community/?subtopic=worlds", Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsOverview_test.go b/src/TibiaWorldsOverview_test.go index 555666ca..127bf4cf 100644 --- a/src/TibiaWorldsOverview_test.go +++ b/src/TibiaWorldsOverview_test.go @@ -28,7 +28,7 @@ func TestWorlds(t *testing.T) { assert := assert.New(t) information := worldsJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.TibiaURL) assert.Equal(8720, worldsJson.Worlds.PlayersOnline) assert.Equal(64028, worldsJson.Worlds.RecordPlayers) diff --git a/src/TibiaWorldsWorld.go b/src/TibiaWorldsWorld.go index 7041c2fe..a3476b86 100644 --- a/src/TibiaWorldsWorld.go +++ b/src/TibiaWorldsWorld.go @@ -230,7 +230,7 @@ func TibiaWorldsWorldImpl(world string, BoxContentHTML string) (WorldResponse, e Information: Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "https://www.tibia.com/community/?subtopic=worlds&world=" + world, + TibiaURL: "https://www.tibia.com/community/?subtopic=worlds&world=" + world, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsWorld_test.go b/src/TibiaWorldsWorld_test.go index 997a9b68..1e6ed207 100644 --- a/src/TibiaWorldsWorld_test.go +++ b/src/TibiaWorldsWorld_test.go @@ -29,7 +29,7 @@ func TestWorldEndebra(t *testing.T) { world := worldJson.World information := worldJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.Link) + assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.TibiaURL) assert.Equal("Endebra", world.Name) assert.Equal("online", world.Status) diff --git a/src/webserver.go b/src/webserver.go index c28661cc..add6207b 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -47,7 +47,7 @@ type OutInformation struct { type Information struct { APIDetails APIDetails `json:"api"` // The API details. Timestamp string `json:"timestamp"` // The timestamp from when the data was processed. - Link string `json:"link"` // The link to the source of the data. + TibiaURL []string `json:"tibia_url"` // The links to the sources of the data on tibia.com. Status Status `json:"status"` // The response status information. } @@ -122,7 +122,7 @@ func runWebServer() { data := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "-", + TibiaURL: []string{}, Status: Status{ HTTPCode: http.StatusOK, Message: "pong", @@ -1091,7 +1091,7 @@ func TibiaDataErrorHandler(c *gin.Context, err error, httpCode int) { info := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - Link: "-", + TibiaURL: []string{}, Status: Status{ HTTPCode: httpCode, }, From cbeb45a63aa4642e4fa0519ab332fb5f510c886d Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 16:33:42 +0900 Subject: [PATCH 20/36] TibiaBossesOverview URL test/func and webserver Updates --- src/TibiaBoostableBossesOverview.go | 4 ++-- src/TibiaBoostableBossesOverview_test.go | 4 ++-- src/webserver.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TibiaBoostableBossesOverview.go b/src/TibiaBoostableBossesOverview.go index 39ea827f..4ca75255 100644 --- a/src/TibiaBoostableBossesOverview.go +++ b/src/TibiaBoostableBossesOverview.go @@ -27,7 +27,7 @@ type BoostableBossesOverviewResponse struct { Information Information `json:"information"` } -func TibiaBoostableBossesOverviewImpl(BoxContentHTML string) (BoostableBossesOverviewResponse, error) { +func TibiaBoostableBossesOverviewImpl(BoxContentHTML string, url string) (BoostableBossesOverviewResponse, error) { const ( bodyIndexer = `` @@ -151,7 +151,7 @@ func TibiaBoostableBossesOverviewImpl(BoxContentHTML string) (BoostableBossesOve Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/library/?subtopic=boostablebosses", + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaBoostableBossesOverview_test.go b/src/TibiaBoostableBossesOverview_test.go index 73c9f051..d7ec6ac4 100644 --- a/src/TibiaBoostableBossesOverview_test.go +++ b/src/TibiaBoostableBossesOverview_test.go @@ -20,7 +20,7 @@ func TestBoostableBossesOverview(t *testing.T) { t.Fatalf("File reading error: %s", err) } - boostableBossesJson, _ := TibiaBoostableBossesOverviewImpl(string(data)) + boostableBossesJson, _ := TibiaBoostableBossesOverviewImpl(string(data), "https://www.tibia.com/library/?subtopic=boostablebosses") assert := assert.New(t) boosted := boostableBossesJson.BoostableBosses.Boosted bosses := boostableBossesJson.BoostableBosses.BoostableBosses @@ -109,6 +109,6 @@ func BenchmarkTibiaBoostableBossesOverviewImpl(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - bossSink, _ = TibiaBoostableBossesOverviewImpl(data) + bossSink, _ = TibiaBoostableBossesOverviewImpl(data, "https://www.tibia.com/library/?subtopic=boostablebosses") } } diff --git a/src/webserver.go b/src/webserver.go index add6207b..fbaa35d8 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -275,7 +275,7 @@ func tibiaBoostableBosses(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaBoostableBossesOverviewImpl(BoxContentHTML) + return TibiaBoostableBossesOverviewImpl(BoxContentHTML, tibiadataRequest.URL) }, "TibiaBoostableBosses") } From 35fe5624518f1fc66623f2c0e90ee6501fb98285 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 16:56:35 +0900 Subject: [PATCH 21/36] TibiaCharactersCharacter test and func rewrite passing URL as argument --- src/TibiaCharactersCharacter.go | 4 ++-- src/TibiaCharactersCharacter_test.go | 30 ++++++++++++++-------------- src/webserver.go | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/TibiaCharactersCharacter.go b/src/TibiaCharactersCharacter.go index f422bb05..18950c0d 100644 --- a/src/TibiaCharactersCharacter.go +++ b/src/TibiaCharactersCharacter.go @@ -124,7 +124,7 @@ type CharacterResponse struct { const Br = 0x202 // TibiaCharactersCharacter func -func TibiaCharactersCharacterImpl(BoxContentHTML string) (CharacterResponse, error) { +func TibiaCharactersCharacterImpl(BoxContentHTML string, url string) (CharacterResponse, error) { var ( // local strings used in this function localDivQueryString = ".TableContentContainer tr" @@ -725,7 +725,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string) (CharacterResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=characters&name=" + TibiaDataQueryEscapeString(CharacterInfoData.Name), + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCharactersCharacter_test.go b/src/TibiaCharactersCharacter_test.go index ee1b4cf6..f14bb397 100644 --- a/src/TibiaCharactersCharacter_test.go +++ b/src/TibiaCharactersCharacter_test.go @@ -26,7 +26,7 @@ func TestNumber1(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa") if err != nil { t.Fatal(err) } @@ -71,7 +71,7 @@ func TestNumber2(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -137,7 +137,7 @@ func TestNumber3(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -172,7 +172,7 @@ func TestNumber4(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -2787,7 +2787,7 @@ func TestNumber5(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -2841,7 +2841,7 @@ func TestNumber6(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -2891,7 +2891,7 @@ func TestNumber7(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -2916,7 +2916,7 @@ func TestNumber8(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -3076,7 +3076,7 @@ func TestNumber9(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -3178,7 +3178,7 @@ func TestNumber10(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -3207,7 +3207,7 @@ func TestNumber11(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -3288,7 +3288,7 @@ func TestNumber12(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -3313,7 +3313,7 @@ func TestNumber13(t *testing.T) { t.Fatalf("File reading error: %s", err) } - characterJson, err := TibiaCharactersCharacterImpl(string(data)) + characterJson, err := TibiaCharactersCharacterImpl(string(data), "") if err != nil { t.Fatal(err) } @@ -3404,7 +3404,7 @@ func BenchmarkNumber1(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - characterJson, _ := TibiaCharactersCharacterImpl(string(data)) + characterJson, _ := TibiaCharactersCharacterImpl(string(data), "") assert.Equal(b, "Darkside Rafa", characterJson.Character.CharacterInfo.Name) } @@ -3425,7 +3425,7 @@ func BenchmarkNumber2(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - characterJson, _ := TibiaCharactersCharacterImpl(string(data)) + characterJson, _ := TibiaCharactersCharacterImpl(string(data), "") assert.Equal(b, "Riley No Hands", characterJson.Character.CharacterInfo.Name) } diff --git a/src/webserver.go b/src/webserver.go index fbaa35d8..ca0327d9 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -314,7 +314,7 @@ func tibiaCharactersCharacter(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaCharactersCharacterImpl(BoxContentHTML) + return TibiaCharactersCharacterImpl(BoxContentHTML, tibiadataRequest.URL) }, "TibiaCharactersCharacter") } From f7ad7a12182ed75292ca1a1c5f9613cc7459c80f Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 17:23:25 +0900 Subject: [PATCH 22/36] TibiaCreatures & CreaturesOverview func/test/server changes (url as argument) --- src/TibiaCreaturesCreature.go | 4 ++-- src/TibiaCreaturesCreature_test.go | 12 ++++++------ src/TibiaCreaturesOverview.go | 4 ++-- src/TibiaCreaturesOverview_test.go | 2 +- src/webserver.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index 61eb12d6..8ee4c839 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -52,7 +52,7 @@ var ( CreatureLootRegex = regexp.MustCompile(`.*yield (.*) experience.*carry (.*)with them.`) ) -func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureResponse, error) { +func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string, url string) (CreatureResponse, error) { // local strings used in this function localDamageString := " damage" @@ -192,7 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/library/?subtopic=creatures&race=" + race, + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesCreature_test.go b/src/TibiaCreaturesCreature_test.go index 6c87f3cb..7991faf9 100644 --- a/src/TibiaCreaturesCreature_test.go +++ b/src/TibiaCreaturesCreature_test.go @@ -20,7 +20,7 @@ func TestDemon(t *testing.T) { t.Fatalf("File reading error: %s", err) } - demonJson, err := TibiaCreaturesCreatureImpl("Demon", string(data)) + demonJson, err := TibiaCreaturesCreatureImpl("Demon", string(data), "https://www.tibia.com/library/?subtopic=creatures&race=demon") if err != nil { t.Fatal(err) } @@ -78,7 +78,7 @@ func TestQuaraPredatorFeatured(t *testing.T) { t.Fatalf("File reading error: %s", err) } - quaraPredatorJson, err := TibiaCreaturesCreatureImpl("Quara Predator", string(data)) + quaraPredatorJson, err := TibiaCreaturesCreatureImpl("Quara Predator", string(data), "") if err != nil { t.Fatal(err) } @@ -130,7 +130,7 @@ func TestCentipede(t *testing.T) { t.Fatalf("File reading error: %s", err) } - centipedeJson, _ := TibiaCreaturesCreatureImpl("Centipede", string(data)) + centipedeJson, _ := TibiaCreaturesCreatureImpl("Centipede", string(data), "") assert := assert.New(t) assert.Equal("Centipedes", centipedeJson.Creature.Name) @@ -154,7 +154,7 @@ func TestHunter(t *testing.T) { t.Fatalf("File reading error: %s", err) } - hunterJson, _ := TibiaCreaturesCreatureImpl("Hunter", string(data)) + hunterJson, _ := TibiaCreaturesCreatureImpl("Hunter", string(data), "") assert := assert.New(t) assert.Equal("Hunters", hunterJson.Creature.Name) @@ -178,7 +178,7 @@ func TestSkunk(t *testing.T) { t.Fatalf("File reading error: %s", err) } - skunkJson, _ := TibiaCreaturesCreatureImpl("Skunk", string(data)) + skunkJson, _ := TibiaCreaturesCreatureImpl("Skunk", string(data), "") assert := assert.New(t) assert.Equal("Skunks", skunkJson.Creature.Name) @@ -202,7 +202,7 @@ func TestLavaLurkers(t *testing.T) { t.Fatalf("File reading error: %s", err) } - lavalurkersJson, _ := TibiaCreaturesCreatureImpl("Lava Lurkers", string(data)) + lavalurkersJson, _ := TibiaCreaturesCreatureImpl("Lava Lurkers", string(data), "") assert := assert.New(t) assert.Equal("Lava Lurkers", lavalurkersJson.Creature.Name) diff --git a/src/TibiaCreaturesOverview.go b/src/TibiaCreaturesOverview.go index b3cdd688..5bdc7846 100644 --- a/src/TibiaCreaturesOverview.go +++ b/src/TibiaCreaturesOverview.go @@ -35,7 +35,7 @@ var ( CreatureInformationRegex = regexp.MustCompile(`.*race=(.*)">(.*)<\/div>`) ) -func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewResponse, error) { +func TibiaCreaturesOverviewImpl(BoxContentHTML string, url string) (CreaturesOverviewResponse, error) { var BoostedCreatureName, BoostedCreatureRace, BoostedCreatureImage string // Loading HTML data into ReaderHTML for goquery with NewReader @@ -125,7 +125,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewRespons Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/library/?subtopic=creatures", + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesOverview_test.go b/src/TibiaCreaturesOverview_test.go index b9c65886..b9b82ed1 100644 --- a/src/TibiaCreaturesOverview_test.go +++ b/src/TibiaCreaturesOverview_test.go @@ -20,7 +20,7 @@ func TestOverview(t *testing.T) { t.Fatalf("File reading error: %s", err) } - creaturesJson, err := TibiaCreaturesOverviewImpl(string(data)) + creaturesJson, err := TibiaCreaturesOverviewImpl(string(data), "https://www.tibia.com/library/?subtopic=creatures") if err != nil { t.Fatal(err) } diff --git a/src/webserver.go b/src/webserver.go index ca0327d9..56009756 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -340,7 +340,7 @@ func tibiaCreaturesOverview(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaCreaturesOverviewImpl(BoxContentHTML) + return TibiaCreaturesOverviewImpl(BoxContentHTML, tibiadataRequest.URL) }, "TibiaCreaturesOverview") } @@ -377,7 +377,7 @@ func tibiaCreaturesCreature(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaCreaturesCreatureImpl(endpoint, BoxContentHTML) + return TibiaCreaturesCreatureImpl(endpoint, BoxContentHTML, tibiadataRequest.URL) }, "TibiaCreaturesCreature") } From 860a08ee1a07c14abe85accd0ca7e3d6774c6cea Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 17:30:00 +0900 Subject: [PATCH 23/36] TibiaFansites func/test/webserver updates (passing url argument) --- src/TibiaFansites.go | 4 ++-- src/TibiaFansites_test.go | 2 +- src/webserver.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TibiaFansites.go b/src/TibiaFansites.go index 47980db9..e9cd5cf5 100644 --- a/src/TibiaFansites.go +++ b/src/TibiaFansites.go @@ -61,7 +61,7 @@ var ( FansiteAnchorRegex = regexp.MustCompile(`.*src="(.*)" alt=".*`) ) -func TibiaFansitesImpl(BoxContentHTML string) (FansitesResponse, error) { +func TibiaFansitesImpl(BoxContentHTML string, url string) (FansitesResponse, error) { // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) if err != nil { @@ -97,7 +97,7 @@ func TibiaFansitesImpl(BoxContentHTML string) (FansitesResponse, error) { Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=fansites", + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaFansites_test.go b/src/TibiaFansites_test.go index 244ab69c..d30c3e89 100644 --- a/src/TibiaFansites_test.go +++ b/src/TibiaFansites_test.go @@ -20,7 +20,7 @@ func TestFansites(t *testing.T) { t.Fatalf("File reading error: %s", err) } - fansitesJson, err := TibiaFansitesImpl(string(data)) + fansitesJson, err := TibiaFansitesImpl(string(data), "https://www.tibia.com/community/?subtopic=fansites") if err != nil { t.Fatal(err) } diff --git a/src/webserver.go b/src/webserver.go index 56009756..3735d686 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -403,7 +403,7 @@ func tibiaFansites(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaFansitesImpl(BoxContentHTML) + return TibiaFansitesImpl(BoxContentHTML, tibiadataRequest.URL) }, "TibiaFansites") } From 631ec36a050d1761f0437572a825feddc1bc5b3e Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 17:37:29 +0900 Subject: [PATCH 24/36] Guilds & GuildsOverview func/test/server update (url as args) --- src/TibiaGuildsGuild.go | 4 ++-- src/TibiaGuildsGuild_test.go | 10 +++++----- src/TibiaGuildsOverview.go | 4 ++-- src/TibiaGuildsOverview_test.go | 2 +- src/webserver.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/TibiaGuildsGuild.go b/src/TibiaGuildsGuild.go index 72227d18..87d29de4 100644 --- a/src/TibiaGuildsGuild.go +++ b/src/TibiaGuildsGuild.go @@ -78,7 +78,7 @@ var ( GuildMemberInvitesInformationRegex = regexp.MustCompile(`(.*)<\/a><\/td>(.*)<\/td>`) ) -func TibiaGuildsGuildImpl(guild string, BoxContentHTML string) (GuildResponse, error) { +func TibiaGuildsGuildImpl(guild string, BoxContentHTML string, url string) (GuildResponse, error) { // Creating empty vars var ( MembersData []GuildMember @@ -282,7 +282,7 @@ func TibiaGuildsGuildImpl(guild string, BoxContentHTML string) (GuildResponse, e Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=" + TibiaDataQueryEscapeString(guildName), + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsGuild_test.go b/src/TibiaGuildsGuild_test.go index f57ff7aa..665e0b41 100644 --- a/src/TibiaGuildsGuild_test.go +++ b/src/TibiaGuildsGuild_test.go @@ -20,7 +20,7 @@ func TestOrderofGlory(t *testing.T) { t.Fatalf("File reading error: %s", err) } - orderOfGloryJson, err := TibiaGuildsGuildImpl("Order of Glory", string(data)) + orderOfGloryJson, err := TibiaGuildsGuildImpl("Order of Glory", string(data), "") if err != nil { t.Fatal(err) } @@ -70,7 +70,7 @@ func TestElysium(t *testing.T) { t.Fatalf("File reading error: %s", err) } - elysiumJson, err := TibiaGuildsGuildImpl("Elysium", string(data)) + elysiumJson, err := TibiaGuildsGuildImpl("Elysium", string(data), "") if err != nil { t.Fatal(err) } @@ -126,7 +126,7 @@ func TestMercenarys(t *testing.T) { t.Fatalf("File reading error: %s", err) } - mercenarysJson, err := TibiaGuildsGuildImpl("Mercenarys", string(data)) + mercenarysJson, err := TibiaGuildsGuildImpl("Mercenarys", string(data), "https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys") if err != nil { t.Fatal(err) } @@ -165,7 +165,7 @@ func TestKotkiAntica(t *testing.T) { t.Fatalf("File reading error: %s", err) } - kotkianticaJson, err := TibiaGuildsGuildImpl("Kotki Antica", string(data)) + kotkianticaJson, err := TibiaGuildsGuildImpl("Kotki Antica", string(data), "") if err != nil { t.Fatal(err) } @@ -193,7 +193,7 @@ func TestNightsWatch(t *testing.T) { t.Fatalf("File reading error: %s", err) } - nightswatchJson, err := TibiaGuildsGuildImpl("Nights Watch", string(data)) + nightswatchJson, err := TibiaGuildsGuildImpl("Nights Watch", string(data), "") if err != nil { t.Fatal(err) } diff --git a/src/TibiaGuildsOverview.go b/src/TibiaGuildsOverview.go index 1a7cc2be..dacc3c80 100644 --- a/src/TibiaGuildsOverview.go +++ b/src/TibiaGuildsOverview.go @@ -28,7 +28,7 @@ type GuildsOverviewResponse struct { Information Information `json:"information"` } -func TibiaGuildsOverviewImpl(world string, BoxContentHTML string) (GuildsOverviewResponse, error) { +func TibiaGuildsOverviewImpl(world string, BoxContentHTML string, url string) (GuildsOverviewResponse, error) { // Creating empty vars var ( ActiveGuilds, FormationGuilds []OverviewGuild @@ -95,7 +95,7 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string) (GuildsOvervie Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=guilds&world=" + world, + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsOverview_test.go b/src/TibiaGuildsOverview_test.go index 7b64b644..0c555ffe 100644 --- a/src/TibiaGuildsOverview_test.go +++ b/src/TibiaGuildsOverview_test.go @@ -20,7 +20,7 @@ func TestPremia(t *testing.T) { t.Fatalf("File reading error: %s", err) } - premiaGuildsJson, err := TibiaGuildsOverviewImpl("Premia", string(data)) + premiaGuildsJson, err := TibiaGuildsOverviewImpl("Premia", string(data), "https://www.tibia.com/community/?subtopic=guilds&world=Premia") if err != nil { t.Fatal(err) } diff --git a/src/webserver.go b/src/webserver.go index 3735d686..c39c1ef2 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -440,7 +440,7 @@ func tibiaGuildsGuild(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaGuildsGuildImpl(guild, BoxContentHTML) + return TibiaGuildsGuildImpl(guild, BoxContentHTML, tibiadataRequest.URL) }, "TibiaGuildsGuild") } From 7ce818d3912c217f2bdfc4b8b148c56e565581e7 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 17:45:31 +0900 Subject: [PATCH 25/36] HousesHouse & Highscores func/webserver/test updates (passing url as args) --- src/TibiaHighscores.go | 5 ++--- src/TibiaHighscores_test.go | 4 ++-- src/TibiaHousesHouse.go | 5 ++--- src/TibiaHousesHouse_test.go | 10 +++++----- src/webserver.go | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/TibiaHighscores.go b/src/TibiaHighscores.go index ab53720e..19af3eb4 100644 --- a/src/TibiaHighscores.go +++ b/src/TibiaHighscores.go @@ -4,7 +4,6 @@ import ( "fmt" "net/http" "regexp" - "strconv" "strings" "github.com/PuerkitoBio/goquery" @@ -54,7 +53,7 @@ var ( SixColumnRegex = regexp.MustCompile(`(.*)<\/td>(.*)<\/a><\/td>(.*)<\/td>(.*)<\/td>(.*)<\/td>(.*)<\/td>`) ) -func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vocationName string, currentPage int, BoxContentHTML string) (HighscoresResponse, error) { +func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vocationName string, currentPage int, BoxContentHTML string, url string) (HighscoresResponse, error) { // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) if err != nil { @@ -178,7 +177,7 @@ func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vo Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=highscores&world=" + cases.Title(language.English).String(world) + "&category=" + categoryString + "&profession=" + TibiaDataQueryEscapeString(vocationName) + "¤tpage=" + strconv.Itoa(currentPage), + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHighscores_test.go b/src/TibiaHighscores_test.go index b4dd7ec3..2a9f43d6 100644 --- a/src/TibiaHighscores_test.go +++ b/src/TibiaHighscores_test.go @@ -21,7 +21,7 @@ func TestHighscoresAll(t *testing.T) { t.Fatalf("File reading error: %s", err) } - highscoresJson, err := TibiaHighscoresImpl("", validation.HighScoreExperience, "all", 1, string(data)) + highscoresJson, err := TibiaHighscoresImpl("", validation.HighScoreExperience, "all", 1, string(data), "https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1") if err != nil { t.Fatal(err) } @@ -74,7 +74,7 @@ func TestHighscoresLoyalty(t *testing.T) { t.Fatalf("File reading error: %s", err) } - highscoresJson, err := TibiaHighscoresImpl("Vunira", validation.HighScoreLoyaltypoints, "druids", 4, string(data)) + highscoresJson, err := TibiaHighscoresImpl("Vunira", validation.HighScoreLoyaltypoints, "druids", 4, string(data), "") if err != nil { t.Fatal(err) } diff --git a/src/TibiaHousesHouse.go b/src/TibiaHousesHouse.go index 0f3df96e..0b034225 100644 --- a/src/TibiaHousesHouse.go +++ b/src/TibiaHousesHouse.go @@ -4,7 +4,6 @@ import ( "fmt" "net/http" "regexp" - "strconv" "strings" "github.com/PuerkitoBio/goquery" @@ -73,7 +72,7 @@ var ( ) // TibiaHousesHouse func -func TibiaHousesHouseImpl(houseid int, BoxContentHTML string) (HouseResponse, error) { +func TibiaHousesHouseImpl(houseid int, BoxContentHTML string, url string) (HouseResponse, error) { // Creating empty vars var HouseData House @@ -171,7 +170,7 @@ func TibiaHousesHouseImpl(houseid int, BoxContentHTML string) (HouseResponse, er Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=houses&page=view&world=" + HouseData.World + "&houseid=" + strconv.Itoa(HouseData.Houseid), + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesHouse_test.go b/src/TibiaHousesHouse_test.go index 224c0b20..673338c6 100644 --- a/src/TibiaHousesHouse_test.go +++ b/src/TibiaHousesHouse_test.go @@ -20,7 +20,7 @@ func TestCormaya10(t *testing.T) { t.Fatalf("File reading error: %s", err) } - houseJson, err := TibiaHousesHouseImpl(54025, string(data)) + houseJson, err := TibiaHousesHouseImpl(54025, string(data), "https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025") if err != nil { t.Fatal(err) } @@ -72,7 +72,7 @@ func TestCormaya11(t *testing.T) { t.Fatalf("File reading error: %s", err) } - houseJson, err := TibiaHousesHouseImpl(54026, string(data)) + houseJson, err := TibiaHousesHouseImpl(54026, string(data), "") if err != nil { t.Fatal(err) } @@ -118,7 +118,7 @@ func TestCormaya9c(t *testing.T) { t.Fatalf("File reading error: %s", err) } - houseJson, _ := TibiaHousesHouseImpl(54023, string(data)) + houseJson, _ := TibiaHousesHouseImpl(54023, string(data), "") assert := assert.New(t) assert.Equal(54023, houseJson.House.Houseid) @@ -160,7 +160,7 @@ func TestBeachHomeApartmentsFlat14(t *testing.T) { t.Fatalf("File reading error: %s", err) } - houseJson, err := TibiaHousesHouseImpl(10214, string(data)) + houseJson, err := TibiaHousesHouseImpl(10214, string(data), "") if err != nil { t.Fatal(err) } @@ -206,7 +206,7 @@ func TestBeachHomeApartmentsFlat15(t *testing.T) { t.Fatalf("File reading error: %s", err) } - houseJson, err := TibiaHousesHouseImpl(10215, string(data)) + houseJson, err := TibiaHousesHouseImpl(10215, string(data), "") if err != nil { t.Fatal(err) } diff --git a/src/webserver.go b/src/webserver.go index c39c1ef2..7affa911 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -485,7 +485,7 @@ func tibiaGuildsOverview(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaGuildsOverviewImpl(world, BoxContentHTML) + return TibiaGuildsOverviewImpl(world, BoxContentHTML, tibiadataRequest.URL) }, "TibiaGuildsOverview") } @@ -578,7 +578,7 @@ func tibiaHighscores(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaHighscoresImpl(world, highscoreCategory, vocationName, TibiaDataStringToInteger(page), BoxContentHTML) + return TibiaHighscoresImpl(world, highscoreCategory, vocationName, TibiaDataStringToInteger(page), BoxContentHTML, tibiadataRequest.URL) }, "TibiaHighscores") } From 96dbbe6913131afc2f562a5ef6a5633ea9d80b77 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 19:10:27 +0900 Subject: [PATCH 26/36] HousesOverview update (urls) --- src/TibiaHousesOverview.go | 16 +++++++++------- src/TibiaHousesOverview_test.go | 4 +++- src/webserver.go | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/TibiaHousesOverview.go b/src/TibiaHousesOverview.go index 069d03f8..a65de482 100644 --- a/src/TibiaHousesOverview.go +++ b/src/TibiaHousesOverview.go @@ -50,16 +50,16 @@ var ( // TibiaHousesOverview func func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlDataCollector func(TibiaDataRequestStruct) (string, error)) (HousesOverviewResponse, error) { - // Creating empty vars var HouseData, GuildhallData []HousesHouse + var TibiaHouseURLs []string // list of different fansite types HouseTypes := []string{"houses", "guildhalls"} // running over the FansiteTypes array for _, HouseType := range HouseTypes { - houses, err := makeHouseRequest(HouseType, world, town, htmlDataCollector) + houses, houseUrl, err := makeHouseRequest(HouseType, world, town, htmlDataCollector) if err != nil { return HousesOverviewResponse{}, fmt.Errorf("[error] TibiaHousesOverviewImpl failed at makeHouseRequest, type: %s, err: %s", HouseType, err) } @@ -70,6 +70,8 @@ func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlData case "guildhalls": GuildhallData = houses } + + TibiaHouseURLs = append(TibiaHouseURLs, houseUrl) } // Build the data-blob @@ -83,7 +85,7 @@ func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlData Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=houses&world=" + TibiaDataQueryEscapeString(world) + "&town=" + TibiaDataQueryEscapeString(town), + TibiaURL: TibiaHouseURLs, Status: Status{ HTTPCode: http.StatusOK, }, @@ -91,7 +93,7 @@ func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlData }, nil } -func makeHouseRequest(HouseType, world, town string, htmlDataCollector func(TibiaDataRequestStruct) (string, error)) ([]HousesHouse, error) { +func makeHouseRequest(HouseType, world, town string, htmlDataCollector func(TibiaDataRequestStruct) (string, error)) ([]HousesHouse, string, error) { // Creating an empty var var output []HousesHouse @@ -103,13 +105,13 @@ func makeHouseRequest(HouseType, world, town string, htmlDataCollector func(Tibi BoxContentHTML, err := htmlDataCollector(tibiadataRequest) // return error (e.g. for maintenance mode) if err != nil { - return nil, err + return nil, "", err } // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) if err != nil { - return nil, err + return nil, "", err } var insideError error @@ -161,5 +163,5 @@ func makeHouseRequest(HouseType, world, town string, htmlDataCollector func(Tibi return true }) - return output, insideError + return output, tibiadataRequest.URL, insideError } diff --git a/src/TibiaHousesOverview_test.go b/src/TibiaHousesOverview_test.go index bc877b05..0a058a9e 100644 --- a/src/TibiaHousesOverview_test.go +++ b/src/TibiaHousesOverview_test.go @@ -50,7 +50,9 @@ func TestAnticaThaisHousesOverview(t *testing.T) { assert := assert.New(t) information := housesJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais&type=houses", information.TibiaURL[0]) + + assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais&type=guildhalls", information.TibiaURL[1]) assert.Equal("Antica", housesJson.Houses.World) assert.Equal("Thais", housesJson.Houses.Town) diff --git a/src/webserver.go b/src/webserver.go index 7affa911..a8b3a02e 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -643,7 +643,7 @@ func tibiaHousesHouse(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaHousesHouseImpl(houseid, BoxContentHTML) + return TibiaHousesHouseImpl(houseid, BoxContentHTML, tibiadataRequest.URL) }, "TibiaHousesHouse") } From e3feaea7afbdaf6c103200831acd97e7c788ea2e Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 19:13:27 +0900 Subject: [PATCH 27/36] Update tests to read from slices instead of string --- src/TibiaBoostableBossesOverview_test.go | 2 +- src/TibiaCharactersCharacter_test.go | 2 +- src/TibiaCreaturesCreature_test.go | 2 +- src/TibiaCreaturesOverview_test.go | 2 +- src/TibiaFansites_test.go | 2 +- src/TibiaGuildsGuild_test.go | 2 +- src/TibiaGuildsOverview_test.go | 2 +- src/TibiaHighscores_test.go | 2 +- src/TibiaHousesHouse_test.go | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/TibiaBoostableBossesOverview_test.go b/src/TibiaBoostableBossesOverview_test.go index d7ec6ac4..eed31c6f 100644 --- a/src/TibiaBoostableBossesOverview_test.go +++ b/src/TibiaBoostableBossesOverview_test.go @@ -26,7 +26,7 @@ func TestBoostableBossesOverview(t *testing.T) { bosses := boostableBossesJson.BoostableBosses.BoostableBosses information := boostableBossesJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.TibiaURL) + assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.TibiaURL[0]) assert.Equal(95, len(bosses)) assert.Equal("Ragiaz", boosted.Name) assert.Equal( diff --git a/src/TibiaCharactersCharacter_test.go b/src/TibiaCharactersCharacter_test.go index f14bb397..b24f60c7 100644 --- a/src/TibiaCharactersCharacter_test.go +++ b/src/TibiaCharactersCharacter_test.go @@ -56,7 +56,7 @@ func TestNumber1(t *testing.T) { assert.Equal("Premium Account", character.AccountStatus) assert.Empty(character.Comment) - assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.TibiaURL[0]) } func TestNumber2(t *testing.T) { diff --git a/src/TibiaCreaturesCreature_test.go b/src/TibiaCreaturesCreature_test.go index 7991faf9..2ed1e65f 100644 --- a/src/TibiaCreaturesCreature_test.go +++ b/src/TibiaCreaturesCreature_test.go @@ -28,7 +28,7 @@ func TestDemon(t *testing.T) { assert := assert.New(t) information := demonJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.TibiaURL) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.TibiaURL[0]) assert.Equal("Demons", demonJson.Creature.Name) assert.Equal("Demon", demonJson.Creature.Race) assert.Equal("https://static.tibia.com/images/library/demon.gif", demonJson.Creature.ImageURL) diff --git a/src/TibiaCreaturesOverview_test.go b/src/TibiaCreaturesOverview_test.go index b9b82ed1..5dff5b91 100644 --- a/src/TibiaCreaturesOverview_test.go +++ b/src/TibiaCreaturesOverview_test.go @@ -28,7 +28,7 @@ func TestOverview(t *testing.T) { assert := assert.New(t) information := creaturesJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.TibiaURL) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.TibiaURL[0]) assert.Equal("Minotaur Amazon", creaturesJson.Creatures.Boosted.Name) assert.Equal("minotauramazon", creaturesJson.Creatures.Boosted.Race) assert.Equal("https://static.tibia.com/images/global/header/monsters/minotauramazon.gif", creaturesJson.Creatures.Boosted.ImageURL) diff --git a/src/TibiaFansites_test.go b/src/TibiaFansites_test.go index d30c3e89..773807f0 100644 --- a/src/TibiaFansites_test.go +++ b/src/TibiaFansites_test.go @@ -88,5 +88,5 @@ func TestFansites(t *testing.T) { assert.Equal("https://static.tibia.com/images/community/fansiteitems/TibiaGallery.com.gif", tibiaGalleryFansite.FansiteItemURL) information := fansitesJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.TibiaURL[0]) } diff --git a/src/TibiaGuildsGuild_test.go b/src/TibiaGuildsGuild_test.go index 665e0b41..44bce06f 100644 --- a/src/TibiaGuildsGuild_test.go +++ b/src/TibiaGuildsGuild_test.go @@ -150,7 +150,7 @@ func TestMercenarys(t *testing.T) { assert.Equal("if there are still less than four vice leaders or an insufficient amount of premium accounts in the leading ranks by then", guild.DisbandedCondition) information := mercenarysJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys", information.TibiaURL[0]) } func TestKotkiAntica(t *testing.T) { diff --git a/src/TibiaGuildsOverview_test.go b/src/TibiaGuildsOverview_test.go index 0c555ffe..d422e6a5 100644 --- a/src/TibiaGuildsOverview_test.go +++ b/src/TibiaGuildsOverview_test.go @@ -43,5 +43,5 @@ func TestPremia(t *testing.T) { assert.Equal("https://static.tibia.com/images/community/default_logo.gif", secondGuildInFormation.LogoURL) assert.Empty(secondGuildInFormation.Description) - assert.Equal("https://www.tibia.com/community/?subtopic=guilds&world=Premia", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&world=Premia", information.TibiaURL[0]) } diff --git a/src/TibiaHighscores_test.go b/src/TibiaHighscores_test.go index 2a9f43d6..56023d53 100644 --- a/src/TibiaHighscores_test.go +++ b/src/TibiaHighscores_test.go @@ -29,7 +29,7 @@ func TestHighscoresAll(t *testing.T) { assert := assert.New(t) information := highscoresJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.TibiaURL[0]) assert.Empty(highscoresJson.Highscores.World) diff --git a/src/TibiaHousesHouse_test.go b/src/TibiaHousesHouse_test.go index 673338c6..8568d1bd 100644 --- a/src/TibiaHousesHouse_test.go +++ b/src/TibiaHousesHouse_test.go @@ -28,7 +28,7 @@ func TestCormaya10(t *testing.T) { assert := assert.New(t) information := houseJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025", information.TibiaURL[0]) assert.Equal(54025, houseJson.House.Houseid) assert.Equal("Premia", houseJson.House.World) From 478f9edac39fa5858bcf3db96ad8bb5798f5e4cd Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 19:17:03 +0900 Subject: [PATCH 28/36] Killstatistics update (url as param) --- src/TibiaKillstatistics.go | 4 ++-- src/TibiaKillstatistics_test.go | 6 +++--- src/webserver.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/TibiaKillstatistics.go b/src/TibiaKillstatistics.go index 37d9a1f7..d17b358d 100644 --- a/src/TibiaKillstatistics.go +++ b/src/TibiaKillstatistics.go @@ -38,7 +38,7 @@ type KillStatisticsResponse struct { Information Information `json:"information"` } -func TibiaKillstatisticsImpl(world string, BoxContentHTML string) (KillStatisticsResponse, error) { +func TibiaKillstatisticsImpl(world string, BoxContentHTML string, url string) (KillStatisticsResponse, error) { // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) if err != nil { @@ -90,7 +90,7 @@ func TibiaKillstatisticsImpl(world string, BoxContentHTML string) (KillStatistic Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=killstatistics&world=" + TibiaDataQueryEscapeString(world), + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaKillstatistics_test.go b/src/TibiaKillstatistics_test.go index 6f3bca8b..ab65c8ea 100644 --- a/src/TibiaKillstatistics_test.go +++ b/src/TibiaKillstatistics_test.go @@ -20,7 +20,7 @@ func TestAntica(t *testing.T) { t.Fatalf("File reading error: %s", err) } - anticaJson, err := TibiaKillstatisticsImpl("Antica", string(data)) + anticaJson, err := TibiaKillstatisticsImpl("Antica", string(data), "https://www.tibia.com/community/?subtopic=killstatistics&world=Antica") if err != nil { t.Fatal(err) } @@ -28,7 +28,7 @@ func TestAntica(t *testing.T) { assert := assert.New(t) information := anticaJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=killstatistics&world=Antica", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=killstatistics&world=Antica", information.TibiaURL[0]) assert.Equal("Antica", anticaJson.KillStatistics.World) assert.Equal(1159, len(anticaJson.KillStatistics.Entries)) @@ -65,7 +65,7 @@ func BenchmarkAntica(b *testing.B) { assert := assert.New(b) for i := 0; i < b.N; i++ { - anticaJson, err := TibiaKillstatisticsImpl("Antica", string(data)) + anticaJson, err := TibiaKillstatisticsImpl("Antica", string(data), "") if err != nil { b.Fatal(err) } diff --git a/src/webserver.go b/src/webserver.go index a8b3a02e..eb026faa 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -751,7 +751,7 @@ func tibiaKillstatistics(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaKillstatisticsImpl(world, BoxContentHTML) + return TibiaKillstatisticsImpl(world, BoxContentHTML, tibiadataRequest.URL) }, "TibiaKillstatistics") } From 12e659289ed33eff885c7be9b706a5b89ed5edbe Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 19:29:10 +0900 Subject: [PATCH 29/36] news and Newslist func/test/webserver updates (pass url as args) --- src/TibiaNews.go | 3 +-- src/TibiaNews_test.go | 2 +- src/TibiaNewslist.go | 4 ++-- src/TibiaNewslist_test.go | 4 ++-- src/webserver.go | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/TibiaNews.go b/src/TibiaNews.go index 7bec2fe7..d11a8c28 100644 --- a/src/TibiaNews.go +++ b/src/TibiaNews.go @@ -4,7 +4,6 @@ import ( "fmt" "net/http" "regexp" - "strconv" "strings" "github.com/PuerkitoBio/goquery" @@ -142,7 +141,7 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/news/?subtopic=newsarchive&id=" + strconv.Itoa(NewsID), + TibiaURL: []string{rawUrl}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNews_test.go b/src/TibiaNews_test.go index 89712a48..a7b1c035 100644 --- a/src/TibiaNews_test.go +++ b/src/TibiaNews_test.go @@ -28,7 +28,7 @@ func TestNewsById(t *testing.T) { assert := assert.New(t) information := newsArticleJson.Information - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", information.TibiaURL) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", information.TibiaURL[0]) assert.Equal(6529, newsArticleJson.News.ID) assert.Equal("2022-01-12", newsArticleJson.News.Date) diff --git a/src/TibiaNewslist.go b/src/TibiaNewslist.go index 3a9f9782..1ee3939e 100644 --- a/src/TibiaNewslist.go +++ b/src/TibiaNewslist.go @@ -26,7 +26,7 @@ type NewsListResponse struct { Information Information `json:"information"` } -func TibiaNewslistImpl(days int, BoxContentHTML string) (NewsListResponse, error) { +func TibiaNewslistImpl(days int, BoxContentHTML string, handlerURL string) (NewsListResponse, error) { // Declaring vars for later use.. var NewsListData []NewsItem @@ -86,7 +86,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string) (NewsListResponse, error Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/news/?subtopic=newsarchive", + TibiaURL: []string{handlerURL}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNewslist_test.go b/src/TibiaNewslist_test.go index 7d1440c6..2a128b23 100644 --- a/src/TibiaNewslist_test.go +++ b/src/TibiaNewslist_test.go @@ -22,7 +22,7 @@ func TestNewsList(t *testing.T) { TibiaDataHost = "unittest.example.com" - newsListJson, err := TibiaNewslistImpl(90, string(data)) + newsListJson, err := TibiaNewslistImpl(90, string(data), "https://www.tibia.com/news/?subtopic=newsarchive") if err != nil { t.Fatal(err) } @@ -30,7 +30,7 @@ func TestNewsList(t *testing.T) { assert := assert.New(t) information := newsListJson.Information - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive", information.TibiaURL) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive", information.TibiaURL[0]) assert.Equal(50, len(newsListJson.News)) diff --git a/src/webserver.go b/src/webserver.go index eb026faa..c01ed854 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -879,7 +879,7 @@ func tibiaNewslist(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaNewslistImpl(days, BoxContentHTML) + return TibiaNewslistImpl(days, BoxContentHTML, tibiadataRequest.URL) }, "TibiaNewslist") } From d2c1ebf4610636293df67db09d851e7654d6a2fd Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 19:36:55 +0900 Subject: [PATCH 30/36] Spells and SpellsOverview func/webserver/test update (pass url as args) --- src/TibiaSpellsOverview.go | 4 ++-- src/TibiaSpellsOverview_test.go | 6 +++--- src/TibiaSpellsSpell.go | 4 ++-- src/TibiaSpellsSpell_test.go | 12 ++++++------ src/webserver.go | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/TibiaSpellsOverview.go b/src/TibiaSpellsOverview.go index 8c5fa78a..0326642d 100644 --- a/src/TibiaSpellsOverview.go +++ b/src/TibiaSpellsOverview.go @@ -37,7 +37,7 @@ type SpellsOverviewResponse struct { } // TibiaSpellsOverview func -func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string) (SpellsOverviewResponse, error) { +func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string, url string) (SpellsOverviewResponse, error) { // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) if err != nil { @@ -122,7 +122,7 @@ func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string) (Spells Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/library/?subtopic=spells", + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsOverview_test.go b/src/TibiaSpellsOverview_test.go index 1fee3e2e..af021475 100644 --- a/src/TibiaSpellsOverview_test.go +++ b/src/TibiaSpellsOverview_test.go @@ -20,7 +20,7 @@ func TestOverviewAll(t *testing.T) { t.Fatalf("File reading error: %s", err) } - spellsOverviewJson, err := TibiaSpellsOverviewImpl("", string(data)) + spellsOverviewJson, err := TibiaSpellsOverviewImpl("", string(data), "https://www.tibia.com/library/?subtopic=spells") if err != nil { t.Fatal(err) } @@ -28,7 +28,7 @@ func TestOverviewAll(t *testing.T) { assert := assert.New(t) information := spellsOverviewJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=spells", information.TibiaURL) + assert.Equal("https://www.tibia.com/library/?subtopic=spells", information.TibiaURL[0]) assert.Equal(152, len(spellsOverviewJson.Spells.Spells)) @@ -78,7 +78,7 @@ func TestOverviewDruid(t *testing.T) { t.Fatalf("File reading error: %s", err) } - spellsOverviewJson, err := TibiaSpellsOverviewImpl("druid", string(data)) + spellsOverviewJson, err := TibiaSpellsOverviewImpl("druid", string(data), "") if err != nil { t.Fatal(err) } diff --git a/src/TibiaSpellsSpell.go b/src/TibiaSpellsSpell.go index f8b20bb4..56bfb9f1 100644 --- a/src/TibiaSpellsSpell.go +++ b/src/TibiaSpellsSpell.go @@ -67,7 +67,7 @@ var ( ) // TibiaSpellsSpell func -func TibiaSpellsSpellImpl(spell string, BoxContentHTML string) (SpellInformationResponse, error) { +func TibiaSpellsSpellImpl(spell string, BoxContentHTML string, url string) (SpellInformationResponse, error) { // TODO: There is currently a bug with description, it always comes back empty // Loading HTML data into ReaderHTML for goquery with NewReader @@ -313,7 +313,7 @@ func TibiaSpellsSpellImpl(spell string, BoxContentHTML string) (SpellInformation Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/library/?subtopic=spells&spell=" + SpellID, + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsSpell_test.go b/src/TibiaSpellsSpell_test.go index 7b2153ac..1c795815 100644 --- a/src/TibiaSpellsSpell_test.go +++ b/src/TibiaSpellsSpell_test.go @@ -20,7 +20,7 @@ func TestFindPerson(t *testing.T) { t.Fatalf("File reading error: %s", err) } - findPersonJson, err := TibiaSpellsSpellImpl("Find Person", string(data)) + findPersonJson, err := TibiaSpellsSpellImpl("Find Person", string(data), "https://www.tibia.com/library/?subtopic=spells&spell=findperson") if err != nil { t.Fatal(err) } @@ -71,7 +71,7 @@ func TestHeavyMagicMissileRune(t *testing.T) { t.Fatalf("File reading error: %s", err) } - hmmJson, err := TibiaSpellsSpellImpl("Heavy Magic Missile Rune", string(data)) + hmmJson, err := TibiaSpellsSpellImpl("Heavy Magic Missile Rune", string(data), "") if err != nil { t.Fatal(err) } @@ -130,7 +130,7 @@ func TestAnnihilation(t *testing.T) { t.Fatalf("File reading error: %s", err) } - annihilationJson, err := TibiaSpellsSpellImpl("Annihilation", string(data)) + annihilationJson, err := TibiaSpellsSpellImpl("Annihilation", string(data), "") if err != nil { t.Fatal(err) } @@ -173,7 +173,7 @@ func TestBruiseBane(t *testing.T) { t.Fatalf("File reading error: %s", err) } - bruisebaneJson, err := TibiaSpellsSpellImpl("Bruise Bane", string(data)) + bruisebaneJson, err := TibiaSpellsSpellImpl("Bruise Bane", string(data), "") if err != nil { t.Fatal(err) } @@ -216,7 +216,7 @@ func TestCurePoisonRune(t *testing.T) { t.Fatalf("File reading error: %s", err) } - curepoisonruneJson, err := TibiaSpellsSpellImpl("Cure Poison Rune", string(data)) + curepoisonruneJson, err := TibiaSpellsSpellImpl("Cure Poison Rune", string(data), "") if err != nil { t.Fatal(err) } @@ -255,7 +255,7 @@ func TestConvinceCreatureRune(t *testing.T) { t.Fatalf("File reading error: %s", err) } - convincecreatureruneJson, err := TibiaSpellsSpellImpl("Convince Creature Rune", string(data)) + convincecreatureruneJson, err := TibiaSpellsSpellImpl("Convince Creature Rune", string(data), "") if err != nil { t.Fatal(err) } diff --git a/src/webserver.go b/src/webserver.go index c01ed854..dbd2b99d 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -971,7 +971,7 @@ func tibiaSpellsOverview(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaSpellsOverviewImpl(vocationName, BoxContentHTML) + return TibiaSpellsOverviewImpl(vocationName, BoxContentHTML, tibiadataRequest.URL) }, "TibiaSpellsOverview") } @@ -1007,7 +1007,7 @@ func tibiaSpellsSpell(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaSpellsSpellImpl(spell, BoxContentHTML) + return TibiaSpellsSpellImpl(spell, BoxContentHTML, tibiadataRequest.URL) }, "TibiaSpellsSpell") } From 71b9f13acfb6638a533c44a277735640a2c30057 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Wed, 16 Oct 2024 19:41:32 +0900 Subject: [PATCH 31/36] Worlds & WorldsOverview func/test/webserver updates (pass url as args) --- src/TibiaWorldsOverview.go | 4 ++-- src/TibiaWorldsOverview_test.go | 4 ++-- src/TibiaWorldsWorld.go | 4 ++-- src/TibiaWorldsWorld_test.go | 12 ++++++------ src/webserver.go | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/TibiaWorldsOverview.go b/src/TibiaWorldsOverview.go index ab4084c8..0f5e20ab 100644 --- a/src/TibiaWorldsOverview.go +++ b/src/TibiaWorldsOverview.go @@ -46,7 +46,7 @@ var ( ) // TibiaWorldsOverview func -func TibiaWorldsOverviewImpl(BoxContentHTML string) (WorldsOverviewResponse, error) { +func TibiaWorldsOverviewImpl(BoxContentHTML string, url string) (WorldsOverviewResponse, error) { // Loading HTML data into ReaderHTML for goquery with NewReader ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML)) if err != nil { @@ -206,7 +206,7 @@ func TibiaWorldsOverviewImpl(BoxContentHTML string) (WorldsOverviewResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=worlds", + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsOverview_test.go b/src/TibiaWorldsOverview_test.go index 127bf4cf..af815ded 100644 --- a/src/TibiaWorldsOverview_test.go +++ b/src/TibiaWorldsOverview_test.go @@ -20,7 +20,7 @@ func TestWorlds(t *testing.T) { t.Fatalf("File reading error: %s", err) } - worldsJson, err := TibiaWorldsOverviewImpl(string(data)) + worldsJson, err := TibiaWorldsOverviewImpl(string(data), "https://www.tibia.com/community/?subtopic=worlds") if err != nil { t.Fatal(err) } @@ -28,7 +28,7 @@ func TestWorlds(t *testing.T) { assert := assert.New(t) information := worldsJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.TibiaURL[0]) assert.Equal(8720, worldsJson.Worlds.PlayersOnline) assert.Equal(64028, worldsJson.Worlds.RecordPlayers) diff --git a/src/TibiaWorldsWorld.go b/src/TibiaWorldsWorld.go index a3476b86..78d837c4 100644 --- a/src/TibiaWorldsWorld.go +++ b/src/TibiaWorldsWorld.go @@ -50,7 +50,7 @@ var ( ) // TibiaWorldsWorld func -func TibiaWorldsWorldImpl(world string, BoxContentHTML string) (WorldResponse, error) { +func TibiaWorldsWorldImpl(world string, BoxContentHTML string, url string) (WorldResponse, error) { // TODO: We need to read the world name from the response rather than pass it into this func // Loading HTML data into ReaderHTML for goquery with NewReader @@ -230,7 +230,7 @@ func TibiaWorldsWorldImpl(world string, BoxContentHTML string) (WorldResponse, e Information: Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: "https://www.tibia.com/community/?subtopic=worlds&world=" + world, + TibiaURL: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsWorld_test.go b/src/TibiaWorldsWorld_test.go index 1e6ed207..058a97dc 100644 --- a/src/TibiaWorldsWorld_test.go +++ b/src/TibiaWorldsWorld_test.go @@ -20,7 +20,7 @@ func TestWorldEndebra(t *testing.T) { t.Fatalf("File reading error: %s", err) } - worldJson, err := TibiaWorldsWorldImpl("Endebra", string(data)) + worldJson, err := TibiaWorldsWorldImpl("Endebra", string(data), "https://www.tibia.com/community/?subtopic=worlds&world=Endebra") if err != nil { t.Fatal(err) } @@ -29,7 +29,7 @@ func TestWorldEndebra(t *testing.T) { world := worldJson.World information := worldJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.TibiaURL) + assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.TibiaURL[0]) assert.Equal("Endebra", world.Name) assert.Equal("online", world.Status) @@ -61,7 +61,7 @@ func TestWorldPremia(t *testing.T) { t.Fatalf("File reading error: %s", err) } - worldJson, err := TibiaWorldsWorldImpl("Premia", string(data)) + worldJson, err := TibiaWorldsWorldImpl("Premia", string(data), "") if err != nil { t.Fatal(err) } @@ -103,7 +103,7 @@ func TestWorldWintera(t *testing.T) { t.Fatalf("File reading error: %s", err) } - worldJson, err := TibiaWorldsWorldImpl("Wintera", string(data)) + worldJson, err := TibiaWorldsWorldImpl("Wintera", string(data), "") if err != nil { t.Fatal(err) } @@ -150,7 +150,7 @@ func TestWorldZuna(t *testing.T) { t.Fatalf("File reading error: %s", err) } - worldJson, err := TibiaWorldsWorldImpl("Zuna", string(data)) + worldJson, err := TibiaWorldsWorldImpl("Zuna", string(data), "") if err != nil { t.Fatal(err) } @@ -195,7 +195,7 @@ func TestWorldOceanis(t *testing.T) { t.Fatalf("File reading error: %s", err) } - worldJson, err := TibiaWorldsWorldImpl("Oceanis", string(data)) + worldJson, err := TibiaWorldsWorldImpl("Oceanis", string(data), "") if err != nil { t.Fatal(err) } diff --git a/src/webserver.go b/src/webserver.go index dbd2b99d..f87718e5 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -1033,7 +1033,7 @@ func tibiaWorldsOverview(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaWorldsOverviewImpl(BoxContentHTML) + return TibiaWorldsOverviewImpl(BoxContentHTML, tibiadataRequest.URL) }, "TibiaWorldsOverview") } @@ -1078,7 +1078,7 @@ func tibiaWorldsWorld(c *gin.Context) { c, tibiadataRequest, func(BoxContentHTML string) (interface{}, error) { - return TibiaWorldsWorldImpl(world, BoxContentHTML) + return TibiaWorldsWorldImpl(world, BoxContentHTML, tibiadataRequest.URL) }, "TibiaWorldsWorld") } From af471830bb78009ac1613ca54f4ae4dd21a2632e Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Fri, 25 Oct 2024 13:25:42 +0900 Subject: [PATCH 32/36] replace TibiaURL to TibiaURLs --- src/TibiaBoostableBossesOverview.go | 2 +- src/TibiaBoostableBossesOverview_test.go | 2 +- src/TibiaCharactersCharacter.go | 2 +- src/TibiaCharactersCharacter_test.go | 2 +- src/TibiaCreaturesCreature.go | 2 +- src/TibiaCreaturesCreature_test.go | 2 +- src/TibiaCreaturesOverview.go | 2 +- src/TibiaCreaturesOverview_test.go | 2 +- src/TibiaFansites.go | 2 +- src/TibiaFansites_test.go | 2 +- src/TibiaGuildsGuild.go | 2 +- src/TibiaGuildsGuild_test.go | 2 +- src/TibiaGuildsOverview.go | 2 +- src/TibiaGuildsOverview_test.go | 2 +- src/TibiaHighscores.go | 2 +- src/TibiaHighscores_test.go | 2 +- src/TibiaHousesHouse.go | 2 +- src/TibiaHousesHouse_test.go | 2 +- src/TibiaHousesOverview.go | 2 +- src/TibiaHousesOverview_test.go | 4 ++-- src/TibiaKillstatistics.go | 2 +- src/TibiaKillstatistics_test.go | 2 +- src/TibiaNews.go | 6 +++--- src/TibiaNews_test.go | 10 +++++----- src/TibiaNewslist.go | 6 +++--- src/TibiaNewslist_test.go | 4 ++-- src/TibiaSpellsOverview.go | 2 +- src/TibiaSpellsOverview_test.go | 2 +- src/TibiaSpellsSpell.go | 2 +- src/TibiaSpellsSpell_test.go | 2 +- src/TibiaWorldsOverview.go | 2 +- src/TibiaWorldsOverview_test.go | 2 +- src/TibiaWorldsWorld.go | 2 +- src/TibiaWorldsWorld_test.go | 2 +- src/webserver.go | 6 +++--- 35 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/TibiaBoostableBossesOverview.go b/src/TibiaBoostableBossesOverview.go index 4ca75255..169fe069 100644 --- a/src/TibiaBoostableBossesOverview.go +++ b/src/TibiaBoostableBossesOverview.go @@ -151,7 +151,7 @@ func TibiaBoostableBossesOverviewImpl(BoxContentHTML string, url string) (Boosta Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaBoostableBossesOverview_test.go b/src/TibiaBoostableBossesOverview_test.go index eed31c6f..a5ac7042 100644 --- a/src/TibiaBoostableBossesOverview_test.go +++ b/src/TibiaBoostableBossesOverview_test.go @@ -26,7 +26,7 @@ func TestBoostableBossesOverview(t *testing.T) { bosses := boostableBossesJson.BoostableBosses.BoostableBosses information := boostableBossesJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.TibiaURLs[0]) assert.Equal(95, len(bosses)) assert.Equal("Ragiaz", boosted.Name) assert.Equal( diff --git a/src/TibiaCharactersCharacter.go b/src/TibiaCharactersCharacter.go index 18950c0d..589fe292 100644 --- a/src/TibiaCharactersCharacter.go +++ b/src/TibiaCharactersCharacter.go @@ -725,7 +725,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string, url string) (CharacterR Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCharactersCharacter_test.go b/src/TibiaCharactersCharacter_test.go index b24f60c7..b502ed73 100644 --- a/src/TibiaCharactersCharacter_test.go +++ b/src/TibiaCharactersCharacter_test.go @@ -56,7 +56,7 @@ func TestNumber1(t *testing.T) { assert.Equal("Premium Account", character.AccountStatus) assert.Empty(character.Comment) - assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.TibiaURLs[0]) } func TestNumber2(t *testing.T) { diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index 8ee4c839..04df6f33 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -192,7 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string, url string) Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesCreature_test.go b/src/TibiaCreaturesCreature_test.go index 2ed1e65f..91cdffeb 100644 --- a/src/TibiaCreaturesCreature_test.go +++ b/src/TibiaCreaturesCreature_test.go @@ -28,7 +28,7 @@ func TestDemon(t *testing.T) { assert := assert.New(t) information := demonJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.TibiaURLs[0]) assert.Equal("Demons", demonJson.Creature.Name) assert.Equal("Demon", demonJson.Creature.Race) assert.Equal("https://static.tibia.com/images/library/demon.gif", demonJson.Creature.ImageURL) diff --git a/src/TibiaCreaturesOverview.go b/src/TibiaCreaturesOverview.go index 5bdc7846..d96b318c 100644 --- a/src/TibiaCreaturesOverview.go +++ b/src/TibiaCreaturesOverview.go @@ -125,7 +125,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string, url string) (CreaturesOve Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesOverview_test.go b/src/TibiaCreaturesOverview_test.go index 5dff5b91..6c3e0a1b 100644 --- a/src/TibiaCreaturesOverview_test.go +++ b/src/TibiaCreaturesOverview_test.go @@ -28,7 +28,7 @@ func TestOverview(t *testing.T) { assert := assert.New(t) information := creaturesJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.TibiaURLs[0]) assert.Equal("Minotaur Amazon", creaturesJson.Creatures.Boosted.Name) assert.Equal("minotauramazon", creaturesJson.Creatures.Boosted.Race) assert.Equal("https://static.tibia.com/images/global/header/monsters/minotauramazon.gif", creaturesJson.Creatures.Boosted.ImageURL) diff --git a/src/TibiaFansites.go b/src/TibiaFansites.go index e9cd5cf5..c4391d46 100644 --- a/src/TibiaFansites.go +++ b/src/TibiaFansites.go @@ -97,7 +97,7 @@ func TibiaFansitesImpl(BoxContentHTML string, url string) (FansitesResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaFansites_test.go b/src/TibiaFansites_test.go index 773807f0..f6a78430 100644 --- a/src/TibiaFansites_test.go +++ b/src/TibiaFansites_test.go @@ -88,5 +88,5 @@ func TestFansites(t *testing.T) { assert.Equal("https://static.tibia.com/images/community/fansiteitems/TibiaGallery.com.gif", tibiaGalleryFansite.FansiteItemURL) information := fansitesJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.TibiaURLs[0]) } diff --git a/src/TibiaGuildsGuild.go b/src/TibiaGuildsGuild.go index 87d29de4..4631950a 100644 --- a/src/TibiaGuildsGuild.go +++ b/src/TibiaGuildsGuild.go @@ -282,7 +282,7 @@ func TibiaGuildsGuildImpl(guild string, BoxContentHTML string, url string) (Guil Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsGuild_test.go b/src/TibiaGuildsGuild_test.go index 44bce06f..86aec98d 100644 --- a/src/TibiaGuildsGuild_test.go +++ b/src/TibiaGuildsGuild_test.go @@ -150,7 +150,7 @@ func TestMercenarys(t *testing.T) { assert.Equal("if there are still less than four vice leaders or an insufficient amount of premium accounts in the leading ranks by then", guild.DisbandedCondition) information := mercenarysJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=Mercenarys", information.TibiaURLs[0]) } func TestKotkiAntica(t *testing.T) { diff --git a/src/TibiaGuildsOverview.go b/src/TibiaGuildsOverview.go index dacc3c80..27dda2fb 100644 --- a/src/TibiaGuildsOverview.go +++ b/src/TibiaGuildsOverview.go @@ -95,7 +95,7 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string, url string) (G Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsOverview_test.go b/src/TibiaGuildsOverview_test.go index d422e6a5..d75c60c3 100644 --- a/src/TibiaGuildsOverview_test.go +++ b/src/TibiaGuildsOverview_test.go @@ -43,5 +43,5 @@ func TestPremia(t *testing.T) { assert.Equal("https://static.tibia.com/images/community/default_logo.gif", secondGuildInFormation.LogoURL) assert.Empty(secondGuildInFormation.Description) - assert.Equal("https://www.tibia.com/community/?subtopic=guilds&world=Premia", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=guilds&world=Premia", information.TibiaURLs[0]) } diff --git a/src/TibiaHighscores.go b/src/TibiaHighscores.go index 19af3eb4..f6216d84 100644 --- a/src/TibiaHighscores.go +++ b/src/TibiaHighscores.go @@ -177,7 +177,7 @@ func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vo Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHighscores_test.go b/src/TibiaHighscores_test.go index 56023d53..c18ad7cb 100644 --- a/src/TibiaHighscores_test.go +++ b/src/TibiaHighscores_test.go @@ -29,7 +29,7 @@ func TestHighscoresAll(t *testing.T) { assert := assert.New(t) information := highscoresJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.TibiaURLs[0]) assert.Empty(highscoresJson.Highscores.World) diff --git a/src/TibiaHousesHouse.go b/src/TibiaHousesHouse.go index 0b034225..73afa014 100644 --- a/src/TibiaHousesHouse.go +++ b/src/TibiaHousesHouse.go @@ -170,7 +170,7 @@ func TibiaHousesHouseImpl(houseid int, BoxContentHTML string, url string) (House Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesHouse_test.go b/src/TibiaHousesHouse_test.go index 8568d1bd..2c10c358 100644 --- a/src/TibiaHousesHouse_test.go +++ b/src/TibiaHousesHouse_test.go @@ -28,7 +28,7 @@ func TestCormaya10(t *testing.T) { assert := assert.New(t) information := houseJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=houses&page=view&world=Premia&houseid=54025", information.TibiaURLs[0]) assert.Equal(54025, houseJson.House.Houseid) assert.Equal("Premia", houseJson.House.World) diff --git a/src/TibiaHousesOverview.go b/src/TibiaHousesOverview.go index a65de482..711b3b5d 100644 --- a/src/TibiaHousesOverview.go +++ b/src/TibiaHousesOverview.go @@ -85,7 +85,7 @@ func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlData Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: TibiaHouseURLs, + TibiaURLs: TibiaHouseURLs, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesOverview_test.go b/src/TibiaHousesOverview_test.go index 0a058a9e..26239127 100644 --- a/src/TibiaHousesOverview_test.go +++ b/src/TibiaHousesOverview_test.go @@ -50,9 +50,9 @@ func TestAnticaThaisHousesOverview(t *testing.T) { assert := assert.New(t) information := housesJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais&type=houses", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais&type=houses", information.TibiaURLs[0]) - assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais&type=guildhalls", information.TibiaURL[1]) + assert.Equal("https://www.tibia.com/community/?subtopic=houses&world=Antica&town=Thais&type=guildhalls", information.TibiaURLs[1]) assert.Equal("Antica", housesJson.Houses.World) assert.Equal("Thais", housesJson.Houses.Town) diff --git a/src/TibiaKillstatistics.go b/src/TibiaKillstatistics.go index d17b358d..6bd7fc5a 100644 --- a/src/TibiaKillstatistics.go +++ b/src/TibiaKillstatistics.go @@ -90,7 +90,7 @@ func TibiaKillstatisticsImpl(world string, BoxContentHTML string, url string) (K Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaKillstatistics_test.go b/src/TibiaKillstatistics_test.go index ab65c8ea..f3bd8830 100644 --- a/src/TibiaKillstatistics_test.go +++ b/src/TibiaKillstatistics_test.go @@ -28,7 +28,7 @@ func TestAntica(t *testing.T) { assert := assert.New(t) information := anticaJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=killstatistics&world=Antica", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=killstatistics&world=Antica", information.TibiaURLs[0]) assert.Equal("Antica", anticaJson.KillStatistics.World) assert.Equal(1159, len(anticaJson.KillStatistics.Entries)) diff --git a/src/TibiaNews.go b/src/TibiaNews.go index d11a8c28..d96b95d5 100644 --- a/src/TibiaNews.go +++ b/src/TibiaNews.go @@ -16,7 +16,7 @@ type News struct { Title string `json:"title,omitempty"` // The title of the news. Category string `json:"category"` // The category of the news. Type string `json:"type,omitempty"` // The type of news. - TibiaURL string `json:"url"` // The URL for the news with id. + TibiaURLs string `json:"url"` // The URL for the news with id. Content string `json:"content"` // The news in plain text. ContentHTML string `json:"content_html"` // The news in HTML format. } @@ -45,7 +45,7 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon } NewsData.ID = NewsID - NewsData.TibiaURL = rawUrl + NewsData.TibiaURLs = rawUrl ReaderHTML.Find(".NewsHeadline").EachWithBreak(func(index int, s *goquery.Selection) bool { // getting category by image src @@ -141,7 +141,7 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{rawUrl}, + TibiaURLs: []string{rawUrl}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNews_test.go b/src/TibiaNews_test.go index a7b1c035..2fc12488 100644 --- a/src/TibiaNews_test.go +++ b/src/TibiaNews_test.go @@ -28,14 +28,14 @@ func TestNewsById(t *testing.T) { assert := assert.New(t) information := newsArticleJson.Information - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", information.TibiaURLs[0]) assert.Equal(6529, newsArticleJson.News.ID) assert.Equal("2022-01-12", newsArticleJson.News.Date) assert.Empty(newsArticleJson.News.Title) assert.Equal("development", newsArticleJson.News.Category) assert.Equal("ticker", newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", newsArticleJson.News.TibiaURL) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", newsArticleJson.News.TibiaURLs) assert.Equal("A number of issues related to the 25 years activities have been fixed, including the following: Dragon pinatas that were stuck in the inbox have been changed into dragon pinata kits. The wind-up loco can now be taken even after defeating Lord Retro. The baby seals can now be painted even when the quest The Ice Islands is active. The weight of wallpapers and fairy lights has been increased and their market category has been changed to decoration. A number of typos and map issues have been fixed as well.", newsArticleJson.News.Content) assert.Equal("A number of issues related to the 25 years activities have been fixed, including the following: Dragon pinatas that were stuck in the inbox have been changed into dragon pinata kits. The wind-up loco can now be taken even after defeating Lord Retro. The baby seals can now be painted even when the quest The Ice Islands is active. The weight of wallpapers and fairy lights has been increased and their market category has been changed to decoration. A number of typos and map issues have been fixed as well.", newsArticleJson.News.ContentHTML) } @@ -64,7 +64,7 @@ func TestNews6512(t *testing.T) { assert.Empty(newsArticleJson.News.Title) assert.Equal("community", newsArticleJson.News.Category) assert.Equal("ticker", newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6512", newsArticleJson.News.TibiaURL) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6512", newsArticleJson.News.TibiaURLs) assert.Equal("TibiaData.com has some news to share! First of all, they invite you to participate in their Discord Server. Further, they are now present on GitHub. They are working on their v3, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.Content) assert.Equal("TibiaData.com has some news to share! First of all, they invite you to participate in their Discord Server. Further, they are now present on GitHub. They are working on their v3, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.ContentHTML) } @@ -93,7 +93,7 @@ func TestNews504(t *testing.T) { assert.Empty(newsArticleJson.News.Title) assert.Equal("community", newsArticleJson.News.Category) assert.Equal("ticker", newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=504", newsArticleJson.News.TibiaURL) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=504", newsArticleJson.News.TibiaURLs) assert.Equal("A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.Content) assert.Equal("
A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.ContentHTML) } @@ -122,7 +122,7 @@ func TestNews6481(t *testing.T) { assert.Equal("New Mounts", newsArticleJson.News.Title) assert.Equal("development", newsArticleJson.News.Category) assert.Empty(newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6481", newsArticleJson.News.TibiaURL) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6481", newsArticleJson.News.TibiaURLs) assert.Equal("New mounts have been added to the Store today!\nThe origins of the Emerald Raven, Mystic Raven, and Radiant Raven are shrouded in darkness, as no written record nor tale told by even the most knowing storytellers mentions but a trace of them. Superstition surrounds them, as some see these gigantic birds as an echo of a long forgotten past, while others believe them to herald hitherto unknown events. What is clear is that they are highly intelligent beings which make great companions if they deem somebody worthy.\n\nClick on image to enlarge.\n\nOnce bought, your character can use the mount ingame anytime, no matter if you are a free account or a Premium account.\nGet yourself a corvid companion!Your Community Managers ", newsArticleJson.News.Content) assert.Equal("

New mounts have been added to the Store today!

\n

The origins of the Emerald Raven, Mystic Raven, and Radiant Raven are shrouded in darkness, as no written record nor tale told by even the most knowing storytellers mentions but a trace of them. Superstition surrounds them, as some see these gigantic birds as an echo of a long forgotten past, while others believe them to herald hitherto unknown events. What is clear is that they are highly intelligent beings which make great companions if they deem somebody worthy.

\n
\n
Click on image to enlarge.
\n
\n

Once bought, your character can use the mount ingame anytime, no matter if you are a free account or a Premium account.

\n

Get yourself a corvid companion!
Your Community Managers

", newsArticleJson.News.ContentHTML) } diff --git a/src/TibiaNewslist.go b/src/TibiaNewslist.go index 1ee3939e..3528f966 100644 --- a/src/TibiaNewslist.go +++ b/src/TibiaNewslist.go @@ -16,7 +16,7 @@ type NewsItem struct { News string `json:"news"` // The news in plain text. Category string `json:"category"` // The category of the news. Type string `json:"type"` // The type of news. - TibiaURL string `json:"url"` // The URL for the news with id. + TibiaURLs string `json:"url"` // The URL for the news with id. ApiURL string `json:"url_api,omitempty"` // The URL for the news in this API. } @@ -63,7 +63,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string, handlerURL string) (News NewsID := p.Query().Get("id") NewsSplit := strings.Split(NewsURL, NewsID) OneNews.ID = TibiaDataStringToInteger(NewsID) - OneNews.TibiaURL = NewsSplit[0] + NewsID + OneNews.TibiaURLs = NewsSplit[0] + NewsID if TibiaDataHost != "" { OneNews.ApiURL = "https://" + TibiaDataHost + "/v4/news/id/" + NewsID @@ -86,7 +86,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string, handlerURL string) (News Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{handlerURL}, + TibiaURLs: []string{handlerURL}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNewslist_test.go b/src/TibiaNewslist_test.go index 2a128b23..3a197902 100644 --- a/src/TibiaNewslist_test.go +++ b/src/TibiaNewslist_test.go @@ -30,7 +30,7 @@ func TestNewsList(t *testing.T) { assert := assert.New(t) information := newsListJson.Information - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive", information.TibiaURLs[0]) assert.Equal(50, len(newsListJson.News)) @@ -40,6 +40,6 @@ func TestNewsList(t *testing.T) { assert.Equal("A number of issues related to the 25 years activities have been fixed,...", firstArticle.News) assert.Equal("development", firstArticle.Category) assert.Equal("ticker", firstArticle.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", firstArticle.TibiaURL) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", firstArticle.TibiaURLs) assert.Equal("https://unittest.example.com/v4/news/id/6529", firstArticle.ApiURL) } diff --git a/src/TibiaSpellsOverview.go b/src/TibiaSpellsOverview.go index 0326642d..9cbb0f9e 100644 --- a/src/TibiaSpellsOverview.go +++ b/src/TibiaSpellsOverview.go @@ -122,7 +122,7 @@ func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string, url str Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsOverview_test.go b/src/TibiaSpellsOverview_test.go index af021475..d76a0b73 100644 --- a/src/TibiaSpellsOverview_test.go +++ b/src/TibiaSpellsOverview_test.go @@ -28,7 +28,7 @@ func TestOverviewAll(t *testing.T) { assert := assert.New(t) information := spellsOverviewJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=spells", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/library/?subtopic=spells", information.TibiaURLs[0]) assert.Equal(152, len(spellsOverviewJson.Spells.Spells)) diff --git a/src/TibiaSpellsSpell.go b/src/TibiaSpellsSpell.go index 56bfb9f1..d6b22c8f 100644 --- a/src/TibiaSpellsSpell.go +++ b/src/TibiaSpellsSpell.go @@ -313,7 +313,7 @@ func TibiaSpellsSpellImpl(spell string, BoxContentHTML string, url string) (Spel Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsSpell_test.go b/src/TibiaSpellsSpell_test.go index 1c795815..0ec34122 100644 --- a/src/TibiaSpellsSpell_test.go +++ b/src/TibiaSpellsSpell_test.go @@ -29,7 +29,7 @@ func TestFindPerson(t *testing.T) { spell := findPersonJson.Spell information := findPersonJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=spells&spell=findperson", information.TibiaURL) + assert.Equal("https://www.tibia.com/library/?subtopic=spells&spell=findperson", information.TibiaURLs) assert.Empty(spell.Description) assert.Equal("Find Person", spell.Name) diff --git a/src/TibiaWorldsOverview.go b/src/TibiaWorldsOverview.go index 0f5e20ab..aa24a481 100644 --- a/src/TibiaWorldsOverview.go +++ b/src/TibiaWorldsOverview.go @@ -206,7 +206,7 @@ func TibiaWorldsOverviewImpl(BoxContentHTML string, url string) (WorldsOverviewR Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsOverview_test.go b/src/TibiaWorldsOverview_test.go index af815ded..38920690 100644 --- a/src/TibiaWorldsOverview_test.go +++ b/src/TibiaWorldsOverview_test.go @@ -28,7 +28,7 @@ func TestWorlds(t *testing.T) { assert := assert.New(t) information := worldsJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.TibiaURLs[0]) assert.Equal(8720, worldsJson.Worlds.PlayersOnline) assert.Equal(64028, worldsJson.Worlds.RecordPlayers) diff --git a/src/TibiaWorldsWorld.go b/src/TibiaWorldsWorld.go index 78d837c4..c065c4b3 100644 --- a/src/TibiaWorldsWorld.go +++ b/src/TibiaWorldsWorld.go @@ -230,7 +230,7 @@ func TibiaWorldsWorldImpl(world string, BoxContentHTML string, url string) (Worl Information: Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsWorld_test.go b/src/TibiaWorldsWorld_test.go index 058a97dc..147bd557 100644 --- a/src/TibiaWorldsWorld_test.go +++ b/src/TibiaWorldsWorld_test.go @@ -29,7 +29,7 @@ func TestWorldEndebra(t *testing.T) { world := worldJson.World information := worldJson.Information - assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.TibiaURL[0]) + assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.TibiaURLs[0]) assert.Equal("Endebra", world.Name) assert.Equal("online", world.Status) diff --git a/src/webserver.go b/src/webserver.go index f87718e5..44004dc4 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -47,7 +47,7 @@ type OutInformation struct { type Information struct { APIDetails APIDetails `json:"api"` // The API details. Timestamp string `json:"timestamp"` // The timestamp from when the data was processed. - TibiaURL []string `json:"tibia_url"` // The links to the sources of the data on tibia.com. + TibiaURLs []string `json:"tibia_url"` // The links to the sources of the data on tibia.com. Status Status `json:"status"` // The response status information. } @@ -122,7 +122,7 @@ func runWebServer() { data := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{}, + TibiaURLs: []string{}, Status: Status{ HTTPCode: http.StatusOK, Message: "pong", @@ -1091,7 +1091,7 @@ func TibiaDataErrorHandler(c *gin.Context, err error, httpCode int) { info := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURL: []string{}, + TibiaURLs: []string{}, Status: Status{ HTTPCode: httpCode, }, From df41128f273f03900fc368b255b2b736d8c38e60 Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Sat, 26 Oct 2024 23:27:34 +0900 Subject: [PATCH 33/36] Fixed json:tibia_url reference to json:tibia_urls instead --- src/webserver.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/webserver.go b/src/webserver.go index 44004dc4..1b6694d2 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -45,10 +45,10 @@ type OutInformation struct { // Information stores some API related data type Information struct { - APIDetails APIDetails `json:"api"` // The API details. - Timestamp string `json:"timestamp"` // The timestamp from when the data was processed. - TibiaURLs []string `json:"tibia_url"` // The links to the sources of the data on tibia.com. - Status Status `json:"status"` // The response status information. + APIDetails APIDetails `json:"api"` // The API details. + Timestamp string `json:"timestamp"` // The timestamp from when the data was processed. + TibiaURLs []string `json:"tibia_urls"` // The links to the sources of the data on tibia.com + Status Status `json:"status"` // The response status information. } // API details store information about this API @@ -122,7 +122,7 @@ func runWebServer() { data := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{}, + TibiaURLs: []string{}, Status: Status{ HTTPCode: http.StatusOK, Message: "pong", @@ -1091,7 +1091,7 @@ func TibiaDataErrorHandler(c *gin.Context, err error, httpCode int) { info := Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{}, + TibiaURLs: []string{}, Status: Status{ HTTPCode: httpCode, }, From 758f09cc666b2996eff73e9441603e28a556440e Mon Sep 17 00:00:00 2001 From: Kaire Montenegro Date: Mon, 28 Oct 2024 21:18:15 +0900 Subject: [PATCH 34/36] Revert changes made accidentally in TibiaNews and Newslist (TibiaURLs to TibiaURL) --- src/TibiaNews.go | 6 +++--- src/TibiaNews_test.go | 8 ++++---- src/TibiaNewslist.go | 6 +++--- src/TibiaNewslist_test.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/TibiaNews.go b/src/TibiaNews.go index d96b95d5..bd4cf990 100644 --- a/src/TibiaNews.go +++ b/src/TibiaNews.go @@ -16,7 +16,7 @@ type News struct { Title string `json:"title,omitempty"` // The title of the news. Category string `json:"category"` // The category of the news. Type string `json:"type,omitempty"` // The type of news. - TibiaURLs string `json:"url"` // The URL for the news with id. + TibiaURL string `json:"url"` // The URL for the news with id. Content string `json:"content"` // The news in plain text. ContentHTML string `json:"content_html"` // The news in HTML format. } @@ -45,7 +45,7 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon } NewsData.ID = NewsID - NewsData.TibiaURLs = rawUrl + NewsData.TibiaURL = rawUrl ReaderHTML.Find(".NewsHeadline").EachWithBreak(func(index int, s *goquery.Selection) bool { // getting category by image src @@ -141,7 +141,7 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{rawUrl}, + TibiaURLs: []string{rawUrl}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNews_test.go b/src/TibiaNews_test.go index 2fc12488..b4aae93d 100644 --- a/src/TibiaNews_test.go +++ b/src/TibiaNews_test.go @@ -35,7 +35,7 @@ func TestNewsById(t *testing.T) { assert.Empty(newsArticleJson.News.Title) assert.Equal("development", newsArticleJson.News.Category) assert.Equal("ticker", newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", newsArticleJson.News.TibiaURLs) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", newsArticleJson.News.TibiaURL) assert.Equal("A number of issues related to the 25 years activities have been fixed, including the following: Dragon pinatas that were stuck in the inbox have been changed into dragon pinata kits. The wind-up loco can now be taken even after defeating Lord Retro. The baby seals can now be painted even when the quest The Ice Islands is active. The weight of wallpapers and fairy lights has been increased and their market category has been changed to decoration. A number of typos and map issues have been fixed as well.", newsArticleJson.News.Content) assert.Equal("A number of issues related to the 25 years activities have been fixed, including the following: Dragon pinatas that were stuck in the inbox have been changed into dragon pinata kits. The wind-up loco can now be taken even after defeating Lord Retro. The baby seals can now be painted even when the quest The Ice Islands is active. The weight of wallpapers and fairy lights has been increased and their market category has been changed to decoration. A number of typos and map issues have been fixed as well.", newsArticleJson.News.ContentHTML) } @@ -64,7 +64,7 @@ func TestNews6512(t *testing.T) { assert.Empty(newsArticleJson.News.Title) assert.Equal("community", newsArticleJson.News.Category) assert.Equal("ticker", newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6512", newsArticleJson.News.TibiaURLs) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6512", newsArticleJson.News.TibiaURL) assert.Equal("TibiaData.com has some news to share! First of all, they invite you to participate in their Discord Server. Further, they are now present on GitHub. They are working on their v3, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.Content) assert.Equal("TibiaData.com has some news to share! First of all, they invite you to participate in their Discord Server. Further, they are now present on GitHub. They are working on their v3, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.ContentHTML) } @@ -93,7 +93,7 @@ func TestNews504(t *testing.T) { assert.Empty(newsArticleJson.News.Title) assert.Equal("community", newsArticleJson.News.Category) assert.Equal("ticker", newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=504", newsArticleJson.News.TibiaURLs) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=504", newsArticleJson.News.TibiaURL) assert.Equal("A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.Content) assert.Equal("
A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.ContentHTML) } @@ -122,7 +122,7 @@ func TestNews6481(t *testing.T) { assert.Equal("New Mounts", newsArticleJson.News.Title) assert.Equal("development", newsArticleJson.News.Category) assert.Empty(newsArticleJson.News.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6481", newsArticleJson.News.TibiaURLs) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6481", newsArticleJson.News.TibiaURL) assert.Equal("New mounts have been added to the Store today!\nThe origins of the Emerald Raven, Mystic Raven, and Radiant Raven are shrouded in darkness, as no written record nor tale told by even the most knowing storytellers mentions but a trace of them. Superstition surrounds them, as some see these gigantic birds as an echo of a long forgotten past, while others believe them to herald hitherto unknown events. What is clear is that they are highly intelligent beings which make great companions if they deem somebody worthy.\n\nClick on image to enlarge.\n\nOnce bought, your character can use the mount ingame anytime, no matter if you are a free account or a Premium account.\nGet yourself a corvid companion!Your Community Managers ", newsArticleJson.News.Content) assert.Equal("

New mounts have been added to the Store today!

\n

The origins of the Emerald Raven, Mystic Raven, and Radiant Raven are shrouded in darkness, as no written record nor tale told by even the most knowing storytellers mentions but a trace of them. Superstition surrounds them, as some see these gigantic birds as an echo of a long forgotten past, while others believe them to herald hitherto unknown events. What is clear is that they are highly intelligent beings which make great companions if they deem somebody worthy.

\n
\n
Click on image to enlarge.
\n
\n

Once bought, your character can use the mount ingame anytime, no matter if you are a free account or a Premium account.

\n

Get yourself a corvid companion!
Your Community Managers

", newsArticleJson.News.ContentHTML) } diff --git a/src/TibiaNewslist.go b/src/TibiaNewslist.go index 3528f966..0c3c9473 100644 --- a/src/TibiaNewslist.go +++ b/src/TibiaNewslist.go @@ -16,7 +16,7 @@ type NewsItem struct { News string `json:"news"` // The news in plain text. Category string `json:"category"` // The category of the news. Type string `json:"type"` // The type of news. - TibiaURLs string `json:"url"` // The URL for the news with id. + TibiaURL string `json:"url"` // The URL for the news with id. ApiURL string `json:"url_api,omitempty"` // The URL for the news in this API. } @@ -63,7 +63,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string, handlerURL string) (News NewsID := p.Query().Get("id") NewsSplit := strings.Split(NewsURL, NewsID) OneNews.ID = TibiaDataStringToInteger(NewsID) - OneNews.TibiaURLs = NewsSplit[0] + NewsID + OneNews.TibiaURL = NewsSplit[0] + NewsID if TibiaDataHost != "" { OneNews.ApiURL = "https://" + TibiaDataHost + "/v4/news/id/" + NewsID @@ -86,7 +86,7 @@ func TibiaNewslistImpl(days int, BoxContentHTML string, handlerURL string) (News Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{handlerURL}, + TibiaURLs: []string{handlerURL}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaNewslist_test.go b/src/TibiaNewslist_test.go index 3a197902..fa9ac309 100644 --- a/src/TibiaNewslist_test.go +++ b/src/TibiaNewslist_test.go @@ -40,6 +40,6 @@ func TestNewsList(t *testing.T) { assert.Equal("A number of issues related to the 25 years activities have been fixed,...", firstArticle.News) assert.Equal("development", firstArticle.Category) assert.Equal("ticker", firstArticle.Type) - assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", firstArticle.TibiaURLs) + assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6529", firstArticle.TibiaURL) assert.Equal("https://unittest.example.com/v4/news/id/6529", firstArticle.ApiURL) } From 91be53db492eb409b4a3552449a4dd0eaa56055a Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Thu, 21 Nov 2024 22:54:53 +0100 Subject: [PATCH 35/36] fix: test case of TestFindPerson --- src/TibiaSpellsSpell_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TibiaSpellsSpell_test.go b/src/TibiaSpellsSpell_test.go index 0ec34122..6033bf37 100644 --- a/src/TibiaSpellsSpell_test.go +++ b/src/TibiaSpellsSpell_test.go @@ -29,7 +29,7 @@ func TestFindPerson(t *testing.T) { spell := findPersonJson.Spell information := findPersonJson.Information - assert.Equal("https://www.tibia.com/library/?subtopic=spells&spell=findperson", information.TibiaURLs) + assert.Equal("https://www.tibia.com/library/?subtopic=spells&spell=findperson", information.TibiaURLs[0]) assert.Empty(spell.Description) assert.Equal("Find Person", spell.Name) From 8071c58d0f77aefba8dcb2c7b0a95edcf33403fa Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Thu, 21 Nov 2024 22:55:10 +0100 Subject: [PATCH 36/36] chore: linting --- src/TibiaBoostableBossesOverview.go | 2 +- src/TibiaCharactersCharacter.go | 2 +- src/TibiaCreaturesCreature.go | 2 +- src/TibiaCreaturesOverview.go | 2 +- src/TibiaFansites.go | 2 +- src/TibiaGuildsGuild.go | 2 +- src/TibiaGuildsOverview.go | 2 +- src/TibiaHighscores.go | 2 +- src/TibiaHousesHouse.go | 2 +- src/TibiaHousesOverview.go | 2 +- src/TibiaKillstatistics.go | 2 +- src/TibiaSpellsOverview.go | 2 +- src/TibiaSpellsSpell.go | 2 +- src/TibiaWorldsOverview.go | 2 +- src/TibiaWorldsWorld.go | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/TibiaBoostableBossesOverview.go b/src/TibiaBoostableBossesOverview.go index 169fe069..a0e10106 100644 --- a/src/TibiaBoostableBossesOverview.go +++ b/src/TibiaBoostableBossesOverview.go @@ -151,7 +151,7 @@ func TibiaBoostableBossesOverviewImpl(BoxContentHTML string, url string) (Boosta Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCharactersCharacter.go b/src/TibiaCharactersCharacter.go index 589fe292..c9231aa4 100644 --- a/src/TibiaCharactersCharacter.go +++ b/src/TibiaCharactersCharacter.go @@ -725,7 +725,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string, url string) (CharacterR Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index 04df6f33..79d5bd85 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -192,7 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string, url string) Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaCreaturesOverview.go b/src/TibiaCreaturesOverview.go index d96b318c..f98fbc8d 100644 --- a/src/TibiaCreaturesOverview.go +++ b/src/TibiaCreaturesOverview.go @@ -125,7 +125,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string, url string) (CreaturesOve Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaFansites.go b/src/TibiaFansites.go index c4391d46..303e5cf6 100644 --- a/src/TibiaFansites.go +++ b/src/TibiaFansites.go @@ -97,7 +97,7 @@ func TibiaFansitesImpl(BoxContentHTML string, url string) (FansitesResponse, err Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsGuild.go b/src/TibiaGuildsGuild.go index 4631950a..1e37e143 100644 --- a/src/TibiaGuildsGuild.go +++ b/src/TibiaGuildsGuild.go @@ -282,7 +282,7 @@ func TibiaGuildsGuildImpl(guild string, BoxContentHTML string, url string) (Guil Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaGuildsOverview.go b/src/TibiaGuildsOverview.go index 27dda2fb..36f365a7 100644 --- a/src/TibiaGuildsOverview.go +++ b/src/TibiaGuildsOverview.go @@ -95,7 +95,7 @@ func TibiaGuildsOverviewImpl(world string, BoxContentHTML string, url string) (G Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHighscores.go b/src/TibiaHighscores.go index f6216d84..160d21aa 100644 --- a/src/TibiaHighscores.go +++ b/src/TibiaHighscores.go @@ -177,7 +177,7 @@ func TibiaHighscoresImpl(world string, category validation.HighscoreCategory, vo Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesHouse.go b/src/TibiaHousesHouse.go index 73afa014..9e4b9a25 100644 --- a/src/TibiaHousesHouse.go +++ b/src/TibiaHousesHouse.go @@ -170,7 +170,7 @@ func TibiaHousesHouseImpl(houseid int, BoxContentHTML string, url string) (House Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaHousesOverview.go b/src/TibiaHousesOverview.go index 711b3b5d..2d070d0c 100644 --- a/src/TibiaHousesOverview.go +++ b/src/TibiaHousesOverview.go @@ -85,7 +85,7 @@ func TibiaHousesOverviewImpl(c *gin.Context, world string, town string, htmlData Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: TibiaHouseURLs, + TibiaURLs: TibiaHouseURLs, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaKillstatistics.go b/src/TibiaKillstatistics.go index 6bd7fc5a..ebb350f1 100644 --- a/src/TibiaKillstatistics.go +++ b/src/TibiaKillstatistics.go @@ -90,7 +90,7 @@ func TibiaKillstatisticsImpl(world string, BoxContentHTML string, url string) (K Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsOverview.go b/src/TibiaSpellsOverview.go index 9cbb0f9e..be11aa59 100644 --- a/src/TibiaSpellsOverview.go +++ b/src/TibiaSpellsOverview.go @@ -122,7 +122,7 @@ func TibiaSpellsOverviewImpl(vocationName string, BoxContentHTML string, url str Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaSpellsSpell.go b/src/TibiaSpellsSpell.go index d6b22c8f..c3cbd0af 100644 --- a/src/TibiaSpellsSpell.go +++ b/src/TibiaSpellsSpell.go @@ -313,7 +313,7 @@ func TibiaSpellsSpellImpl(spell string, BoxContentHTML string, url string) (Spel Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsOverview.go b/src/TibiaWorldsOverview.go index aa24a481..1ee44ba9 100644 --- a/src/TibiaWorldsOverview.go +++ b/src/TibiaWorldsOverview.go @@ -206,7 +206,7 @@ func TibiaWorldsOverviewImpl(BoxContentHTML string, url string) (WorldsOverviewR Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, }, diff --git a/src/TibiaWorldsWorld.go b/src/TibiaWorldsWorld.go index c065c4b3..9423cafe 100644 --- a/src/TibiaWorldsWorld.go +++ b/src/TibiaWorldsWorld.go @@ -230,7 +230,7 @@ func TibiaWorldsWorldImpl(world string, BoxContentHTML string, url string) (Worl Information: Information{ APIDetails: TibiaDataAPIDetails, Timestamp: TibiaDataDatetime(""), - TibiaURLs: []string{url}, + TibiaURLs: []string{url}, Status: Status{ HTTPCode: http.StatusOK, },