Giter Site home page Giter Site logo

cleopard99 / twitter-bot Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 11.2 MB

A Twitter bot built in NodeJS - the bot tweets the top post of my favorite plant subreddits, post a new succulent/cacti every day, retweets every few hours, and responds to activity involving the bot.

Home Page: https://twitter.com/DailyPlantBot

License: Apache License 2.0

JavaScript 99.73% Procfile 0.27%
twitter twitter-api reddit-api nodejs heroku json web-scraping twitter-bot cheerio-node axios-node

twitter-bot's Introduction

NodeJS Twitter Bot

I built this Twitter-Bot built in NodeJS to use social media APIs and web-scraping. This bot is deployed to Heroku and be found at @DailyPlantBot on Twitter, which tweets the top post of selected plant-related subreddits, post a new succulent/cacti every day from a database, retweets every few hours, and responds to activity involving the bot (e.g., liking comments).

This project includes the following:

  • The Twitter API (with twit) is used to tweet, tweet with media, search & retweet, like, & notice follows & mentions

  • Uses the Reddit API (with snoowrap) to grab the top posts of specified subreddits

  • Axios and Cheerio are used for web-scraping to write to a large JSON file to create unique daily tweets

  • The functions required to download images from urls, convert to base64 for media uploads, tweet creation etc.

Making Your Own Bot

If you wanted to build something similar, you will first have to connect to Twitter's API by:

  1. Creating a Twitter account for the bot (Twitter does not allows multiple accounts on the same email)

  2. Log in here and fill in the form for a developer account

  3. You can now access the developer portal which has the:

    • Settings for updating details

    • Permissions for the bot (Read/Write/Message)

    • Keys and Access Token tab for your config file

  4. Click Create my access token and fill in the fields for your config file, twitter-config.js shows an example of this:

module.exports = {
  consumer_key:         'XXXXXXXX',
  consumer_secret:      'XXXXXXXX',
  access_token:         'XXXXXXXX',
  access_token_secret:  'XXXXXXXX'
}
  1. You can now create your own bot with your own values and interact with other APIs or databases

  2. Enter `npm start' in your project directory

If you have done it correctly (with immediate function calls) then you should see some activity e.g. the bot tweeting. A running server like Heroku can run your Twitter bot for you.

Credits

Twit API Client for Node

snoowrap JS Wrapper for Reddit API

Axios HTTP Client

Cheerio API

Node Image Downloader

License

Copyright 2020 Charles Leopard

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   <http://www.apache.org/licenses/LICENSE-2.0>

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

twitter-bot's People

Contributors

cleopard99 avatar

Stargazers

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