Custom prefix, can now change settings on the fly

!setting [setting] [value]
This commit is contained in:
Twentysix
2016-01-25 21:49:25 +01:00
parent ef05727477
commit 970c3a5ef0
3 changed files with 366 additions and 294 deletions

View File

@@ -5,7 +5,7 @@ import glob
default_settings = ('{"TRIVIA_ADMIN_ONLY": false, "EDIT_CC_ADMIN_ONLY": false, "PASSWORD": "PASSWORDHERE", "FILTER": true, "CUSTOMCOMMANDS": true, ' +
'"TRIVIA_MAX_SCORE": 10, "TRIVIA_DELAY": 15, "LOGGING": true, "EMAIL": "EMAILHERE", "ADMINROLE": "Transistor", "DOWNLOADMODE" : true, ' +
'"VOLUME": 0.20, "TRIVIA_BOT_PLAYS" : false, "TRIVIA_TIMEOUT" : 120, "DEBUG_ID" : "IgnoreThis", "POLL_DURATION" : 60}')
'"VOLUME": 0.20, "TRIVIA_BOT_PLAYS" : false, "TRIVIA_TIMEOUT" : 120, "DEBUG_ID" : "IgnoreThis", "POLL_DURATION" : 60, "PREFIX" : "!"}')
default_apis = ('{"IMGFLIP_USERNAME": "USERNAMEHERE", "IMGFLIP_PASSWORD": "PASSWORDHERE", "MYAPIFILMS_TOKEN" : "TOKENHERE"}')
@@ -99,12 +99,19 @@ def createEmptyFiles():
admin_role = input(">")
if admin_role == "":
admin_role = "Transistor"
print("Command prefix? Leave empty for default, '!'. Maximum 1 character.")
prefix = input(">")
if len(prefix) != 1 or prefix == " ":
print("Invalid prefix. Setting prefix as '!'...")
prefix = "!"
new_settings = json.loads(default_settings)
new_settings["EMAIL"] = email
new_settings["PASSWORD"] = password
new_settings["ADMINROLE"] = admin_role
new_settings["PREFIX"] = prefix
fileIO("json/settings.json", "save", new_settings )
logger.info("Settings have been saved.")
if not os.path.isfile("json/apis.json"):
logger.info("Missing apis.json. Creating it...\n")
fileIO("json/apis.json", "save", json.loads(default_apis))