Skip to content

hugovk/randimgbot

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

randimgbot

Test Python: 3.7+ Code style: Black

Pick a random image and toot or tweet it.

Example

Randimgbot powers @FlagFacts@botsin.space on Mastodon and @FlagFacts on Twitter.

Set up Mastodon

Create an account at:

https://botsin.space/auth/sign_up

Follow https://gist.github.com/aparrish/661fca5ce7b4882a8c6823db12d42d26 to create a client ID, client secret, and access token, and store in YAML file. See data/randimgbot_example.yaml.

Set up Twitter

Create and authorise an app with (read and) write access at:

https://dev.twitter.com/apps/new

Store credentials in YAML file. See data/randimgbot_example.yaml.

Install dependencies

pip install -r requirements.txt

Run it

Call something like:

python randimgbot.py -y path/to/randimgbot.yaml -i path/to/dir/full/of/images/*.jpg -t "Random thing: {0} #randomthing {1}"
  • Add --mastodon to post to Mastodon.
  • Add --twitter to post to Twitter.

Where {0} will be replaced with a name taken from the filename, and {1} is a hashtag from the name. Either or both can be omitted.

Alternatively with a JSON file:

python randimgbot.py -y path/to/randimgbot.yaml -i data/randimgbot_example.json -t "Random thing: {0} #randomthing {1}"

Where the JSON file looks something like data/randimgbot_example.json:

{
  "image1.jpg": "Description 1",
  "image2.jpg": "Description 2\nLine 2"
}

By default it will only tweet randomly 1/12 times. Change this denominator with --chance.

Check full options with:

python randimgbot.py -h

About

Pick a random image and tweet it

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published