-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdrawmulti.py
177 lines (151 loc) · 7.85 KB
/
drawmulti.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
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
import requests
import json
import time
import logging
import os
import getpass
import csv
import random
from datetime import datetime
from colorama import Fore, Style
logging.basicConfig(filename='hana_auto_grow.log', level=logging.INFO)
def refresh_access_token(refresh_token):
api_key = "AIzaSyDipzN0VRfTPnMGhQ5PSzO27Cxm3DohJGY"
url = f"https://securetoken.googleapis.com/v1/token?key={api_key}"
headers = {
"Content-Type": "application/json",
}
body = json.dumps({
"grant_type": "refresh_token",
"refresh_token": refresh_token,
})
response = requests.post(url, headers=headers, data=body)
if response.status_code != 200:
error_response = response.json()
raise Exception(f"Failed to refresh access token: {error_response['error']}")
try:
return response.json()
except json.JSONDecodeError:
raise Exception("Failed to parse JSON response for access token refresh.")
def print_intro():
print(Fore.CYAN + Style.BRIGHT + """ █████╗ ██████╗ ███████╗███╗ ███╗██╗██████╗ ███╗ ██╗""" + Style.RESET_ALL)
print(Fore.CYAN + Style.BRIGHT + """██╔══██╗██╔══██╗██╔════╝████╗ ████║██║██╔══██╗████╗ ██║""" + Style.RESET_ALL)
print(Fore.CYAN + Style.BRIGHT + """███████║██║ ██║█████╗ ██╔████╔██║██║██║ ██║██╔██╗ ██║""" + Style.RESET_ALL)
print(Fore.CYAN + Style.BRIGHT + """██╔══██║██║ ██║██╔══╝ ██║╚██╔╝██║██║██║ ██║██║╚██╗██║""" + Style.RESET_ALL)
print(Fore.CYAN + Style.BRIGHT + """██║ ██║██████╔╝██║ ██║ ╚═╝ ██║██║██████╔╝██║ ╚████║""" + Style.RESET_ALL)
print(Fore.CYAN + Style.BRIGHT + """╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚═╝ ╚═══╝""" + Style.RESET_ALL)
print(Fore.CYAN + Style.BRIGHT + """ Auto Draw for HANAFUDA x t.me/dpangestuw""" + Style.RESET_ALL)
def print_success(message):
print(Fore.GREEN + Style.BRIGHT + message + Style.RESET_ALL)
def print_error(message):
print(Fore.RED + Style.BRIGHT + message + Style.RESET_ALL)
def print_warning(message):
print(Fore.YELLOW + Style.BRIGHT + message + Style.RESET_ALL)
def load_tokens_from_file():
try:
with open("tokens.json", "r") as token_file:
return json.load(token_file)
except FileNotFoundError:
logging.error("File 'tokens.json' not found.")
print(Fore.RED + Style.BRIGHT + "File 'tokens.json' not found." + Style.RESET_ALL)
exit()
def main():
accounts = load_tokens_from_file()
while True:
for account in accounts:
refresh_token = account['refresh_token']
try:
num_iterations = random.randint(20, 31)
print(Fore.BLUE + Style.BRIGHT + f"Random of Hanafuda Draws chosen: {num_iterations}" + Style.RESET_ALL)
token_data = refresh_access_token(refresh_token)
access_token = token_data["access_token"]
url = "https://hanafuda-backend-app-520478841386.us-central1.run.app/graphql"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
}
for i in range(num_iterations):
query_get_hanafuda_list = {
"query": """
query getHanafudaList($groups: [YakuGroup!]) {
getYakuListForCurrentUser(groups: $groups) {
cardId
group
}
}
""",
"variables": {
"groups": ["SPRING", "SUMMER", "AUTUMN", "WINTER", "SECRET"]
},
"operationName": "getHanafudaList"
}
requests.post(url, headers=headers, json=query_get_hanafuda_list)
mutation_execute_garden_reward = {
"query": """
mutation executeGardenRewardAction($limit: Int!) {
executeGardenRewardAction(limit: $limit) {
data {
cardId
group
}
isNew
}
}
""",
"variables": {"limit": 10},
"operationName": "executeGardenRewardAction"
}
response_garden_reward = requests.post(url, headers=headers, json=mutation_execute_garden_reward)
if response_garden_reward.status_code == 200:
garden_reward_data = response_garden_reward.json()
print("-" * 27)
print(Fore.YELLOW + Style.BRIGHT + "Card ID | Group | Is New" + Style.RESET_ALL)
print("-" * 27)
for item in garden_reward_data['data']['executeGardenRewardAction']:
card_id = item['data'].get('cardId')
group = item['data'].get('group')
is_new = item.get('isNew')
print(Fore.GREEN + Style.BRIGHT + f"{card_id:<8} | {group:<7} | {is_new}" + Style.RESET_ALL)
query_get_garden = {
"query": """
query GetGardenForCurrentUser {
getGardenForCurrentUser {
id
inviteCode
gardenDepositCount
gardenStatus {
id
growActionCount
gardenRewardActionCount
}
gardenMilestoneRewardInfo {
id
gardenDepositCountWhenLastCalculated
lastAcquiredAt
createdAt
}
gardenMembers {
id
sub
name
iconPath
depositCount
}
}
}
""",
"operationName": "GetGardenForCurrentUser"
}
response_garden = requests.post(url, headers=headers, json=query_get_garden)
if response_garden.status_code == 200:
garden_data = response_garden.json()
sleep_time = random.randint(1, 11)
time.sleep(sleep_time)
except Exception as e:
logging.error(f"Error refreshing token for account {account['name']}: {e}")
for remaining in range(600, 0, -1):
print(Fore.YELLOW + Style.BRIGHT + f"Next in {remaining} seconds" + Style.RESET_ALL, end="\r")
time.sleep(1)
if __name__ == "__main__":
print_intro()
main()