You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.3KB

  1. import os
  2. import sys
  3. import configparser
  4. # Version Checking
  5. # Basically reject anything not 3.5 or 3.6 as those are the only versions that work.
  6. if not sys.version_info[:2] == (3, 5) or sys.version_info[:2] == (3, 6):
  7. print("Roxbot does not support Python {}".format(".".join(sys.version_info[:2])))
  8. exit(0)
  9. # Install Requirements
  10. code = os.system("python3 -m pip install -r requirements.txt")
  11. if code != 0:
  12. print("Error occurred while installing requirements. Exiting...")
  13. exit(1)
  14. else:
  15. print("Requirements successfully installed.")
  16. # Create preferences file.
  17. with open("roxbot/settings/preferences_example.ini", "r") as orig:
  18. fp = orig.read()
  19. with open("roxbot/settings/preferences.ini", "w") as new:
  20. new.write(fp)
  21. print("Preferences file created")
  22. # Ask to do preferences.ini setup
  23. print("Most of the setup is complete. All there is to do is setup the preferences.ini file.")
  24. print("You can do the quick setup in this script, or manually setup the file yourself.")
  25. while True:
  26. choice = input("Do you want to continue to the easy preferences setup? (y/n): ")
  27. if choice.strip(" ").lower() == "y":
  28. print("You can leave the field empty if you don't have the required thing.")
  29. print("Note: Everything that is asked here is required and not having it can lead ot issues.")
  30. break
  31. elif choice.strip(" ").lower() == "n":
  32. print("Exiting...")
  33. exit(0)
  34. # Preferences.ini setup
  35. config = configparser.ConfigParser()
  36. config.read("roxbot/settings/preferences.ini")
  37. print("Setting up preferences file...")
  38. owner_id = str(input("Bot Owner ID: ")).strip(" ")
  39. if not owner_id or not owner_id.isdigit():
  40. print("Invalid owner ID given. Skipping...")
  41. else:
  42. config["Roxbot"]["OwnerID"] = owner_id
  43. prefix = str(input("Command Prefix: ")).strip(" ")
  44. if not prefix:
  45. print("Invalid Owner ID given. Skipping...")
  46. else:
  47. config["Roxbot"]["Command_Prefix"] = prefix
  48. token = str(input("Discord Bot Token: ")).strip(" ")
  49. if not token:
  50. print("Invalid token given. Skipping...")
  51. else:
  52. config["Tokens"]["Discord"] = token
  53. token = str(input("Imgur Client ID: ")).strip(" ")
  54. if not token:
  55. print("Invalid client ID given. Skipping...")
  56. else:
  57. config["Tokens"]["Imgur"] = token
  58. print("Finished preferences.ini setup.")
  59. print("There are more options avaliable in the file (found at ./roxbot/settings/preferences.ini) if you want to make optional tweaks to Roxbot.")
  60. print("Exiting...")