Skip to content

vinlegend1/twitterbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter Bot

Usage

$ git clone https://github.com/vinlegend1/twitterbot.git
$ cd twitterbot
$ npm install
$ code .

Open the server.js file

// server.js file
// need to create a config file
const Twit = require('twit');
const { tweetIt, tweetCopier, tweetWithImage } = require('./helper/tweet');
const fs = require('fs');

// config.js is "git-ignored" and all it has is my api and access token things
const { consumer_key, consumer_secret, access_token, access_token_secret } = require('./config')

// create new Twit object
const T = new Twit({
    consumer_key,
    consumer_secret,
    access_token,
    access_token_secret
});

// call the helper functions here...

Create a config.js file

// in the config.js file
module.exports = {
    consumer_key:         '...',
    consumer_secret:      '...',
    access_token:         '...',
    access_token_secret:  '...'
}

Dependencies

Helper Functions

  • tweetIt(T: Twit Object, tweetText: String);
    • regular tweet with text message
const time_break = 1000 * 60 * 60 * 2; // every 2 hours
setInterval(() => {
    let random = Math.floor(Math.random() * 1000);
    tweetIt(T, "Hello from Node " + random)
}, time_break); // tweet every two hours
  • tweetCopier(T: Twit Object, trackArr)
    • Tweet someone else's tweet with an extra message of "P.S. this is a bot", not to be confused with retweets or quote tweets
tweetCopier(T, ['java']);
  • tweetWithImage(T: Twit Object, b64Image, tweetMessage: String, altOfImage: String)
    • Tweet with an Image
    • Implementation:
const b64content = fs.readFileSync('./images/khanacademy.jpg', { encoding: 'base64' })
tweetWithImage(T, b64content, "Khan Academy is awesome", "Khan Academy is awesome");

About

Making a bot that tweers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published