Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import socket
- import string
- import time
- import os
- print("EveGossip Beta\nBy Paul Clavet\n<paul@mylootyourtears.com>")
- filename = (sys.argv[1])
- print("Using file " + filename + "\n")
- HOST = raw_input("Enter the server you wish to use: ")
- PORT=6667
- NICK = raw_input("Enter the nick for this bot: ")
- IDENT="EveGossip"
- REALNAME="EveGossip"
- CHAN = raw_input("Enter the channel you wish to use: ")
- readbuffer=""
- lastime = 0.0
- #Set the filename and open the file
- file = open(filename,'rb')
- #Find the size of the file and move to the end
- st_results = os.stat(filename)
- st_size = st_results[6]
- file.seek(st_size)
- s=socket.socket( )
- s.connect((HOST, PORT))
- s.setblocking(0)
- s.send("NICK %s\r\n" % NICK)
- s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
- loggedin = 0
- lasttime = time.clock()
- starttime = lastime
- while 1: # main loop
- while (time.clock() < (lastime + 0.01)):
- time.sleep(.005)
- lastime = time.clock()
- if loggedin == 1:
- where = file.tell()
- fileline = file.readline()
- if not fileline:
- file.seek(where)
- else:
- fileline = fileline[0:len(fileline)]
- filteredline = ""
- i = 0
- while i < ((len(fileline)/2))-2:
- i = i + 1
- filteredline = filteredline + fileline[(i*2)]
- print (filteredline + "\r\n"), # already has newline
- s.send("PRIVMSG %s :%s\r\n" % (CHAN, filteredline))
- try:
- readbuffer=readbuffer+s.recv(1024)
- temp=string.split(readbuffer, "\n")
- readbuffer=temp.pop( )
- for wholeline in temp:
- line=string.rstrip(wholeline)
- print(wholeline)
- line=string.split(line)
- if(line[0]=="PING"):
- s.send("PONG %s\r\n" % line[1])
- if(loggedin == 0 & (string.join(line[3:]) == ":End of /MOTD command.")): #Check for login
- loggedin = 1
- s.send("JOIN :%s\r\n" % CHAN)
- s.send("PRIVMSG %s :%s\r\n" % (CHAN, ("EveGossip by Paul Clavet (http://mylootyourtears.com) Begining gossip session for log file " + filename)))
- except socket.error, detail:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement