forked from hallosayael/paws
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
204 lines (187 loc) · 10.3 KB
/
Copy pathapp.py
File metadata and controls
204 lines (187 loc) · 10.3 KB
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
from aiohttp import (
ClientResponseError,
ClientSession,
ClientTimeout
)
from colorama import *
from datetime import datetime, timedelta
from fake_useragent import FakeUserAgent
import asyncio, json, os, sys
class Paws:
def __init__(self) -> None:
self.headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8',
'Cache-Control': 'no-cache',
'Host': 'api.paws.community',
'Origin': 'https://app.paws.community',
'Pragma': 'no-cache',
'Priority': 'u=3, i',
'Referer': 'https://app.paws.community/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': FakeUserAgent().random
}
self.proxies = 'http://shyzagonakamoto-rotate:Shyzago011219@p.webshare.io:80/'
def clear_terminal(self):
os.system('cls' if os.name == 'nt' else 'clear')
def print_timestamp(self, message):
print(
f"{Fore.BLUE + Style.BRIGHT}[ {datetime.now().astimezone().strftime('%x %X %Z')} ]{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}"
f"{message}",
flush=True
)
async def user(self, token: str):
url = 'https://api.paws.community/v1/user'
headers = {
**self.headers,
'Content-Type': 'application/json',
'Authorization': f'Bearer {token}'
}
try:
async with ClientSession(timeout=ClientTimeout(total=20)) as session:
async with session.get(url=url, headers=headers, ssl=False) as response:
response.raise_for_status()
return await response.json()
except ClientResponseError as error:
self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An HTTP Error Occurred While Project Verify Task: {str(error)} ]{Style.RESET_ALL}")
return None
except Exception as error:
self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An Unexpected Error Occurred While Project Verify Task: {str(error)} ]{Style.RESET_ALL}")
return None
async def quests_list(self, token: str):
url = 'https://api.paws.community/v1/quests/list'
headers = {
**self.headers,
'Content-Type': 'application/json',
'Authorization': f'Bearer {token}'
}
try:
async with ClientSession(timeout=ClientTimeout(total=20)) as session:
async with session.get(url=url, headers=headers, ssl=False) as response:
if response.status in [500, 502, 503, 520]:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ Server Paws Down While Fetching Quests List ]{Style.RESET_ALL}")
response.raise_for_status()
quests_list = await response.json()
for quest in quests_list['data']:
await self.quests_completed(token=token, quest_id=quest['_id'], quest_title=quest['title'], quest_reward=quest['rewards'][0]['amount'])
except ClientResponseError as error:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An HTTP Error Occurred While Fetching Quests List: {str(error)} ]{Style.RESET_ALL}")
except Exception as error:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An Unexpected Error Occurred While Fetching Quests List: {str(error)} ]{Style.RESET_ALL}")
async def quests_completed(self, token: str, quest_id: str, quest_title: str, quest_reward: str):
url = 'https://api.paws.community/v1/quests/completed'
data = json.dumps({'questId':quest_id})
headers = {
**self.headers,
'Content-Length': str(len(data)),
'Content-Type': 'application/json',
'Authorization': f'Bearer {token}'
}
try:
async with ClientSession(timeout=ClientTimeout(total=20)) as session:
async with session.post(url=url, headers=headers, data=data, ssl=False) as response:
if response.status in [500, 502, 503, 520]:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ Server Paws Down While Completed {quest_title} ]{Style.RESET_ALL}")
response.raise_for_status()
quests_completed = await response.json()
if quests_completed['success'] and quests_completed['data']:
return await self.quests_claim(token=token, quest_id=quest_id, quest_title=quest_title, quest_reward=quest_reward)
except ClientResponseError as error:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An HTTP Error Occurred While Quests Completed: {str(error)} ]{Style.RESET_ALL}")
except Exception as error:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An Unexpected Error Occurred While Quests Completed: {str(error)} ]{Style.RESET_ALL}")
async def quests_claim(self, token: str, quest_id: str, quest_title: str, quest_reward: str):
url = 'https://api.paws.community/v1/quests/claim'
data = json.dumps({'questId':quest_id})
headers = {
**self.headers,
'Content-Length': str(len(data)),
'Content-Type': 'application/json',
'Authorization': f'Bearer {token}'
}
try:
async with ClientSession(timeout=ClientTimeout(total=20)) as session:
async with session.post(url=url, headers=headers, data=data, ssl=False) as response:
if response.status in [500, 502, 503, 520]:
self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ Server Paws Down While Claim {quest_title} ]{Style.RESET_ALL}")
response.raise_for_status()
quests_claim = await response.json()
if quests_claim['success'] and quests_claim['data']:
return self.print_timestamp(f"{Fore.GREEN + Style.BRIGHT}[ You\'ve Got {quest_reward} From {quest_title} ]{Style.RESET_ALL}")
except ClientResponseError as error:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An HTTP Error Occurred While Quests Claim: {str(error)} ]{Style.RESET_ALL}")
except Exception as error:
return self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ An Unexpected Error Occurred While Quests Claim: {str(error)} ]{Style.RESET_ALL}")
async def generate_token(self, query: str):
url = 'https://api.paws.community/v1/user/auth'
data = json.dumps({'data':query,'referralCode':'2A6XEyqW'})
headers = {
**self.headers,
'Content-Length': str(len(data)),
'Content-Type': 'application/json'
}
while True:
try:
async with ClientSession(timeout=ClientTimeout(total=20)) as session:
async with session.post(url=url, headers=headers, data=data, ssl=False) as response:
if response.status in [500, 502, 503, 520]:
self.print_timestamp(f"{Fore.YELLOW + Style.BRIGHT}[ Server Paws Down While Generate Token ]{Style.RESET_ALL}")
else:
response.raise_for_status()
generate_token = await response.json()
return (generate_token['data'][1]['userData']['firstname'], generate_token['data'][0])
except (Exception, ClientResponseError) as error:
self.print_timestamp(
f"{Fore.YELLOW + Style.BRIGHT}[ Failed To Process {query} ]{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}"
f"{Fore.RED + Style.BRIGHT}[ {str(error)} ]{Style.RESET_ALL}"
)
return None
async def generate_tokens(self, queries):
tasks = [self.generate_token(query) for query in queries]
results = await asyncio.gather(*tasks)
return [result for result in results if result is not None]
async def main(self):
while True:
try:
queries = [line.strip() for line in open('queries.txt') if line.strip()]
if not queries:
raise FileNotFoundError("Fill Your Query In 'queries.txt'")
accounts = await self.generate_tokens(queries)
total_balance = 0
for (name, token) in accounts:
self.print_timestamp(
f"{Fore.WHITE + Style.BRIGHT}[ Quests ]{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}"
f"{Fore.CYAN + Style.BRIGHT}[ {name} ]{Style.RESET_ALL}"
)
await self.quests_list(token=token)
for (name, token) in accounts:
user = await self.user(token=token)
total_balance += user['data']['gameData']['balance'] if user is not None else 0
self.print_timestamp(
f"{Fore.CYAN + Style.BRIGHT}[ Total Account {len(accounts)} ]{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}"
f"{Fore.GREEN + Style.BRIGHT}[ Total Balance {total_balance} ]{Style.RESET_ALL}"
)
self.print_timestamp(f"{Fore.CYAN + Style.BRIGHT}[ Restarting At {(datetime.now().astimezone() + timedelta(seconds=3600)).strftime('%x %X %Z')} ]{Style.RESET_ALL}")
await asyncio.sleep(3600)
self.clear_terminal()
except Exception as e:
self.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ {str(e)} ]{Style.RESET_ALL}")
continue
if __name__ == '__main__':
try:
if hasattr(asyncio, 'WindowsSelectorEventLoopPolicy'):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
init(autoreset=True)
paws = Paws()
asyncio.run(paws.main())
except (ValueError, IndexError, FileNotFoundError) as e:
paws.print_timestamp(f"{Fore.RED + Style.BRIGHT}[ {str(e)} ]{Style.RESET_ALL}")
except KeyboardInterrupt:
sys.exit(0)