a twitter bot that monitors specific twitter account(s) and tweets screenshots of any messages which they subsequently delete
- this is technically breaking the twitter API tos, so be warned your account or API key may get suspended.
- for the v1.1 standard REST API, tweets over 140 characters don't include the
extended_tweet
object, which means backfilled tweets over 140 characters won't be rendered properly. this isn't an issue currently for the v1.1 streaming API. - "extended tweets" are available on the v1.1 premium and v2 APIs but i haven't had the time to apply for a v2 API key, especially considering the above.
- wkhtmltopdf - in most cases it's best to just download it from here then install it rather than directly through your package manager.
- Python 3 (>= 3.7) and
pip
virtualenv
- clone
virtualenv venv
. venv/bin/activate
pip3 install -r requirements.txt
all of these below guides assume you are in an activated virtualenv.
- create a new Twitter API application, if you haven't done so already, and have the consumer key and secret ready.
- run
python add_account.py
- this creates adata
directory relative to where you extracted everything, and adds yourconfig.json
file. if you would like to use a different directory, pass the--init-dir <dir>
option on this and subsequent commands. - open
data/config.json
in a text editor and set your consumer keys under theconsumer
object.
- run
python add_account.py
- this will generate an authorization URL you can go to in your browser. - once you have authorized the application, enter the PIN code Twitter gives you into the prompt.
- run
python add_watcher.py <watcher name> [account names...]
, where watcher name is the name of the watcher you want to add, followed by the accounts you want to watch. - if the watcher does not exist, you will be prompted to select an account to watch/post from.
- By default, the watcher and poster account IDs are the same. You can specify
separate accounts for watchers and posters by specifying a value for
poster_account_id
in the watcher object. - You can also specify a tz name
as
poster_timezone
to offset the timestamps displayed on the tweet renderings.
If you are running it on Linux the rendered output will probably use Bitstream Vera or whatever wkhtmltoimage uses as its default sans serif font. Since you probably won't want this, you can configure a custom font to use.
- Download https://about.twitter.com/content/dam/about-twitter/en/brand-toolkit/downloads/twitter-tweet-template-helvetica-01272021.zip and copy everything from the
Fonts
directory toassets/fonts
- In
config.json
, setcustom_font
tohelvetica
.
- You can download them here as WOFFs:
- Convert them to TTF (thanks wkhtmltoimage!), then copy them to the
assets/fonts
directory. - In
config.json
, setcustom_font
tochirp
.