Advertisement
Guest User

Untitled

a guest
Aug 7th, 2010
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. import sys
  2. import socket
  3. import string
  4. import time
  5. import os
  6.  
  7. print("EveGossip Beta\nBy Paul Clavet\n<paul@mylootyourtears.com>")
  8.  
  9. filename = (sys.argv[1])
  10. print("Using file " + filename + "\n")
  11. HOST = raw_input("Enter the server you wish to use: ")
  12. PORT=6667
  13. NICK = raw_input("Enter the nick for this bot: ")
  14. IDENT="EveGossip"
  15. REALNAME="EveGossip"
  16. CHAN = raw_input("Enter the channel you wish to use: ")
  17. readbuffer=""
  18. lastime = 0.0
  19.  
  20.  
  21.  
  22. #Set the filename and open the file
  23. file = open(filename,'rb')
  24.  
  25. #Find the size of the file and move to the end
  26. st_results = os.stat(filename)
  27. st_size = st_results[6]
  28. file.seek(st_size)
  29.  
  30.  
  31.  
  32. s=socket.socket( )
  33. s.connect((HOST, PORT))
  34. s.setblocking(0)
  35. s.send("NICK %s\r\n" % NICK)
  36. s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
  37. loggedin = 0
  38. lasttime = time.clock()
  39. starttime = lastime
  40.  
  41. while 1: # main loop
  42. while (time.clock() < (lastime + 0.01)):
  43. time.sleep(.005)
  44. lastime = time.clock()
  45.  
  46. if loggedin == 1:
  47. where = file.tell()
  48. fileline = file.readline()
  49. if not fileline:
  50. file.seek(where)
  51. else:
  52. fileline = fileline[0:len(fileline)]
  53. filteredline = ""
  54. i = 0
  55. while i < ((len(fileline)/2))-2:
  56. i = i + 1
  57. filteredline = filteredline + fileline[(i*2)]
  58. print (filteredline + "\r\n"), # already has newline
  59. s.send("PRIVMSG %s :%s\r\n" % (CHAN, filteredline))
  60.  
  61. try:
  62. readbuffer=readbuffer+s.recv(1024)
  63. temp=string.split(readbuffer, "\n")
  64. readbuffer=temp.pop( )
  65.  
  66.  
  67.  
  68.  
  69.  
  70. for wholeline in temp:
  71. line=string.rstrip(wholeline)
  72. print(wholeline)
  73.  
  74. line=string.split(line)
  75. if(line[0]=="PING"):
  76. s.send("PONG %s\r\n" % line[1])
  77. if(loggedin == 0 & (string.join(line[3:]) == ":End of /MOTD command.")): #Check for login
  78. loggedin = 1
  79. s.send("JOIN :%s\r\n" % CHAN)
  80. s.send("PRIVMSG %s :%s\r\n" % (CHAN, ("EveGossip by Paul Clavet (http://mylootyourtears.com) Begining gossip session for log file " + filename)))
  81.  
  82.  
  83.  
  84. except socket.error, detail:
  85. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement