Advertisement
Guest User

Untitled

a guest
May 9th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #! /usr/bin/env python
  2.  
  3. from socket import *
  4.  
  5. #################################################
  6.  
  7. HOST = "irc.freenode.net" # Needed for the initial socket connection
  8. PORT = 6667 # This is the normal port used for IRC connections
  9. USERNAME = "Bubblebot" # Nick of the bot
  10. HOSTNAME = "NULL" # This is not needed for a client but is there for compliance
  11. SERVERNAME = "NULL" # This is not needed for a client but is there for compliance
  12. REALNAME = "Bubble bot" # Realname to pass to the IRC server
  13. PASS = "bubblebot" # Password for authentication to the server
  14.  
  15. irc_socket = socket(AF_INET, SOCK_STREAM) # This creates the socket used for connection
  16. irc_socket.connect((HOST, PORT)) # This makes the actual connection
  17.  
  18. def send(data): # This function is defined for sending a message to the server
  19. irc_socket.send(data)
  20.  
  21. def receive(buffer_size = 1024): # This function is defined for receiving messages from the server
  22. irc_socket.recv(buffer_size)
  23.  
  24. #################################################
  25.  
  26.  
  27. # The correct order for registering a connection with an IRC server according to RFC 1459 is as follows:
  28. # 1) Pass message
  29. # 2) Nick message
  30. # 3) User message
  31.  
  32. # Pass message
  33. # Command: PASS
  34. # Parameters: <password>
  35. send("PASS %s" % PASS)
  36.  
  37. # Nick message
  38. # Command: NICK
  39. # Parameters: <nickname> [<hopcount>]
  40. send("NICK %s" % NICK)
  41.  
  42. # User message
  43. # Command: USER
  44. # Paremeters <username> [<hostname>] [<servername>] <realname>
  45. send("USER %s %s %s %s" % (USERNAME, HOSTNAME, SERVERNAME, REALNAME))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement