Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import socket
  2.  
  3. class irc:
  4.     def __init__(self, address, protocol=6667):
  5.         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  6.         self.sock.connect((socket.gethostbyname(address), protocol))
  7.     def server_response(self):
  8.         full_response = ""
  9.         response = self.sock.recv(25)
  10.         full_response = response
  11.         while response:
  12.             full_response += response
  13.             response = self.sock.recv(25)
  14.         return full_response
  15.     def send_message(self, message):
  16.         self.sock.send(message)
  17.         return
  18.     def close(self):
  19.         self.sock.close()
  20.         return
  21.  
  22. connection = irc("irc.420chan.org")
  23. connected = 1
  24.  
  25. while connected:
  26.     print connection.server_response()
  27.  
  28. irc.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement