From 9aebe3fa3bbdd0a8d2cc535fcf6e1d0b56797a02 Mon Sep 17 00:00:00 2001 From: Alastair Holland Date: Sun, 3 May 2020 20:55:18 +0100 Subject: [PATCH] Added some comments --- lib/librarySetup.py | 13 +++++++++++-- lib/setup.py | 19 ++++++++++++++++--- run.py | 7 +++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lib/librarySetup.py b/lib/librarySetup.py index b53d027..24441c9 100755 --- a/lib/librarySetup.py +++ b/lib/librarySetup.py @@ -3,25 +3,34 @@ def checkLibraries(): import getpass import os + '''Check to see if pip3 is installed''' try: os.system("pip3 -V") except: os.system("sudo apt install python3-pip") + + '''Check discord.py''' try: import discord except: try: - os.system("python3 -m pip install -U discord.py") + os.system("python3 -m pip install -U discord.py") #Linux/Mac OS except: - os.system("py3 -m pip install -U discord.py") + os.system("py3 -m pip install -U discord.py") #Windows + + '''Check mcstatus''' try: import mcstatus except: os.system("pip3 install mcstatus") + + '''Check status''' try: import status except: os.system("pip3 install status") + + '''Check dotenv''' try: import dotenv except: diff --git a/lib/setup.py b/lib/setup.py index 4c4cbca..4369073 100755 --- a/lib/setup.py +++ b/lib/setup.py @@ -9,13 +9,13 @@ def environment(): if overwrite == "y" or overwrite == "yes": print("\nChoose settings to change") for i in settingList: - print("{} - {}".format((settingList.index(i)+1), i)) + print("{} - {}".format((settingList.index(i)+1), i)) #Lists all the options to set settingsChoice = input("\nInput the numbers of the settings you want to change\nYou can change multiple numbers by typing more than one (Example: 12345)\n > ") else: return #Exit function - else: + else: #If the environment file has not been set settingsChoice = "" - for s in range(1, len(settingList)+1): + for s in range(1, len(settingList)+1): #Goes through all the options and selects all of them to set settingsChoice = settingsChoice + str(s) '''Gets information''' @@ -23,6 +23,8 @@ def environment(): token = input("Input your bot token here > ") else: token = os.environ['TOKEN'] + + '''Sets the IP/address of the server''' if str(settingList.index("Server address/IP")+1) in settingsChoice: serverIP = input("Input your server address/IP here > ") differentIP = input("Is this different from the public URL/IP? (y/n) > ") @@ -34,18 +36,24 @@ def environment(): else: serverIP = os.environ['SERVER'] externalIP = os.environ['EXTSERVER'] + + '''Sets the port used for the minecraft server''' if str(settingList.index("Port")+1) in settingsChoice: port = input("Input your bot port here (If you don't know it, leave blank) > ") if port == "": port = "25565" #Default Minecraft server port else: port = os.environ['PORT'] + + '''Sets the prefix for the command usage''' if str(settingList.index("Command Prefix")+1) in settingsChoice: commandPrefix = input("If you want a custom command prefix, enter is here (Default is '?' - Leave bank for default)> ") if commandPrefix == "": commandPrefix = "?" else: commandPrefix = os.environ['PREFIX'] + + '''Sets the option for the custom file''' if str(settingList.index("Custom File")+1) in settingsChoice: customFile = input("Would you like a custom file to add your code to? (y/n) > ") customFile = customFile.lower() @@ -82,6 +90,8 @@ def environment(): custom = "TRUE" else: custom = os.environ['CUSTOM'] + + '''Sets the URL for the server map''' if str(settingList.index("Server Map")+1) in settingsChoice: mapCheck = input("Do you have an online map on your server? (y/n) > ") mapCheck = mapCheck.lower() @@ -94,6 +104,7 @@ def environment(): else: mapURL = os.environ['MAP'] + '''Set the world download URL''' if str(settingList.index("World Downloads")+1) in settingsChoice: worldCheck = input("Do you have an online world download on your server? (y/n) > ") worldCheck = worldCheck.lower() @@ -106,6 +117,7 @@ def environment(): else: worldURL = os.environ['DOWNLOAD'] + '''Sets the anti-spam variable''' if str(settingList.index("Anti Spam")+1) in settingsChoice: spam = input("Stop users from spamming commands? (y/n) > ") spam = spam.lower() @@ -116,6 +128,7 @@ def environment(): else: antiSpam = os.environ['ANTISPAM'] + '''Sets the name of the server owner''' if str(settingList.index("Owner Name")+1) in settingsChoice: owner = input("What's the name of the server owner? > ") else: diff --git a/run.py b/run.py index b69587a..7004cd5 100755 --- a/run.py +++ b/run.py @@ -1,15 +1,14 @@ def run(): from lib import librarySetup - librarySetup.checkLibraries() + librarySetup.checkLibraries() #Check and install libraries from lib import setup #from lib import online import os - - if not os.path.isfile('.env'): + if not os.path.isfile('.env'): #Initial setup setup.environment() - os.system("python3 lib/bot.py") + os.system("python3 lib/bot.py") #Run main program run() \ No newline at end of file