Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- from socket import *
- #################################################
- HOST = "irc.freenode.net" # Needed for the initial socket connection
- PORT = 6667 # This is the normal port used for IRC connections
- USERNAME = "Bubblebot" # Nick of the bot
- HOSTNAME = "NULL" # This is not needed for a client but is there for compliance
- SERVERNAME = "NULL" # This is not needed for a client but is there for compliance
- REALNAME = "Bubble bot" # Realname to pass to the IRC server
- PASS = "bubblebot" # Password for authentication to the server
- irc_socket = socket(AF_INET, SOCK_STREAM) # This creates the socket used for connection
- irc_socket.connect((HOST, PORT)) # This makes the actual connection
- def send(data): # This function is defined for sending a message to the server
- irc_socket.send(data)
- def receive(buffer_size = 1024): # This function is defined for receiving messages from the server
- irc_socket.recv(buffer_size)
- #################################################
- # The correct order for registering a connection with an IRC server according to RFC 1459 is as follows:
- # 1) Pass message
- # 2) Nick message
- # 3) User message
- # Pass message
- # Command: PASS
- # Parameters: <password>
- send("PASS %s" % PASS)
- # Nick message
- # Command: NICK
- # Parameters: <nickname> [<hopcount>]
- send("NICK %s" % NICK)
- # User message
- # Command: USER
- # Paremeters <username> [<hostname>] [<servername>] <realname>
- send("USER %s %s %s %s" % (USERNAME, HOSTNAME, SERVERNAME, REALNAME))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement