-
Notifications
You must be signed in to change notification settings - Fork 6
Testing
wolfy1339 edited this page Sep 15, 2016
·
3 revisions
If you wish to test your bot offline, you can use the TestCase class:
Please note: that the nickname used for the bot while testing is hardcoded as zIRC-test
from zirc.test import TestCase
class botTest(TestCase):
def on_privmsg(self, event):
self.reply(event, "Hi!")
bot = botTest()
log = """:user!~user@user/user PRIVMSG #zirc :Hey!
:user2!~user@user/user2 PRIVMSG #zirc :How are you?
:user3!~user@user/user3 PRIVMSG zIRC-test :Hello there!"""
bot.start(log)
Output:
Starting...
Parsed line ':user!~user@user/user PRIVMSG #zirc :Hey!'
Attempting to run on_privmsg
RESPONSE: 'PRIVMSG #zirc :Hi!'
Parsed line ':user2!~user@user/user2 PRIVMSG #zirc :How are you?'
Attempting to run on_privmsg
RESPONSE: 'PRIVMSG #zirc :Hi!'
Parsed line ':user3!~user@user/user3 PRIVMSG zIRC-test :Hello there!'
Attempting to run on_privmsg
RESPONSE: 'PRIVMSG user3 :Hi!'
Done!