.BANCHO. pep.py modules

This commit is contained in:
Nyo 2016-05-18 19:12:46 +02:00
parent 993079d2dd
commit 9325578377
74 changed files with 212 additions and 212 deletions

View File

@ -1,7 +1,7 @@
""" Contains functions used to read specific client packets from byte stream """ """ Contains functions used to read specific client packets from byte stream """
import dataTypes from constants import dataTypes
import packetHelper from helpers import packetHelper
import slotStatuses from constants import slotStatuses
""" General packets """ """ General packets """

View File

@ -1,11 +1,11 @@
import fokabot from objects import fokabot
import random import random
import glob from objects import glob
import serverPackets from constants import serverPackets
import exceptions from constants import exceptions
import userHelper from helpers import userHelper
import time import time
import systemHelper from helpers import systemHelper
""" """
Commands callbacks Commands callbacks

View File

@ -1,12 +1,12 @@
""" Contains functions used to write specific server packets to byte streams """ """ Contains functions used to write specific server packets to byte streams """
import packetHelper from helpers import packetHelper
import dataTypes from constants import dataTypes
import userHelper from helpers import userHelper
import glob from objects import glob
import userRanks from constants import userRanks
import packetIDs from constants import packetIDs
import slotStatuses from constants import slotStatuses
import matchModModes from constants import matchModModes
import random import random
""" Login errors packets """ Login errors packets

View File

@ -1,8 +1,8 @@
import glob from objects import glob
import serverPackets from constants import serverPackets
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import exceptions from constants import exceptions
def handle(userToken, packetData): def handle(userToken, packetData):
# get usertoken data # get usertoken data

View File

@ -1,8 +1,8 @@
import glob from objects import glob
import clientPackets from constants import clientPackets
import serverPackets from constants import serverPackets
from constants import actions from constants import actions
import userHelper from helpers import userHelper
def handle(userToken, packetData): def handle(userToken, packetData):
# Get usertoken data # Get usertoken data

View File

@ -1,6 +1,6 @@
import glob from objects import glob
import clientPackets from constants import clientPackets
import matchModModes from constants import matchModModes
from constants import mods from constants import mods
def handle(userToken, packetData): def handle(userToken, packetData):

View File

@ -1,5 +1,5 @@
import clientPackets from constants import clientPackets
import glob from objects import glob
def handle(userToken, packetData): def handle(userToken, packetData):
# Read packet data. Same structure as changeMatchSettings # Read packet data. Same structure as changeMatchSettings

View File

@ -1,12 +1,12 @@
import glob from objects import glob
import clientPackets from constants import clientPackets
import matchModModes from constants import matchModModes
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import random import random
import matchTeamTypes from constants import matchTeamTypes
import matchTeams from constants import matchTeams
import slotStatuses from constants import slotStatuses
def handle(userToken, packetData): def handle(userToken, packetData):
# Read new settings # Read new settings

View File

@ -1,5 +1,5 @@
import clientPackets from constants import clientPackets
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors

View File

@ -2,12 +2,12 @@
Event called when someone joins a channel Event called when someone joins a channel
""" """
import clientPackets from constants import clientPackets
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import serverPackets from constants import serverPackets
import glob from objects import glob
import exceptions from constants import exceptions
def handle(userToken, packetData): def handle(userToken, packetData):
# Channel join packet # Channel join packet

View File

@ -4,9 +4,9 @@ Event called when someone parts a channel
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import glob from objects import glob
import clientPackets from constants import clientPackets
import serverPackets from constants import serverPackets
def handle(userToken, packetData): def handle(userToken, packetData):
# Channel part packet # Channel part packet

View File

@ -1,10 +1,10 @@
import serverPackets from constants import serverPackets
import clientPackets from constants import clientPackets
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import joinMatchEvent from events import joinMatchEvent
import exceptions from constants import exceptions
def handle(userToken, packetData): def handle(userToken, packetData):
try: try:

View File

@ -1,5 +1,5 @@
import userHelper from helpers import userHelper
import clientPackets from constants import clientPackets
def handle(userToken, packetData): def handle(userToken, packetData):
# Friend add packet # Friend add packet

View File

@ -1,5 +1,5 @@
import userHelper from helpers import userHelper
import clientPackets from constants import clientPackets
def handle(userToken, packetData): def handle(userToken, packetData):
# Friend remove packet # Friend remove packet

View File

@ -1,5 +1,5 @@
import serverPackets from constants import serverPackets
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors

View File

@ -1,9 +1,9 @@
import clientPackets from constants import clientPackets
import serverPackets from constants import serverPackets
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import exceptions from constants import exceptions
def handle(userToken, packetData): def handle(userToken, packetData):
# read packet data # read packet data

