Event driven Python IRC library
- 1 - Installation
- 2 - API documentation
- 3 - Usage
- 3.1 - Simple example
- 3.2 - Implementation example
- Appendix - Testing
This IRC framework uses Python 3. To install the bot type the following:
git clone http://github.com/veiset/pyric.git
cd pyric
git submodule init
git submodule update
python setup.py install
In this simple example we will create an IRC bot that listens to the command .greet
and replies with text Oh no you didn't!
. The bot will also ask people joining channle
I like bacon, <username>. Do you?
.
from pyric import irc
bot = irc.Instance('vzbot', 'vz', 'vz', 'irc.homelien.no', 6667)
def myHandler(event):
bot.say(event.get("channel"), "Oh no you didn't!")
def myJoinHandler(event):
bot.say(event.get("channel"), "I like bacon, %s. Do you?" % event.get('user')[0])
bot.addListener("cmd.greet", myHandler)
bot.addListener("join", myJoinHandler)
bot.connect()
bot.join('#brbot')
Scenario:
--> | simpleBot has joined #brbot
vz | Welcome slave IRC bot!
vz | .greet
simpleBot | Oh no you didn't!
--> | andern has joined #brbot
simpleBot | I like bacon, andern. Do you?
For an implementation example see the Brunobot IRC bot project.
Using py.test
py.test -v test/test_events.py
Using nosetests with test-coverage
nosetests-3.3 --with-coverage --cover-html