Giter VIP home page Giter VIP logo

reddit-placebot's Introduction

Reddit Placebot

Anything that can be automated should be automated

Place has ended. It was a good run, thanks everyone that supported the project!


This is a bot I made for the Reddit /r/place event of 2017 April Fools Day. I just wanted to make a simple quick script because I expected it to last until April 2nd. It lasted a total of 72 hours.

Originally made this bot to protect our national flag on /r/argentina. But you can use it for your artwork or evil deeds, with your own account, your other 4 throwaways, or the 1000 accounts dump you found on Pastebin. The Placebot is impartial and doesn't discriminate.

The /r/place final board

Non-tech install

These are the step-by step instructions for non-tech people:

  • Go to nodejs.org and download and install the latest version
  • On this page, click the green Clone or download button and then on Download ZIP
  • Uncompress the downloaded zip file
  • Go to the uncompressed folder
  • Rename the users.example.json to users.json and open it up to put your Reddit user names and passwords in the same format the examples (and erase the examples)
  • Run one time: install.bat (Windows) or install.sh (Linux or Mac) and wait until it finishes
  • Run every time you want to use it: start.bat (Windows) or start.sh (Linux or Mac)
  • Configure stuff if you need to on config.json, or open the start scripts and add command line arguments there

Para la imagen oficial de Argentina usen start_argentina.bat o start_argentina.sh

Installation

You need to have NodeJS installed

git clone https://github.com/zequez/reddit-placebot
cd reddit-placebot
npm install

Users

Change users.example.json to users.json and add your username and password of your account and all your throwaways.

Usage

Any command line options will override the options on config.json:

  npm run start
  npm run start --remote --target <REMOTE_TARGET_URL>
  npm run start --target <LOCAL_TARGET_FILE>
  npm run start --target <LOCAL_TARGET_FILE> --startX <targetStartX> --startY <targetStartY>

Target Oficial Argentino

Este comando es nosotros boludo:

npm run start --argentinaTarget

This uses the file at: https://raw.githubusercontent.com/Zequez/placebot-argentina-target/master/official_target.png

Configuration

The Target Image File

It can be a PNG, JPG or BMP file of any size or compression.

To change the position of the board you want to paint the target in:

  • targetStartX: 0-999
  • targetStartY: 0-999

Transparent pixels are just transparent pixels in PNG, or #ff00ff (for legacy reasons) and will be ignored by the bot.

Colors

You can use any colors and will try to find the closest match. The available board colors are visible in the file /src/colors.js. But it's better if you use and eyedropper tool from a board image.

Target Location

The bot downloads the board each time it's time to draw, so it only changes the necessary pixels that don't match the target.

Remote (for multiple people)

You can configure the target to be downloaded from a remote URL:

  • useRemoteTarget: true
  • REMOTE_TARGET_URL: "http://example.com/remote_target.png"

The image will be downloaded before painting and saved to images/remote_target.

Local (just for your own bots)

images/target.png

  • useRemoteTarget: false
  • LOCAL_TARGET_FILE: __dirname + '/images/target.png'

Bundle up changes

If you want to wait until multiple users are available to paint and do the changes all at the same time, change the config:

  • bundleAccounts: <Number 1-Infinity> (default = 8)

Drawing Mode

  • drawMode: <mode> (default = 'RANDOM')
    • 'LEFTTOP': Will draw from left to right and top to bottom
    • 'RANDOM': Will draw at random points

Testing

LOL

My initial intention was to make a simple script, didn't expect it to last, so testing manually was feasible. Now I should be writing tests, because it's getting tedious, but I don't know how long will /r/place last for.

Other Projects

Thanks to trosh/rplace to figure out how to actually read the bitmap from the server. I just ported that to Node.

Thanks oliver-moran/jimp for a Node image processing library without any kind of binary dependencies.

Thanks dtao/nearest-color for the nearest color matching.

License

The Reddit Placebot is released under the MIT License.

reddit-placebot's People

Contributors

ale1 avatar martinrlilja avatar robinflikkema avatar zequez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reddit-placebot's Issues

Good job.

Thanks to your bot, many people got to keep their piece of the canvas. I just noticed your little piece:

github com-zequez-r-place

I wish you could have completed it and got the credit you deserve. Anyway, thanks again.

Login fails

Code 400 incorrect username or password but I'm sure it's correct.

Error in Raspian Jesse

When I "npm run start" on Raspbian Jesse (Debian for Raspberry Pi) I get an error. I checked how I configured it, and couldn't find an issue. It may just not work on Raspbian Jesse. Here's the command line readout:

