Advertisement
metalx1000

Very Simple IRC Bot

Jan 11th, 2012
1,644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. import socket
  5. import string
  6. import time
  7.  
  8. HOST="irc.freenode.net"
  9. PORT=6667
  10. NICK="metalbot"
  11. IDENT="metalbot"
  12. REALNAME="MetalBot"
  13. readbuffer=""
  14.  
  15. s=socket.socket( )
  16. s.connect((HOST, PORT))
  17. s.send("NICK %s\r\n" % NICK)
  18. s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
  19.  
  20. while 1:
  21.     readbuffer=readbuffer+s.recv(1024)
  22.     temp=string.split(readbuffer, "\n")
  23.     readbuffer=temp.pop( )
  24.  
  25.     for line in temp:
  26.         print line
  27.         line=string.rstrip(line)
  28.         line=string.split(line)
  29.  
  30.         if "/MOTD" in line:
  31.             print "Connecting..."
  32.             time.sleep(5)
  33.             s.send("JOIN #filmsbykris \r\n")
  34.  
  35.         if "metalbot" in line:
  36.             print "<===========metabot==============>"
  37.             if "Linux" in line:
  38.                 print "<===============Linux==========>"
  39.                 s.send("PRIVMSG #filmsbykris : I think Linux is cool!!! \r\n")
  40.  
  41.         if(line[0]=="PING"):
  42.             s.send("PONG %s\r\n" % line[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement