https://github.com/hugovk/randimgbot
Pick a random image and tweet it
https://github.com/hugovk/randimgbot
bot python twitterbot
Last synced: 6 months ago
JSON representation
Pick a random image and tweet it
- Host: GitHub
- URL: https://github.com/hugovk/randimgbot
- Owner: hugovk
- Created: 2014-10-20T19:33:59.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T19:37:31.000Z (11 months ago)
- Last Synced: 2025-03-28T17:47:54.858Z (6 months ago)
- Topics: bot, python, twitterbot
- Language: Python
- Homepage: https://twitter.com/FlagFacts
- Size: 43 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# randimgbot
[](https://github.com/hugovk/randimgbot/actions/workflows/test.yml)
[](https://www.python.org/downloads/)
[](https://github.com/psf/black)Pick a random image and toot it.
## Example
Randimgbot powers **[@FlagFacts@mas.to on Mastodon](https://mas.to/@FlagFacts)**.
## Set up Mastodon
Create an account at:
https://mas.to/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`.## Install dependencies
```bash
pip install -r requirements.txt
```## Run it
Call something like:
```bash
python randimgbot.py -y path/to/randimgbot.yaml -i path/to/dir/full/of/images/*.jpg -t "Random thing: {0} #randomthing {1}"
```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:
```bash
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:
```json
{
"image1.jpg": "Description 1",
"image2.jpg": "Description 2\nLine 2"
}
```By default it will only toot randomly 1/12 times. Change this denominator with
`--chance`.Check full options with:
```bash
python randimgbot.py -h
```