Skip to content

A bot for Twitter that will post a random image from a local folder

License

Notifications You must be signed in to change notification settings

logans-stuff/twitter-image-bot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twitter-image-bot

A bot for Twitter that will post a random image from a local folder

How to Setup

  1. Install Node.Js
  2. cd to the extracted twitter-image-bot folder you downloaded
  3. Install node with npm install
  4. Edit config.js and add your Twitter developer credentials which you can get here
  5. In server.js edit var post_delay = to how many ms you want between posts.
  6. Start by running node server.js or you can make it into a docker container
  • If you wish to caption the images with text, you can edit metadata.json

How it works

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.

Using docker

  1. Install Docker
  2. Build your docker image sudo docker build -t reponame/twitter-image-bot . --no-cache
  3. 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 -v flags

Hopes for the future

Video files will crash the bot currently. I hope I can use the bot to post video files in the future.

About

A bot for Twitter that will post a random image from a local folder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%