Bot.
Go to file
2014-11-15 16:44:23 -08:00
.gitignore Deleted error.log and added error.log into .gitignore 2014-11-15 16:26:33 -08:00
bot.py Check if actor is empty before cleaning nicks 2014-10-18 01:13:46 -04:00
LICENSE.txt adds license, fixes #3 2014-01-27 00:54:02 -05:00
nicks.csv Update newcomer list when a newcomer changes name before being greeted 2014-09-14 22:08:58 -07:00
README.md Update README 2014-09-13 13:40:08 -04:00
requirements.txt Add requirements.txt 2014-08-01 13:04:23 -04:00
test_bot.py Change how bot.py is imported by test suite 2014-09-13 15:18:42 -04:00
test_nicks.csv Fixed a test involving writing nicks to csv file. 2014-05-22 21:55:43 +05:30

What is this?

oh-irc-bot (or "WelcomeBot", its IRC nick) is a bot for welcoming people into the #openhatch irc channel when no one is paying attention. The goals are to:

  1. alert community members when someone new enters the room and says hello (either by using their nick in a response, or by sending a private message)
  2. help a person to feel welcome even when there's no one around, and providing more information about staying in touch

Basic Structure

bot.py is the project's main file. It uses the socket module to communicate and gathers a list of known IRC nicknames, stored in nicks.csv. Its basic functions include:

  1. If someone enters the channel, the bot checks to see if they are a known nick. If not, it adds them to a list of people to greet. If no one else has spoken into the channel after a period of time, 60 seconds by default, it greets them. If someone else (not the new nick) speaks into the channel within the set wait time, or if the nick is known, the bot remains silent. The bots response text includes the nicks of channel maintainers/frequent contributors so that they are pinged. Channel maintainers can change the wait time of the bot by using the following command in the irc channel: Botname --wait-time new wait time in seconds.
  2. If someone says hello to the bot, the bot says hello back.
  3. If someone asks the bot for information (via key phrases like "help", "faq", etc) the bot explains what it is and links to this repository.

The repository also contains test_bot.py, which is a set of automated tests for the bot. To learn more about these, see Testing below. test_nicks.csv, which is the set of nicks used for the automated tests.

There are also some miscellaneous files that you can ignore for now. We'll clean them up eventually. :)

Setting up

To run the bot:

  1. Download the repository. If you need help using github, see here.
  2. Edit bot.py to change the nickname to something besides "WelcomeBot" and the channel to "openhatch-bots".
  3. Open up a command line and type python bot.py.
  4. Although all IRC messages should be printed to your command line, for development purposes, it will probably be useful to be on IRC separately using your normal nick.

If you run into setup difficulties, ping shauna on freenode (via the #openhatch channel is preferred) and/or leave an issue in this repository's issue tracker.

In order to keep the bot continuously running, we put it on a server using the following command:

nohup python bot.py &

Nohup keeps it from terminating when we close the terminal and & keeps it from printing the IRC messages to the terminal.

Testing

We use Python unittest to test the bot, and Coverage to look at the test coverage.

When running tests, use this command:

python -m unittest test_bot

The output should tell you how many tests you ran and if any of them are failures.

When creating tests, you can use the following series of commands to see whether your test is testing the code you want it to test:

./bin/coverage run test_bot.py

Note: You will likely need to install coverage. The above command assumes you have installed it to a virtual environment. If you haven't, the command to use is: coverage run test_bot.py

How to help

The issue tracker lists improvements we want to make. I strongly encourage you to contact me and say hello before you get started (I am shauna on the #openhatch IRC). Please feel free to submit pull requests to address these issues. If you're not familiar with how to do this using github, see here. You can also always ask me for help or clarification.

Credit

This bot was adapted from code found here.

Also this has been very helpful.