-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcheck_in.py
78 lines (75 loc) · 2.88 KB
/
check_in.py
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
import aiohttp
from colorama import Fore, Style
from config import GRAPHQL_URL
async def check_points(address):
"""Check points for an account."""
short_address = f"{address[:8]}...{address[-4:]}"
headers = {"Content-Type": "application/json"}
payload = {
"query": """
query PointsLeaderboard($filter: UserFilter!) {
userdrop {
user(filter: $filter) {
address
points
pointsHistories {
histories {
points
}
}
}
}
}
""",
"variables": {
"filter": {"address": address}
}
}
async with aiohttp.ClientSession() as session:
async with session.post(GRAPHQL_URL, json=payload, headers=headers) as response:
if response.status == 200:
data = await response.json()
try:
user_data = data["data"]["userdrop"]["user"]
histories = user_data["pointsHistories"]["histories"]
total_points = sum(history["points"] for history in histories)
current_points = user_data["points"]
pending_points = total_points - current_points
print(f"{Fore.GREEN}[{short_address}] Current Points: {current_points} | Pending Points: {pending_points} | Total Points: {total_points}{Style.RESET_ALL}")
except KeyError as e:
print(f"{Fore.RED}Unexpected response structure. Missing key: {e}{Style.RESET_ALL}")
else:
print(f"{Fore.RED}[{short_address}] Checking Points failed: {response.status}{Style.RESET_ALL}")
async def check_in(address):
"""Perform daily check-in."""
short_address = f"{address[:8]}...{address[-4:]}"
headers = {"Content-Type": "application/json"}
payload = {
"query": """
mutation UpdateAirdropTaskStatus($input: UpdateTaskStatusInputData!) {
userdrop {
updateTaskStatus(input: $input) {
success
progress {
isCompleted
completedAt
}
}
}
}
""",
"variables": {
"input": {
"address": address,
"taskID": 1
}
}
}
async with aiohttp.ClientSession() as session:
async with session.post(GRAPHQL_URL, json=payload, headers=headers) as response:
if response.status == 200:
data = await response.json()
print(f"{Fore.GREEN}[{short_address}] Check-in successful: {data['data']['userdrop']['updateTaskStatus']['progress']}{Style.RESET_ALL}")
await check_points(address)
else:
print(f"{Fore.RED}[{short_address}] Check-in failed: {response.status}{Style.RESET_ALL}")