Prosty i napisany na szybko bot w pythonie do gry Arena Mody http://arenamody.pl/
Bot loguje się i walczy na arenie musi być odpalony ciągle ;). Napisane na szybko ;).
Kod:
#-*- encoding: utf-8 -*-
import pycurl
import urllib.parse
import urllib.request
import json
import sched, time
import io
from time import strftime
login = input( "Podaj login: " )
password = input( "Podaj hasło: " )
counter = 0
cookies = {}
def zaloguj( userLogin , userPassword ):
url = 'http://arenamody.pl/ajax/user.php'
values = {
'login_user': userLogin,
'login_pass': userPassword,
'login_remember_me': 1,
'login_world': 1,
'type': 'login'
}
c = pycurl.Curl()
c.setopt( pycurl.URL, url );
c.setopt( pycurl.NOBODY, True );
c.setopt( pycurl.COOKIEJAR, 'cookie.txt');
c.setopt( c.POST, True)
data = urllib.parse.urlencode( values )
c.setopt( c.POSTFIELDS, data)
c.setopt( pycurl.HEADER, True);
c.setopt( pycurl.HTTPHEADER, [ "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" , "Connection: keep-alive" ] );
c.setopt( pycurl.TIMEOUT, 10);
body = io.BytesIO()
c.setopt( pycurl.WRITEFUNCTION, body.write )
c.perform()
stringResponse = body.getvalue().decode('utf-8')
indexPosition = stringResponse.rfind( '{' )
responseObject = json.loads( stringResponse[ indexPosition : ] );
if( responseObject[ 'error' ] == False ):
auth = pycurl.Curl()
auth.setopt( pycurl.URL, responseObject[ 'url' ] );
auth.setopt( pycurl.COOKIEJAR, 'cookie.txt');
auth.setopt( pycurl.COOKIEFILE , 'cookie.txt' )
auth.setopt( pycurl.HEADER, True);
auth.setopt( pycurl.HTTPHEADER, [ "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" , "Connection: keep-alive" ] );
auth.setopt( pycurl.TIMEOUT, 10);
bodyAuth = io.BytesIO()
auth.setopt( pycurl.WRITEFUNCTION, bodyAuth.write )
auth.setopt(pycurl.FOLLOWLOCATION, 1)
auth.setopt(pycurl.MAXREDIRS, 5)
auth.perform()
return True;
else:
print( "Nie udało się zalogować" );
return False;
def fight():
print( "[" + strftime("%H:%M:%S") + "] Walcze" );
url = 'http://g.arenamody.pl/ajax/arena.php'
values = {
'action': 'searchOpponent',
'type': 'weaker'
}
data = urllib.parse.urlencode( values )
c = pycurl.Curl()
c.setopt( pycurl.URL, url );
#c.setopt( pycurl.NOBODY, True );
c.setopt( pycurl.COOKIEJAR, 'cookie.txt');
c.setopt( pycurl.COOKIEFILE , 'cookie.txt' )
c.setopt( c.POST, True)
data = urllib.parse.urlencode( values )
c.setopt( c.POSTFIELDS, data)
c.setopt( pycurl.HEADER, True);
c.setopt( pycurl.HTTPHEADER, [ "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" , "Connection: keep-alive" ] );
c.setopt( pycurl.TIMEOUT, 10);
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
body = io.BytesIO()
c.setopt( pycurl.WRITEFUNCTION, body.write )
c.perform()
stringResponse = body.getvalue().decode('utf-8')
indexPosition = stringResponse.rfind( '{' )
if indexPosition == -1:
return
responseObject = json.loads( stringResponse[ indexPosition : ] );
if responseObject[ 'status' ] != 1:
return
valuesFight = {
'action': 'challenge',
'attack': responseObject[ 'id' ]
}
fightRequest = pycurl.Curl()
fightRequest.setopt( pycurl.URL, url );
fightRequest.setopt( pycurl.COOKIEJAR, 'cookie.txt');
fightRequest.setopt( pycurl.COOKIEFILE , 'cookie.txt' )
fightRequest.setopt( c.POST, True)
dataFight = urllib.parse.urlencode( valuesFight )
fightRequest.setopt( c.POSTFIELDS, dataFight)
fightRequest.setopt( pycurl.HEADER, True);
fightRequest.setopt( pycurl.HTTPHEADER, [ "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" , "Connection: keep-alive" ] );
fightRequest.setopt( pycurl.TIMEOUT, 10);
fightRequest.setopt(pycurl.FOLLOWLOCATION, 1)
fightRequest.setopt(pycurl.MAXREDIRS, 5)
bodyFight = io.BytesIO()
fightRequest.setopt( pycurl.WRITEFUNCTION, bodyFight.write )
fightRequest.perform()
stringResponse = bodyFight.getvalue().decode('utf-8')
indexPosition = stringResponse.rfind( '{' )
if indexPosition == -1:
return
responseObject = json.loads( stringResponse[ indexPosition : ] );
if responseObject[ 'status' ] != 1:
r eturn
fightRequestSecond = pycurl.Curl()
fightRequestSecond.setopt( pycurl.URL, 'http://g.arenamody.pl/duel.php?id=' + responseObject[ 'duel' ] + '&password=' + responseObject[ 'password' ] );
fightRequestSecond.setopt( pycurl.COOKIEJAR, 'cookie.txt');
fightRequestSecond.setopt( pycurl.COOKIEFILE , 'cookie.txt' )
fightRequestSecond.setopt( pycurl.HEADER, True);
fightRequestSecond.setopt( pycurl.HTTPHEADER, [ "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" , "Connection: keep-alive" ] );
fightRequestSecond.setopt( pycurl.TIMEOUT, 10);
fightRequestSecond.setopt(pycurl.FOLLOWLOCATION, 1)
fightRequestSecond.setopt(pycurl.MAXREDIRS, 5)
bodyRequestSecond = io.BytesIO()
fightRequestSecond.setopt( pycurl.WRITEFUNCTION, bodyRequestSecond.write )
fightRequestSecond.perform()
def fightPippi():
print( "[" + strftime("%H:%M:%S") + "] Walcze" );
url = 'http://g.arenamody.pl/ajax/events.php'
values = {
'type': 'factionsFightBoss'
}
data = urllib.parse.urlencode( values )
c = pycurl.Curl()
c.setopt( pycurl.URL, url );
#c.setopt( pycurl.NOBODY, True );
c.setopt( pycurl.COOKIEJAR, 'cookie.txt');
c.setopt( pycurl.COOKIEFILE , 'cookie.txt' )
c.setopt( c.POST, True)
data = urllib.parse.urlencode( values )
c.setopt( c.POSTFIELDS, data)
c.setopt( pycurl.HEADER, True);
c.setopt( pycurl.HTTPHEADER, [ "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" , "Connection: keep-alive" ] );
c.setopt( pycurl.TIMEOUT, 10);
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
body = io.BytesIO()
c.setopt( pycurl.WRITEFUNCTION, body.write )
c.perform()
stringResponse = body.getvalue().decode('utf-8')
indexPosition = stringResponse.rfind( '{' )
if indexPosition == -1:
return
responseObject = json.loads( stringResponse[ indexPosition : ] );
if responseObject[ 'status' ] != 1:
return
fightRequestSecond = pycurl.Curl()
fightRequestSecond.setopt( pycurl.URL, 'http://g.arenamody.pl/duel.php?id=' + responseObject[ 'duel' ] + '&password=' + responseObject[ 'password' ] );
fightRequestSecond.setopt( pycurl.COOKIEJAR, 'cookie.txt');
fightRequestSecond.setopt( pycurl.COOKIEFILE , 'cookie.txt' )
fightRequestSecond.setopt( pycurl.HEADER, True);
fightRequestSecond.setopt( pycurl.HTTPHEADER, [ "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" , "Connection: keep-alive" ] );
fightRequestSecond.setopt( pycurl.TIMEOUT, 10);
fightRequestSecond.setopt(pycurl.FOLLOWLOCATION, 1)
fightRequestSecond.setopt(pycurl.MAXREDIRS, 5)
bodyRequestSecond = io.BytesIO()
fightRequestSecond.setopt( pycurl.WRITEFUNCTION, bodyRequestSecond.write )
fightRequestSecond.perform()
def doStuff( sc ):
global login , password , counter
if counter % 15 == 0:
if not zaloguj( login , password ):
sc.enter(60, 1, doStuff, (sc,))
return
fight()
#fightPippi()
counter = counter + 1
sc.enter(60, 1, doStuff, (sc,))
for x in range( 10 ):
if zaloguj( login , password ):
fight()
#fightPippi()
s = sched.scheduler(time.time, time.sleep)
s.enter(1, 1, doStuff, (s,))
s.run()
uruchamiamy jak normalny skrypt pythona. Przy uruchomieniu musimy podać login i hasło do konta aby bot mógł się na nie zalogować.
Można jednocześnie grać i mieć odpalonego bota , jednak będzie nas wylogowywało co 10 minut ;).
I czasem zastanawiam się czy Ty już na pewno dorosłeś 😀
Lubie czasami po prostu zrobić coś dla zabawy 😀