Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import socket
  2. import sys
  3.  
  4. server = "irc.freenode.net" #settings
  5. channel = "#gliwice"
  6. botnick = "jakisciec"
  7.  
  8. irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
  9. print "connecting to:"+server
  10. irc.connect((server, 6667)) #connects to the server
  11. irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This is a fun bot!\n") #user authentication
  12. irc.send("NICK "+ botnick +"\n") #sets nick
  13. irc.send("PRIVMSG nickserv :iNOOPE\r\n") #auth
  14. irc.send("JOIN "+ channel +"\n") #join the chan
  15.  
  16. while 1: #puts it in a loop
  17. text=irc.recv(2040) #receive the text
  18. print text #print text to console
  19.  
  20. if text.find('PING') != -1: #check if 'PING' is found
  21. irc.send('PONG ' + text.split() [1] + '\r\n') #returnes 'PONG' back to the server (prevents pinging out!)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement