Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. # Import socket libraries
  2. import socket
  3.  
  4. # The variables that can be configured
  5. server = "irc.malvager.com" # Server
  6. channel = "bot" # Channel
  7. botnick = "BiowBot" # Your bots nick
  8.  
  9. def ping(): # Function to respond to PINGs
  10. ircsock.send("PONG :pingis\n")
  11.  
  12. def sendmsg(chan , msg): # Function for sending messages to a channel
  13. ircsock.send(str.encode("PRIVMSG " + "#" + chan +" :" + msg + "\n") )
  14.  
  15. def joinchan(chan): # This function is used to join channels.
  16. ircsock.send(str.encode("JOIN " + "#" + chan + "\n"))
  17.  
  18. def leavechan(chan): # This is used to part a chan
  19. ircsock.send(str.encode("PART " + "#" + chan + "\n"))
  20.  
  21. ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  22. ircsock.connect((server, 6667)) # The actual connection to the server through the socket
  23. ircsock.send(str.encode("USER "+ botnick +" "+ botnick +" "+ botnick +" :hax\n")) # user authentication
  24. ircsock.send(str.encode("NICK "+ botnick +"\n")) # here we actually assign the nick to the bot
  25.  
  26. joinchan(channel) # Join the channel using the functions we previously defined
  27. hello(channel)
  28. sendmsg(channel,"sup")
  29.  
  30.  
  31. while 1: # Inb4infinite loop
  32. ircmsg = ircsock.recv(2048) # receive data from the server
  33. print(ircmsg)
  34. if ircmsg.find("PING :") != -1: # if the server pings us then we've got to respond!
  35. ping()
  36. print('Ping received')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement