Skip to content

Commit

Permalink
Fix bug + improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
UrbsKali committed Feb 27, 2024
1 parent 00e3e98 commit 57461db
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 43 deletions.
3 changes: 3 additions & 0 deletions models/Getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ func (g Getter) Get(url string) string {

r, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s%s", g.BaseURL, url), nil)
if err != nil {
fmt.Println("Error creating request")
panic(err)
}
r.Header.Add("Authorization", fmt.Sprintf("Basic %s", g.AuthToken))
resp, err := g.Client.Do(r)
if err != nil {
fmt.Println("Error sending request")
panic(err)
}
resBody, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response")
panic(err)
}
return string(resBody)
Expand Down
2 changes: 1 addition & 1 deletion overlay/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1>TEAM 2</h1>
<img src="./img/_notfound.png" alt="" srcset="">
</div>
<div class="player">
<h2>test</h2>
<h2></h2>
</div>
<div class="player">
<h2></h2>
Expand Down
3 changes: 1 addition & 2 deletions overlay/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ async function setupTeamInfo() {
for (let i = 0; i < teamName.length; i++) {
teamName[i].getElementsByTagName("h1")[0].innerText = selected[i]["name"];

// REMOVE COMMENT FOR PRODUCTION ------------------------------------------------------------------------------------------------------------------------------------------------
//teamName[i].getElementsByTagName("img")[0].src = `./teams_img/${selected[i]["tag"]}.png`;
teamName[i].getElementsByTagName("img")[0].src = `./teams_img/${selected[i]["tag"]}.png`;

//teamName[i].children[1].innerText = selected[i]["tag"];
score[i].innerText = selected[i]["score"];
Expand Down
35 changes: 0 additions & 35 deletions overlay/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,5 @@
.blob {
height: 100vh;
filter: blur(10px);
box-shadow: -10vmin 10vmin 0 rgba(255, 255, 255, 0.07);
width: 500px;
}
/*
.shade2 .blob {
animation: AnimateBlobTwo 8s ease-out infinite alternate;
}
.shade1 .blob {
animation: AnimateBlobOne 10s ease-in infinite alternate;
}
*/

@keyframes AnimateBlobOne {
0% {
border-radius: 0% 4% 5% 0% / 67% 37% 56% 34%;
width: 370px;
}

100% {
border-radius: 0% 31% 9% 0% / 20% 86% 16% 79%;
width: 350px;
}
}

@keyframes AnimateBlobTwo {
0% {
border-radius: 5% 0% 0% 10% / 67% 89% 56% 9%;
width: 370px;
}

100% {
border-radius: 20% 0% 0% 5% / 41% 37% 10% 34%;
width: 350px;
}
}
17 changes: 14 additions & 3 deletions routes/DraftRoutes.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
package routes

import (
"fmt"
"oblivion/draft/api"
"oblivion/draft/middleware"
"oblivion/draft/models"
"time"

"github.com/ImOlli/go-lcu/lcu"
"github.com/gofiber/fiber/v2"
)

func DraftRoutes(app *fiber.App) {
g, err := models.NewGetter()
if err != nil {
panic(err)
var g models.Getter
var err error
for {
g, err = models.NewGetter()
if err != nil && !lcu.IsProcessNotFoundError(err) {
panic(err)
} else if err == nil {
break
}
fmt.Println("LeagueClient not found, retrying in 2 second")
time.Sleep(2 * time.Second)
}

r := app.Group("/draft")
Expand Down
8 changes: 6 additions & 2 deletions utils/GetName.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package utils

import (
"fmt"
"oblivion/draft/models"
"strings"
)

func GetName(g models.Getter, summonerID string) string {
if summonerID == "0" {
if summonerID == "0" || summonerID == "" {
return "Bot"
}

raw := g.Get("/lol-summoner/v1/summoners/" + summonerID)
if strings.Contains(raw, "RPC_ERROR") {
fmt.Println("Error getting summoner name")
return "Bot"
}
displayName := strings.Split(strings.Split(raw, "\"displayName\":\"")[1], "\"")[0]
return displayName
}

0 comments on commit 57461db

Please sign in to comment.