- import time
- import datetime
- import urllib2
- import cookielib
- import os
- import sys
- import socket
- import threading
- socket.setdefaulttimeout(10.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')]
- GOD_CHECK_TIME = 2 # The speed at which it rechecks for a raid in the room
- FORMER_ID = "2666877" # Form account ID
- CAST_SIN = False # True or False to cast a SiN
- SIN_ID = "" # Optional if you set CAST_SIN to True
- rg_sess_id = "amyfjxu1trxgeqhmw9zz1jzy63k6zwry" # From typpo
- chars = (["830086", "1753066", "1658603", "2318884",
- "2203114", "659396", "1711831", "2204849", "2270628",
- "2198627", "1455048", "602961", "2556351", "1624984", "2403961",
- "2603131", "1946930", "2235855", "2547504", "2253210",
- "2298687", "2213078", "1496440", "1273553", "2201558",
- "2204829", "1723437", "2562778", "2315488", "2313637",
- "2309921", "1585569", "1034587", "2239674", "2022747"])
- LOGIN_WITH_SESSION = True # Change to True to log in with session
- # or False to use the stored user/pass
- rg_sess_id = "amyfjxu1trxgeqhmw9zz1jzy63k6zwry"
- server = "sigil"
- username = ""
- password = ""
- #global editables, dont touch these
- RAID_ID = ""
- RAID_NAME = ""
- _startTime = datetime.datetime.now()
- _finishTime = datetime.datetime.now()
- #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..."
- except Exception:
- print "Unknown error, retrying..."
- return site
- def alo2(url, pData):
- lagsafe = 1
- while lagsafe == 1:
- try:
- site = opener.open(url, pData)
- lagsafe = 0
- except IOError:
- print "URLError: Site not loading. Retrying..."
- except Exception:
- print "Unknown error, retrying..."
- return site
- # Print a message with timestamp
- def msg(out):
- thetime = time.strftime("[%H:%M:%S]", time.localtime(time.time()))
- message = thetime + " " + out
- print message
- return message
- def getCharName(src):
- charName = "Unknown"
- try:
- charName = src.split('" selected>')[1].split('</option>')[0]
- except:
- msg("Could not retrieve character name.")
- return charName
- # Get the substring of a string,
- # iB("<hello> world </hello>", "<hello>", "</hello>")
- # The above would return "world"
- def iB(src, start, end):
- try:
- return src.split(start)[1].split(end)[0]
- except IndexError:
- msg("Could not retrieve the inbetween value.")
- return
- def formRaid(formerID):
- one = 1
- while one == 1:
- try:
- global _startTime
- _startTime = datetime.datetime.now()
- srcworld = alo("http://sigil.outwar.com/ajax_changeroomb.php?suid=" + formerID + '&serverid=1').read()
- raidLink = srcworld.split("formraid.php?target=")[1].split('\\">')[0]
- print ""
- msg("***Raid spotted, forming raid.")
- formpage = alo("http://sigil.outwar.com/formraid.php?target=" + raidLink).read()
- codeID = formpage.split('codeid" value="')[1].split('">')[0]
- Form = alo2("http://sigil.outwar.com/formraid.php?target=" + raidLink, "target=" + raidLink + "&codeid=" + codeID + "&formtime=3&submit=Launch!").read()
- global RAID_ID, RAID_NAME
- RAID_ID = getRaidID(Form)
- RAID_NAME = getRaidName(Form)
- msg("***" + RAID_NAME + " Formed.")
- one = 0
- return True
- except IndexError:
- msg("God not spawned.")
- time.sleep(GOD_CHECK_TIME)
- def getRaidID(src):
- #raids = alo("http://sigil.outwar.com/crew_raidsforming.php")
- #srcraids = raids.read()
- try:
- return iB(src, "joinraid.php?raidid=", "&")
- except IndexError:
- msg("Couldn't retrieve raid ID")
- return False
- def getRaidName(src):
- try:
- return iB(src, "<div ONMOUSEOVER=\"statspopup(event,'<b>", "</b>')\" ONMOUSEOUT=\"kill()\">")
- except IndexError:
- msg("Couldn't retrieve raid name")
- return False
- def launchRaid(launchURL):
- x = 1
- while x == 1:
- try:
- launch = alo(launchURL).read()
- if "Your raid will launch shortly" in launch:
- msg("RAID LAUNCHED!")
- global _finishTime
- _finishTime = datetime.datetime.now()
- x = 0
- return True
- except IndexError:
- x = 1
- time.sleep(1)
- def createReport(raidTime):
- r = open("numero.txt", "a")
- r.write("Raid launched at " + time.strftime("[%H:%M:%S]", time.localtime(time.time())) + " \nThe raid took "+str(raidTime.seconds)+" seconds.")
- r.close()
- return True
- loginrpg = alo("http://sigil.outwar.com/myaccount.php?rg_sess_id=" + rg_sess_id + "&serverid=1&suid="+FORMER_ID)
- #loginrpg = alo2("http://sigil.outwar.com/myaccount.php", "login_username=" + username + "&login_password=" + password + "&serverid=1&suid="+FORMER_ID)
- msg("Logged in RGA\n")
- # God name was found on the page, so form and join the raid.
- formRaid(FORMER_ID)
- # Start to join
- #for i in range(len(chars)):
- # join = alo2('http://sigil.outwar.com/joinraid.php?raidid=' + RAID_ID + '&suid=' + chars[i] + '&serverid=1', "join=1").read()
- # msg("Joined character: " + getCharName(join))
- class ThreadClass(threading.Thread):
- def __init__(self, char):
- self.char = char
- threading.Thread.__init__(self)
- def run(self):
- join = alo2('http://sigil.outwar.com/joinraid.php?raidid='+RAID_ID+'&suid='+self.char+'&serverid=1', "join=1").read()
- if "error" in join:
- x = 1
- while x == 1:
- join = alo2('http://sigil.outwar.com/joinraid.php?raidid='+RAID_ID+'&suid='+self.char+'&serverid=1', "join=1").read()
- if "Please click" in join:
- x = 0
- time.sleep(0.2)
- msg("Joined character: " + getCharName(join))
- for i in range(len(chars)):
- t = ThreadClass(chars[i])
- t.start()
- # Cast SiN
- if CAST_SIN == True:
- cast = alo2("http://sigil.outwar.com/cast_skills.php?C=5", "suid="+SIN_ID+"&castskillid=3015&cast=Cast+Skill")
- msg("Casted Strength in Numbers on " + getCharName(cast))
- launchURL = 'http://sigil.outwar.com/joinraid.php?raidid=' + RAID_ID + '&suid=' + FORMER_ID + '&serverid=1&launchraid=yes&x=141&y=36'
- launchRaid(launchURL)
- tTime = _finishTime - _startTime
- msg("TOTAL RAID TIME: " + str(tTime.seconds) + " seconds.\n")
- keepChecking = 0