Skip to content
Permalink
Browse files
Added prefix into code
  • Loading branch information
hollan84 committed May 3, 2020
1 parent 93faa04 commit e7caca9b84f7580e0a0e86f86a45f7339a7fa582
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
BIN +205 Bytes (110%) lib/__pycache__/setup.cpython-36.pyc
Binary file not shown.
@@ -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,15 +82,15 @@ 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]
f = open(path, "w")
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
@@ -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")

0 comments on commit e7caca9

Please sign in to comment.