forked from raresoft/NeoAuto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
251 lines (167 loc) · 8.21 KB
/
client.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
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
######################################################
################NeoAuto BETA - Darkbyte##########
######################################################
############Open Source Neopets Automation############
######################################################
#Neobot is a tool created to play neopets for you. It does this by simulating data real games
#Or webpages send to the server , tricking neopets into thinking we are a legit user
#All this uses one principle
#Get Data - > Do some new event based on this data - > Get Event result and store it
#Credits:
#Darkbyte - Main Code
#Infamous Joe - Work on altador plot chart finder (bot uses cks chart finder)
#Zach - Work on altador plot chart finder(bot uses cks chart finder)
######################################################Imports######################################################
import urllib2, re
from cookielib import CookieJar
from urllib import urlencode
import urllib
import threading
import sys
import time
import random
import ConfigParser
from classes.InventoryManager import InventoryManager
from pyamf.remoting.client import RemotingService #Pyamf class used for amf request (slightly edited)
from classes.NeoAccount import NeoAccount
from classes.settings import settings
from classes.dailys import dailys
from classes.mobileservices import mobileservices
from classes.nomobileservices import nomobileservices
from classes.hotel import hotel
from classes.battle import battle
from classes.nsthandler import nsthandler
from classes.shopmanager import shopmanager
from classes.altadorauto import altador
from classes.bankmanager import bankmanager
from classes.autotrainer import autotrainer
from classes.avatar import avatar
from classes.gamerunner import gamerunner
from classes.nsthandler import nsthandler
#from classes.nq2 import nq2
######################################################End Imports##################################################
config1 = ConfigParser.RawConfigParser()
strcookie= []
CJ=CookieJar() #Cookies
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(CJ))
Dodebugmode = 1
neouser = "" #Neopets username
neopass = "" #Neopets password
neopin = "" #Neopets pin number (if used , leave as "" if not used)
proxy = "" #localhost:8888 or 123.123.123.123:8080 ect - "" for none
if neouser == "":
#Todo add a user input option here if neouser not set
print 'Username not set , exiting in 10 seconds...'
time.sleep(10)
sys.exit()
if neopass == "":
#Todo add a user input option here if neopass not set
print 'Username not set , exiting in 10 seconds...'
time.sleep(10)
sys.exit()
pyamfhandler = RemotingService('http://habitarium.neopets.com/amfphp/gateway.php')
def dologin(debugmode=1): #Debug mode is optional and set to 1 by default
if proxy == "": #No proxy
theacc = NeoAccount(neouser,neopass,neopin)
else: #if proxy is anything but "" , use it
theacc = NeoAccount(neouser,neopass,neopin,proxy)
login_return = theacc.login() #Login here
if login_return[0] == False: #Bad login
print 'Login Failed - ' + login_return[1] + ' Closing myself in 10 seconds'
time.sleep(10)
sys.exit()
else:
print "Logged in as - " + theacc.user
#Check result was valid:
return theacc
acc = dologin(Dodebugmode) #Do login trys to login and returns a new instance of NeoAccount
nsthandler = nsthandler(acc)
settingsmanager = settings(acc.user) #Load settings for this account , store data/class in sessionmanager
depositfile = settingsmanager.getvalue("Settings","depositlist") #Deposit list items
doaltador =settingsmanager.getvalue("misc","altador_on") #Altador on off switch
inventorymanager = InventoryManager(acc,depositfile,settingsmanager)
shopmanager = shopmanager (acc,settingsmanager)
lastlogintime = time.time()
#nq2handler= nq2(acc,settingsmanager)
dailyshander = dailys(acc,settingsmanager) #Setup dailys hander module
mobilehandler = mobileservices (acc,settingsmanager) #Mobile services , uses a seperate login to main neo
if not mobilehandler.usemobileservices == 'on': #mobile handler = off , so sets our bot to replace mobilehandler with nomobilehandler
mobilehandler = nomobileservices (acc,settingsmanager) #Mobile services , uses a seperate login to main neo
battlemanager = battle(acc,mobilehandler,settingsmanager)
hotelmanager = hotel(acc,settingsmanager,mobilehandler) #Lol hotelmanager i made a funny...... I'll see myself out
bankhandler = bankmanager(acc,mobilehandler,settingsmanager)
althandler = altador(acc,settingsmanager,bankhandler)
gamerunnerhandler = gamerunner(acc,settingsmanager,mobilehandler) #Setup dailys hander module
avatarhandler = avatar(acc,settingsmanager,mobilehandler)
traininghandler =autotrainer(acc,mobilehandler,settingsmanager,inventorymanager)
#bankhandler.checknpbalance() #Check we have enough np on hand once before run
test = 1
while test ==1:
# battlemanager.dotick()
# time.sleep(10)
# continue
#
try:
if not dailyshander.DoTick(mobilehandler) == 0:
continue #Done something so exit
if traininghandler.trainingon == 'on':
if (time.time() - float(traininghandler.lasttraintime) > 180): #Auto train check every 3 mins
traininghandler.dotick()
time.sleep(10)
continue #Done something so exit
if bankhandler.checknp_on == 'on':
if (time.time() - float(bankhandler.lastbanktime) > 900): #Auto check cash on hand every half hour
bankhandler.checknpbalance()
time.sleep(10)
continue #Done something so exit
if hotelmanager.autohotel_on == 'on':
if (time.time() - float(hotelmanager.lasthoteltime) > 86400): #Auto hotel check every day
hotelmanager.dotick()
time.sleep(10)
continue #Done something so exit
if battlemanager.battle_on == 'on':
if (time.time() - float(battlemanager.nextbattletime) > 86400): #Auto Battle check everyday (time only updates when we stope earning prizes)
if battlemanager.dotick() == 1: #Won battle
nextbattletime = time.time() + 300
settingsmanager.setvalue("timecache","nextbattletime" , nextbattletime )
time.sleep(10)
continue #Done something so exit
print 'Battle manager'
#We did nothing if this runs.. so check for punchbag bob and process it if needed
if battlemanager.punchbag_on == 'on':
#Check is needed by the user
battlemanager.startpunchbag()
continue #Done something so exit
if inventorymanager.invenotrymanageron == 'on':
if (time.time() - float(inventorymanager.lastsdbticktime) > 900): #Invenotry manager check every half hour
inventorymanager.Depositall()
time.sleep(10)
continue #Done something so exit
if shopmanager.withdrawtill == 'on':
if (time.time() - float(shopmanager.lasttilltime) > 300): #till check every 5 mins
shopmanager.checktill()
time.sleep(10)
continue #Done something so exit
if shopmanager.withdrawtill == 'on':
if (time.time() - float(shopmanager.lasttilltime) > 300): #till check every 5 mins
shopmanager.checktill()
time.sleep(10)
continue #Done something so exit
if shopmanager.autoprice_on == 'on':
if (time.time() - float(shopmanager.lastpricetime) > 900): #price items every half hour
shopmanager.priceitems()
time.sleep(10)
continue #Done something so exit
if avatarhandler.avataron == 'on':
if (time.time() - float(avatarhandler.lastavatartime) > 300): #grab a avatar every 5 mins
avatarhandler.getavatar()
time.sleep(10)
continue #Done something so exit
if doaltador == 'on':
if althandler.DoTick() == 999:#Done if 999
doaltador ='off'
gamerunnerhandler.rungames()
except:
print "Except"
time.sleep(10)
continue