Guest User

Untitled

a guest
Aug 7th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. import socket
  2. import string
  3.  
  4. HOST="irc.gtanet.com"
  5. PORT="6667"
  6. NICK="Juan"
  7. IDENT="Juan"
  8. REALNAME="Juan"
  9. CHAN="#xMovie"
  10. readbuffer=""
  11.  
  12. s=socket.socket( )
  13. s.connect((HOST, PORT))
  14. s.send("NICK %srn" % NICK)
  15. s.send("USER %s %s bla :%srn" % (IDENT, HOST, REALNAME))
  16. s.send("JOIN :%srn" % CHAN)
  17.  
  18. # python doesn't use braces {} for code blocks, it uses whitespace
  19. # a statement followed by a : means you need to indent the code following it, like so
  20. while 1:
  21.     readbuffer=readbuffer+s.recv(1024)
  22.     temp=string.split(readbuffer, "n")
  23.     readbuffer=temp.pop( )
  24.     for line in temp:
  25.         line=string.rstrip(line)
  26.         line=line.split(CHAN + ' :')
  27.  
  28. if line[0].find("PING") != -1:
  29.     pingid = line[0].split()[1]
  30.     s.send("PONG %srn" % pingid)
  31.  
  32. if len(line) > 1:
  33.     if line[1] == '!Juan':
  34.     s.send("PRIVMSG %s Hi" % CHAN)
Add Comment
Please, Sign In to add comment