forked from t-rekttt/Piggy-Boom-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpiggyboom.py
159 lines (148 loc) · 4.98 KB
/
piggyboom.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
import requests, json, time
banner = '''=======================================
* _ ___ _______ __ __ *
* | |__ \__ __| | \/ | *
* | | ) | | | ___ __ _| \ / | *
* _ | | / / | |/ _ \/ _` | |\/| | *
* | |__| |/ /_ | | __/ (_| | | | | *
* \____/|____| |_|\___|\__,_|_| |_| *
* *
=======================================
'''
url = 'http://d2fd20abim5npz.cloudfront.net/planetpigth/m/'
login_url = url+'gameNew/#/'
play_url = url+'zhuanpan/play/'
def check(arr):
if arr['_d']['ret']==0:
return True
else:
return False
def steal(sid,data):
try:
data['id'] = sid
steal_result = requests.post(url+'userweapon/steal/',data=data).json()
if check(steal_result):
return (steal_result)
else:
return False
except Exception as e:
print(e)
return False
def get_info(puid,data):
try:
data['puid'] = puid
info = requests.post(url+'userplanet/get/',data=data).json()
if check(info):
return info['_d']
else:
return False
except Exception as e:
print(e)
return False
def get_frlist(data):
try:
flist = requests.post(url+'userfriend/list/',data=data)
flist = flist.json()
if check(flist):
return flist['_d']
else:
return False
except Exception as e:
print(e)
return False
def l(access_token):
try:
login = requests.post(login_url,data={'access_token':access_token, 'loginType':'1'}).json()
if check(login):
l_data = login['_d']
return_code = l_data['ret']
t = login['_t']
return [l_data,t,l_data['name']]
else:
return [False]
except Exception as e:
print(e)
return [False]
def s(data):
try:
p = requests.post(play_url,data=data)
play = p.json()
if check(play):
p_data = play['_d']['data']
reward_type = p_data['rewardType']
tili = p_data['tili']
return [p_data,reward_type,str(tili),data]
else:
return [False]
except Exception as e:
print(e)
return [False]
def start(access_token):
login = l(access_token)
if login[0]:
print "Logged in"
while (1>0):
login = l(access_token)
l_data = login[0]
if not login[0]:
break
count_down = l_data['zhuanpan']['time']
mtkey = l_data['mtkey']
skey = l_data['skey']
uid = l_data['uid']
status = l_data['status']
data = {
'_mtkey':mtkey,
'_skey':skey,
'_uid':uid,
'_version':'2.5.0',
'time':time.time(),
}
if status != 'steal':
time.sleep(2)
spin = s(data)
if spin[0]:
print('Reward: '+spin[1]+'. Spin left: '+spin[2])
if spin[1]=='fire':
print('Waiting for you to fire')
time.sleep(30)
else:
print('Out of spin, sleeping '+str(count_down))
time.sleep(count_down)
elif status == 'steal':
fbpic = l_data['zhuanpan']['stealTarget']['fbpic']
if fbpic != '':
target_id = fbpic.split('/')[3]
targets = l_data['stealTarget']
fr_list = get_frlist(data)
target_uid = -1
for i in fr_list['list']:
if target_id == i['siteuid']:
target_uid = i['uid']
if target_uid != -1:
target_info = get_info(target_uid,data)
target_star = target_info['planet']['star']
for z in range(0,len(targets)):
if targets[z]['planet']['star']==target_star:
status = steal(z,data)
else:
status = steal(1,data)
else:
status = steal(1,data)
if status:
if status['_d']['data']['king']=='true':
print('Found the king')
else:
print('Didn\'t got the king, sorry')
else:
print('Steal error')
else:
print('Login error')
if __name__ == '__main__':
print(banner)
f = open('token.txt')
#token = raw_input('Token: ')
token = f.read().strip('\n')
f.close()
while (1>0):
start(token)