Guest User

Untitled

a guest
Mar 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. # TODO: Add +B mode to this bot, read foonetic botmotd
  2.  
  3. import sys
  4. import socket
  5. import string
  6.  
  7. HOST="irc.foonetic.net"
  8. PORT=6667
  9. NICK="DaedBot"
  10. IDENT="daedbot"
  11. REALNAME="Daedalus Bot"
  12. CHANNEL="#xkcd"
  13. readbuffer=""
  14.  
  15. bugfile=open('debug.txt', 'w')
  16.  
  17. s=socket.socket( )
  18. s.connect((HOST, PORT))
  19. s.send("NICK %s\r\n" % NICK)
  20. s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
  21. #s.send("JOIN %s\r\n" % (CHANNEL))
  22.  
  23. while 1:
  24. recv=s.recv(4096)
  25. readbuffer=readbuffer+recv
  26. bugfile.write("BEEP")
  27. bugfile.write(recv)
  28. temp=string.split(readbuffer, "\n")
  29. readbuffer=temp.pop( )
  30.  
  31. for line in temp:
  32. line=string.rstrip(line)
  33. line=string.split(line)
  34.  
  35. if(line[0][0]==":"):
  36. user=line[0][1:line[0].find('!')]
  37. line=line[1:]
  38. else: user="Daedalus"
  39. if(line[0]=="PING"):
  40. s.send("PONG %s\r\n" % line[1])
  41. if(line[0]=="PRIVMSG"):
  42. message=line[2][1:]+' '+' '.join(line[3:])
  43. reply="Yo, I'm totally replying to your PM."
  44. s.send("PRIVMSG %s %s\r\n" % (user, reply))
Add Comment
Please, Sign In to add comment