View File

@ -1,14 +1,14 @@
import userHelper from helpers import userHelper
import serverPackets from constants import serverPackets
import exceptions from constants import exceptions
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import locationHelper from helpers import locationHelper
import countryHelper from helpers import countryHelper
import time import time
import generalFunctions from helpers import generalFunctions
import channelJoinEvent from events import channelJoinEvent
import sys import sys
import traceback import traceback

View File

@ -1,7 +1,7 @@
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import serverPackets from constants import serverPackets
import time import time
def handle(userToken, _): def handle(userToken, _):

View File

@ -1,4 +1,4 @@
import glob from objects import glob
def handle(userToken, packetData, has): def handle(userToken, packetData, has):
# Get usertoken data # Get usertoken data

View File

@ -1,4 +1,4 @@
import glob from objects import glob
def handle(userToken, _): def handle(userToken, _):
# Read token data # Read token data

View File

@ -1,4 +1,4 @@
import glob from objects import glob
def handle(userToken, packetData): def handle(userToken, packetData):
# Get usertoken data # Get usertoken data

View File

@ -1,4 +1,4 @@
import glob from objects import glob
def handle(userToken, _): def handle(userToken, _):
# Get usertoken data # Get usertoken data

View File

@ -1,6 +1,6 @@
import glob from objects import glob
import slotStatuses from constants import slotStatuses
import serverPackets from constants import serverPackets
def handle(userToken, packetData): def handle(userToken, packetData):
# Get usertoken data # Get usertoken data

View File

@ -1,3 +1,3 @@
import matchBeatmapEvent from events import matchBeatmapEvent
def handle(userToken, packetData): def handle(userToken, packetData):
matchBeatmapEvent.handle(userToken, packetData, True) matchBeatmapEvent.handle(userToken, packetData, True)

View File

@ -1,5 +1,5 @@
import clientPackets from constants import clientPackets
import glob from objects import glob
def handle(userToken, packetData): def handle(userToken, packetData):
# Read token and packet data # Read token and packet data

View File

@ -1,5 +1,5 @@
import glob from objects import glob
import clientPackets from constants import clientPackets
def handle(userToken, packetData): def handle(userToken, packetData):
# Get token data # Get token data

View File

@ -1,3 +1,3 @@
import matchBeatmapEvent from events import matchBeatmapEvent
def handle(userToken, packetData): def handle(userToken, packetData):
matchBeatmapEvent.handle(userToken, packetData, False) matchBeatmapEvent.handle(userToken, packetData, False)

View File

@ -1,4 +1,4 @@
import glob from objects import glob
def handle(userToken, packetData): def handle(userToken, packetData):
# Get userToken data # Get userToken data

View File

@ -1,4 +1,4 @@
import glob from objects import glob
def handle(userToken, _): def handle(userToken, _):
# Get usertoken data # Get usertoken data

View File

@ -1,4 +1,4 @@
import glob from objects import glob
def handle(userToken, packetData): def handle(userToken, packetData):
# Get userToken data # Get userToken data

View File

@ -1,6 +1,6 @@
import glob from objects import glob
import slotStatuses from constants import slotStatuses
import serverPackets from constants import serverPackets
def handle(userToken, _): def handle(userToken, _):
# TODO: Host check # TODO: Host check

View File

@ -1,5 +1,5 @@
import glob from objects import glob
import clientPackets from constants import clientPackets
def handle(userToken, packetData): def handle(userToken, packetData):
# Get packet data # Get packet data

View File

@ -1,5 +1,5 @@
import glob from objects import glob
import channelPartEvent from events import channelPartEvent
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors

View File

@ -1,5 +1,5 @@
import glob from objects import glob
import serverPackets from constants import serverPackets
def handle(userToken, _): def handle(userToken, _):
# get data from usertoken # get data from usertoken

View File

@ -1,11 +1,11 @@
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import clientPackets from constants import clientPackets
import serverPackets from constants import serverPackets
import glob from objects import glob
import fokabot from objects import fokabot
import exceptions from constants import exceptions
import messageTemplates from constants import messageTemplates
def handle(userToken, packetData): def handle(userToken, packetData):
""" """

View File

@ -1,10 +1,10 @@
import exceptions from constants import exceptions
import clientPackets from constants import clientPackets
import glob from objects import glob
import fokabot from objects import fokabot
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import serverPackets from constants import serverPackets
def handle(userToken, packetData): def handle(userToken, packetData):
""" """

View File

@ -1,5 +1,5 @@
import clientPackets from constants import clientPackets
import serverPackets from constants import serverPackets
def handle(userToken, packetData): def handle(userToken, packetData):
# get token data # get token data

View File

@ -1,8 +1,8 @@
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import serverPackets from constants import serverPackets
import exceptions from constants import exceptions
def handle(userToken, packetData): def handle(userToken, packetData):
# get token data # get token data

View File

@ -1,10 +1,10 @@
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import clientPackets from constants import clientPackets
import serverPackets from constants import serverPackets
import exceptions from constants import exceptions
import glob from objects import glob
import userHelper from helpers import userHelper
def handle(userToken, packetData): def handle(userToken, packetData):
try: try:

View File

@ -1,8 +1,8 @@
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import glob from objects import glob
import serverPackets from constants import serverPackets
import exceptions from constants import exceptions
def handle(userToken, _): def handle(userToken, _):
try: try:

View File

@ -3,8 +3,8 @@ WIP feature that will come in the future.
Don't import Don't import
""" """
import flask import flask
import glob from objects import glob
import exceptions from constants import exceptions
@app.route("/api/online-users-count") @app.route("/api/online-users-count")
def APIonlineUsersCount(): def APIonlineUsersCount():

View File

@ -1,7 +1,7 @@
"""Some console related functions""" """Some console related functions"""
from constants import bcolors from constants import bcolors
import glob from objects import glob
def printServerStartHeader(asciiArt): def printServerStartHeader(asciiArt):
"""Print server start header with optional ascii art """Print server start header with optional ascii art

View File

@ -2,7 +2,7 @@ import pymysql
from constants import bcolors from constants import bcolors
from helpers import consoleHelper from helpers import consoleHelper
import threading import threading
import glob from objects import glob
class db: class db:
"""A MySQL database connection""" """A MySQL database connection"""

View File

@ -1,5 +1,5 @@
import struct import struct
import dataTypes from constants import dataTypes
def uleb128Encode(num): def uleb128Encode(num):
""" """

View File

@ -1,4 +1,4 @@
import crypt from helpers import cryptHelper
import base64 import base64
import bcrypt import bcrypt
@ -12,24 +12,24 @@ def checkOldPassword(password, salt, rightPassword):
return -- bool return -- bool
""" """
return (rightPassword == crypt.crypt(password, "$2y$"+str(base64.b64decode(salt)))) return (rightPassword == cryptHelper.crypt(password, "$2y$"+str(base64.b64decode(salt))))
def checkNewPassword(password, dbPassword): def checkNewPassword(password, dbPassword):
""" """
Check if a password (version 2) is right. Check if a password (version 2) is right.
password -- input password password -- input password
dbPassword -- the password in the database dbPassword -- the password in the database
return -- bool return -- bool
""" """
password = password.encode("utf8") password = password.encode("utf8")
dbPassword = dbPassword.encode("utf8") dbPassword = dbPassword.encode("utf8")
return bcrypt.hashpw(password, dbPassword) == dbPassword return bcrypt.hashpw(password, dbPassword) == dbPassword
def genBcrypt(password): def genBcrypt(password):
""" """
Bcrypts a password. Bcrypts a password.
password -- the password to hash. password -- the password to hash.
return -- bytestring return -- bytestring
""" """

View File

@ -1,5 +1,5 @@
import glob from objects import glob
import serverPackets from constants import serverPackets
import psutil import psutil
import os import os
import sys import sys

View File

@ -1,7 +1,7 @@
import passwordHelper from helpers import passwordHelper
import gameModes from constants import gameModes
import generalFunctions from helpers import generalFunctions
import glob from objects import glob
def getID(username): def getID(username):
""" """

View File

@ -1,5 +1,5 @@
import glob from objects import glob
import generalFunctions from helpers import generalFunctions
class banchoConfig: class banchoConfig:
""" """

View File

@ -1,5 +1,5 @@
import glob from objects import glob
import channel from objects import channel
class channelList: class channelList:
""" """

View File

@ -1,9 +1,9 @@
"""FokaBot related functions""" """FokaBot related functions"""
import userHelper from helpers import userHelper
import glob from objects import glob
from constants import actions from constants import actions
import serverPackets from constants import serverPackets
import fokabotCommands from constants import fokabotCommands
def connect(): def connect():
"""Add FokaBot to connected users and send userpanel/stats packet to everyone""" """Add FokaBot to connected users and send userpanel/stats packet to everyone"""

View File

@ -1,8 +1,8 @@
"""Global objects and variables""" """Global objects and variables"""
import tokenList from objects import tokenList
import channelList from objects import channelList
import matchList from objects import matchList
VERSION = "0.9" VERSION = "0.9"

View File

@ -1,15 +1,15 @@
# TODO: Enqueue all # TODO: Enqueue all
import gameModes from constants import gameModes
import matchScoringTypes from constants import matchScoringTypes
import matchTeamTypes from constants import matchTeamTypes
import matchModModes from constants import matchModModes
import slotStatuses from constants import slotStatuses
import glob from objects import glob
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import serverPackets from constants import serverPackets
import dataTypes from constants import dataTypes
import matchTeams from constants import matchTeams
class match: class match:
"""Multiplayer match object""" """Multiplayer match object"""

View File

@ -1,6 +1,6 @@
import match from objects import match
import glob from objects import glob
import serverPackets from constants import serverPackets
class matchList: class matchList:
matches = {} matches = {}

View File

@ -1,12 +1,12 @@
import uuid import uuid
from constants import actions from constants import actions
import gameModes from constants import gameModes
import userHelper from helpers import userHelper
import time import time
from helpers import consoleHelper from helpers import consoleHelper
from constants import bcolors from constants import bcolors
import serverPackets from constants import serverPackets
import logoutEvent from events import logoutEvent
class token: class token:
"""Osu Token object """Osu Token object

View File

@ -1,7 +1,7 @@
import osuToken from objects import osuToken
import time import time
import threading import threading
import logoutEvent from events import logoutEvent
class tokenList: class tokenList:
""" """

98
pep.py
View File

@ -11,58 +11,58 @@ from tornado.ioloop import IOLoop
# pep.py files # pep.py files
from constants import bcolors from constants import bcolors
import packetIDs from constants import packetIDs
import serverPackets from constants import serverPackets
import config from helpers import configHelper
import exceptions from constants import exceptions
import glob from objects import glob
import fokabot from objects import fokabot
import banchoConfig from objects import banchoConfig
import sendPublicMessageEvent from events import sendPublicMessageEvent
import sendPrivateMessageEvent from events import sendPrivateMessageEvent
import channelJoinEvent from events import channelJoinEvent
import channelPartEvent from events import channelPartEvent
import changeActionEvent from events import changeActionEvent
import cantSpectateEvent from events import cantSpectateEvent
import startSpectatingEvent from events import startSpectatingEvent
import stopSpectatingEvent from events import stopSpectatingEvent
import spectateFramesEvent from events import spectateFramesEvent
import friendAddEvent from events import friendAddEvent
import friendRemoveEvent from events import friendRemoveEvent
import logoutEvent from events import logoutEvent
import loginEvent from events import loginEvent
import setAwayMessageEvent from events import setAwayMessageEvent
import joinLobbyEvent from events import joinLobbyEvent
import createMatchEvent from events import createMatchEvent
import partLobbyEvent from events import partLobbyEvent
import changeSlotEvent from events import changeSlotEvent
import joinMatchEvent from events import joinMatchEvent
import partMatchEvent from events import partMatchEvent
import changeMatchSettingsEvent from events import changeMatchSettingsEvent
import changeMatchPasswordEvent from events import changeMatchPasswordEvent
import changeMatchModsEvent from events import changeMatchModsEvent
import matchReadyEvent from events import matchReadyEvent
import matchLockEvent from events import matchLockEvent
import matchStartEvent from events import matchStartEvent
import matchPlayerLoadEvent from events import matchPlayerLoadEvent
import matchSkipEvent from events import matchSkipEvent
import matchFramesEvent from events import matchFramesEvent
import matchCompleteEvent from events import matchCompleteEvent
import matchNoBeatmapEvent from events import matchNoBeatmapEvent
import matchHasBeatmapEvent from events import matchHasBeatmapEvent
import matchTransferHostEvent from events import matchTransferHostEvent
import matchFailedEvent from events import matchFailedEvent
import matchInviteEvent from events import matchInviteEvent
import matchChangeTeamEvent from events import matchChangeTeamEvent
# pep.py helpers # pep.py helpers
import packetHelper from helpers import packetHelper
from helpers import consoleHelper from helpers import consoleHelper
import databaseHelper from helpers import databaseHelper
import responseHelper from helpers import responseHelper
import generalFunctions from helpers import generalFunctions
import systemHelper from helpers import systemHelper
# Create flask instance # Create flask instance
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -249,7 +249,7 @@ if __name__ == "__main__":
# Read config.ini # Read config.ini
consoleHelper.printNoNl("> Loading config file... ") consoleHelper.printNoNl("> Loading config file... ")
glob.conf = config.config("config.ini") glob.conf = configHelper.config("config.ini")
if glob.conf.default == True: if glob.conf.default == True:
# We have generated a default config.ini, quit server # We have generated a default config.ini, quit server