A Twitter Bot, Mom Bot, that provides encouragement and warns about bad word usage to those who follow her.
To install this project to make your own Twitter Bot:
-
Click the "Fork" button to create your own repository.
-
From your forked repository, clone or download the the repository to your local system.
-
Go to Twitter and create a separate Twitter account for your bot. You will need to include a mobile phone number on this account, but you can remove the number after completing these installation steps.
-
Go to Twitter Dev and click on "Manage Your Apps" (in the footer). Sign in as your bot and click "Create New App".
-
Enter a name and description for your bot, as well as a website, which can be a link to your bot repository on GitHub. Read the Twitter Developer Agreement and check it off, then click "Create your Twitter application".

-
When your Twitter app pulls up, switch to the "Keys and Access Tokens" tab. Make note of the Consumer Key (API Key) and Consumer Secret (API Secret). Under "Your Access Token", click to generate your Access Token and Access Token Secret. If your bot is ever compromised, you will want to regenerate these keys as well as the Consumer Key and Secret.

-
Create a
config.jsfile in the root of this project's directory. Insert your bot account's Twitter API keys like this:module.exports = { consumer_key: '...', consumer_secret: '...', access_token: '...', access_token_secret: '...' }
-
Because the
config.jsfile has your authentication keys within it, make sure it is in your.gitignorefile. This can be done from your terminal like this:echo config.js >> .gitignore
-
In the
bot.jsfile, change thebot_namevariable value to your bot's name (like Mom Bot), thebot_screen_namevariable value to your bot's Twitter handle, and thebot_owner_namevariable value to your own primary Twitter handle. -
Commit and push your changes to your forked repository.
git add . git commit -m "add config.js and api keys" git push origin master
-
In your terminal, create and checkout a local branch with some
<BRANCH-NAME>. You will removeconfig.jsfrom the.gitignorefile on this branch use this branch to push to Heroku.git checkout -b <BRANCH-NAME>
-
Create a Heroku account if you don't already have one. In your dashboard, create a new app, calling it whatever you like.
-
In your terminal, download the Heroku CLI if you haven't already. Log in to your account by entering the following into your terminal and following the prompts:
heroku login
-
Connect your directory with your Heroku app:
heroku git:remote -a <YOUR-APP-NAME>
-
Deploy your application to Heroku:
git add . git commit -am "add project files" git push heroku <BRANCH-NAME>:master
-
By default, Heroku apps use web dynos. A Procfile has been included to instruct a worker dyno to be used to run your app instead. As an extra precaution, you can correct the dynos used in your terminal like this:
heroku ps:scale web=0 worker=1
-
You may need to restart your worker dyno in order to get your app up and running. Do that like this:
heroku restart worker.1
-
A few additional tools to check on your app:
heroku ps // Checks the status of your dynos heroku logs // Shows your app console, any errors and shutdowns/restarts
To use the existing bot, a user can simply follow Mom Bot on Twitter. Mom Bot will respond to the follow request and follow the user back.

From there, Mom Bot will scan tweets in the stream for use of bad words. If a tweet contains a bad word, Mom Bot will respond with an @reply to the tweeter.

Mom Bot will also scan for @replies directed at Mom Bot. If a user tweets an @reply that includes a sad word, Mom Bot will tweet an @reply to the user to cheer them up.

If a user tweets an @reply that includes a proud or happy word, Mom Bot will tweet an @reply to the user to express her pride in the user.

If a user tweets an @reply that includes a phrase like "go away" or "leave me alone", Mom Bot will respond to the user and unfollow them.

If a user includes the word "stop" in an @reply to Mom Bot, she will tweet a request to have the bot owner help out, for example, if there is a bug or the bot won't unfollow as expected.

Once your bot is installed, you can dig into the code to add or change functionality. This bot uses the twit NPM package to manipulate tweets and streams. Be sure to review the documentation for that project prior to making substantial changes.
No worries. You can still help out by:
- Pointing out bugs/errors.
- Recommending cool features.
For either of these options, please create an issue so it can be addressed. New to GitHub issues? They have a pretty handy guide you can use to familiarize yourself with them.
Simply:
- Fork the repository
- Make your suggested change
- Make sure the code style looks similar to the existing code
- Create a pull request
- Created by Chazona Baum as a personal project.
- Uses the twit NPM package to maniuplate tweets and streams.
- Uses the badwords NPM package to provide its list of "bad words" (profanity) in English.
- Created after viewing the Twitter Bot Tutorial Series provided by Daniel Shiffman. His Coding Rainbow series is so many shades of amazing. You should watch his YouTube videos and contribute on Patreon.
MIT License
Copyright (c) 2016 Chazona Baum chazona@chazonabaum.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Initial release