Skip to content
Permalink
Browse files
Added some comments
  • Loading branch information
hollan84 committed May 3, 2020
1 parent 5c52f8c commit 9aebe3fa3bbdd0a8d2cc535fcf6e1d0b56797a02
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
@@ -3,25 +3,34 @@ def checkLibraries():
import getpass import getpass
import os import os


'''Check to see if pip3 is installed'''
try: try:
os.system("pip3 -V") os.system("pip3 -V")
except: except:
os.system("sudo apt install python3-pip") os.system("sudo apt install python3-pip")

'''Check discord.py'''
try: try:
import discord import discord
except: except:
try: try:
os.system("python3 -m pip install -U discord.py") os.system("python3 -m pip install -U discord.py") #Linux/Mac OS
except: except:
os.system("py3 -m pip install -U discord.py") os.system("py3 -m pip install -U discord.py") #Windows

'''Check mcstatus'''
try: try:
import mcstatus import mcstatus
except: except:
os.system("pip3 install mcstatus") os.system("pip3 install mcstatus")

'''Check status'''
try: try:
import status import status
except: except:
os.system("pip3 install status") os.system("pip3 install status")

'''Check dotenv'''
try: try:
import dotenv import dotenv
except: except:
@@ -9,20 +9,22 @@ def environment():
if overwrite == "y" or overwrite == "yes": if overwrite == "y" or overwrite == "yes":
print("\nChoose settings to change") print("\nChoose settings to change")
for i in settingList: 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 > ") 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: else:
return #Exit function return #Exit function
else: else: #If the environment file has not been set
settingsChoice = "" 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) settingsChoice = settingsChoice + str(s)


'''Gets information''' '''Gets information'''
if str(settingList.index("Token")+1) in settingsChoice: if str(settingList.index("Token")+1) in settingsChoice:
token = input("Input your bot token here > ") token = input("Input your bot token here > ")
else: else:
token = os.environ['TOKEN'] token = os.environ['TOKEN']

'''Sets the IP/address of the server'''
if str(settingList.index("Server address/IP")+1) in settingsChoice: if str(settingList.index("Server address/IP")+1) in settingsChoice:
serverIP = input("Input your server address/IP here > ") serverIP = input("Input your server address/IP here > ")
differentIP = input("Is this different from the public URL/IP? (y/n) > ") differentIP = input("Is this different from the public URL/IP? (y/n) > ")
@@ -34,18 +36,24 @@ def environment():
else: else:
serverIP = os.environ['SERVER'] serverIP = os.environ['SERVER']
externalIP = os.environ['EXTSERVER'] externalIP = os.environ['EXTSERVER']

'''Sets the port used for the minecraft server'''
if str(settingList.index("Port")+1) in settingsChoice: if str(settingList.index("Port")+1) in settingsChoice:
port = input("Input your bot port here (If you don't know it, leave blank) > ") port = input("Input your bot port here (If you don't know it, leave blank) > ")
if port == "": if port == "":
port = "25565" #Default Minecraft server port port = "25565" #Default Minecraft server port
else: else:
port = os.environ['PORT'] port = os.environ['PORT']

'''Sets the prefix for the command usage'''
if str(settingList.index("Command Prefix")+1) in settingsChoice: 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)> ") commandPrefix = input("If you want a custom command prefix, enter is here (Default is '?' - Leave bank for default)> ")
if commandPrefix == "": if commandPrefix == "":
commandPrefix = "?" commandPrefix = "?"
else: else:
commandPrefix = os.environ['PREFIX'] commandPrefix = os.environ['PREFIX']

'''Sets the option for the custom file'''
if str(settingList.index("Custom File")+1) in settingsChoice: 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 = input("Would you like a custom file to add your code to? (y/n) > ")
customFile = customFile.lower() customFile = customFile.lower()
@@ -82,6 +90,8 @@ def environment():
custom = "TRUE" custom = "TRUE"
else: else:
custom = os.environ['CUSTOM'] custom = os.environ['CUSTOM']

'''Sets the URL for the server map'''
if str(settingList.index("Server Map")+1) in settingsChoice: if str(settingList.index("Server Map")+1) in settingsChoice:
mapCheck = input("Do you have an online map on your server? (y/n) > ") mapCheck = input("Do you have an online map on your server? (y/n) > ")
mapCheck = mapCheck.lower() mapCheck = mapCheck.lower()
@@ -94,6 +104,7 @@ def environment():
else: else:
mapURL = os.environ['MAP'] mapURL = os.environ['MAP']


'''Set the world download URL'''
if str(settingList.index("World Downloads")+1) in settingsChoice: if str(settingList.index("World Downloads")+1) in settingsChoice:
worldCheck = input("Do you have an online world download on your server? (y/n) > ") worldCheck = input("Do you have an online world download on your server? (y/n) > ")
worldCheck = worldCheck.lower() worldCheck = worldCheck.lower()
@@ -106,6 +117,7 @@ def environment():
else: else:
worldURL = os.environ['DOWNLOAD'] worldURL = os.environ['DOWNLOAD']


'''Sets the anti-spam variable'''
if str(settingList.index("Anti Spam")+1) in settingsChoice: if str(settingList.index("Anti Spam")+1) in settingsChoice:
spam = input("Stop users from spamming commands? (y/n) > ") spam = input("Stop users from spamming commands? (y/n) > ")
spam = spam.lower() spam = spam.lower()
@@ -116,6 +128,7 @@ def environment():
else: else:
antiSpam = os.environ['ANTISPAM'] antiSpam = os.environ['ANTISPAM']


'''Sets the name of the server owner'''
if str(settingList.index("Owner Name")+1) in settingsChoice: if str(settingList.index("Owner Name")+1) in settingsChoice:
owner = input("What's the name of the server owner? > ") owner = input("What's the name of the server owner? > ")
else: else:
7 run.py
@@ -1,15 +1,14 @@
def run(): def run():


from lib import librarySetup from lib import librarySetup
librarySetup.checkLibraries() librarySetup.checkLibraries() #Check and install libraries


from lib import setup from lib import setup
#from lib import online #from lib import online
import os import os



if not os.path.isfile('.env'): if not os.path.isfile('.env'): #Initial setup
setup.environment() setup.environment()


os.system("python3 lib/bot.py") os.system("python3 lib/bot.py") #Run main program
run() run()

0 comments on commit 9aebe3f

Please sign in to comment.