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. It has two main goals: first, to 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). Second, it helps the new person to feel welcome even when there's no one around, and provides more information to them about staying in touch.
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:
The repository contains test_bot.py
, which is a set of automated tests for the bot. To learn more about these, see Testing below or the testing tutorial. It also contains test_nicks.csv
, the set of nicks used for the automated tests.
Finally, we have a docs folder which contains tutorial-style instructions for various concepts used by WelcomeBot. Currently there is one tutorial, for unit testing.
Currently, the bot is only compatible up to Python 2.7.
To run the bot:
python bot.py
. 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.
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
./bin/coverage html
You can then see the results in htmlcov/index.html
.
Note: You will likely need to install coverage. The above command assumes you have installed it to a virtual environment. If you haven't, use coverage
instead of bin/coverage
, for example: coverage run test_bot.py
The issue tracker lists improvements we want to make. Tasks that are better for newcomers are labelled first task.
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.
This bot was adapted from code found here.