Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import socket
- import sys
- ##take user input
- while(1):
- print("Server to run bot on: ")
- server = raw_input()
- print("Port to connect to: ")
- port = raw_input()
- print("Channel to join? (omit \#): ")
- channel = "#" + raw_input()
- print("\nChannel %s at %s:%s.\nIs this correct[y/n]?\n") % (channel, server, port)
- ##check if this is valid info, if not, reiterate
- yon = raw_input()
- ##formatting
- yon = yon.lower();
- if(yon[0]=='y'):
- break
- else:
- continue
- #convert port to an integer
- try:
- port = int(port)
- except:
- print("Port must be an integer.")
- sys.exit()
- # create the socket
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- # connect to the socket
- try:
- sock.connect((server, port))
- except:
- print("Error in connecting to %s.") % (server)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement