1.2.1 • Published 4 years ago

cpustejovsky-twitter-bot v1.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

cpustejovsky-twitter-bot

Setup

  • Set up credentials through Twitter's API
  • Create a .env file in the root of your app if you don't have one already and add the following:
API_KEY=""
API_SECRET_KEY=""
ACCESS_TOKEN=""
ACCESS_TOKEN_SECRET=""
  • Add the .env file to your .gitignore file to not risk exposing your API credentials.

Installation

  • NPM: npm install --save cpustejovsky-twitter-bot dotenv

##Usage

  • Run with
const require("dotenv").config({ path: "/path/to/your/.env"});
const bot = require("cpustejovsky-twitter-bot");

Test config variables

bot.testConfigData() logs the config vars; this can be helpful for making sure you set the correct path to your .env file.

Accessing twitter data

bot.getTwitterData(screename, count);

This is an example of what it would return for screen name "CCpustejovsky" and count 2:

{ 
  name: 'Charles C. Pustejovsky III 👍',
  screenName: 'CCPustejovsky',
  tweets: 
   [ { content: 'Test Tweet 1',
       id: '1200569616998772730',
       url: 'https://twitter.com/CCPustejovsky/status/1200569616998772730',
       previouslyLiked: false,
       previouslyRetweeted: false },
     { content: 'Test Tweet 2',
       id: '1200520702476083203',
       url: 'https://twitter.com/CCPustejovsky/status/1200520702476083203',
       previouslyLiked: false,
       previouslyRetweeted: false }
   ]
}

Liking and Retweeting

  • Liking a tweet: bot.like(returnData)
  • Retweeting a tweet: bot.retweet(returnData)

NOTE: like() and retweet() try to like or retweet all of the tweets contained in the return data. It only returns the tweets that have not already been liked and retweeted. This allows you to like/retweet a specified amount of tweets from a given user and only see unliked/unretweeted tweets.

To like a specific tweet, use bot.likeTweet(tweet)

To retweet a specific tweet, use bot.retweetTweet(tweet)

Searching for a specific tweet

bot.search(screenName, query, count) //count is not able to exceed 200 currently

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago