welcomebot/README.md

66 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

2014-02-08 18:14:12 +01:00
## What is this?
2013-12-21 22:14:36 +01:00
2014-11-25 18:57:02 +01:00
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.
2013-12-21 22:14:36 +01:00
2014-02-08 18:14:12 +01:00
## Basic Structure
2013-12-21 22:14:36 +01:00
2014-02-08 18:14:12 +01:00
<code>bot.py</code> is the project's main file. It uses the socket module to communicate and gathers a list of known IRC nicknames, stored in <code>nicks.csv</code>. Its basic functions include:
2013-12-21 22:14:36 +01:00
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*.
2014-02-08 18:14:12 +01:00
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.
2013-12-21 22:14:36 +01:00
2014-11-25 18:57:02 +01:00
The repository contains <code>test_bot.py</code>, which is a set of automated tests for the bot. To learn more about these, see __Testing__ below or [the testing tutorial](https://github.com/shaunagm/WelcomeBot/blob/master/docs/testing.md). It also contains <code>test_nicks.csv</code>, the set of nicks used for the automated tests.
2014-09-13 19:40:08 +02:00
2014-11-25 18:57:02 +01:00
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.
2014-09-13 19:40:08 +02:00
2014-02-08 18:14:12 +01:00
## Setting up
2014-11-25 18:57:02 +01:00
2014-11-16 01:55:33 +01:00
Currently, the bot is only compatible up to Python 2.7.
2013-12-21 22:14:36 +01:00
2014-02-08 18:14:12 +01:00
To run the bot:
2013-12-21 22:14:36 +01:00
2014-02-08 18:14:12 +01:00
1. Download the repository. If you need help using github, see [here](https://openhatch.org/wiki/Git_Basics).
2. Edit bot.py to change the nickname to something besides "WelcomeBot" and the channel to "openhatch-bots".
2. Open up a command line and type <code>python bot.py</code>.
3. 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.
2013-12-21 22:14:36 +01:00
2014-02-08 18:14:12 +01:00
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.
2013-12-21 22:14:36 +01:00
2014-09-13 19:40:08 +02:00
In order to keep the bot continuously running, we put it on a server using the following command:
<code>nohup python bot.py &</code>
[Nohup](http://en.wikipedia.org/wiki/Nohup) keeps it from terminating when we close the terminal and <code>&</code> keeps it from printing the IRC messages to the terminal.
## Testing
We use [Python unittest](https://docs.python.org/2/library/unittest.html) to test the bot, and [Coverage](http://nedbatchelder.com/code/coverage/) to look at the test coverage.
When running tests, use this command:
<code>python -m unittest test_bot</code>
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:
<code>
./bin/coverage run test_bot.py
2014-11-25 18:57:02 +01:00
./bin/coverage html
2014-09-13 19:40:08 +02:00
</code>
2014-11-25 18:57:02 +01:00
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: <code>coverage run test_bot.py</code>
2014-09-13 19:40:08 +02:00
2014-02-08 18:14:12 +01:00
## How to help
2013-12-21 22:14:36 +01:00
2014-11-25 18:57:02 +01:00
The [issue tracker](https://github.com/shaunagm/oh-irc-bot/issues?state=open) lists improvements we want to make. Tasks that are better for newcomers are labelled [first task](https://github.com/shaunagm/WelcomeBot/labels/first%20task).
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](https://openhatch.org/wiki/Git_Basics). You can also always ask me for help or clarification.
2013-12-21 22:14:36 +01:00
2014-02-08 18:14:12 +01:00
## Credit
2013-12-21 22:14:36 +01:00
2013-12-22 03:40:59 +01:00
This bot was adapted from code found [here](http://wiki.shellium.org/w/Writing_an_IRC_bot_in_Python).