Simple Twitter bot to post "x-word is the opium of the people.", every 20 minutes, where x-word is a random word.
Explore the docs »
Report Bug
·
Request Feature
Main libraries and CLI tools used to built the project:
- Axios: Promise based HTTP client for the browser and node.js;
- Pluralize: Pluralize or singularize any word based on a count;
- Random word API: API that returns a collection of random words;
- Twit: Twitter API Client for node (REST & Streaming API);
- Wordfilter: A small module meant for use in text generators that lets you filter strings for bad words.
To manage the code style and formatting:
To get a local copy up and running follow these steps.
Install NodeJS:
Install a package manager:
- yarn: Yarn 1.x (classic) was used in this project.
or
- npm
npm install npm@latest -g
- Obtain Twitter access keys/tokens
To create a bot for Twitter it is necessary to create a Twitter app to obtain the access keys/tokens. Create one account in Twitter (It is necessary to have a verified email associated with the account), then go to https://developer.twitter.com/apps to create the app and get your bot keys/tokens.
I will assume you are using a Linux distribution.
-
Clone the repository:
Using ssh: git clone git@github.com:tukno/opium-bot.git Or using https: git clone https://github.com/tukno/opium-bot.git
-
Install the project dependencies:
cd opium-bot yarn
or using npm:
cd opium-bot npm install
-
Configure environment variables:
- Run the following command to create your local .env file:
cp .env.example .env
the .env file has the following properties that needs to be set (use a text editor of your choice):
- The Twitter consumer keys and access tokens you got at https://developer.twitter.com/apps
- The time interval between tweets in minutes(default is 20 minutes)
# Twitter tokens TWITTER_CONSUMER_KEY='' TWITTER_CONSUMER_SECRET_KEY='' TWITTER_ACCESS_TOKEN='' TWITTER_ACCESS_TOKEN_SECRET='' INTERVAL_MINUTES=20
-
Well looks like you are done with configuration and ready to code! (I hope so 🎉), run the following commands to execute the bot locally:
yarn dev
PS: I deployed this bot at Heroku. For instructions on how to deploy apps to Heroku, check this.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
David Oliveira - oliveiradavid.dev@gmail.com
Project Link: https://github.com/tukno/opium-bot