Giter VIP home page Giter VIP logo

twitterbot's Introduction

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");

twitterbot's People

Contributors

vinlegend1 avatar

Stargazers

 avatar

Watchers

 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.