I am attempting to extend the example bot that comes with this IRC library here. I've repasted the code of said bot here.
My problem is that I don't quite see what needs to be modified in order to enable the bot to respond to events, like getting a message - there's no event dispatcher that I can see.
What I can do is
bot = irc.bot.SingleServerIRCBot(server_list = [('irc.whatever.net.', 6667)],realname = 'irclibbot',nickname = 'irclibbot',)
bot.start()
and it runs fine - connects to the network and all that, but it doesn't do anything. Doesn't even respond to the basic CTCP events like VERSION and PING.
How does this work?
Check out this example of what you need to do.
class TestBot(irc.bot.SingleServerIRCBot):
def __init__(self, channel, nickname, server, port=6667):
irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
def on_nicknameinuse(self, c, e):
c.nick(c.get_nickname() + "_")
def on_welcome(self, c, e):
c.join(self.channel)
def on_privmsg(self, c, e):
self.do_command(e, e.arguments[0])
Define your own class that inherits from the actual irc.bot.SingleServerIRCBot
class. Then, the events will automatically be bound to the methods named on_'event'
like on_privmsg
, on_part
, etc.
Here you can find the reference of the supported events.