Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import sys
- import time
- import random
- import requests
- from requests.adapters import HTTPAdapter
- username = sys.argv[1]
- password = sys.argv[2]
- buzzPixDict = {
- (380,321) : 13,
- (381,321) : 13,
- (404,357) : 1
- }
- def get_current_pixel(x,y):
- r = s.get("http://reddit.com/api/place/pixel.json?x={}&y={}".format(x, y), timeout=5)
- data = "";
- if r.status_code == 200:
- data = r.json()
- else:
- print("ERROR: ", r, r.text)
- old_color = data["color"] if "color" in data else -1
- return old_color
- def check_replace(x,y, new_color):
- old_color = get_current_pixel(x,y);
- if old_color == new_color:
- print("Pixel is correct, skipping")
- elif (old_color != -1):
- print("Placing color #{} at {},{}".format(new_color, x, y))
- r = s.post("https://www.reddit.com/api/place/draw.json",
- data={"x": str(x), "y": str(y), "color": str(new_color)})
- 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():
- check_replace(x, y, new_color)
- s = requests.Session()
- s.mount('https://www.reddit.com', HTTPAdapter(max_retries=5))
- s.headers["User-Agent"] = "PlacePlacer"
- 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"]
- while True:
- for k in buzzPixDict:
- print(check_replace(k[0],k[1],buzzPixDict[k]))
Add Comment
Please, Sign In to add comment