diff --git a/config.json b/config.json deleted file mode 100644 index ca6cb5a..0000000 --- a/config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "support-email": "support@ripple.moe", - "faq": - { - "rules": "Please make sure to check (Ripple's rules)[http://ripple.moe/?p=23].", - "swearing": "Please don't abuse swearing", - "spam": "Please don't spam", - "offend": "Please don't offend other players", - "github": "(Ripple's Github page!)[https://github.com/osuripple/ripple]", - "discord": "(Join Ripple's Discord!)[https://discord.gg/0rJcZruIsA6rXuIx]", - "blog": "You can find the latest Ripple news on the (blog)[https://ripple.moe/blog/]!", - "changelog": "Check the (changelog)[https://ripple.moe/index.php?p=17] !", - "status": "Check the server status (here!)[https://ripple.moe/index.php?p=27]", - "english": "Please keep this channel in english.", - "topic": "Can you please drop the topic and talk about something else?", - "lines": "Please try to keep your sentences on a single line to avoid getting silenced." - } -} \ No newline at end of file diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index 0fbf83f..33f0621 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -51,9 +51,9 @@ def instantRestart(fro, chan, message): def faq(fro, chan, message): key = message[0].lower() - if key not in glob.conf.extra["faq"]: + if key not in glob.conf.extra["pep.py"]["faq"]: return False - return glob.conf.extra["faq"][key] + return glob.conf.extra["pep.py"]["faq"][key] def roll(fro, chan, message): maxPoints = 100 diff --git a/constants/serverPackets.py b/constants/serverPackets.py index 06573bd..c9936d6 100644 --- a/constants/serverPackets.py +++ b/constants/serverPackets.py @@ -16,12 +16,12 @@ def forceUpdate(): def loginBanned(): packets = packetHelper.buildPacket(packetIDs.server_userID, [[-1, dataTypes.SINT32]]) - packets += notification("You are banned. You can appeal after one month since your ban by sending an email to {} from the email address you've used to sign up.".format(glob.conf.extra["support-email"])) + packets += notification("You are banned. You can appeal after one month since your ban by sending an email to {} from the email address you've used to sign up.".format(glob.conf.extra["pep.py"]["support-email"])) return packets def loginLocked(): packets = packetHelper.buildPacket(packetIDs.server_userID, [[-1, dataTypes.SINT32]]) - packets += notification("Your account is locked. You can't log in, but your profile and scores are still visible from the website. If you want to unlock your account, send an email to {} from the email address you've used to sign up.".format(glob.conf.extra["support-email"])) + packets += notification("Your account is locked. You can't log in, but your profile and scores are still visible from the website. If you want to unlock your account, send an email to {} from the email address you've used to sign up.".format(glob.conf.extra["pep.py"]["support-email"])) return packets def loginError(): diff --git a/handlers/mainHandler.pyx b/handlers/mainHandler.pyx index 1341581..f8d96ea 100644 --- a/handlers/mainHandler.pyx +++ b/handlers/mainHandler.pyx @@ -243,7 +243,7 @@ class handler(requestsManager.asyncRequestHandler): @tornado.web.asynchronous @tornado.gen.engine def asyncGet(self): - html = "MA MAURO ESISTE?
"
+		html = 	"MA MAURO ESISTE?
"
 		html += "           _                 __
" html += " (_) / /
" html += " ______ __ ____ ____ / /____
" @@ -262,5 +262,5 @@ class handler(requestsManager.asyncRequestHandler): html += " \\\"\"\"\"\"\"\"\"\"\"\"\"\"\"/
" html += " \\ . .. .. . /
" html += "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
" - html += "
reverse engineering a protocol impossible to reverse engineer since always
we are actually reverse engineering bancho successfully. for the third time.

© Ripple team, 2016
" + html += "
reverse engineering a protocol impossible to reverse engineer since always
we are actually reverse engineering bancho successfully. for the third time.

