From 4f5e14e13118b8d1457fe8bd3c51677124626c8e Mon Sep 17 00:00:00 2001 From: justuser31 Date: Fri, 21 Apr 2023 20:48:27 +0300 Subject: [PATCH] Pass colored pixels --- bot.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/bot.py b/bot.py index 82b5d5b..fba437e 100644 --- a/bot.py +++ b/bot.py @@ -5,17 +5,27 @@ from tqdm import tqdm global xc, yc xc = 0 ; yc = 0 +def gcolor(x, y): + response = requests.get(f'http://pb.dmcraft.online/?get_color={x},{y}') + return response.text + def draw(cords, color = "black"): global xc, yc for i in tqdm(range(len(cords))): - payload = {'x': cords[i][1] + yc, 'y': cords[i][0] + xc, 'color': color } - - response = requests.post('http://pb.dmcraft.online', data=payload) + try: + color = cords[i][2] + except: + pass + + if str(gcolor(cords[i][1], cords[i][0])) != color: + payload = {'x': cords[i][1] + yc, 'y': cords[i][0] + xc, 'color': color } - while str(response) != "": response = requests.post('http://pb.dmcraft.online', data=payload) - print("Error, retrying...") - sleep(0.1) + + while str(response) != "": + response = requests.post('http://pb.dmcraft.online', data=payload) + print("Error, retrying...") + sleep(0.1) print("DONE!") def linex(y, x1, x2): @@ -40,10 +50,9 @@ def fill(xy1, xy2): -#xc = 500 -#yc = 500 +print(gcolor(0, 1)) +draw([[0,1, "red"]]) -draw(fill([26,0], [50, 85]),"white") ''' #Russian flag