import sys import socket import string SERV="irc.project-x.fr" PORT=6667 NICK="Python_Bot" IDENT="Python_Bot" REALNAME="Bot En Python" readbuffer="" s=socket.socket( ) s.connect((SERV, PORT)) s.send("NICK %s\r\n" % NICK) s.send("USER %s %s bla :%s\r\n" % (IDENT, SERV, REALNAME)) while 1: readbuffer=readbuffer+s.recv(1024) temp=string.split(readbuffer, "\n") readbuffer=temp.pop( ) for line in temp: line=string.rstrip(line) line=string.split(line) print line if (line[0]=="PING"): s.send("PONG %s\r\n" % line[1]) print "PING" if (len(line)>2): if (line[1]=="PRIVMSG"): if (line[3]==":!test"): s.send("PRIVMSG #Accueil :hehe je réponds aux messages\r\n") print "PRIVMSG"