#!/usr/bin/env python import sys import socket import string import time import select HOST="irc.blackened.com" PORT=6667 NICK="CJL|Pre1" IDENT="asdf" REALNAME="asdf" CHAN="#CJL|BotRoom" readbuffer="" path = 'log.txt' text = open(path,'r+',0) old = 0 s=socket.socket( ) s.connect((HOST, PORT)) s.send("NICK %s\r\n" % NICK) s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME)) s.send("JOIN %s :%s\r\n" % (CHAN,'')) s.send("PRIVMSG %s :%s\r\n" % (CHAN, "Hello There!")) s.send("PRIVMSG %s :%s\r\n" % (CHAN, "I am a bot")) while 1: """time.sleep(.2) length = len(text.readline()) text.seek(-length,1) if len(text.readline()) == 0: continue else: text.seek(-length,1) s.send("PRIVMSG %s :%s\r\n" % (CHAN, text.readline()))""" readbuffer=readbuffer+s.recv(1024) temp=string.split(readbuffer, "\n") readbuffer=temp.pop( ) potential_readers = [] potential_writers = [] potential_errs = [] #ready_to_read, ready_to_write, in_error = select.select([], potential_writers, potential_errs) #print ready_to_read #print ready_to_write 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])