Guest User

Untitled

a guest
Nov 13th, 2018
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import socket
  2. import sys
  3.  
  4. server = "server"       #settings
  5. channel = "#channel"
  6. botnick = "botname"
  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!)
Add Comment
Please, Sign In to add comment