Compare commits

...

12 Commits

Author SHA1 Message Date
APEX FIGHT
18052d3d89 doc formatting 2025-04-08 20:36:27 -04:00
APEX FIGHT
999fdbe54e dependencies 2025-04-08 20:36:00 -04:00
APEX FIGHT
d3e9b24631 current interaction and scanning logic 2025-04-08 20:35:52 -04:00
APEX FIGHT
fd4e2b2905 funtion gets pixel color from raw raster 2025-04-08 20:35:26 -04:00
APEX FIGHT
049d19c1f1 taxicab style color comparison 2025-04-08 20:33:58 -04:00
APEX FIGHT
ca154a1e20 added rasterization functions 2025-04-08 20:33:41 -04:00
APEX FIGHT
845e0406ca added file configs 2025-04-08 20:32:56 -04:00
APEX FIGHT
3b10097ba8 added node-screenshots dependency 2025-04-08 20:31:01 -04:00
APEX FIGHT
d578fc660b updated readme 2025-04-08 20:30:42 -04:00
APEX FIGHT
8b6c2df82e added config file 2025-04-08 20:30:34 -04:00
APEX FIGHT
05a066849e python program that clicks anywhere 2025-04-08 20:30:02 -04:00
APEX FIGHT
079899dd46 added python stuff to gitignore 2025-04-08 20:29:48 -04:00
7 changed files with 423 additions and 3 deletions

174
.gitignore vendored
View File

@ -130,3 +130,177 @@ dist
.yarn/install-state.gz
.pnp.*
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc

View File

@ -1,3 +1,9 @@
# eatdrywallbot
A bot for eat drywall probably idk
A bot for eat drywall probably idk.
Run with `node main`.
Configure in "config.jsonc".

8
click.py Normal file
View File

@ -0,0 +1,8 @@
import sys
import pyautogui
x = sys.argv[1]
y = sys.argv[2]
pyautogui.click(x,y)

10
config.jsonc Normal file
View File

@ -0,0 +1,10 @@
{
"photoInterval": 5, //interval in seconds to snap a photo and eat drywall
"targetColor": { //target color to click on
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"tolerance": 20 //color tolerance (basic taxicab direction currently)
}

76
main.js
View File

@ -1,3 +1,79 @@
const jimp = require("jimp");
const ss = require("node-screenshots");
const proc = require("child_process");
const fs = require("fs");
let config = JSON.parse(fs.readFileSync("./config.jsonc"));
const photoInterval = config.photoInterval;
const targetColor = config.targetColor;
const tolerance = config.tolerance;
setInterval(eatDrywall, photoInterval * 1000);
async function eatDrywall() {
let monitors = ss.Monitor.all();
monitors.forEach((i) => {
var im = i;
if (im.isPrimary) {
let image = im.captureImageSync();
let img = image.toRawSync();
clickRandomPixelOfColor(im.width, im.height, img);
}
});
}
function clickRandomPixelOfColor(width, height, image) {
var hits = [];
for (let i = 0; i < width * height; i++) {
if (compareColors(targetColor, getPixel(i, image))) {
hits.push(i);
}
}
let click = Math.floor(Math.random() * hits.length); //get index of random viable pixel
let target = deRasterize(hits[click], width);//get coordinates of random pixel
console.log("Clicking: " + target);
proc.execSync("python click.py " + target.x + " " + target.y);
}
function rasterize(x, y, width) { //scale to image
return (x + y * width);
}
function deRasterize(i, width) {
return ({
y: Math.floor(i / width),
x: i % width
});
}
function compareColors(c1, c2) { //compare two rgba color structs
//general basic distance nothing too special
let sum1 = c1.r + c1.g + c1.b + c1.a;
let sum2 = c2.r + c2.g + c2.b + c2.a;
if (Math.abs(sum1 - sum2) < (tolerance * 4)) {
return true;
} else return false;
}
//gets color of a pixel at given coordinate
function getPixel(pos, img) {
//pixel origin
let o = pos * 4;
let p = {
r: img[o],
g: img[o + 1],
b: img[o + 2],
a: img[o + 3]
};
return p;
}

147
package-lock.json generated
View File

@ -9,7 +9,8 @@
"version": "1.0.0",
"license": "AGPL-3.0-or-later",
"dependencies": {
"jimp": "^1.6.0"
"jimp": "^1.6.0",
"node-screenshots": "^0.2.1"
}
},
"node_modules/@jimp/core": {
@ -648,6 +649,150 @@
"node": ">=10.0.0"
}
},
"node_modules/node-screenshots": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots/-/node-screenshots-0.2.1.tgz",
"integrity": "sha512-1UY7VY/34uE6Giq/Winl0J7022KKwWt9T9Gu5ZBCxhXkWrv9q5pTVQRgZCcUIsIHq3zu8UFu5s8rqgauK2CnLA==",
"license": "Apache-2.0",
"engines": {
"node": ">= 10"
},
"optionalDependencies": {
"node-screenshots-darwin-arm64": "0.2.1",
"node-screenshots-darwin-universal": "0.2.1",
"node-screenshots-darwin-x64": "0.2.1",
"node-screenshots-linux-x64-gnu": "0.2.1",
"node-screenshots-linux-x64-musl": "0.2.1",
"node-screenshots-win32-arm64-msvc": "0.2.1",
"node-screenshots-win32-ia32-msvc": "0.2.1",
"node-screenshots-win32-x64-msvc": "0.2.1"
}
},
"node_modules/node-screenshots-darwin-arm64": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-darwin-arm64/-/node-screenshots-darwin-arm64-0.2.1.tgz",
"integrity": "sha512-mcNcdn5zABYNVXIb1vq58mItFlpr03T8VJetD892qy+hqNAQdZd/vvplw+ZIlb4tuH7sR1gia67WRsBRO5nrQA==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/node-screenshots-darwin-universal": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-darwin-universal/-/node-screenshots-darwin-universal-0.2.1.tgz",
"integrity": "sha512-cNqBasCyMU/P87Ej3hK/vedAk86DrVkpoxd2zz5qLA3h850Ew9qb/7g0MTYsRatbZFoLhw7MgFwAZkiNh4Mr9g==",
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/node-screenshots-darwin-x64": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-darwin-x64/-/node-screenshots-darwin-x64-0.2.1.tgz",
"integrity": "sha512-8TOou5WwytgGV+IuV1vnnYaGzwfYgIw6XkOoZtt4qhSmTEW0K8EGa46Uq42/W5qQPxKt3GLqjlY3wL69eZWIyA==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/node-screenshots-linux-x64-gnu": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-linux-x64-gnu/-/node-screenshots-linux-x64-gnu-0.2.1.tgz",
"integrity": "sha512-P2h511my2JytMSAW8+uvO+lGj1BwapERWbC6i56u5WbLIy/zgT1SQwNvcZNbPE8sxb1q8pqF3MerLcftnW0f+w==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/node-screenshots-linux-x64-musl": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-linux-x64-musl/-/node-screenshots-linux-x64-musl-0.2.1.tgz",
"integrity": "sha512-+B37/VYzH86ywWyF9XkYYicyf/BTan4TADsmxPlK+a/UHHZEnp1YjEM66sBIQTIVhVhv1DC6YUv9AppBpoV9AA==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/node-screenshots-win32-arm64-msvc": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-win32-arm64-msvc/-/node-screenshots-win32-arm64-msvc-0.2.1.tgz",
"integrity": "sha512-+sj1FAF4qufcWO1KdmCOhPRMELfWu7hRv2qvr8e3jLPLM0/XGU8UTWWej9qAhf3UY83LaAsvxMhzai9JLIis1w==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/node-screenshots-win32-ia32-msvc": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-win32-ia32-msvc/-/node-screenshots-win32-ia32-msvc-0.2.1.tgz",
"integrity": "sha512-8fzmFqbotHAzwIARG9fI8eD+Vw2g98Bl7aKlhu57nCjCXNrdl4Ck+b3uvMjdQD+v7rKC/sT+NZK973y4YgRoMA==",
"cpu": [
"ia32"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/node-screenshots-win32-x64-msvc": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-screenshots-win32-x64-msvc/-/node-screenshots-win32-x64-msvc-0.2.1.tgz",
"integrity": "sha512-dfxAck3LR9eTYpc/hVtomQYxpP/80p4+vP9k1whDBCClTzRlHvgx1U9b6c5bYpe8JZFtCZsJL75S5p0kQJk7Dg==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/omggif": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/omggif/-/omggif-1.0.10.tgz",

View File

@ -13,6 +13,7 @@
"author": "StressedCatInABox & Apexfight",
"license": "AGPL-3.0-or-later",
"dependencies": {
"jimp": "^1.6.0"
"jimp": "^1.6.0",
"node-screenshots": "^0.2.1"
}
}