Skip to content
main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

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

Tools for Thought (TfT) Twitter Bot

GitHub License Black Twitter Follow GitHub Sponsors

Supports Roam and Obsidian!

Setting up

Twitter Credentials

Apply for a twitter developer account which will let you the credentials you need to create a bot. Should get automatically approved since you are an individual developer. Once approved, getting credentials should be intuitive.

Obsidian Credentials

  • You will need to sync your obsidian vault to Google Drive
    • Copy the id of your vault folder and store that somewhere, you will fill that in for NOTES_FOLDER_ID when setting up the server.
  • Obtain the credentials JSON file by following the following instructions
  • Then you will need to manually run the generate_initial_token function
  • Run:
./generate_token.py
  • Copy the contents of the file and set it to GDRIVE_TOKEN in .env (this is also used when deploying the server)

Roam credentials

If you signed up using Google OAuth, make sure to reset your password so that you can set a manual password.

Deploying

Heroku

Simply click the button and fill in the credentials you got from the previous step. You should immediately see a sample tweet show up on your timeline.

Deploy

Locally / Custom Server

Developed on Python 3.8+

Install geckodriver (required for selenium)

Then run the following commands

$ python -m venv tft_bot
$ ./tft_bot/bin/activate
(tft_bot) $ pip install -r requirements.txt
(tft_bot) $ pip install -e .
(tft_bot) $ cp .env.sample .env  # now update these values manually

You should just be able to run the cron script in a background process.

(tft_bot) $ nohup ./cron.py &

Running Tests

Running the simple tests.

(tft_bot) $ pip install -r requirements-dev.txt
(tft_bot) $ pytest

Running the integration tests. WARNING: these actually tweet out using the provided credentials and require configuring your local environment according to the instructions above.

(tft_bot) $ INTEGRATION=1 pytest -s -k integration

Roadmap

The future roadmap for different features.

  • Draft README on setting up bot for other people

    • Acquiring Twitter API credentials
    • Deploying bot to Heroku
  • Roam

    • Pull blocks from roam database using a single backlink/tag
    • Switch from roam-api to self-contained dependency
  • Obsidian

    • Add Obsidian support and optional env var switch
  • Bot

    • Split long tweets into threads (max size = 9)
    • For some reason Heroku does not seem to like "cron" mode of APScheduler only interval seems to work.
    • Refactor the bot into python package
    • Migrate to Heroku Scheduler to use one-off runners instead of continuously running dyno. There are only 550 dyno hours for the free tier in a month which is ~22 days.
  • Advertise the project

    • Slack
    • Reddit
    • Twitter

About

A twitter bot for roam and obsidian

Topics

Resources

License

Stars

Watchers

Forks