A Simple Twitter Bot built using the twit Twitter API Client and the PokeAPI (and a little bit of web scraping from https://www.pokemon.com). The bot will tweet about a pokemon.
The
api
folder in this repo is for the serverless API setup using Zeit(Vercel). It uses an Airtable config for storing which pokemons have been tweeted and uses a cron job service like EasyCron to hit this API everyday.
1. Ensure that Node.js and yarn have been installed
2. Clone the repo
git clone https://github.com/statebait/poketwitbot.git
3. Install Dependencies
cd poketwitbot # Go to the project root directory
yarn
4. Create the Environment File
In the project root directory create a file called .env
which contains your twitter app's access keys and tokens. The file should look like this:
TWITTER_USERNAME=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_TOKEN_SECRET=
5. Run the bot
To run the bot you will need to import/require the bot.js file in your script, function or whatsoever like this:
const bot = require("./path/to/bot.js");
async function main() {
const { success, error, message } = await bot(250); // Pass in any pokemon id as the argument (pokemon id is the pokemon no. in the pokedex
if (err) {
console.error(message);
} else if (success) {
console.log(message);
}
}
This project is licensed under the MIT License - Copyright (c) 2020 Mohamed Shadab