tweet-images
Send tweets with images from the command line
Installation
Install this tool using pip:
pip install tweet-images
Example
This tool is used by the @covidsewage bot on Twitter, see simonw/covidsewage-bot and Building a Covid sewage Twitter bot.
Usage
You'll need a consumer key, consumer secret, access token key and access token secret for a Twitter account that you wish to tweet from. See How to get credentials for a new Twitter bot for tips on obtaining these.
You can pass those as the --consumer-key, --consumer-secret, --access-token-key, --access-token-secret options to the command, or you can set them as environment variables like this:
export TWITTER_CONSUMER_KEY="..."
export TWITTER_CONSUMER_SECRET="..."
export TWITTER_ACCESS_TOKEN_KEY="..."
export TWITTER_ACCESS_TOKEN_SECRET=".."
You can then send a tweet like this:
tweet-images "This is my tweet"
Or attach between one and four images to that tweet by passing their file paths:
tweet-images "Three pictures attached" one.jpg two.jpg three.jpg
You can pass --alt "alt text" one or more times to attach alt text to your images:
tweet-images "Three pictures attached" one.jpg two.jpg \
--alt "Alt text for one" --alt "Alt text for two"
Using this with GitHub Actions
Here's an example fragment from a GitHub Actions workflow that uses this tool. The repository has four repository secrets configured with the necessary credentials, and a previous step has already installed the tweet-images Python package:
- name: Tweet the new image
env:
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
run: |-
tweet-images "Latest Covid sewage charts for the SF Bay Area" \
/tmp/covid.png --alt "Screenshot of the charts"
Development
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd tweet-images
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Metadata
Release files for tweet-images 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tweet-images-0.1.2.tar.gz | 7.5 kB | Without provenance | Details for tweet-images-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tweet_images-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for tweet_images-0.1.2-py3-none-any.whl |
Total release size: 15.5 kB
Release files / tweet-images-0.1.2.tar.gz
| Download URL | tweet-images-0.1.2.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c7526ee73bca2f4c13bfa17b1a2bffc9e7d562715041a1f8c07357853e4e8d5
|
|
BLAKE2b-256 checksum How to use checksums |
ff711f09cbec1011eb10c1415f99196e1860c777478605955ec01f404ad98b07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Release files / tweet_images-0.1.2-py3-none-any.whl
| Download URL | tweet_images-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2711115059014e0fdd746109546bddf1d33bfd85b057c6add6274bac2067bb8
|
|
BLAKE2b-256 checksum How to use checksums |
1dd24d992adfeda41b85c7abb6adcca776dc628f547b6b3bb76e6c1341e0bdd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Security for tweet-images 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.