Git Product home page Git Product logo

caparledev-bot's Introduction

CaParleDev Bot

Twitter bot used to retweet all tweets having the hashtag #caparledev

Prerequisites

  • Node.js
  • MongoDB
  • Typescript

Installation

  • Clone the repository
git clone https://github.com/osscameroon/caparledev-bot.git [project_name]

cd [project_name]
  • Create configuration file and edit with your own value
cp .env.example .env
nano .env
  • Create a Twitter application
  1. Login to your Twitter account on developer.twitter.com.
  2. Navigate to the Twitter App dashboard
  3. If you have an existing app, go to the next step. If not, to create an app, you will be first asked to create a project. You can give the app the name you want. When asked the access level required for your app, select Read Only, it will be enough for the script to work.
  4. Open the app and navigate to the "keys and tokens" page.
  5. Copy the Consumer Key and Secret, Access Token and Secret
  • Set credentials in .env
TWITTER_APP_CONSUMER_KEY=consumer_key
TWITTER_APP_CONSUMER_SECRET=consumer_secret
TWITTER_APP_ACCESS_TOKEN_KEY=access_token_key
TWITTER_APP_ACCESS_TOKEN_SECRET=access_token_secret
  • Start application
yarn watch # On Terminal 1
yarn start # On Terminal 2
  • Launch ngrok tunnels to the app
yarn ngrok
  • Register the auth callback in twitter application

    Copy the url generated by Ngrok, go to to your Twitter app in developer portal, locate the section the section "CALLBACK URLS", paste the url and save the changes.

  • Call the endpoint to set generate auth URL

# The call
curl http://localhost:7432/auth/url

# The response
{"url":"https://api.twitter.com/oauth/authenticate?force_login=true&oauth_token=Qj8UOwBBAAABTOKhAAABdCZxfsI"}
  • Authenticate with the bot account

Navigate to the URL in the browser and login with the bot account. After successful login, you will receive a JSON reponse with OAuth access token key and OAuth access token secret

{
  "oauthToken": "OAuth access token key",
  "oauthTokenSecret": "OAuth access token secret"
}
  • Set in config file the OAuth token key and secret generated
TWITTER_BOT_ACCESS_TOKEN_KEY=oauth_access_token_key
TWITTER_BOT_ACCESS_TOKEN_SECRET=oauth_access_token_secret
  • Generate Bearer token
yarn bearer:token

Open the .env file and set the generated bearer token

TWITTER_BEARER_TOKEN=bearer_token
  • Enable Twitter stream and set the hashtag(s) you want to stream.

Separate hashtag with a comma if you have many. You can set up to 5000

ENABLE_STREAM=true
HASHTAG_TO_TRACK=#hastag1,#hastag2,#hastag3,....,#hastagn
  • Restart the app
yarn start

caparledev-bot's People

Contributors

tericcabrel avatar

Stargazers

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

Watchers

 avatar  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.