Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 17th, 2012  |  syntax: None  |  size: 6.82 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import time
  2. import datetime
  3. import urllib2
  4. import cookielib
  5. import os
  6. import sys
  7. import socket
  8. import threading
  9. socket.setdefaulttimeout(10.0)
  10.  
  11. cj = cookielib.CookieJar()
  12. opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  13. opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1 ID:20120614114901')]
  14.  
  15.  
  16. GOD_CHECK_TIME = 2 # The speed at which it rechecks for a raid in the room
  17. FORMER_ID = "2666877"     # Form account ID
  18. CAST_SIN = False   # True or False to cast a SiN
  19. SIN_ID = ""        # Optional if you set CAST_SIN to True
  20. rg_sess_id = "amyfjxu1trxgeqhmw9zz1jzy63k6zwry"    # From typpo
  21.  
  22. chars = (["830086", "1753066", "1658603", "2318884",
  23.           "2203114", "659396", "1711831", "2204849", "2270628",
  24.           "2198627", "1455048", "602961", "2556351", "1624984", "2403961",
  25.           "2603131", "1946930", "2235855", "2547504", "2253210",
  26.           "2298687", "2213078", "1496440", "1273553", "2201558",
  27.           "2204829", "1723437", "2562778", "2315488", "2313637",
  28.           "2309921", "1585569", "1034587", "2239674", "2022747"])
  29. LOGIN_WITH_SESSION = True # Change to True to log in with session
  30. # or False to use the stored user/pass
  31. rg_sess_id = "amyfjxu1trxgeqhmw9zz1jzy63k6zwry"
  32. server = "sigil"
  33. username = ""
  34. password = ""
  35.  
  36.  
  37. #global editables, dont touch these
  38. RAID_ID = ""
  39. RAID_NAME = ""
  40. _startTime = datetime.datetime.now()
  41. _finishTime = datetime.datetime.now()
  42.  
  43. #anti-lag-opener
  44. def alo(url):
  45.     lagsafe = 1
  46.     while lagsafe == 1:
  47.         try:
  48.             site = opener.open(url)
  49.             lagsafe = 0
  50.         except IOError:
  51.             print "URLError: Site not loading. Retrying..."
  52.         except Exception:
  53.             print "Unknown error, retrying..."
  54.     return site
  55.  
  56. def alo2(url, pData):
  57.     lagsafe = 1
  58.     while lagsafe == 1:
  59.         try:
  60.             site = opener.open(url, pData)
  61.             lagsafe = 0
  62.         except IOError:
  63.             print "URLError: Site not loading. Retrying..."
  64.         except Exception:
  65.             print "Unknown error, retrying..."
  66.     return site
  67.  
  68.  
  69. # Print a message with timestamp
  70. def msg(out):
  71.     thetime = time.strftime("[%H:%M:%S]", time.localtime(time.time()))
  72.     message = thetime + " " + out
  73.     print message
  74.     return message
  75.  
  76.  
  77. def getCharName(src):
  78.     charName = "Unknown"
  79.     try:
  80.         charName = src.split('" selected>')[1].split('</option>')[0]
  81.     except:
  82.         msg("Could not retrieve character name.")
  83.  
  84.     return charName
  85.  
  86. # Get the substring of a string,
  87. # iB("<hello> world </hello>", "<hello>", "</hello>")
  88. # The above would return "world"
  89. def iB(src, start, end):
  90.     try:
  91.         return src.split(start)[1].split(end)[0]
  92.     except IndexError:
  93.         msg("Could not retrieve the inbetween value.")
  94.         return
  95.  
  96. def formRaid(formerID):
  97.     one = 1
  98.     while one == 1:
  99.         try:
  100.             global _startTime
  101.             _startTime = datetime.datetime.now()
  102.             srcworld = alo("http://sigil.outwar.com/ajax_changeroomb.php?suid=" + formerID + '&serverid=1').read()
  103.             raidLink = srcworld.split("formraid.php?target=")[1].split('\\">')[0]
  104.             print ""
  105.             msg("***Raid spotted, forming raid.")
  106.  
  107.             formpage = alo("http://sigil.outwar.com/formraid.php?target=" + raidLink).read()
  108.             codeID = formpage.split('codeid" value="')[1].split('">')[0]
  109.  
  110.             Form = alo2("http://sigil.outwar.com/formraid.php?target=" + raidLink, "target=" + raidLink + "&codeid=" + codeID + "&formtime=3&submit=Launch!").read()
  111.  
  112.             global RAID_ID, RAID_NAME
  113.             RAID_ID = getRaidID(Form)
  114.             RAID_NAME = getRaidName(Form)
  115.  
  116.             msg("***" + RAID_NAME + " Formed.")
  117.             one = 0
  118.             return True
  119.  
  120.         except IndexError:
  121.             msg("God not spawned.")
  122.             time.sleep(GOD_CHECK_TIME)
  123.  
  124.  
  125. def getRaidID(src):
  126.     #raids = alo("http://sigil.outwar.com/crew_raidsforming.php")
  127.     #srcraids = raids.read()
  128.     try:
  129.         return iB(src, "joinraid.php?raidid=", "&")
  130.     except IndexError:
  131.         msg("Couldn't retrieve raid ID")
  132.         return False
  133.  
  134. def getRaidName(src):
  135.     try:
  136.         return iB(src, "<div ONMOUSEOVER=\"statspopup(event,'<b>", "</b>')\" ONMOUSEOUT=\"kill()\">")
  137.     except IndexError:
  138.         msg("Couldn't retrieve raid name")
  139.         return False
  140.  
  141. def launchRaid(launchURL):
  142.     x = 1
  143.     while x == 1:
  144.         try:
  145.             launch = alo(launchURL).read()
  146.             if "Your raid will launch shortly" in launch:
  147.                 msg("RAID LAUNCHED!")
  148.                 global _finishTime
  149.                 _finishTime = datetime.datetime.now()
  150.                 x = 0
  151.                 return True
  152.         except IndexError:
  153.             x = 1
  154.             time.sleep(1)
  155.  
  156. def createReport(raidTime):
  157.     r = open("numero.txt", "a")
  158.     r.write("Raid launched at " + time.strftime("[%H:%M:%S]", time.localtime(time.time())) + " \nThe raid took "+str(raidTime.seconds)+" seconds.")
  159.     r.close()
  160.     return True
  161.  
  162.  
  163. loginrpg = alo("http://sigil.outwar.com/myaccount.php?rg_sess_id=" + rg_sess_id + "&serverid=1&suid="+FORMER_ID)
  164. #loginrpg = alo2("http://sigil.outwar.com/myaccount.php", "login_username=" + username + "&login_password=" + password + "&serverid=1&suid="+FORMER_ID)
  165. msg("Logged in RGA\n")
  166.  
  167.  
  168. # God name was found on the page, so form and join the raid.
  169. formRaid(FORMER_ID)
  170.  
  171. # Start to join
  172. #for i in range(len(chars)):
  173. #    join = alo2('http://sigil.outwar.com/joinraid.php?raidid=' + RAID_ID + '&suid=' + chars[i] + '&serverid=1', "join=1").read()
  174. #    msg("Joined character: " + getCharName(join))
  175.  
  176. class ThreadClass(threading.Thread):
  177.     def __init__(self, char):
  178.         self.char = char
  179.         threading.Thread.__init__(self)
  180.  
  181.     def run(self):
  182.         join = alo2('http://sigil.outwar.com/joinraid.php?raidid='+RAID_ID+'&suid='+self.char+'&serverid=1', "join=1").read()
  183.         if "error" in join:
  184.             x = 1
  185.             while x == 1:
  186.                join = alo2('http://sigil.outwar.com/joinraid.php?raidid='+RAID_ID+'&suid='+self.char+'&serverid=1', "join=1").read()
  187.                if "Please click" in join:
  188.                    x = 0
  189.  
  190.         time.sleep(0.2)
  191.         msg("Joined character: " + getCharName(join))
  192.  
  193.  
  194. for i in range(len(chars)):
  195.   t = ThreadClass(chars[i])
  196.   t.start()
  197.  
  198. # Cast SiN
  199. if CAST_SIN == True:
  200.     cast = alo2("http://sigil.outwar.com/cast_skills.php?C=5", "suid="+SIN_ID+"&castskillid=3015&cast=Cast+Skill")
  201.     msg("Casted Strength in Numbers on " + getCharName(cast))
  202.  
  203.  
  204. launchURL = 'http://sigil.outwar.com/joinraid.php?raidid=' + RAID_ID + '&suid=' + FORMER_ID + '&serverid=1&launchraid=yes&x=141&y=36'
  205. launchRaid(launchURL)
  206. tTime = _finishTime - _startTime
  207. msg("TOTAL RAID TIME: " + str(tTime.seconds) + " seconds.\n")
  208. keepChecking = 0