diff --git a/README.md b/README.md index 578f0f7..8ec5771 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,3 @@ # DraconBot -This is a bot for the website https://pixworld.vercel.app/ -Please use it carefully since bots are only allowed in antartica. -We do not take responsibility if you get banned! - -# Instalation - -### get python -Install python in [here](https://www.python.org/downloads/). -All versions from python 3 tested and working. - -### Bot zip archive (latest version) -Download latest file [here](https://github.com/AsumaPT/draconBot/releases/). - -### Setup bot -Navigate to the directory and execute the `setup.bat`. - -# Usage - -## Command, only requires parameters: - -* `python ./draconBot.py canvas coordX coordY image strategy options` - * **canvas** [required] - Select the canvas that u want to draw. (world, art) - * **coordX** [required] - X axis where u want to begin. (Ex: -30) - * **coordY** [required] - Y axis where u want to begin. (Ex: 324) - * **image** [required] - Select the image that u want do draw. (Ex: sexo.png / needs to be in image folder) - * **strategy** [optional] - Select the order of pixel placement. (Default: random) - * *list* : (linear, random, columns, lines, diagonal, spiral, linear-random, diagonal-right, horizontal, circle and zigzag) - * **options** [optional] - Changes somethings in the bot. (reverse) - +An overlay with r/Portugal plans for r/place \ No newline at end of file diff --git a/bot/config.json b/bot/config.json deleted file mode 100644 index 68c0a2d..0000000 --- a/bot/config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "account": { - "active": false, - "username": "", - "password": "" - } -} \ No newline at end of file diff --git a/bot/draconBot.py b/bot/draconBot.py deleted file mode 100644 index 5561693..0000000 --- a/bot/draconBot.py +++ /dev/null @@ -1,44 +0,0 @@ -# Packages - -import sys -import time -import ctypes - -from src.update import checkUpdate -from src.template import startTemplate -from src.console import * - -# Variables - -version = 1.2 - -# Main - -clear() -ctypes.windll.kernel32.SetConsoleTitleW("DRACON BOT v"+str(version)) -uptodate = checkUpdate(version) -printDragon() - -if uptodate: - printUptodate(version) -else: - printAvaiable() - sys.exit() - -canvas = sys.argv[1] -x = int(sys.argv[2]) -y = int(sys.argv[3]) -template = sys.argv[4] -try: - strategy = sys.argv[5] -except: - strategy = "random" - -try: - option = sys.argv[6] -except: - option = None - -time.sleep(2) -clear() -startTemplate(canvas, x, y, template, strategy, option) diff --git a/bot/setup.py b/bot/setup.py deleted file mode 100644 index 1a07f03..0000000 --- a/bot/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -print("Checking required packages") -pkgs = ['websocket-client', 'Pillow', 'requests', 'colorama', 'pypresence', ] - -import pip - -try: - for package in pkgs: - try: - import package - except ImportError as e: - pip.main(['install', package]) - - print("OK") -except AttributeError as e: - print("It seems you pip version is over 10.0, please install the required packages manually, " - "by executing following command:\n" - "pip install websocket-client Pillow requests pyqrcode pypng six") diff --git a/bot/src/chunks.py b/bot/src/chunks.py deleted file mode 100644 index ea50adf..0000000 --- a/bot/src/chunks.py +++ /dev/null @@ -1,59 +0,0 @@ -# Libraries -from PIL import Image -from math import floor -from urllib.request import urlopen - - -# Variables -chunks_to_get = [] - - -# Get chunks -def getChunksIds(world, xi, yi, xf, yf): - - pos1 = 0 - pos2 = 0 - - world = "art" if world == "art" else "world" - - if (xf % 256 != 0 and xf != 0): - pos1 = 1 - if (yf % 256 != 0 and yf != 0): - pos2 = 1 - - firstChunkX = floor(xi / 256) - firstChunkY = floor(yi / 256) - - lastChunkX = floor(xf / 256)+pos1 - lastChunkY = floor(yf / 256)+pos2 - - chunksXtoGet = lastChunkX - firstChunkX - chunksYtoGet = lastChunkY - firstChunkY - - chunksXGot = 0 - chunksYGot = 0 - - canvas = Image.new('RGB', (256*chunksXtoGet, 256*chunksYtoGet)) - - for y in range(firstChunkY, firstChunkY+chunksYtoGet): - for x in range(firstChunkX, firstChunkX+chunksXtoGet): - chunks_to_get.append([xi+x,yi+y]) - chunk = Image.open(urlopen(f"https://api.henrixounez.com/pixworld/chunk/{world}/{x}/{y}")) - canvas.paste(chunk, (256*chunksXGot, 256*chunksYGot)) - chunksXGot = chunksXGot + 1 - chunksXGot = 0 - chunksYGot = chunksYGot + 1 - - CoordXi = abs((firstChunkX*256)-xi) - CoordYi = abs((firstChunkY*256)-yi) - - CoordXfCrop = xf-xi - CoordYfCrop = yf-yi - - template = canvas - - template = template.crop((CoordXi, CoordYi, CoordXi+CoordXfCrop, CoordYi+CoordYfCrop)) - template.convert('RGBA') - - return template - diff --git a/bot/src/compare.py b/bot/src/compare.py deleted file mode 100644 index c49876f..0000000 --- a/bot/src/compare.py +++ /dev/null @@ -1,27 +0,0 @@ -from PIL import Image -def compare(template, canvas, xi, yi): - - img = template.convert('RGBA') - canvas = canvas.convert('RGBA') - - width = template.width - height = template.height - - transparent = 0 - erros = 0 - - pixels = [] - - for y in range(height): - for x in range(width): - ri, gi, bi, ai = img.getpixel((x,y)) - rc, gb, bc, ac = canvas.getpixel((x,y)) - if ai == 0: - transparent+=1 - continue - if ri == rc and gi == gb and bi == bc: - continue - pixels.append([x+xi,y+yi,(ri,gi,bi)]) - erros+=1 - - return pixels, erros, (canvas.width * canvas.height) - transparent \ No newline at end of file diff --git a/bot/src/console.py b/bot/src/console.py deleted file mode 100644 index 519a697..0000000 --- a/bot/src/console.py +++ /dev/null @@ -1,78 +0,0 @@ -from colorama import Fore, Style, init -import os -from datetime import datetime - -init() - -dragon_ascii = """$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -$$$$$$$$$$$$$$$$Y/'$$$$P'a$$$$$$$$$$$$$$$$ -$$$$$$$$$",` /,/,mT$$$$ d$$$$$$$$$$$$$$$$$ -$$$$$l',` , '/d$$$$P^$a `^a`W$$$$$$$$$$$$$ -$$l', ` , |d$$$P^$' _ _ ==~a$$$$$$$$$ -$l.` . \\'i$^4' _eP$$$$$$$$$$$$$$$$$ -l ' . / , $$$$' `$~$$$$$$$$$$$ ___ ___ _ ___ ___ _ _ _____ __ -; ' , l /^' .,$oa$$$$$$$$$$$$ | \\| _ \\ /_\\ / __/ _ \\| \\| | | _ \\ \\ / / -b ' , . (_ ,1$$$$$$'$$$$$$$$$$$ | |) | / / _ \\ (_| (_) | .` |_| _/\\ V / -$ , , .; _$$$$$$$P $a$$$$$$$$$$ |___/|_|_\\/_/ \\_\\___\\___/|_|\\_(_)_| |_| -$, ,` .$Ly lM"^ , ,$$$$$$$'$$$$ -$$, ,` d$Liy /' edb $$$$$$$'$$$$$ -$$$$,,'. $$$Li ( d$$$$$$$$$$'$$$$$$ -$$$$$$,' v$$$Li4. ` `Q$$$$$$$P',$$$$$$$ -$$$$$$$$,$$$$$$$L44., . . ,,;d$$$$$$$$ -$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -""" - -clear = lambda: os.system('cls') -printDragon = lambda: print(f'{Fore.RED}{dragon_ascii}{Style.RESET_ALL}') -printAvaiable = lambda: print(f'{Fore.RED}[DRACON] Update avaiable!{Style.RESET_ALL}') - -def printUptodate(version): - print(f'{Fore.RED}[DRACON] Version: {version}{Style.RESET_ALL}') - print(f'{Fore.RED}[DRACON] Author: Asuma{Style.RESET_ALL}') - -def printPixel(x, y, color): - h = datetime.now() - horas = f'{h.strftime("%H")}:{h.strftime("%M")}:{h.strftime("%S")}' - print(f'{Fore.GREEN}[{horas}]: Pixel placed at {x}, {y}, color: {color}.{Style.RESET_ALL}') - -def printRefuse(x, y, color): - h = datetime.now() - horas = f'{h.strftime("%H")}:{h.strftime("%M")}:{h.strftime("%S")}' - print(f'{Fore.RED}[{horas}]: Pixel failed placing at {x}, {y}, color: {color}.{Style.RESET_ALL}') - -def printCaptcha(): - h = datetime.now() - horas = f'{h.strftime("%H")}:{h.strftime("%M")}:{h.strftime("%S")}' - print(f'{Fore.YELLOW}[{horas}]: Captcha, please solve it and then press enter.{Style.RESET_ALL}') - - - -def printFinished(template, pixeisc): - h = datetime.now() - horas = f'{h.strftime("%H")}:{h.strftime("%M")}:{h.strftime("%S")}' - print(f'{Fore.BLUE}[{horas}]: Template finished! Dracon placed in total ({pixeisc} pixels.) ') - -def printAssist(x, y, color): - h = datetime.now() - horas = f'{h.strftime("%H")}:{h.strftime("%M")}:{h.strftime("%S")}' - print(f'{Fore.LIGHTGREEN_EX}[{horas}]: Assist pixel placed at {x}, {y}, color: {color}.{Style.RESET_ALL}') - -def printAttack(x,y,color): - h = datetime.now() - horas = f'{h.strftime("%H")}:{h.strftime("%M")}:{h.strftime("%S")}' - print(f'{Fore.LIGHTRED_EX}[{horas}]: Attack pixel placed at {x}, {y}, color: {color}.{Style.RESET_ALL}') - -def printGetChunks(): - print(f'{Fore.LIGHTCYAN_EX}[DRACON] Downloading chunks.{Style.RESET_ALL}') - -def printCompare(): - print(f'{Fore.LIGHTCYAN_EX}[DRACON] Comparing template.{Style.RESET_ALL}') - -def printConnection(): - print(f'{Fore.LIGHTCYAN_EX}[DRACON] Connecting to the websocket.{Style.RESET_ALL}') - -def printCalculating(): - print(f'{Fore.LIGHTCYAN_EX}[DRACON] Calculating order of pixels.{Style.RESET_ALL}') - - diff --git a/bot/src/pixworld.py b/bot/src/pixworld.py deleted file mode 100644 index 691148f..0000000 --- a/bot/src/pixworld.py +++ /dev/null @@ -1,59 +0,0 @@ -import requests, re, websocket, time, json -from datetime import datetime, timezone -import ctypes - -from src.console import printPixel, printRefuse, printCaptcha - -captcha = 0 -def generateHash(): - URL = 'https://pixworld.vercel.app/ptbr' - r = requests.get(URL, headers={ - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0' - }) - - hash = re.findall(r'"wsHash":"(.+?)"', r.text)[0] - - return hash - -def connect(hash, token=None): - ws = websocket.WebSocket() - ws.connect(f'wss://api.henrixounez.com/pixworld/pix/connect?hash={hash}', header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0'},origin='https://pixworld.vercel.app') - - if token != None: - time.sleep(2) - ws.send('{"type":"loginUser","data":"%s"}' % (token)) - - return ws - - -def getAccount(username, password): - token = json.loads(requests.post('https://api.henrixounez.com/pixworld/user/login', json = {'username': f'{username}', 'password': f'{password}'}).content)['token'] - return token - -def placePixel(ws, world, x, y, color): - - ws.send('{"type":"placePixel","data":{"x":%s,"y":%s,"color":"%s","canvas":"%s"}}' % (x,y,color,world)) - global captcha - while True: - data = json.loads(ws.recv()) - if data["type"] == 'confirmPixel': - printPixel(x, y, color) - cd = int(str(data['data']['cd'])[:-3]) - - utc = datetime.now(timezone.utc) - utc = utc.timestamp() - - now = int(utc) - cooldown = cd - now - return cooldown - break - elif data['type'] == "refusePixel": - printRefuse(x, y, color) - break - elif data['type'] == "captchaNeeded": - printCaptcha() - ctypes.windll.kernel32.SetConsoleTitleW("DRACON BOT | CAPTCHA") - return "captcha" - break - - diff --git a/bot/src/strategy.py b/bot/src/strategy.py deleted file mode 100644 index bbd08a7..0000000 --- a/bot/src/strategy.py +++ /dev/null @@ -1,172 +0,0 @@ -import random -import math - -def randomizar(ps): - pixelStack = random.sample(ps, len(ps)) - return pixelStack - -def columns(ps): - pixelStack = [] - for i in ps: - if i[0] % 2 == 0: - pixelStack.append(i) - for i in ps: - pixelStack.append(i) - - return pixelStack - -def lines(ps): - pixelStack = [] - for i in ps: - if i[1] % 2 == 0: - pixelStack.append(i) - for i in ps: - pixelStack.append(i) - - return pixelStack - -def checkers(ps): - pixelStack = [] - vez = 0 - for i in ps: - if vez == 0: - pixelStack.append(i) - vez = 1 - else: - vez = 0 - - for i in ps: - pixelStack.append(i) - - return pixelStack - -def diagonal(ps): - pixelStack = [] - numbers = [] - for i in ps: - x = i[0] - y = i[1] - numbers.append(x+y) - - while len(ps) > 0: - index = numbers.index(min(numbers)) - pixelStack.append(ps[index]) - numbers.pop(index) - ps.pop(index) - - return pixelStack - - -def rightdiagonal(ps): - pixelStack = [] - numbers = [] - for i in ps: - x = i[0] - y = i[1] - numbers.append(x-y) - - while len(ps) > 0: - index = numbers.index(max(numbers)) - pixelStack.append(ps[index]) - numbers.pop(index) - ps.pop(index) - - return pixelStack - -def horizontal(ps): - pixelStack = sorted(ps, key=lambda x: x[0]) - return pixelStack - -def spiral(ps, x, y, width, height): - pixelStack = [] - - def spiral(N, M): - x,y = 0,0 - dx, dy = 0, -1 - out = [] - for _ in range(N*M): - if abs(x) == abs(y) and [dx,dy] != [1,0] or x>0 and y == 1-x: - dx, dy = -dy, dx # corner, change direction - if abs(x)>N/2 or abs(y)>M/2: # non-square - dx, dy = -dy, dx # change direction - x, y = -y+dx, x+dy # jump - out.append([x, y]) - x, y = x+dx, y+dy - return out - - start_x = math.trunc((width-1)/2) - start_y = math.trunc((height-1)/2) - for a,b in spiral(width, height): - sx = x+(start_x+a) - sy = y+(start_y+b) - for i in ps: - if i[0] == sx and i[1] == sy: - pixelStack.append(i) - return pixelStack - -def randomlinear(ps): - pixelStack = [] - line_random = [] - line = ps[0][1] - for i in ps: - line_atual = i[1] - if line == line_atual: - line_random.append(i) - else: - random.shuffle(line_random) - pixelStack.extend(line_random) - line = i[1] - line_random = [] - line_random.append(i) - return pixelStack - -def circle(ps, x, y, width, height): - pixelStack = [] - distances = [] - start_x = x+(math.trunc((width-1)/2)) - start_y = y+(math.trunc((height-1)/2)) - for i in ps: - if i[0] == start_x and i[1] == start_y: - pixelStack.append(i) - distances.append(0) - else: - dist = math.sqrt((i[0] - start_x)**2 + (i[1] - start_y)**2) - distances.append(dist) - - while len(ps) > 0: - index = distances.index(min(distances)) - pixelStack.append(ps[index]) - distances.pop(index) - ps.pop(index) - - return pixelStack - -def alternativelinear(ps): - pixelStack = [] - line_random = [] - line = ps[0][1] - for i in ps: - line_atual = i[1] - if line == line_atual: - line_random.append(i) - else: - line_random = line_random if line % 2 == 0 else line_random[::-1] - pixelStack.extend(line_random) - line = i[1] - line_random = [] - line_random.append(i) - return pixelStack - - - - - - - - - - - - - - diff --git a/bot/src/template.py b/bot/src/template.py deleted file mode 100644 index 701472c..0000000 --- a/bot/src/template.py +++ /dev/null @@ -1,143 +0,0 @@ -import os, time -from PIL import Image -import json -import ctypes -from pypresence import Presence -import time -import threading - -from src.chunks import getChunksIds -from src.compare import compare -from src.pixworld import * -from src.strategy import * -from src.console import printFinished, printGetChunks, printCompare, printConnection, printCalculating - - -def hex(r, g, b): - return '#{:02x}{:02x}{:02x}'.format(r, g, b).upper() - -def hex_to_rgb(value): - value = value.lstrip('#') - lv = len(value) - return tuple(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3)) - -""" -def pixelUpdate(ws, xi, yi, xf, yf): - global pixelStack - print("b") - while True: - data = json.loads(ws.recv()) - if data["type"] == "placePixel": - x = data["data"]["x"] - y = data["data"]["y"] - color = hex_to_rgb(data["data"]["color"]) - pixel = [x,y,color] - if pixel not in pixelPlaced: - if pixel in pixelStack: - pixelStack.pop(pixelStack.index(pixel)) - printAssist(x, y, color) - else: - if x >= xi and y >= yi and x <= xf and y <= yf: - pixelStack.append(pixel) - printAttack(x, y, color)""" - -def richPresence(): - rpc = Presence("876161456717041694") - rpc.connect() - return rpc - -totais = 0 -erros = 0 -count = 0 - -def loopPrecense(rpc, templat, start): - while True: - updateRich(rpc,templat,start) - time.sleep(5) - -def updateRich(rpc, templat, strat): - - rpc.update(large_image="logo", large_text=f"{strat}", details=f"Template: {templat}", state=f"Pixels: ({(totais-erros)+count}/{totais})") - - -def startTemplate(world, x, y, templat, strat, option=None): - global totais, erros, count - path = os.getcwd() - template = Image.open(os.path.dirname(path)+'\\bot\\images\\'+templat) - printGetChunks() - canvas = getChunksIds(world, x, y, x+template.width, y+template.height) - printCompare() - pixelStack, erros, totais = compare(template, canvas, x, y) - - hashG = generateHash() - - f = open(os.path.dirname(path)+'\\bot\\config.json') - data = json.load(f) - account = data["account"]["active"] - - printConnection() - if account: - username = data["account"]["username"] - password = data["account"]["password"] - - token = getAccount(username, password) - ws = connect(hashG, token) - else: - ws = connect(hashG) - - printCalculating() - if strat == "random": - pixelStack = randomizar(pixelStack) - elif strat == "linear": - pass - elif strat == "columns": - pixelStack = columns(pixelStack) - elif strat == "checkers": - pixelStack = checkers(pixelStack) - elif strat == "lines": - pixelStack = lines(pixelStack) - elif strat == "diagonal": - pixelStack = diagonal(pixelStack) - elif strat == "spiral": - pixelStack = spiral(pixelStack, x, y, template.width, template.height) - elif strat == "linear-random": - pixelStack = randomlinear(pixelStack) - elif strat == "diagonal-right": - pixelStack = rightdiagonal(pixelStack) - elif strat == "horizontal": - pixelStack = horizontal(pixelStack) - elif strat == "circle": - pixelStack = circle(pixelStack, x, y, template.width, template.height) - elif strat == "zigzag": - pixelStack = alternativelinear(pixelStack) - - count = 0 - - if option == "reverse" or option == "reversed" or option == "inverted" or option == "invert": - pixelStack = pixelStack[::-1] - try: - rpc = richPresence() - threading.Thread(target=loopPrecense, args=(rpc, templat, strat)).start() - except: - pass - while(len(pixelStack) > 0): - i = pixelStack[0] - x = i[0] - y = i[1] - hexcolor = hex(i[2][0],i[2][1],i[2][2]) - response = placePixel(ws, world, x, y, hexcolor) - time.sleep(0.2) - if type(response) == int: - pixelStack.pop(0) - count+=1 - ctypes.windll.kernel32.SetConsoleTitleW(f"DRACON BOT | {templat} ({(totais-erros)+count}/{totais}) | {round((100*((totais-erros)+count))/totais, 2)}%") - if response >= 50: - time.sleep(4) - elif response == "captcha": - input() - - printFinished(templat, count) - - - - diff --git a/bot/src/update.py b/bot/src/update.py deleted file mode 100644 index 3a5f323..0000000 --- a/bot/src/update.py +++ /dev/null @@ -1,10 +0,0 @@ -# Check if the bot is up to date -import requests - -def checkUpdate(version): - url = requests.get(url="https://raw.githubusercontent.com/AsumaPT/draconBot/main/info.json") - data = url.json() - - uptodate = True if data["version"] == version else False - return uptodate - diff --git a/canvas.png b/canvas.png new file mode 100644 index 0000000..6594dc2 Binary files /dev/null and b/canvas.png differ diff --git a/canvas_pt(3).png b/canvas_pt(3).png deleted file mode 100644 index 24ae216..0000000 Binary files a/canvas_pt(3).png and /dev/null differ diff --git a/canvas_pt.png b/canvas_pt.png deleted file mode 100644 index 3cc4466..0000000 Binary files a/canvas_pt.png and /dev/null differ diff --git a/userscript.user.js b/userscript.user.js index eb958c8..b6eb3d8 100644 --- a/userscript.user.js +++ b/userscript.user.js @@ -1,9 +1,9 @@ // ==UserScript== // @name Portugal Overlay // @namespace http://tampermonkey.net/ -// @version 0.2 +// @version 0.4 // @description Orgulho tuga! -// @author Some anon +// @author r/Portugal // @match https://hot-potato.reddit.com/embed* // @icon https://i.pinimg.com/originals/bb/28/f0/bb28f08db88265208c7329474998d8a5.png // @grant none @@ -12,9 +12,12 @@ if (window.top !== window.self) { window.addEventListener('load', () => { document.getElementsByTagName("mona-lisa-embed")[0].shadowRoot.children[0].getElementsByTagName("mona-lisa-canvas")[0].shadowRoot.children[0].appendChild( (function () { + if (!Date.now) { + Date.now = function() { return new Date().getTime(); } + } const i = document.createElement("img"); - i.src = "https://raw.githubusercontent.com/AsumaPT/draconBot/main/canvas_pt.png"; - i.style = "position: absolute;left: 0;top: 0px;image-rendering: pixelated;width: 2000px;height: 1000px"; + i.src = "https://raw.githubusercontent.com/devpt-org/draconBot/main/canvas_pt.png"; + i.style = "position: absolute;left: 0;top: 0px;image-rendering: pixelated;width: 2000px;height: 2000px"; i.id = "mcss-overlay" i.setAttribute("vis",1) console.log(i);