From YourMom, 6 Years ago, written in Python.
Embed
  1. #irconnect.py
  2.  
  3. import sys
  4. import random
  5. socket = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
  6.  
  7. if (len(sys.argv) > 1):
  8.    try:
  9.       server = sys.argv[1] + ":"
  10.       port_str = sys.argv[2]
  11.       port = int(port_str)
  12.       full = server + str(port)
  13.       nickname = random.randint(100,999)
  14.       nickname = "ConnTest-" + str(nickname)
  15.       if server and str(port):
  16.          if port:
  17.             print full
  18.             socket.connect((server, port))
  19.             socket.send('USER ConnTest ConnText Conntext :Python IRC Connection tester.')
  20.             socket.send('NICK %s' % nickname)
  21.             try:
  22.                if socket:
  23.                   print "Connected to the server."
  24.             except:
  25.                print "Connection failed!"
  26.          else:
  27.             print "Port does not exist, Please only use numbers!"
  28.       else:
  29.          print "If you encounter this, Please kill yourself."      
  30.    except:
  31.       print "Incorrect syntax."
  32.       print "Missing parameters (2) -> [server port]"
  33. else:
  34.    print "Incorrect syntax."
  35.    print "Missing parameters (2) -> [server port]"