Giter Site home page Giter Site logo

syncom / twitbot-iwpt Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 1.0 1.23 MB

Twitter bot that tweets about the primality of today's date in ISO 8601 format

License: BSD 2-Clause "Simplified" License

Shell 15.30% Python 81.33% Makefile 3.36%
twitter-bot prime-numbers prime-factorizations prime-days

twitbot-iwpt's Introduction

twitbot-iwpt: Is What Prime Today?

Sanity checks

A Twitter bot that tweets, if the current date in ISO 8601 format, without the hyphens (e.g., 20170913), is a prime number. For example, on September 1, 2017, it would tweet

Today 20170901 is a prime
a Chen prime
an Eisenstein prime
a Pythagorean prime
has a twin prime
has a cousin prime.

If the current date is not a prime number, it will tweet the factorization of the ISO-8601-formatted date. For example,

Today 20180503 is not a prime
20180503 = 7^2 x 37 x 11131

Dependencies

Usage

Similar to that described in https://github.com/syncom/twitbot-tih.

  1. Create a Twitter app and obtain the API Key, API Secret, Access Token, and Access Token Secret for the app. This can be done by following the instructions at: https://developer.twitter.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api. On 20230429, we started to see API authentication errors, and a message "This app has violated Twitter rules and policies" on the Twitter app setting page. According to this discussion, we signed up for the Free tier of "Twitter API v2" (at no cost), and clicked button "downgrade to free"; this resolved the auth issue. You may also need to put the Twitter app under a "project" for better organization and monitoring of the app.

  2. Clone this repository with the submodule and change directory to it. Set up Python3 virtual environment.

    git clone --recursive https://github.com/syncom/twitbot-iwpt.git
    cd twitbot-iwpt
    # Set up virtualenv and pip install packages
    make install
  3. Set up authentication and authorization secrets by following this Getting Started guide. The preferred way is to set environment variables IWPT_API_KEY, IWPT_API_SECRET, IWPT_ACCESS_TOKEN, and IWPT_ACCESS_SECRET with API Key, API Secret, Access Token, and Access Token Secret values obtained in the first step. Alternatively, one can override the corresponding strings in the file '.auth' with appropriate secret strings. When any of the aformetioned environment variables are set, they take precedence over values in the .auth file.

  4. Run ./iwpt_bot_run.sh to tweet. Note that it only tweets when the ISO 8601 formatted string for today's date is a prime number. The log files for each day's tweet can be found in the 'logs' subdirectory. They keep state of the primality info and the tweet status, and are used by our application to make tweeting decisions.

  5. (Optional) Create a cron job to invoke the bot multiple times a day, to account for sporadic connecitivity issues.

twitbot-iwpt's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar syncom avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

hnjm

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.