Git Product home page Git Product logo

twitter-cloud-run's Introduction

twitter-cloud-run

A (relatively) minimal configuration app to run Twitter bots on a schedule using Google Cloud Run and Google Cloud Scheduler, making running the bot effectively free and can scale to effectively an unlimited number of bots if necessary.

There are two variants in their respective folders:

  • human_curated : Uses a centralized Cloud SQL database to load pregenerated Tweets, and records if a tweet is generated. Recommended for AI tweet generation due to unpredictibility of AI-generated tweets.
  • gpt-2: Uses an pretrained GPT-2 model, similar to the gpt2-cloud-run repo. (although the base app.py is built for gpt-2-simple, it's easy to hack it out and replace your own method of text generation for the bot.

Each folder has a Dockerfile and an app.py which runs the app in Cloud Run: you can build the container in Docker using docker build ., and upload it to Google Container Registry with these instuctions.

Usage

The app is configured using Environment Variables; this avoids hardcoding the access tokens within the container and therefore a security risk (encoding secrets in environment variables isn't the ideal solution for handling secrets in general, but it is sufficient for this app)

Additionally, you can specify a REQUEST_TOKEN as an Environment Variable, to prevent others from triggering the app accidentially (i.e. via random IP sniffing, as Cloud Run URLs are public).

See the READMEs in the folders for more pertinent information to the app.

Setting Up A Twitter Bot

To run a Twitter bot, you need the CONSUMER_KEY and CONSUMER_SECRET for an app, and the ACCESS_TOKEN and ACCESS_SECRET corresponding to the user. Per recent Twitter antibotting changes, this has been made more difficult:

  1. Create a Twitter app on your human account. You will have to go through a manual Twitter review.
  2. In the App Settings, you'll see the CONSUMER_KEY and CONSUMER_SECRET.
  3. Set up Twurl on your computer.
  4. In a Terminal, run twurl authorize --consumer-key <CONSUMER_KEY> --consumer-secret <CONSUMER_SECRET> with the info above. It will give you a URL to approve an app; go to that URL on your bot account and approve the app. It will give you a PIN to input into the terminal.
  5. Open the ~/.twurlrc file, which will have thee ACCESS_TOKEN and ACCESS_SECRET you need for that account.

Examples

Maintainer/Creator

Max Woolf (@minimaxir)

Max's open-source projects are supported by his Patreon and GitHub Sponsors. If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.

License

MIT

Disclaimer

This repo has no affiliation with Twitter Inc.

twitter-cloud-run's People

Contributors

minimaxir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.