A bot that tweets daily updates about questions on Metaforecast, inspired by Astral Codex Ten.
See also:
- Create a new Python 3.11 virtual environment
- Activate the environment
- Install the required packages
$ pyenv local 3.11.2
$ python -m venv env
$ source env/bin/activate
(env) $ pip install -r requirements.txt
- Sign up for a developer account on Twitter using your "regular" account (e.g. fakedrwahl)
- Apply for "Elevated access" (which is required to access parts of the v2 API functionality)
- In the Developer Portal, create a new Project (e.g. "Predictable News") and corresponding App (e.g. "predictable-news-bot")
- Copy the API Key and Secret to a local .env file under
CONSUMER_KEY
andCONSUMER_SECRET
(don't commit this file to GitHub!) - Under "User authentication settings," enable OAuth 1.0a with "Read and write" permissions (Callback and Website URLs are required but not used, so just enter e.g. http://predictable.news)
- Log into Twitter under the "tweeting" account (e.g. PredictableNews)
- Activate the Python virtual environment created above
- Run auth.py script, open the authorization url, input the provided pin, and copy the resulting
ACCESS_TOKEN
andACCESS_TOKEN_SECRET
to the .env file from step 4
$ source env/bin/activate
(env) $ python auth.py
https://api.twitter.com/oauth/authorize?oauth_token=...
...
Input PIN: 1234567
Add the following to your .env file:
ACCESS_TOKEN=...
ACCESS_TOKEN_SECRET=...
Follow the Twitter authentication steps above to create a local .env file. Then the main.py script can then be run as follows:
$ source env/bin/activate
(env) $ python main.py --help
usage: main.py [-h] [-c CHANGE] [-d] [-t]
optional arguments:
-h, --help show this help message and exit
-c CHANGE, --change CHANGE
probability change threshold for tweeting (default: 0.05)
-d, --debug enable debug logging (default: False)
-t, --tweet actually send tweets (default: False)
Add the secrets from your local .env file (CONSUMER_KEY
, CONSUMER_SECRET
, ACCESS_TOKEN
, and ACCESS_TOKEN_SECRET
) to your repository on GitHub as described here.
Optionally, adjust the .github/workflows/main.yml file schedule to run at the desired time.