Skip to content
Permalink
f05950ff97
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 42 lines (37 sloc) 1.48 KB
def environment():
import os.path
'''Prevents overwriting of the environment file'''
if os.path.isfile('.env'): #Checks to see if there is an environment file
overwrite = input("Would you like to overwrite your current credentials? (y/n)")
overwrite = overwrite.lower() #Makes the input string lowercase
if overwrite == "y" or overwrite == "yes":
print("Creating new credientials... \n")
else:
return #Exit function
'''Gets information'''
token = input("Input your bot token here > ")
serverIP = input("Input your server URL/IP here > ")
port = input("Input your bot port here (If you don't know it, leave blank) > ")
if port == "":
port = "25565" #Default Minecraft server port
'''Concantinate into a string'''
data = "TOKEN={}\nSERVER={}\nPORT={}".format(token,serverIP,port) #Sets the format of the data
'''Write data to the .env file'''
creds = open(".env", "w")
creds.write(data)
creds.close()
'''Verify the data has been written'''
print("\nVerifying data..")
verify = open(".env")
readData = verify.read()
verify.close()
if data == readData:
print("Data written successfully")
return
else:
tryAgain = ("Error writing data. \n Try again? (y/n) > ")
tryAgain = tryAgain.lower() #Makes the input string lowercase
if tryAgain == "y" or tryAgain == "yes":
environment()
else:
return