A bot for Twitter that will post a random image from a local folder
- Install Node.Js
cdto the extracted twitter-image-bot folder you downloaded- Install node with
npm install - Edit
config.jsand add your Twitter developer credentials which you can get here - In
server.jseditvar post_delay =to how many ms you want between posts. - Start by running
node server.jsor you can make it into a docker container
- If you wish to caption the images with text, you can edit
metadata.json
After the post delay, the bot will look at images1 pick a random image and post it to Twitter.
After posting the image, it will move that image into images2 so that it will not be picked again.
After images1 folder is exausted a .bookmark file will be created in images2
The bot will look at images2 to pick a random image to post to Twitter as long as the .bookmark file exists.
After posting an image from images2 it will move the image to images1 so it is not picked again.
Once images2 is exausted of images, the .bookmark file will be deleted, thus the bot will look to images1 again for images to post to Twitter.
- Install Docker
- Build your docker image
sudo docker build -t reponame/twitter-image-bot . --no-cache - Deploy your new container
sudo docker run -d \
--name=twitter-image-bot \
-v /opt/twitter-image-bot/images1:/images1 \
-v /opt/twitter-image-bot/images2:/images2 \
--restart unless-stopped \
reponame/twitter-image-bot:latest- If you dont want your images to be mounted to the host remove the
-vflags
Video files will crash the bot currently. I hope I can use the bot to post video files in the future.