transbot v0.3 downloadable

Yeah, I know, I promised that it would release only when reached the version 1.0, but a lot of people sent me mail about the bot, and I had a lot of visits on the project page from people searching for an IRC translation bot.

And you can get it now here! Download!!! Read the README file to know how to put transbot working. And after transbot join the channel that you want it to work, type !help to get a list of supported commands of the bot.

Remember: it’s open source and still on development, i.e., there are a lot of things to do on it yet. Enjoy!

transbot-0.3.tar.bz2

transbot: connecting to the IRC

Hey guys, I’m here again, now with some code on how I do to connect to some IRC server using Python, on the Translation Bot (trully I found another bot with the same name, but I’ll not change it ;p ):

First, we need to add these modules:
import sys
 
import socket

With it, we can define some constants:

NETWORK = 'some.irc.server' # server to connect
PORT = 6667
NICK = 'transbot' # the nick used for the bot
PASSWORD = 'bot_password' # used if you register the bot nick
IDENT = 'transbot'
REALNAME = ':MDK's Translation Bot'
OWNER = 'xMDKx' # yeah, it's me on anonnet and on freenode
CHANNEL = '#some_channel' # the initial channel to join

Cool! Right now we can connect to IRC simply doing:

irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
irc.connect((NETWORK, PORT))

And now, just to enter on some channel (and identify):

send('NICK %s' % NICK)
send('USER %s %s %s %s' % (IDENT, NICK, NICK, REALNAME))
send('NICKSERV IDENTIFY %s ' % PASSWORD)
send('JOIN %s' % CHANNEL)

Now your bot is connected to the NETWOR (server) and joined on the CHANNEL that you specify.

For just grab the messages on the channel, do it:

while True:
data = irc.recv(SOME_SIZE) # with size like 512 bytes, for ex.
 
print data # just print server messages

And it’s all for today, folks! Soon I’ll post some tips on how to parse the messages grabbed from the channel. See ya!