No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

79 líneas
2.4KB

  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(sys.version_info[0],sys.version_info[1]))
  8. exit(0)
  9. # Install Requirements
  10. code = os.system("python3 -m pip install -U -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. with open("roxbot/settings/preferences.ini", 'w') as configfile:
  60. config.write(configfile)
  61. print("There are more options avaliable in the file (found at ./roxbot/settings/preferences.ini) if you want to make optional tweaks to Roxbot.")
  62. print("Exiting...")