Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import time
- import urllib2
- import cookielib
- import os
- import sys
- import socket
- import datetime
- import re
- socket.setdefaulttimeout(15.0)
- cj = cookielib.CookieJar()
- opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
- opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1 ID:20120614114901')]
- FORMER_ID = "682970"
- chars = ([
- "64960" #raider101
- ,"682665" #raidit01
- ,"682666" #raidit02
- ,"682792" #raidit03
- ,"682970" #raidit04
- ])
- LOGIN_WITH_SESSION = False # Change to True to log in with session
- # or False to use the stored user/pass
- ## There are 2 ways to login, session or user/pass
- ## to log in with session you dont need to put the
- ## username or password in below, but set the LOGIN_WITH_SESSION
- ## above to True, quite simple you will get the hang of it, if not
- ## I don't really care :)
- ## Happy hunting!
- # ___ _ _ _
- # | _ |_) | |_ _
- # | _ \ | | | || |
- # |___/_|_|_|\_, |.
- # |__/
- rg_sess_id = ""
- server = "torax"
- username = "raider101"
- password = "password1"
- #####################
- ##### Dont Edit #####
- #####################
- if server.lower() == "sigil":
- SERVER_ID = "1"
- elif server.lower() == "torax":
- SERVER_ID = "2"
- elif server.lower() == "fabar":
- SERVER_ID = "3"
- elif server.lower() == "zimbob":
- SERVER_ID = "4"
- elif server.lower() == "rancid":
- SERVER_ID = "5"
- elif server.lower() == "quiver":
- SERVER_ID = "6"
- else:
- SERVER_ID = "2"
- RAID_ID = ""
- RAID_NAME = ""
- _startTime = datetime.datetime.now()
- _finishTime = datetime.datetime.now()
- bossToRaidId = ""
- bossToRaidName = ""
- totalRaidDamage = 0
- damageLastRaid = 0
- #anti-lag-opener
- def alo(url):
- lagsafe = 1
- while lagsafe == 1:
- try:
- site = opener.open(url)
- lagsafe = 0
- except IOError:
- print "URLError: Site not loading. Retrying..."
- return site
- def alo2(url, postData):
- lagsafe = 1
- while lagsafe == 1:
- try:
- site = opener.open(url, postData)
- lagsafe = 0
- except IOError:
- print "URLError: Site not loading. Retrying..."
- return site
- def msg(out):
- thetime = time.strftime("[%H:%M:%S]", time.localtime(time.time()))
- message = thetime + " " + out
- print message
- return message
- def getCharName(src):
- #<option value="2236250" selected>Eag1e</option>
- charName = "Unknown"
- try:
- charName = src.split('" selected>')[1].split('</option>')[0]
- except:
- print "Could not retrieve character name."
- return charName
- def iB(src, start, end):
- try:
- return src.split(start)[1].split(end)[0]
- except IndexError:
- print "Could not retrieve the inbetween value."
- return
- def getRaidName(src):
- try:
- return iB(src, "<div ONMOUSEOVER=\"statspopup(event,'<b>", "</b>')\" ONMOUSEOUT=\"kill()\">")
- except IndexError:
- print "Couldn't retrieve raid name"
- return False
- def bossSelector():
- bossPage = alo("http://"+server+".outwar.com/crew_bossspawns.php").read()
- bossID = []
- bossName = []
- try:
- exp = re.compile('target=[0-9]+" ONMOUSEOVER="popup\(event,\'<b>(.+)</b>')
- y = re.findall(exp, bossPage)
- bossName.extend(y)
- print "Found "+ str(len(y)) +" bosses\n"
- except:
- print "Unable to retrieve boss names or no bosses are spawned."
- try:
- exp = re.compile('<a href="formraid.php\?target=([0-9]+)">')
- z = re.findall(exp, bossPage)
- bossID.extend(z)
- #print "found "+ str(len(z)) +" boss ids"
- except:
- print "Unable to retrieve boss ID's or no bosses are spawned."
- if len(bossName) > 0 and len(bossID) > 0:
- # bosses found, print them
- print "Select a boss to raid:"
- d = 1
- for name in bossName:
- print str(d) + " - " + name
- d = d + 1
- global bossToRaidName, bossToRaidId
- x = 1
- while x == 1:
- print ""
- cho = raw_input("Number: ")
- if int(cho) < len(bossName)+1:
- print "You have chosen to raid, " + bossName[int(cho)-1]
- #print "ID: " + bossID[int(cho)-1]
- bossToRaidName = bossName[int(cho)-1]
- bossToRaidId = bossID[int(cho)-1]
- x = 0
- else:
- print "Invalid selection, please enter a valid number."
- else:
- print "No bosses found..."
- chk = raw_input("Try again? Y/N")
- if chk.lower() == "y":
- bossSelector()
- else:
- return False
- return True
- def formRaid():
- #print formerID
- one = 1
- while one == 1:
- try:
- global _startTime, bossToRaidName, bossToRaidId
- _startTime = datetime.datetime.now()
- ##It's this formpage. It's not sending the correct data to form the raid, or it doesnt have the data to send
- ## I can try to look at it later, but I have to head out soon
- formpage = alo("http://"+server+".outwar.com/formraid.php?target=" + bossToRaidId +"&suid="+ FORMER_ID).read()
- codeID = formpage.split('codeid" value="')[1].split('">')[0]
- Form = alo2("http://"+server+".outwar.com/formraid.php?target=" + bossToRaidId, "target=" + bossToRaidId + "&codeid=" + codeID + "&formtime=3&submit=Launch!").read()
- global RAID_ID, RAID_NAME
- RAID_ID = getRaidID(Form)
- RAID_NAME = getRaidName(Form)
- print ""
- print "***" + RAID_NAME + " Formed."
- one = 0
- return True
- except IndexError:
- with open("formingTest.txt", "w") as fileID:
- fileID.write(formpage)
- fileID.close()
- print "Forming Error, retrying...."
- time.sleep(1)
- def intC(x):
- if type(x) not in [type(0), type(0L)]:
- raise TypeError("Parameter must be an integer.")
- if x < 0:
- return '-' + intWithCommas(-x)
- result = ''
- #I dont understand this function... I'll indent it as best I cankie
- while x >= 1000:
- x, r = divmod(x, 1000)
- #If you start programming, dont use variables like "x"
- #Freaking name your variables for what they are
- #In this function, i have no idea what "x" is supposed to be (other than it's mathematical meaning due to divmod)
- # But in relation to how it helps the raider, I have no idea because the writer decided to take short cuts
- # instead of writing clear code got it
- result = ",%03d%s" % (r, result)
- ####Come back to this Return, may need to be indented
- return "%d%s" % (x, result)
- def getRaidID(src):
- #raids = alo("http://"+server+".outwar.com/crew_raidsforming.php")
- #srcraids = raids.read()
- try:
- return iB(src, "joinraid.php?raidid=", "&")
- except IndexError:
- print "Couldn't retrieve raid ID"
- return False
- def launchRaid(launchURL):
- x = 1
- while x == 1:
- try:
- launch = alo(launchURL).read()
- if "Your raid will launch shortly" in launch:
- print "RAID LAUNCHED!"
- global _finishTime
- _finishTime = datetime.datetime.now()
- x = 0
- return True
- except IndexError:
- x = 1
- time.sleep(1)
- def launchWait():
- checking = 1
- while checking == 1:
- check = alo('http://'+server+'.outwar.com/joinraid.php?raidid=' + RAID_ID).read()
- if "Attacks!" in check:
- # Raid has launched, gather data
- # attacks for <font color="#FF9900"> 3,651</b><
- # CRITICAL!</font><font color="#FF9900"> 6,491</b>
- attackDamage = 0
- try:
- exp = re.compile('<font color="#FF9900"> (.+)</b><')
- attacks = re.findall(exp, check)
- for i in attacks:
- z = int(i.replace(',', ''))
- attackDamage = attackDamage + z
- except:
- pass
- global damageLastRaid, totalRaidDamage
- damageLastRaid = attackDamage
- totalRaidDamage = totalRaidDamage + attackDamage
- checking = 0
- else:
- time.sleep(1)
- ####This appears to be the beginning of the MAIN function
- if LOGIN_WITH_SESSION:
- loginrpg = alo("http://"+server+".outwar.com/myaccount.php?rg_sess_id=" + rg_sess_id + "&serverid="+SERVER_ID+"&suid=" + FORMER_ID)
- print "Logged in RGA with session ID\n"
- else:
- loginrpg = alo2("http://"+server+".outwar.com/myaccount.php", "login_username="+username+"&login_password="+password)
- loginchar = alo("http://"+server+".outwar.com/world.php?suid="+FORMER_ID+"&serverid="+SERVER_ID)
- print "Logged in RGA\n"
- ####bossSelector()
- if bossSelector():
- x = 1
- while x == 1:
- formRaid()
- chars_to_remove = []
- for i in chars:
- join = alo2('http://'+server+'.outwar.com/joinraid.php?raidid=' + RAID_ID + '&suid=' + i + '&serverid='+SERVER_ID, "join=1").read()
- time.sleep(0.1)
- if "rage to join this raid" in join:
- print i + " out of rage..."
- chars_to_remove.append(i)
- elif "must be a member of this crew" in join:
- print i + " not in crew..."
- chars_to_remove.append(i)
- else:
- print "Joined " + getCharName(join)
- if len(chars_to_remove) > 0 :
- for character in chars_to_remove:
- if character in chars:
- chars.remove(character)
- launchURL = 'http://'+server+'.outwar.com/joinraid.php?raidid=' + RAID_ID + '&suid=' + FORMER_ID + '&serverid='+SERVER_ID+'&launchraid=yes&x=141&y=36'
- launchRaid(launchURL)
- tTime = _finishTime - _startTime
- print "Raid time: " + str(tTime.seconds) + " seconds.\n"
- # Wait for launch before reforming...
- launchWait()
- print "Raid Damage: " + intC(damageLastRaid)
- print "Damage Total: " + intC(totalRaidDamage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement