All pastes #989032 Raw Edit

Python IRC Bot?

public python v1 · immutable
#989032 ·published 2008-04-18 01:47 UTC
rendered paste body
import sysimport osimport mathimport socketclass IRC:  def __init__(self):    self.data = []    self.sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM)  def connect(self, server, port):    self.sock.connect((server, port))    self.sock.send("PASS x\r\n")    self.sock.send("NICK Minamo\r\n")    self.sock.send("USER a b c :d\r\n")  def recieve(self):    line = ""    line = self.sock.recv(4096)    return line  def send(self, line):    self.sock.send(line + "\r\n")    print ">>> " + lineirc = IRC()irc.connect("irc.rizon.net", 6667)while 1:  line = irc.recieve()  if line.find("PING") != -1:    irc.send( "PONG " + line[line.index(":"):len(line)] )  if line.find( "004" ) != -1:    irc.send( "JOIN #paluminum" )    irc.send( "PRIVMSG #paluminum :Hay, this is python!" )