Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import socket
  3. import sys
  4. ##take user input
  5. while(1):
  6. print("Server to run bot on: ")
  7. server = raw_input()
  8. print("Port to connect to: ")
  9. port = raw_input()
  10. print("Channel to join? (omit \#): ")
  11. channel = "#" + raw_input()
  12. print("\nChannel %s at %s:%s.\nIs this correct[y/n]?\n") % (channel, server, port)
  13.  
  14. ##check if this is valid info, if not, reiterate
  15. yon = raw_input()
  16. ##formatting
  17. yon = yon.lower();
  18. if(yon[0]=='y'):
  19. break
  20. else:
  21. continue
  22. #convert port to an integer
  23. try:
  24. port = int(port)
  25. except:
  26. print("Port must be an integer.")
  27. sys.exit()
  28.  
  29. # create the socket
  30. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  31.  
  32. # connect to the socket
  33. try:
  34. sock.connect((server, port))
  35. except:
  36. print("Error in connecting to %s.") % (server)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement