-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_score.go
More file actions
32 lines (28 loc) · 827 Bytes
/
check_score.go
File metadata and controls
32 lines (28 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"encoding/json"
"fmt"
"github.com/valyala/fasthttp"
"TelegramServerChecker/consts"
"TelegramServerChecker/types"
)
func checkScore() {
req := fasthttp.AcquireRequest()
defer fasthttp.ReleaseRequest(req)
resp := fasthttp.AcquireResponse()
defer fasthttp.ReleaseResponse(resp)
req.SetRequestURI(consts.ApiEndpoint + "getScore")
err := fasthttp.Do(req, resp)
if err != nil {
panic("No Internet Connection")
}
statusCode := resp.StatusCode()
if statusCode != fasthttp.StatusOK {
if statusCode == fasthttp.StatusTooManyRequests {
panic("You have been banned from api_client.owlgram.org because you are flooding, wait and retry after 30 minutes")
}
}
var result types.ScoreResult
_ = json.Unmarshal(resp.Body(), &result)
fmt.Printf("\n\nYour Score is of %d%%\n", result.Score)
}