diff --git a/lib/__pycache__/setup.cpython-36.pyc b/lib/__pycache__/setup.cpython-36.pyc index 0833d59..a0f63a4 100755 Binary files a/lib/__pycache__/setup.cpython-36.pyc and b/lib/__pycache__/setup.cpython-36.pyc differ diff --git a/lib/bot.py b/lib/bot.py index cf96281..d878b44 100755 --- a/lib/bot.py +++ b/lib/bot.py @@ -41,19 +41,28 @@ async def on_message(message): global messagetime msg = "" + prefix = os.environ['PREFIX'] + + commandList = ["map", "server", "help", "download", "status", "minecraftNickname"] + commandList2 = [] + for command in commandList: + commandList2.append(prefix + command) + commandList = commandList2 + '''Checking which command has been issued''' if message.author == client.user: #Make sure that the bot doesn't reply to itself return - - elif message.content.startswith('?map'): + elif message.content.startswith(prefix + 'map'): msg = os.environ['MAP'] - elif message.content.startswith('?servername'): - msg = os.environ['SERVER'] - elif message.content.startswith('?help'): - msg = "Commands: \n - ?help \n - ?servername \n - ?map\n - ?status\n - ?minecraftNickname [USERNAME] [NICKNAME]\n - ?download" - elif message.content.startswith('?download'): + elif message.content.startswith(prefix + 'server'): + msg = os.environ['EXTSERVER'] + elif message.content.startswith(prefix + 'help'): + msg = "Commands:\n" + for command in commandList: + msg = "{} - {}\n".format(msg, command) + elif message.content.startswith(prefix + 'download'): msg = os.environ['DOWNLOAD'] - elif message.content.startswith('?status'): + elif message.content.startswith(prefix + 'status'): try: status = server.status() query = server.query() @@ -73,7 +82,7 @@ async def on_message(message): n.close() except: msg = msg - elif message.content.startswith('?minecraftNickname'): + elif message.content.startswith(prefix + 'minecraftNickname'): splitMessage = message.content splitMessage = splitMessage.split() path = "nicknames/" + splitMessage[1] @@ -81,7 +90,7 @@ async def on_message(message): f.write(splitMessage[2]) f.close() msg = "Set " + splitMessage[1] + "'s nickname to " + splitMessage[2] - elif message.content.startswith('?'): + elif message.content.startswith(prefix): msg = "That is not a valid command, use ?help for help" else: return diff --git a/lib/setup.py b/lib/setup.py index 598c041..c37ceec 100755 --- a/lib/setup.py +++ b/lib/setup.py @@ -2,7 +2,7 @@ def environment(): import os '''Prevents overwriting of the environment file''' - settingList = ["Token", "Server IP", "Port", "Command Prefix", "Custom File", "Server Map", "World Downloads", "Anti Spam", "Owner Name"] + settingList = ["Token", "Server address/IP", "Port", "Command Prefix", "Custom File", "Server Map", "World Downloads", "Anti Spam", "Owner Name"] if os.path.isfile('.env'): #Checks to see if there is an environment file overwrite = input("Would you like to change your current settings? (y/n) > ") overwrite = overwrite.lower() #Makes the input string lowercase @@ -23,8 +23,14 @@ def environment(): token = input("Input your bot token here > ") else: token = os.environ['TOKEN'] - if str(settingList.index("Server IP")+1) in settingsChoice: - serverIP = input("Input your server URL/IP here > ") + 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) > ") + differentIP = differentIP.lower() + if differentIP == "y" or differentIP == "yes": + externalIP = input("Input the public server address here > ") + else: + externalIP = serverIP else: serverIP = os.environ['SERVER'] if str(settingList.index("Port")+1) in settingsChoice: @@ -115,7 +121,7 @@ def environment(): owner = os.environ['ADMINNAME'] '''Concantinate into a string''' - data = "TOKEN={}\nSERVER={}\nPORT={}\nPREFIX={}\nCUSTOM={}\nMAP={}\nDOWNLOAD={}\nANTISPAM={}\nADMINNAME={}".format(token,serverIP,port,commandPrefix,custom,mapURL,worldURL,antiSpam,owner) #Sets the format of the data + data = "TOKEN={}\nSERVER={}\nEXTSERVER={}\nPORT={}\nPREFIX={}\nCUSTOM={}\nMAP={}\nDOWNLOAD={}\nANTISPAM={}\nADMINNAME={}".format(token,serverIP,externalIP,port,commandPrefix,custom,mapURL,worldURL,antiSpam,owner) #Sets the format of the data '''Write data to the .env file''' creds = open(".env", "w")