forked from drunkleen/blum-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
requests.go
708 lines (596 loc) · 19.7 KB
/
requests.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
package requests
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net"
"net/http"
"time"
"github.com/drunkleen/blum-bot/types"
)
var (
getHeaders = map[string]string{
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9",
"origin": "https://telegram.blum.codes",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
}
)
func GetNewToken(queryID string) (string, error) {
url := "https://gateway.blum.codes/v1/auth/provider/PROVIDER_TELEGRAM_MINI_APP"
headers := map[string]string{
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9",
"content-type": "application/json",
"origin": "https://telegram.blum.codes",
"priority": "u=1, i",
"referer": "https://telegram.blum.codes/",
}
// Define the data to be sent in the POST request
data := types.RequestBody{Query: queryID}
jsonData, err := json.Marshal(data)
if err != nil {
return "", fmt.Errorf("failed to marshal JSON: %w", err)
}
// Try to get the token up to 3 Times
for attempt := 1; attempt <= 3; attempt++ {
fmt.Printf("Getting token (attempt %d)...\n", attempt)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
return "", fmt.Errorf("failed to create request: %w", err)
}
for key, val := range headers {
req.Header.Set(key, val)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return "", fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
fmt.Println("Token successfully created.")
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("failed to read response body: %w", err)
}
var response types.ResponseBody
if err := json.Unmarshal(body, &response); err != nil {
return "", fmt.Errorf("failed to unmarshal JSON: %w", err)
}
return response.Token.Refresh, nil
} else {
body, _ := io.ReadAll(resp.Body)
fmt.Printf("Failed to get token, attempt %d: %s\n", attempt, body)
}
}
// If all attempts fail
fmt.Println("Failed to get token after 3 attempts.")
return "", nil
}
func GetUserInfo(token string, queryID string) (map[string]any, error) {
url := "https://gateway.blum.codes/v1/user/me"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
for key, val := range headers {
req.Header.Set(key, val)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
if resp.StatusCode == http.StatusOK {
var result map[string]any
if err := json.Unmarshal(body, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)
}
return result, nil
}
var tokenResponse types.TokenResponseBody
if err := json.Unmarshal(body, &tokenResponse); err != nil {
return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)
}
if tokenResponse.Message == "Token is invalid" {
return nil, fmt.Errorf("token is invalid")
} else {
fmt.Println("Failed to get user information.")
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
}
func GetUserBalance(token string) (types.UserBalance, error) {
url := "https://game-domain.blum.codes/api/v1/user/balance"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return types.UserBalance{}, fmt.Errorf("failed to send request: %w", err)
}
for key, val := range headers {
req.Header.Set(key, val)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return types.UserBalance{}, fmt.Errorf("failed to send request: %w", err)
}
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
fmt.Printf("Error closing response body: %v\n", err)
}
}(resp.Body)
if resp.StatusCode == http.StatusOK {
body, err := io.ReadAll(resp.Body)
if err != nil {
return types.UserBalance{}, fmt.Errorf("failed to read response body: %w", err)
}
var result types.UserBalance
if err := json.Unmarshal(body, &result); err != nil {
return types.UserBalance{}, fmt.Errorf("failed to unmarshal JSON: %w", err)
}
return result, nil
}
return types.UserBalance{}, fmt.Errorf("failed to get balance")
}
func CheckDailyReward(token string) (map[string]any, error) {
url := "https://game-domain.blum.codes/api/v1/daily-reward?offset=-420"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
headers["content-length"] = "0"
headers["sec-ch-ua"] = `"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24", "Microsoft Edge WebView2";v="125"`
headers["sec-ch-ua-mobile"] = "?0"
headers["sec-ch-ua-platform"] = `Windows"`
headers["sec-fetch-dest"] = "empty"
headers["sec-fetch-mode"] = "cors"
headers["sec-fetch-site"] = "same-site"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
for key, val := range headers {
req.Header.Set(key, val)
}
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Do(req)
if err != nil {
if err, ok := err.(net.Error); ok && err.Timeout() {
fmt.Println("Failed to claim daily: Timeout")
return nil, err
}
return nil, fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
if resp.StatusCode == 400 {
var result map[string]any
if err := json.Unmarshal(body, &result); err != nil {
if string(body) == "OK" {
return map[string]any{"message": "OK"}, nil
}
return nil, nil
}
return result, nil
}
var result map[string]any
if err := json.Unmarshal(body, &result); err != nil {
fmt.Printf("Json Error: %s\n", string(body))
return nil, nil
}
return result, nil
}
func CheckTasks(token string) {
url := "https://game-domain.blum.codes/api/v1/tasks"
// Assuming getHeaders is a function, invoke it.
headers := getHeaders
headers["Authorization"] = "Bearer " + token
headers["content-length"] = "0"
headers["priority"] = "u=1, i"
headers["sec-ch-ua"] = `"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24", "Microsoft Edge WebView2";v="125"`
headers["sec-ch-ua-mobile"] = "?0"
headers["sec-ch-ua-platform"] = `"Windows"`
headers["sec-fetch-dest"] = "empty"
headers["sec-fetch-mode"] = "cors"
headers["sec-fetch-site"] = "same-site"
// Create a new HTTP GET request
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Printf("failed to create request: %v", err)
return
}
// Set headers for the request
for key, val := range headers {
req.Header.Set(key, val)
}
// Send the request
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Do(req)
if err != nil {
log.Printf("failed to send request: %v", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Printf("Failed to read response body: %v\n", err)
return
}
if resp.StatusCode == http.StatusOK {
var tasks []map[string]any
if err := json.Unmarshal(body, &tasks); err != nil {
log.Printf("Failed to unmarshal JSON: %v\n", err)
return
}
for _, task := range tasks {
taskTitle, ok := task["title"].(string)
if !ok {
continue
}
taskID, ok := task["id"].(string)
if !ok {
continue
}
tasksList, ok := task["tasks"].([]interface{})
if !ok {
continue
}
for _, t := range tasksList {
taskMap, ok := t.(map[string]interface{})
if !ok {
continue
}
taskStatus, ok := taskMap["status"].(string)
if !ok {
continue
}
if taskStatus == "NOT_STARTED" {
fmt.Printf("Starting Task: %s\n", taskTitle)
startTask(token, taskID, taskTitle)
claimTask(token, taskID, taskTitle)
} else {
fmt.Printf("[Task %s | Reward: %v] %s\n", taskStatus, task["reward"], taskTitle)
}
}
}
}
}
func startTask(token, taskID, taskTitle string) {
url := "https://game-domain.blum.codes/api/v1/tasks/" + taskID + "/start"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
headers["content-length"] = "0"
headers["priority"] = "u=1, i"
headers["sec-ch-ua"] = `"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24", "Microsoft Edge WebView2";v="125"`
headers["sec-ch-ua-mobile"] = "?0"
headers["sec-ch-ua-platform"] = `"Windows"`
headers["sec-fetch-dest"] = "empty"
headers["sec-fetch-mode"] = "cors"
headers["sec-fetch-site"] = "same-site"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
log.Printf("failed to send request: %v\n", err)
}
for key, val := range headers {
req.Header.Set(key, val)
}
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Do(req)
if err != nil {
log.Printf("failed to send request: %v\n", err)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
fmt.Printf("[Task Started] %s\n", taskTitle)
} else {
fmt.Printf("[Staring Task Failed] %s\n", taskTitle)
}
}
func claimTask(token, taskID, taskTitle string) {
url := "https://game-domain.blum.codes/api/v1/tasks/" + taskID + "/claim"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
headers["content-length"] = "0"
headers["priority"] = "u=1, i"
headers["sec-ch-ua"] = `"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24", "Microsoft Edge WebView2";v="125"`
headers["sec-ch-ua-mobile"] = "?0"
headers["sec-ch-ua-platform"] = `"Windows"`
headers["sec-fetch-dest"] = "empty"
headers["sec-fetch-mode"] = "cors"
headers["sec-fetch-site"] = "same-site"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
log.Printf("failed to send request: %v\n", err)
}
for key, val := range headers {
req.Header.Set(key, val)
}
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Do(req)
if err != nil {
log.Printf("failed to send request: %v\n", err)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
fmt.Printf("[Task Claimed] %s\n", taskTitle)
} else {
fmt.Printf("[Claim Task Failed] %s\n", taskTitle)
}
}
func PlayGame(token string) (map[string]any, error) {
url := "https://game-domain.blum.codes/api/v1/game/play"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
headers["content-length"] = "0"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
for key, val := range headers {
req.Header.Set(key, val)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to play the game due to connection problems: %w", err)
}
defer resp.Body.Close()
var result map[string]any
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return nil, fmt.Errorf("failed to decode response: %w", err)
}
return result, nil
}
func claimGameRequest(token, gameID string, points int) (*http.Response, error) {
url := "https://game-domain.blum.codes/api/v1/game/claim"
headers := map[string]string{
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9",
"authorization": "Bearer " + token,
"content-type": "application/json",
"origin": "https://telegram.blum.codes",
"priority": "u=1, i",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
}
payload := types.GameClaimRequest{
GameID: gameID,
Points: points,
}
jsonData, err := json.Marshal(payload)
if err != nil {
return nil, fmt.Errorf("failed to marshal JSON: %w", err)
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
for key, value := range headers {
req.Header.Set(key, value)
}
client := &http.Client{
Timeout: 10 * time.Second,
}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to claim game rewards due to connection problems: %w", err)
}
return resp, nil
}
func ClaimGame(token, gameID, queryID string, points int) {
for {
resp, err := claimGameRequest(token, gameID, points)
if err != nil {
fmt.Printf("Failed to claim game, try again: %v\n", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Failed to read response: %v\n", err)
return
}
bodyString := string(body)
if bodyString == `{"message":"game session not finished"}` {
fmt.Println("Playing drop game...")
time.Sleep(1 * time.Second)
continue
} else if bodyString == `{"message":"game session not found"}` {
fmt.Println("The game is over")
break
} else {
var response map[string]interface{}
if err := json.Unmarshal(body, &response); err == nil {
if response["message"] == "Token is invalid" {
fmt.Println("Invalid token, get new token...")
token, _ = GetNewToken(queryID)
continue
}
}
fmt.Printf("Game finished: %s\n", bodyString)
break
}
}
}
func CheckBalanceFriend(token string) (types.FriendsBalance, error) {
url := "https://gateway.blum.codes/v1/friends/balance"
headers := map[string]string{
"Authorization": "Bearer " + token,
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9",
"origin": "https://telegram.blum.codes",
"priority": "u=1, i",
"sec-ch-ua": `"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24", "Microsoft Edge WebView2";v="125"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": `"Windows"`,
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
}
client := &http.Client{Timeout: 10 * time.Second}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return types.FriendsBalance{}, fmt.Errorf("failed to create request: %w", err)
}
for key, value := range headers {
req.Header.Set(key, value)
}
resp, err := client.Do(req)
if err != nil {
return types.FriendsBalance{}, fmt.Errorf("failed to get friend's balance: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return types.FriendsBalance{}, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
var friendsBalance types.FriendsBalance
if err := json.NewDecoder(resp.Body).Decode(&friendsBalance); err != nil {
return types.FriendsBalance{}, fmt.Errorf("failed to decode response: %w", err)
}
return friendsBalance, nil
}
func ClaimBalanceFriend(token string) (bool, error) {
url := "https://gateway.blum.codes/v1/friends/claim"
headers := map[string]string{
"Authorization": "Bearer " + token,
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9",
"content-length": "0",
"origin": "https://telegram.blum.codes",
"priority": "u=1, i",
"sec-ch-ua": `"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24", "Microsoft Edge WebView2";v="125"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": `"Windows"`,
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte{}))
if err != nil {
return false, fmt.Errorf("failed to create request: %w", err)
}
for key, value := range headers {
req.Header.Set(key, value)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return false, fmt.Errorf("failed to claim friend's balance: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
//var claimFriendBalance map[string]any
//if err := json.NewDecoder(resp.Body).Decode(&claimFriendBalance); err != nil {
// return false, fmt.Errorf("failed to decode response: %w", err)
//}
return true, nil
}
func ClaimFarm(token string) (bool, error) {
url := "https://game-domain.blum.codes/api/v1/farming/claim"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return false, fmt.Errorf("failed to create request: %w", err)
}
for key, value := range headers {
req.Header.Set(key, value)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return false, fmt.Errorf("failed to claim farm: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
return true, nil
}
func StartFarm(token string) (bool, error) {
url := "https://game-domain.blum.codes/api/v1/farming/start"
headers := getHeaders
headers["Authorization"] = "Bearer " + token
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return false, fmt.Errorf("failed to create request: %w", err)
}
for key, value := range headers {
req.Header.Set(key, value)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return false, fmt.Errorf("failed to start farm: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
return true, nil
}
func GetDailyRewards(token string) (bool, error) {
url := "https://game-domain.blum.codes/api/v1/daily-reward"
headers := map[string]string{
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9",
"origin": "https://telegram.blum.codes",
"priority": "u=1, i",
"sec-ch-ua": `"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24", "Microsoft Edge WebView2";v="125"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": `"Windows"`,
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
}
headers["Authorization"] = "Bearer " + token
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return false, fmt.Errorf("failed to create request: %w", err)
}
for key, value := range headers {
req.Header.Set(key, value)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return false, fmt.Errorf("failed to make the request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return false, fmt.Errorf("failed to create request: %w", err)
}
for key, value := range headers {
req.Header.Set(key, value)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return false, fmt.Errorf("failed to claim reward: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
return true, nil
}
}
return false, nil
}