Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request, json, requests, time
- from discord_hooks import Webhook
- import math
- def killcheck():
- ship_ids = [3756, 11567, 3764, 671, 23773, 42126, 42241, 45649, 23919, 23917, 23913, 22852, 3514, 42125, 33675,
- 33395, 45531, 32790, 42245, 33673, 35779, 35781, 3518, 32209, 2836, 11942, 11940, 11011, 45530, 33397,
- 42246, 44996, 11936, 11938, 13202, 26840, 26842, 32788, 32207, 3516, 2834]
- # pass true or false to the fuction so it can be used to start the region check
- if killdata.get("package").get("killmail").get("attackers")[i].get("ship_type_id") in ship_ids:
- print("True")
- return True
- else:
- print("False")
- return False
- ESI_URL = "https://esi.tech.ccp.is/latest"
- def regioncheck(system_id):
- home_regions = [10000005, 10000006, 10000007, 10000008, 10000009, 10000011, 10000018, 10000021, 10000027, 10000028]
- def getconstellationid(system_id):
- systems_url = '{}/universe/systems/{}/'.format(ESI_URL, system_id)
- with urllib.request.urlopen(systems_url) as url:
- solar_info = json.loads(url.read().decode())
- constellation_id = solar_info["constellation_id"]
- return constellation_id
- pass
- def getregionid(constellation_id):
- constellation_url = '{}/universe/constellations/{}/'.format(ESI_URL, constellation_id)
- with urllib.request.urlopen(constellation_url) as url:
- constellation_info = json.loads(url.read().decode())
- region_id = constellation_info["region_id"]
- return region_id
- pass
- # runs the subfuctions to get the region id, then we check it against our home regions array and either end the fuction or push it to discord
- constellation_id = getconstellationid(system_id)
- region_id = getregionid(constellation_id)
- if region_id in home_regions:
- systems_url = '{}/universe/systems/{}/'.format(ESI_URL, target_sys_id)
- target_url = urllib.request.urlopen(systems_url)
- target_solar_info = json.loads(target_url.read().decode())
- xtar = target_solar_info["position"]["x"]
- ytar = target_solar_info["position"]["y"]
- ztar = target_solar_info["position"]["z"]
- distancem = math.sqrt(((xhome - xtar) ** 2) + ((yhome - ytar) ** 2) + ((zhome - ztar) ** 2)) #lightyear
- distancely = distancem / 9460730472580.04 / 1000 #lightyear
- discordpush(distancely)
- return True
- else:
- print("not in home_regions")
- pass
- def discordpush(distancely):
- url = 'https://discordapp.com/api/webhooks/449616342056828939/Yhv9q-59eHiWN8rCs8WnV9EkD61nS6dUVEIzDVZcz0-subj6plZ_I0nRHkdeJDci1vLo'
- msg = Webhook(url,
- msg="HVT spotted, checkout this killmail! https://zkillboard.com/kill/{}/ \U0001f62e".format(killid))
- msg1 = Webhook(url,
- msg="HVT is {0:.1f} lightyears away".format(
- distancely, killid))
- msg.post()
- msg1.post()
- pass
- # forever loops the program
- while True:
- ESI_URL = "https://esi.tech.ccp.is/latest"
- # Home ESI
- home_sys_id = 30000794 # currently a24l-v
- home_systems_url = '{}/universe/systems/{}/'.format(ESI_URL, home_sys_id)
- home_url = urllib.request.urlopen(home_systems_url)
- solar_info = json.loads(home_url.read().decode())
- xhome = solar_info["position"]['x']
- yhome = solar_info["position"]['y']
- zhome = solar_info["position"]['z']
- try:
- with urllib.request.urlopen("https://redisq.zkillboard.com/listen.php?queueID=AtrolNalelmir&ttw=1") as url:
- killdata = json.loads(url.read().decode())
- attacklen = len(killdata["package"]["killmail"]["attackers"])
- killid = killdata["package"]["killID"]
- system_id = killdata["package"]["killmail"]["solar_system_id"]
- target_sys_id = system_id #for lightyear calc ezmode
- # starts the killcheck and loops for each attacker
- i = 0
- while i < attacklen:
- # assigns boolean value to target based on killcheck function, so we know if we should check region ids or not
- target = killcheck()
- print(target)
- if target == True:
- print("checking Region IDs")
- #regioncheck(system_id)
- if regioncheck(system_id) == True:
- break
- print(i)
- i = i + 1
- # #RedisQ gives out a null package if no killmail has come in for 10 seconds
- except TypeError:
- print(killdata, "sleeping for 1 seconds")
- time.sleep(0.001)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement