From 993079d2dd9a596a1e68cbe294bb4c591c9f1424 Mon Sep 17 00:00:00 2001 From: Nyo Date: Tue, 17 May 2016 23:40:34 +0200 Subject: [PATCH] .BANCHO. .FIX. Fix mod rank login error, add exception output at login, add some modules --- cantSpectateEvent.py | 4 ++-- changeActionEvent.py | 2 +- changeMatchModsEvent.py | 2 +- changeMatchSettingsEvent.py | 4 ++-- changeSlotEvent.py | 4 ++-- channelJoinEvent.py | 4 ++-- channelPartEvent.py | 4 ++-- constants/__init__.py | 0 actions.py => constants/actions.py | 0 bcolors.py => constants/bcolors.py | 0 mods.py => constants/mods.py | 0 createMatchEvent.py | 4 ++-- databaseHelper.py | 4 ++-- events/__init__.py | 0 fokabot.py | 2 +- handlers/__init__.py | 0 helpers/__init__.py | 0 consoleHelper.py => helpers/consoleHelper.py | 2 +- joinLobbyEvent.py | 4 ++-- joinMatchEvent.py | 4 ++-- locationHelper.py | 4 ++-- loginEvent.py | 12 +++++++++--- logoutEvent.py | 4 ++-- match.py | 4 ++-- objects/__init__.py | 0 osuToken.py | 6 +++--- partLobbyEvent.py | 4 ++-- pep.py | 4 ++-- sendPrivateMessageEvent.py | 4 ++-- sendPublicMessageEvent.py | 4 ++-- serverPackets.py | 2 +- spectateFramesEvent.py | 4 ++-- startSpectatingEvent.py | 4 ++-- stopSpectatingEvent.py | 4 ++-- systemHelper.py | 4 ++-- 35 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 constants/__init__.py rename actions.py => constants/actions.py (100%) rename bcolors.py => constants/bcolors.py (100%) rename mods.py => constants/mods.py (100%) create mode 100644 events/__init__.py create mode 100644 handlers/__init__.py create mode 100644 helpers/__init__.py rename consoleHelper.py => helpers/consoleHelper.py (98%) create mode 100644 objects/__init__.py diff --git a/cantSpectateEvent.py b/cantSpectateEvent.py index 698ddc2..0b9abc5 100644 --- a/cantSpectateEvent.py +++ b/cantSpectateEvent.py @@ -1,7 +1,7 @@ import glob import serverPackets -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import exceptions def handle(userToken, packetData): diff --git a/changeActionEvent.py b/changeActionEvent.py index b7505c3..93abab6 100644 --- a/changeActionEvent.py +++ b/changeActionEvent.py @@ -1,7 +1,7 @@ import glob import clientPackets import serverPackets -import actions +from constants import actions import userHelper def handle(userToken, packetData): diff --git a/changeMatchModsEvent.py b/changeMatchModsEvent.py index fb4ee02..b2d1535 100644 --- a/changeMatchModsEvent.py +++ b/changeMatchModsEvent.py @@ -1,7 +1,7 @@ import glob import clientPackets import matchModModes -import mods +from constants import mods def handle(userToken, packetData): # Get token data diff --git a/changeMatchSettingsEvent.py b/changeMatchSettingsEvent.py index c82cda5..d67b7ee 100644 --- a/changeMatchSettingsEvent.py +++ b/changeMatchSettingsEvent.py @@ -1,8 +1,8 @@ import glob import clientPackets import matchModModes -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import random import matchTeamTypes import matchTeams diff --git a/changeSlotEvent.py b/changeSlotEvent.py index b20b2db..c1a7932 100644 --- a/changeSlotEvent.py +++ b/changeSlotEvent.py @@ -1,7 +1,7 @@ import clientPackets import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors def handle(userToken, packetData): # Get usertoken data diff --git a/channelJoinEvent.py b/channelJoinEvent.py index 25aaf2b..6ada57d 100644 --- a/channelJoinEvent.py +++ b/channelJoinEvent.py @@ -3,8 +3,8 @@ Event called when someone joins a channel """ import clientPackets -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import serverPackets import glob import exceptions diff --git a/channelPartEvent.py b/channelPartEvent.py index 9c34cd7..849b939 100644 --- a/channelPartEvent.py +++ b/channelPartEvent.py @@ -2,8 +2,8 @@ Event called when someone parts a channel """ -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import glob import clientPackets import serverPackets diff --git a/constants/__init__.py b/constants/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/actions.py b/constants/actions.py similarity index 100% rename from actions.py rename to constants/actions.py diff --git a/bcolors.py b/constants/bcolors.py similarity index 100% rename from bcolors.py rename to constants/bcolors.py diff --git a/mods.py b/constants/mods.py similarity index 100% rename from mods.py rename to constants/mods.py diff --git a/createMatchEvent.py b/createMatchEvent.py index 3eca989..e27ebc1 100644 --- a/createMatchEvent.py +++ b/createMatchEvent.py @@ -1,8 +1,8 @@ import serverPackets import clientPackets import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import joinMatchEvent import exceptions diff --git a/databaseHelper.py b/databaseHelper.py index a4a584d..43e6a95 100644 --- a/databaseHelper.py +++ b/databaseHelper.py @@ -1,6 +1,6 @@ import pymysql -import bcolors -import consoleHelper +from constants import bcolors +from helpers import consoleHelper import threading import glob diff --git a/events/__init__.py b/events/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fokabot.py b/fokabot.py index 169668c..40fc873 100644 --- a/fokabot.py +++ b/fokabot.py @@ -1,7 +1,7 @@ """FokaBot related functions""" import userHelper import glob -import actions +from constants import actions import serverPackets import fokabotCommands diff --git a/handlers/__init__.py b/handlers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/helpers/__init__.py b/helpers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/consoleHelper.py b/helpers/consoleHelper.py similarity index 98% rename from consoleHelper.py rename to helpers/consoleHelper.py index 3fcfb0b..6195b89 100644 --- a/consoleHelper.py +++ b/helpers/consoleHelper.py @@ -1,6 +1,6 @@ """Some console related functions""" -import bcolors +from constants import bcolors import glob def printServerStartHeader(asciiArt): diff --git a/joinLobbyEvent.py b/joinLobbyEvent.py index 8f639c6..fef37d2 100644 --- a/joinLobbyEvent.py +++ b/joinLobbyEvent.py @@ -1,7 +1,7 @@ import serverPackets import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors def handle(userToken, _): # Get userToken data diff --git a/joinMatchEvent.py b/joinMatchEvent.py index d483d4d..d242b52 100644 --- a/joinMatchEvent.py +++ b/joinMatchEvent.py @@ -1,8 +1,8 @@ import clientPackets import serverPackets import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import exceptions def handle(userToken, packetData): diff --git a/locationHelper.py b/locationHelper.py index d3c0306..77eb76a 100644 --- a/locationHelper.py +++ b/locationHelper.py @@ -1,8 +1,8 @@ import urllib.request import json -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors # API URL URL = "http://ip.zxq.co/" diff --git a/loginEvent.py b/loginEvent.py index 15855a4..0d08d76 100644 --- a/loginEvent.py +++ b/loginEvent.py @@ -2,13 +2,15 @@ import userHelper import serverPackets import exceptions import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import locationHelper import countryHelper import time import generalFunctions import channelJoinEvent +import sys +import traceback def handle(flaskRequest): # Data to return @@ -123,7 +125,7 @@ def handle(flaskRequest): responseToken.enqueue(serverPackets.onlineUsers()) # Get location and country from ip.zxq.co or database - if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]): + if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]): # Get location and country from IP location = locationHelper.getLocation(requestIP) countryLetters = locationHelper.getCountry(requestIP) @@ -170,6 +172,10 @@ def handle(flaskRequest): # Bancho is restarting responseData += serverPackets.notification("Bancho is restarting. Try again in a few minutes.") responseData += serverPackets.loginError() + except: + # Unknown exception + msg = "UNKNOWN ERROR IN LOGIN!!!\n{}\n{}".format(sys.exc_info(), traceback.format_exc()) + consoleHelper.printColored("[!] {}".format(msg), bcolors.RED) finally: # Print login failed message to console if needed if err == True: diff --git a/logoutEvent.py b/logoutEvent.py index fbbff40..43f991a 100644 --- a/logoutEvent.py +++ b/logoutEvent.py @@ -1,6 +1,6 @@ import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import serverPackets import time diff --git a/match.py b/match.py index a309ba0..83824cc 100644 --- a/match.py +++ b/match.py @@ -5,8 +5,8 @@ import matchTeamTypes import matchModModes import slotStatuses import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import serverPackets import dataTypes import matchTeams diff --git a/objects/__init__.py b/objects/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/osuToken.py b/osuToken.py index 7ac5493..eb9b363 100644 --- a/osuToken.py +++ b/osuToken.py @@ -1,10 +1,10 @@ import uuid -import actions +from constants import actions import gameModes import userHelper import time -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import serverPackets import logoutEvent diff --git a/partLobbyEvent.py b/partLobbyEvent.py index 4136c2b..a9f2273 100644 --- a/partLobbyEvent.py +++ b/partLobbyEvent.py @@ -1,7 +1,7 @@ import glob import channelPartEvent -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors def handle(userToken, _): # Get usertoken data diff --git a/pep.py b/pep.py index 5c041cc..931e34c 100644 --- a/pep.py +++ b/pep.py @@ -10,7 +10,7 @@ from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop # pep.py files -import bcolors +from constants import bcolors import packetIDs import serverPackets import config @@ -58,7 +58,7 @@ import matchChangeTeamEvent # pep.py helpers import packetHelper -import consoleHelper +from helpers import consoleHelper import databaseHelper import responseHelper import generalFunctions diff --git a/sendPrivateMessageEvent.py b/sendPrivateMessageEvent.py index 3b23a38..46a244a 100644 --- a/sendPrivateMessageEvent.py +++ b/sendPrivateMessageEvent.py @@ -1,5 +1,5 @@ -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import clientPackets import serverPackets import glob diff --git a/sendPublicMessageEvent.py b/sendPublicMessageEvent.py index a20d6e3..c7111e7 100644 --- a/sendPublicMessageEvent.py +++ b/sendPublicMessageEvent.py @@ -2,8 +2,8 @@ import exceptions import clientPackets import glob import fokabot -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import serverPackets def handle(userToken, packetData): diff --git a/serverPackets.py b/serverPackets.py index f660cf2..017d226 100644 --- a/serverPackets.py +++ b/serverPackets.py @@ -103,7 +103,7 @@ def userPanel(userID): elif rank == 4: userRank = userRanks.ADMIN elif rank == 3: - userRank = userRank.MOD + userRank = userRanks.MOD elif rank == 2: userRank = userRanks.SUPPORTER else: diff --git a/spectateFramesEvent.py b/spectateFramesEvent.py index 7522392..6a6b2bf 100644 --- a/spectateFramesEvent.py +++ b/spectateFramesEvent.py @@ -1,6 +1,6 @@ import glob -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import serverPackets import exceptions diff --git a/startSpectatingEvent.py b/startSpectatingEvent.py index 6e8414d..d6eaf41 100644 --- a/startSpectatingEvent.py +++ b/startSpectatingEvent.py @@ -1,5 +1,5 @@ -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import clientPackets import serverPackets import exceptions diff --git a/stopSpectatingEvent.py b/stopSpectatingEvent.py index acd9761..e558d39 100644 --- a/stopSpectatingEvent.py +++ b/stopSpectatingEvent.py @@ -1,5 +1,5 @@ -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import glob import serverPackets import exceptions diff --git a/systemHelper.py b/systemHelper.py index b381487..0309a8d 100644 --- a/systemHelper.py +++ b/systemHelper.py @@ -4,8 +4,8 @@ import psutil import os import sys -import consoleHelper -import bcolors +from helpers import consoleHelper +from constants import bcolors import threading import signal