From dc02368709d3255fb785223dae86bc154cd98ffc Mon Sep 17 00:00:00 2001 From: Alastair Holland Date: Sun, 3 May 2020 12:48:18 +0100 Subject: [PATCH] Added custom code backup --- .gitignore | 5 ++++- lib/bot.py | 2 +- lib/setup.py | 20 +++++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index e40a23e..f199a59 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .env -nicknames/ \ No newline at end of file +Custom.py + +nicknames/ +oldCustom/ \ No newline at end of file diff --git a/lib/bot.py b/lib/bot.py index e5f0fde..d3ec1c6 100755 --- a/lib/bot.py +++ b/lib/bot.py @@ -48,7 +48,7 @@ async def on_message(message): elif message.content.startswith('?map'): msg = "http://map.alastairserver.co.uk" elif message.content.startswith('?servername'): - msg = "http://minecraft.alastairserver.co.uk \nhttp://server.alastairserver.co.uk" + 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'): diff --git a/lib/setup.py b/lib/setup.py index 2ffc72f..555b53b 100755 --- a/lib/setup.py +++ b/lib/setup.py @@ -45,9 +45,11 @@ def environment(): newCustom = input("Do you want to overwrite the current custom file? (y/n) > ") newCustom = newCustom.lower() if newCustom == "y" or newCustom == "yes": - oldFile = open("customCode.py", "r") + oldFile = open("Custom.py", "r") oldCode = oldFile.read() oldFile.close() + if not os.path.exists("oldCustom"): + os.makedirs("oldCustom") x = 0 copied = False while copied == False: @@ -58,17 +60,17 @@ def environment(): copied = True x = x + 1 template = open("templates/customTemplate.py", "r") - customFile = open("customCode.py", "w") + customFile = open("Custom.py", "w") customFile.write(template.read()) customFile.close() template.close() - else: - template = open("templates/customTemplate.py", "r") - customFile = open("customCode.py", "w") - customFile.write(template.read()) - customFile.close() - template.close() - custom = "TRUE" + else: + template = open("templates/customTemplate.py", "r") + customFile = open("Custom.py", "w") + customFile.write(template.read()) + customFile.close() + template.close() + custom = "TRUE" else: custom = os.environ['CUSTOM']