Guest User

Void Consumer

a guest
Apr 2nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. # VOID CONSUMER
  2. # Consumes pixels for the glorious void
  3.  
  4. import sys
  5. import time
  6. import requests
  7. import numpy
  8. from requests.adapters import HTTPAdapter
  9.  
  10. #Arguments
  11. username = sys.argv[1]
  12. password = sys.argv[2]
  13.  
  14. #Consts
  15. originX = 0
  16. originY = 0
  17. width = 230
  18. height = 40
  19. black = 3
  20. purple = 15
  21.  
  22. flagMatrix = numpy.zeros((240, 40))
  23. flagMatrix.fill(purple)
  24. print("\n\nConsume For The Void.\n\n")
  25. s = requests.Session()
  26. s.mount('https://www.reddit.com', HTTPAdapter(max_retries=5))
  27. s.headers["User-Agent"] = "Consume For The Void"
  28. r = s.post("https://www.reddit.com/api/login/{}".format(username),
  29. data={"user": username, "passwd": password, "api_type": "json"})
  30. s.headers['x-modhash'] = r.json()["json"]["data"]["modhash"]
  31.  
  32. def place_pixel(ax, ay, new_color):
  33. while True:
  34. r = s.get("http://reddit.com/api/place/pixel.json?x={}&y={}".format(ax, ay), timeout=5)
  35. if r.status_code == 200:
  36. data = r.json()
  37. break
  38. else:
  39. print("ERROR: ", r, r.text)
  40. time.sleep(5)
  41.  
  42. old_color = data["color"] if "color" in data else 0
  43. if old_color == black:
  44. print("Placing color #{} at {},{}".format(new_color, ax, ay))
  45. r = s.post("https://www.reddit.com/api/place/draw.json",
  46. data={"x": str(ax), "y": str(ay), "color": str(int(new_color))})
  47.  
  48. print(r.json())
  49. secs = float(r.json()["wait_seconds"])
  50. if "error" not in r.json():
  51. print("Placed color - waiting {} seconds".format(secs))
  52. else:
  53. print("Cooldown already active - waiting {} seconds".format(int(secs)))
  54. time.sleep(secs + 2)
  55.  
  56. if "error" in r.json():
  57. place_pixel(ax, ay, new_color)
  58. else:
  59. print("{},{} OK {}".format(ax, ay, new_color))
  60.  
  61. while True:
  62. for x in range(originX, originX + width):
  63. for y in range(originY, originY + height):
  64. pixel = flagMatrix[x - originX, y - originY]
  65. place_pixel(x, y, pixel)
Add Comment
Please, Sign In to add comment