Running osufx branch.
© Ripple team, 2016
" self.write(html) \ No newline at end of file diff --git a/helpers/configHelper.py b/helpers/configHelper.py index f99ce88..defbf49 100644 --- a/helpers/configHelper.py +++ b/helpers/configHelper.py @@ -73,6 +73,8 @@ class config: self.config.get("localize","enable") self.config.get("localize","ipapiurl") + + self.config.get("custom", "config") return True except configparser.Error: return False @@ -140,6 +142,9 @@ class config: self.config.set("localize", "enable", "1") self.config.set("localize", "ipapiurl", "http://ip.zxq.co") + self.config.add_section("custom") + self.config.set("custom", "config", "common/config.json") + # Write ini to file and close self.config.write(f) f.close() diff --git a/helpers/consoleHelper.py b/helpers/consoleHelper.py index 6f9a17f..fbb0111 100644 --- a/helpers/consoleHelper.py +++ b/helpers/consoleHelper.py @@ -27,8 +27,11 @@ def printServerStartHeader(asciiArt=True): print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^{}".format(bcolors.ENDC)) printColored("> Welcome to pep.py osu!bancho server v{}".format(glob.VERSION), bcolors.GREEN) + printColored("> Common submodule v{}".format(glob.COMMON_VERSION), bcolors.GREEN) printColored("> Made by the Ripple team", bcolors.GREEN) printColored("> {}https://zxq.co/ripple/pep.py".format(bcolors.UNDERLINE), bcolors.GREEN) + printColored("> Custom branch by the osufx team (just Sunpy)", bcolors.GREEN) + printColored("> {}https://github.com/osufx/pep.py".format(bcolors.UNDERLINE), bcolors.GREEN) printColored("> Press CTRL+C to exit\n", bcolors.GREEN) def printNoNl(string): diff --git a/objects/glob.py b/objects/glob.py index 0e10eb7..11d20ad 100644 --- a/objects/glob.py +++ b/objects/glob.py @@ -49,3 +49,11 @@ restarting = False startTime = int(time.time()) streams = streamList.streamList() + +# Additional modifications +COMMON_VERSION_REQ = "1.2.1" +try: + with open("common/version") as f: + COMMON_VERSION = f.read().strip() +except: + COMMON_VERSION = "Unknown" \ No newline at end of file diff --git a/pep.py b/pep.py index 0605a93..02bacdf 100644 --- a/pep.py +++ b/pep.py @@ -1,7 +1,6 @@ import os import sys import threading -import json from multiprocessing.pool import ThreadPool import tornado.gen import tornado.httpserver @@ -10,6 +9,10 @@ import tornado.web from raven.contrib.tornado import AsyncSentryClient import redis +import json +import shutil +from distutils.version import LooseVersion + from common import generalUtils, agpl from common.constants import bcolors from common.db import dbConnector @@ -71,11 +74,6 @@ if __name__ == "__main__": consoleHelper.printNoNl("> Loading config file... ") glob.conf = configHelper.config("config.ini") - # Read additional config file - consoleHelper.printNoNl("> Loading additional config file... ") - with open("config.json", "r") as f: - glob.conf.extra = json.load(f) - if glob.conf.default: # We have generated a default config.ini, quit server consoleHelper.printWarning() @@ -91,6 +89,34 @@ if __name__ == "__main__": sys.exit() else: consoleHelper.printDone() + + # Read additional config file + consoleHelper.printNoNl("> Loading additional config file... ") + try: + if not os.path.isfile(glob.conf.config["custom"]["config"]): + consoleHelper.printWarning() + consoleHelper.printColored("[!] Missing config file at {}; A default one has been generated at this location.".format(glob.conf.config["custom"]["config"]), bcolors.YELLOW) + shutil.copy("common/default_config.json", glob.conf.config["custom"]["config"]) + + with open(glob.conf.config["custom"]["config"], "r") as f: + glob.conf.extra = json.load(f) + + consoleHelper.printDone() + except: + consoleHelper.printWarning() + consoleHelper.printColored("[!] Unable to load custom config at {}".format(glob.conf.config["custom"]["config"]), bcolors.RED) + consoleHelper.printColored("[!] Make sure you have the latest osufx common submodule!", bcolors.RED) + sys.exit() + + # Check if running common module is usable + if glob.COMMON_VERSION == "Unknown": + consoleHelper.printWarning() + consoleHelper.printColored("[!] You do not seem to be using osufx's common submodule... nothing will work...", bcolors.RED) + consoleHelper.printColored("[!] You can download or fork the submodule from {}https://github.com/osufx/ripple-python-common".format(bcolors.UNDERLINE), bcolors.RED) + sys.exit() + elif LooseVersion(glob.COMMON_VERSION_REQ) > LooseVersion(glob.COMMON_VERSION): + consoleHelper.printColored("[!] Your common submodule version is below the required version number for this version of pep.py.", bcolors.RED) + consoleHelper.printColored("[!] You are highly adviced to update your common submodule as stability may vary with outdated modules.", bcolors.RED) # Create data folder if needed consoleHelper.printNoNl("> Checking folders... ")