pi@raspberrypi:~/reddit-placebot $ npm run start

> [email protected] start /home/pi/reddit-placebot
> node run.js


/home/pi/reddit-placebot/run.js:24
for (let user in users) { if (!queues[user]) scheduleUser(user) }
         ^^^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

npm ERR! [email protected] start: `node run.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is most likely a problem with the reddit-placebot package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node run.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls reddit-placebot
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.4.13+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "run" "start"
npm ERR! cwd /home/pi/reddit-placebot
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
 
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/reddit-placebot/npm-debug.log
npm ERR! not ok code 0

Getting an invalid color at 232,0

This is basically where the "transparency" portion of the image starts for me.

The image is 1000x1000, saved as a 24-bit BMP through GIMP (do not have Windows, so no paint here) and all colors are valid within the painted area. This seems to make the script only paint in 0,0. Any ideas? I had someone 're-save' my BMP and the result is still the same. Though I did notice that the color in board_differ.js is 0xff00fff, with an extra F. Is that intentional?

Not running on Debian

When I try to run the bot i get the following error:

npm ERR! [email protected] start: nodejs run.js
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is most likely a problem with the reddit-placebot package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nodejs run.js
npm ERR! You can get their info via:
npm ERR! npm owner ls reddit-placebot
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-openvz-042stab113.11-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "run" "start"
npm ERR! cwd /root/reddit-placebot-master
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/reddit-placebot-master/npm-debug.log
npm ERR! not ok code 0

r/place comeback.

Hi, do you think this still works for new upcoming r/place? If yes I still don't understand on how to put pictures.

help.

Unhandled rejection Error: Request failed with status code 403
at createError (/root/reddit-placebot/node_modules/axios/lib/core/createError.js:15:15)
at settle (/root/reddit-placebot/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/root/reddit-placebot/node_modules/axios/lib/adapters/http.js:186:11)
at IncomingMessage.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

Getting 403 for all calls to draw.json

I just created a new throwaway account but have been getting only 403 errors:

image

I also seem to get them when doing it from the browser:

image

Any clue what could be going on here?

Properly handle negative index bitmaps

Negative index bitmaps are standard across Mac OS X and it's impossible to generate positive index bitmaps as far as I can tell. These filetypes should be supported.

Display Time of action

Right now the bot logs the remaining time for the next pixel imput, but it doesn't state when it made that last check, it would be a nice addition so we can know if the bot got stuck or something.

So:
HH:MM 'username' ###s

/tmp/cookies.json doesn't exist

Looks like the refactor messed things up a bit:

> [email protected] start /home/cj/clones/reddit-placebot
> node src/run.js "src/run"

fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/home/cj/clones/reddit-placebot/src/../tmp/cookies.json'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.writeFileSync (fs.js:1333:33)
    at Object.<anonymous> (/home/cj/clones/reddit-placebot/src/cookies.js:4:30)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/cj/clones/reddit-placebot/src/authentication.js:3:17)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

Fixed with:

mkdir tmp
echo "{}" > tmp/cookies.json

Update urls please

So yesterday r/place launched again and I get 404 when running the script with two accounts. So I think they have new post links.

error about sign in

how i got error: {"reason": "INCORRECT_USERNAME_PASSWORD", "code": 400, "explanation": "incorrect username or password"}
Meanwhile, those accounts are all logged in normally. Is it because the API is too old?

Red Painting As Blue

I have color matched to get the Red from the tmp/board file and Red will continually paint as blue. My Red color code is 229 0 0 when I eye drop it (E50000) as is the same when going from the board

Invalid Colors for Red and Orange

I've triple checked the exact color values but still get an invalid color error whenever it hits red or orange. There may be other colors it has issues with but these are the two I've run into.

password characters

I was getting this error:
SyntaxError: /home/user/Software/reddit-placebot/users.json: Unexpected token in JSON at position 59

Pretty sure it's because my password included a "". The error went away after i generated a new password.

EDIT. The backslash isn't showing in my quotes here either. \

Unhandled rejection Error: Request failed with status code 503

Unhandled rejection Error: Request failed with status code 503
    at createError (C:\Users\oskar\Desktop\reddit-placebot-e8abb8aa8d82600f9fa7273c250de49028513e45\node_modules\axios\lib\core\createError.js:15:15)
    at settle (C:\Users\oskar\Desktop\reddit-placebot-e8abb8aa8d82600f9fa7273c250de49028513e45\node_modules\axios\lib\core\settle.js:18:12)
    at IncomingMessage.handleStreamEnd (C:\Users\oskar\Desktop\reddit-placebot-e8abb8aa8d82600f9fa7273c250de49028513e45\node_modules\axios\lib\adapters\http.js:186:11)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:188:7)
    at endReadableNT (_stream_readable.js:975:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

It works if I restart it, but happened twice now. Any idea why?

Change location?

I can't seem to figure out exactly how the script determines the location to build the given image. Any way to have it start at a specific set of coordinates?

Wait time is really long

Is there something I'm missing? It's waiting for 1200 seconds even though it should be 330 seconds.

SyntaxError: Unexpected identifier

Heya. I'm getting an error:

/home/wbiggs/reddit-placebot/run.js:24
for (let user in users) { if (!queues[user]) scheduleUser(user) }
         ^^^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0

Any clue what might be causing this?

More map customization?

How about an option to only change a single (or list of) colors, exclude certain ones. Would be super cool.

check for current colour

A good addition would be to check a pixel before it's written. This would allow for "monitoring" an exist area for changes by only updating pixels that don't match the target.

Coordinates

So the config doesn't say where it will place the target file relative to the coordinates. Does it place the image so that the coordinates are in the center? Or does it place the image with the coordinates in the bottom left corner for example?

[Question] Painting { x: NaN, y: NaN, color: 3, name: 'black' }

I couldn't find an easier way to contact you I suppose. So just a quick question, is this working properly then? It seems that I have the correct colors, and all my accounts are logged in, but the fact it's not finding any X or Y has me questioning it

Next account in Infinity seconds

Hi, I'm having an issue. For some reason all three of my accounts are just counting down to lower and lower negative numbers, and saying "Next account in Infinity seconds." Here's a screenshot:

screenshot_143

Any clue what's going on or how I can fix it?

error running script

Hi, i cant get the script to work, This is image of full cmd-log: https://gyazo.com/c970b054045167124473470324f471dc
And this is debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 silly lifecycle [email protected]
prestart: no script for prestart, continuing
7 info lifecycle [email protected]start: [email protected]
8 verbose lifecycle [email protected]
start: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\Henrik\Desktop\swedenplace\reddit-placebot-e8abb8aa8d82600f9fa7273c250de49028513e45\node_modules.bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\MATLAB\R2013b\bin;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Program Files (x86)\Skype\Phone;C:\Program Files\nodejs;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Users\Henrik\AppData\Local\Microsoft\WindowsApps;C:\Users\Henrik\AppData\Roaming\npm
10 verbose lifecycle [email protected]
start: CWD: C:\Users\Henrik\Desktop\swedenplace\reddit-placebot-e8abb8aa8d82600f9fa7273c250de49028513e45
11 silly lifecycle [email protected]start: Args: [ '/d /s /c', 'node src/run.js --harmony' ]
12 silly lifecycle [email protected]
start: Returned: code: 1 signal: null
13 info lifecycle [email protected]~start: Failed to exec start script
14 verbose stack Error: [email protected] start: node src/run.js --harmony
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:194:7)
14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:194:7)
14 verbose stack at maybeClose (internal/child_process.js:899:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd C:\Users\Henrik\Desktop\swedenplace\reddit-placebot-e8abb8aa8d82600f9fa7273c250de49028513e45
17 error Windows_NT 10.0.14393
18 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "start"
19 error node v7.8.0
20 error npm v4.2.0
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] start: node src/run.js --harmony
23 error Exit status 1
24 error Failed at the [email protected] start script 'node src/run.js --harmony'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the reddit-placebot package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error node src/run.js --harmony
24 error You can get information on how to open an issue for this project with:
24 error npm bugs reddit-placebot
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls reddit-placebot
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]

Bot suddenly not painting

Just an hour ago the bot was sustaining a logo of a subreddit. Now it's not noticing the changes that random people are making. I have not changed the bot any since except for addding new users.

Last commit killed the script

In the userPaint function you uncommented the three lines 88, 89, 90 (mock painting). Now the function returns before being able to send the HTTP request.

TypeError: Cannot read property 'modhash' of undefined

http://i.imgur.com/BMoYEJ9.png

I'll edit in my usernames, rename the .json, etc. as per the instructions, and I still get this after installing and running it.

I initially thought it had something to do with my modifications when trying to paint my own image, but it does the exact same thing even when I leave everything default (other than adding my usernames in users.json)

What gives?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.