This is a quick post, I’ve not got exactly all the time I want to have, but I’m very eager to show this one to the world as a useful GPL program.
bot.py is an IRC bot toolkit for python. It’s really quite simple. You:
- Import it.
import bot - Initialize a new bot object
a = bot.bot(master="yourname", channels=["#somechan"], nick="foobar") - Register events
irc.register(check_func, act_func)
Where check_func is a function that receives the sender, arguments of the IRC command and the text of it. Also, it’s possible to set the evtype= argument to act on other commands (e.g. NICK, QUIT, etc.) - Connect and run
a.connect("server.com", 6667)
a.start()
Protip: a.send(a) will send a to the server. For instance:
a.send(b'PRIVMSG #channel :Hello!')
will send “Hello!” to #channel. Or whatever other command you like.
Yes, you need to know the IRC protocol, a bit. The rest should be fairly obvious, if not, contact me. Also, contact me with improvements and I will gladly add them!
NB: This is for Python 3
Download bot.py

Cool Thanks for your article. I am just starting python and this will help a lot.
No problem!
Show us how to make it join channels and how to do a simple “Hello IRC” command.
I like what you did, it’s feel like simple and clean, like python !