Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # VOID CONSUMER
- # Consumes pixels for the glorious void
- import sys
- import time
- import requests
- import numpy
- from requests.adapters import HTTPAdapter
- #Arguments
- username = sys.argv[1]
- password = sys.argv[2]
- #Consts
- originX = 0
- originY = 0
- width = 230
- height = 40
- black = 3
- purple = 15
- flagMatrix = numpy.zeros((240, 40))
- flagMatrix.fill(purple)
- print("\n\nConsume For The Void.\n\n")
- s = requests.Session()
- s.mount('https://www.reddit.com', HTTPAdapter(max_retries=5))
- s.headers["User-Agent"] = "Consume For The Void"
- r = s.post("https://www.reddit.com/api/login/{}".format(username),
- data={"user": username, "passwd": password, "api_type": "json"})
- s.headers['x-modhash'] = r.json()["json"]["data"]["modhash"]
- def place_pixel(ax, ay, new_color):
- while True:
- r = s.get("http://reddit.com/api/place/pixel.json?x={}&y={}".format(ax, ay), timeout=5)
- if r.status_code == 200:
- data = r.json()
- break
- else:
- print("ERROR: ", r, r.text)
- time.sleep(5)
- old_color = data["color"] if "color" in data else 0
- if old_color == black:
- print("Placing color #{} at {},{}".format(new_color, ax, ay))
- r = s.post("https://www.reddit.com/api/place/draw.json",
- data={"x": str(ax), "y": str(ay), "color": str(int(new_color))})
- print(r.json())
- secs = float(r.json()["wait_seconds"])
- if "error" not in r.json():
- print("Placed color - waiting {} seconds".format(secs))
- else:
- print("Cooldown already active - waiting {} seconds".format(int(secs)))
- time.sleep(secs + 2)
- if "error" in r.json():
- place_pixel(ax, ay, new_color)
- else:
- print("{},{} OK {}".format(ax, ay, new_color))
- while True:
- for x in range(originX, originX + width):
- for y in range(originY, originY + height):
- pixel = flagMatrix[x - originX, y - originY]
- place_pixel(x, y, pixel)
Add Comment
Please, Sign In to add comment