Add submodules
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
"""Contains user actions"""
|
||||
IDLE = 0
|
||||
AFK = 1
|
||||
PLAYING = 2
|
||||
EDITING = 3
|
||||
MODDING = 4
|
||||
MULTIPLAYER = 5
|
||||
WATCHING = 6
|
||||
UNKNOWN = 7
|
||||
TESTING = 8
|
||||
SUBMITTING = 9
|
||||
PAUSED = 10
|
||||
LOBBY = 11
|
||||
MULTIPLAYING= 12
|
||||
OSU_DIRECT = 13
|
||||
NONE = 14
|
@@ -1,9 +0,0 @@
|
||||
"""Console colors"""
|
||||
PINK = '\033[95m'
|
||||
BLUE = '\033[94m'
|
||||
GREEN = '\033[92m'
|
||||
YELLOW = '\033[93m'
|
||||
RED = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
@@ -1,17 +1,19 @@
|
||||
from objects import fokabot
|
||||
import random
|
||||
from objects import glob
|
||||
from constants import serverPackets
|
||||
from constants import exceptions
|
||||
from helpers import userHelper
|
||||
from helpers import systemHelper
|
||||
import requests
|
||||
import json
|
||||
from constants import mods
|
||||
from helpers import generalFunctions
|
||||
from helpers import logHelper as log
|
||||
from constants import gameModes
|
||||
from constants import privileges
|
||||
import random
|
||||
|
||||
import requests
|
||||
|
||||
from common import generalUtils
|
||||
from common.constants import mods
|
||||
from common.log import logUtils as log
|
||||
from common.ripple import userUtils
|
||||
from constants import exceptions
|
||||
from common.constants import gameModes
|
||||
from common.constants import privileges
|
||||
from constants import serverPackets
|
||||
from helpers import systemHelper
|
||||
from objects import fokabot
|
||||
from objects import glob
|
||||
|
||||
"""
|
||||
Commands callbacks
|
||||
@@ -147,8 +149,8 @@ def silence(fro, chan, message):
|
||||
reason = ' '.join(message[3:])
|
||||
|
||||
# Get target user ID
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
targetUserID = userUtils.getID(target)
|
||||
userID = userUtils.getID(fro)
|
||||
|
||||
# Make sure the user exists
|
||||
if not targetUserID:
|
||||
@@ -177,7 +179,7 @@ def silence(fro, chan, message):
|
||||
targetToken.silence(silenceTime, reason, userID)
|
||||
else:
|
||||
# User offline, silence user only in db
|
||||
userHelper.silence(targetUserID, silenceTime, reason, userID)
|
||||
userUtils.silence(targetUserID, silenceTime, reason, userID)
|
||||
|
||||
# Log message
|
||||
msg = "{} has been silenced for the following reason: {}".format(target, reason)
|
||||
@@ -190,8 +192,8 @@ def removeSilence(fro, chan, message):
|
||||
target = message[0].replace("_", " ")
|
||||
|
||||
# Make sure the user exists
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
targetUserID = userUtils.getID(target)
|
||||
userID = userUtils.getID(fro)
|
||||
if not targetUserID:
|
||||
return "{}: user not found".format(target)
|
||||
|
||||
@@ -202,7 +204,7 @@ def removeSilence(fro, chan, message):
|
||||
targetToken.silence(0, "", userID)
|
||||
else:
|
||||
# user offline, remove islene ofnlt from db
|
||||
userHelper.silence(targetUserID, 0, "", userID)
|
||||
userUtils.silence(targetUserID, 0, "", userID)
|
||||
|
||||
return "{}'s silence reset".format(target)
|
||||
|
||||
@@ -213,13 +215,13 @@ def ban(fro, chan, message):
|
||||
target = message[0].replace("_", " ")
|
||||
|
||||
# Make sure the user exists
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
targetUserID = userUtils.getID(target)
|
||||
userID = userUtils.getID(fro)
|
||||
if not targetUserID:
|
||||
return "{}: user not found".format(target)
|
||||
|
||||
# Set allowed to 0
|
||||
userHelper.ban(targetUserID)
|
||||
userUtils.ban(targetUserID)
|
||||
|
||||
# Send ban packet to the user if he's online
|
||||
targetToken = glob.tokens.getTokenFromUsername(target)
|
||||
@@ -236,13 +238,13 @@ def unban(fro, chan, message):
|
||||
target = message[0].replace("_", " ")
|
||||
|
||||
# Make sure the user exists
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
targetUserID = userUtils.getID(target)
|
||||
userID = userUtils.getID(fro)
|
||||
if not targetUserID:
|
||||
return "{}: user not found".format(target)
|
||||
|
||||
# Set allowed to 1
|
||||
userHelper.unban(targetUserID)
|
||||
userUtils.unban(targetUserID)
|
||||
|
||||
log.rap(userID, "has unbanned {}".format(target), True)
|
||||
return "Welcome back {}!".format(target)
|
||||
@@ -254,13 +256,13 @@ def restrict(fro, chan, message):
|
||||
target = message[0].replace("_", " ")
|
||||
|
||||
# Make sure the user exists
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
targetUserID = userUtils.getID(target)
|
||||
userID = userUtils.getID(fro)
|
||||
if not targetUserID:
|
||||
return "{}: user not found".format(target)
|
||||
|
||||
# Put this user in restricted mode
|
||||
userHelper.restrict(targetUserID)
|
||||
userUtils.restrict(targetUserID)
|
||||
|
||||
# Send restricted mode packet to this user if he's online
|
||||
targetToken = glob.tokens.getTokenFromUsername(target)
|
||||
@@ -277,13 +279,13 @@ def unrestrict(fro, chan, message):
|
||||
target = message[0].replace("_", " ")
|
||||
|
||||
# Make sure the user exists
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
targetUserID = userUtils.getID(target)
|
||||
userID = userUtils.getID(fro)
|
||||
if not targetUserID:
|
||||
return "{}: user not found".format(target)
|
||||
|
||||
# Set allowed to 1
|
||||
userHelper.unrestrict(targetUserID)
|
||||
userUtils.unrestrict(targetUserID)
|
||||
|
||||
log.rap(userID, "has removed restricted mode from {}".format(target), True)
|
||||
return "Welcome back {}!".format(target)
|
||||
@@ -386,7 +388,7 @@ def getPPMessage(userID, just_data = False):
|
||||
currentAcc = token.tillerino[2]
|
||||
|
||||
# Send request to LETS api
|
||||
resp = requests.get("http://127.0.0.1:5002/api/v1/pp?b={}&m={}&a={}".format(currentMap, currentMods, currentAcc), timeout=10).text
|
||||
resp = requests.get("http://127.0.0.1:5002/api/v1/pp?b={}&m={}".format(currentMap, currentMods, currentAcc), timeout=10).text
|
||||
data = json.loads(resp)
|
||||
|
||||
# Make sure status is in response data
|
||||
@@ -405,23 +407,23 @@ def getPPMessage(userID, just_data = False):
|
||||
|
||||
# Return response in chat
|
||||
# Song name and mods
|
||||
msg = "{song}{plus}{mods} ".format(song=data["song_name"], plus="+" if currentMods > 0 else "", mods=generalFunctions.readableMods(currentMods))
|
||||
msg = "{song}{plus}{mods} ".format(song=data["song_name"], plus="+" if currentMods > 0 else "", mods=generalUtils.readableMods(currentMods))
|
||||
|
||||
# PP values
|
||||
if currentAcc == -1:
|
||||
msg += "95%: {pp95}pp | 98%: {pp98}pp | 99% {pp99}pp | 100%: {pp100}pp".format(pp100=data["pp"][0], pp99=data["pp"][1], pp98=data["pp"][2], pp95=data["pp"][3])
|
||||
else:
|
||||
msg += "{acc:.2f}%: {pp}pp".format(acc=token.tillerino[2], pp=data["pp"][0])
|
||||
|
||||
|
||||
originalAR = data["ar"]
|
||||
# calc new AR if HR/EZ is on
|
||||
if (currentMods & mods.Easy) > 0:
|
||||
if (currentMods & mods.EASY) > 0:
|
||||
data["ar"] = max(0, data["ar"] / 2)
|
||||
if (currentMods & mods.HardRock) > 0:
|
||||
if (currentMods & mods.HARDROCK) > 0:
|
||||
data["ar"] = min(10, data["ar"] * 1.4)
|
||||
|
||||
|
||||
arstr = " ({})".format(originalAR) if originalAR != data["ar"] else ""
|
||||
|
||||
|
||||
# Beatmap info
|
||||
msg += " | {bpm} BPM | AR {ar}{arstr} | {stars:.2f} stars".format(bpm=data["bpm"], stars=data["stars"], ar=data["ar"], arstr=arstr)
|
||||
|
||||
@@ -433,10 +435,10 @@ def getPPMessage(userID, just_data = False):
|
||||
except exceptions.apiException:
|
||||
# API error
|
||||
return "Unknown error in LETS API call. Please tell this to a dev."
|
||||
except:
|
||||
#except:
|
||||
# Unknown exception
|
||||
# TODO: print exception
|
||||
return False
|
||||
# return False
|
||||
|
||||
def tillerinoNp(fro, chan, message):
|
||||
try:
|
||||
@@ -455,15 +457,15 @@ def tillerinoNp(fro, chan, message):
|
||||
|
||||
modsEnum = 0
|
||||
mapping = {
|
||||
"-Easy": mods.Easy,
|
||||
"-NoFail": mods.NoFail,
|
||||
"+Hidden": mods.Hidden,
|
||||
"+HardRock": mods.HardRock,
|
||||
"+Nightcore": mods.Nightcore,
|
||||
"+DoubleTime": mods.DoubleTime,
|
||||
"-HalfTime": mods.HalfTime,
|
||||
"+Flashlight": mods.Flashlight,
|
||||
"-SpunOut": mods.SpunOut
|
||||
"-Easy": mods.EASY,
|
||||
"-NoFail": mods.NOFAIL,
|
||||
"+Hidden": mods.HIDDEN,
|
||||
"+HardRock": mods.HARDROCK,
|
||||
"+Nightcore": mods.NIGHTCORE,
|
||||
"+DoubleTime": mods.DOUBLETIME,
|
||||
"-HalfTime": mods.HALFTIME,
|
||||
"+Flashlight": mods.FLASHLIGHT,
|
||||
"-SpunOut": mods.SPUNOUT
|
||||
}
|
||||
|
||||
if playWatch:
|
||||
@@ -513,23 +515,23 @@ def tillerinoMods(fro, chan, message):
|
||||
modsEnum = 0
|
||||
break
|
||||
elif i == "NF":
|
||||
modsEnum += mods.NoFail
|
||||
modsEnum += mods.NOFAIL
|
||||
elif i == "EZ":
|
||||
modsEnum += mods.Easy
|
||||
modsEnum += mods.EASY
|
||||
elif i == "HD":
|
||||
modsEnum += mods.Hidden
|
||||
modsEnum += mods.HIDDEN
|
||||
elif i == "HR":
|
||||
modsEnum += mods.HardRock
|
||||
modsEnum += mods.HARDROCK
|
||||
elif i == "DT":
|
||||
modsEnum += mods.DoubleTime
|
||||
modsEnum += mods.DOUBLETIME
|
||||
elif i == "HT":
|
||||
modsEnum += mods.HalfTime
|
||||
modsEnum += mods.HALFTIME
|
||||
elif i == "NC":
|
||||
modsEnum += mods.Nightcore
|
||||
modsEnum += mods.NIGHTCORE
|
||||
elif i == "FL":
|
||||
modsEnum += mods.Flashlight
|
||||
modsEnum += mods.FLASHLIGHT
|
||||
elif i == "SO":
|
||||
modsEnum += mods.SpunOut
|
||||
modsEnum += mods.SPUNOUT
|
||||
|
||||
# Set mods
|
||||
token.tillerino[1] = modsEnum
|
||||
@@ -582,22 +584,22 @@ def tillerinoLast(fro, chan, message):
|
||||
return False
|
||||
|
||||
diffString = "difficulty_{}".format(gameModes.getGameModeForDB(data["play_mode"]))
|
||||
rank = generalFunctions.getRank(data["play_mode"], data["mods"], data["accuracy"],
|
||||
data["300_count"], data["100_count"], data["50_count"], data["misses_count"])
|
||||
rank = generalUtils.getRank(data["play_mode"], data["mods"], data["accuracy"],
|
||||
data["300_count"], data["100_count"], data["50_count"], data["misses_count"])
|
||||
|
||||
ifPlayer = "{0} | ".format(fro) if chan != "FokaBot" else ""
|
||||
ifFc = " (FC)" if data["max_combo"] == data["fc"] else " {0}x/{1}x".format(data["max_combo"], data["fc"])
|
||||
beatmapLink = "[http://osu.ppy.sh/b/{1} {0}]".format(data["sn"], data["bid"])
|
||||
|
||||
hasPP = data["play_mode"] == gameModes.std or data["play_mode"] == gameModes.mania
|
||||
hasPP = data["play_mode"] == gameModes.STD or data["play_mode"] == gameModes.MANIA
|
||||
|
||||
msg = ifPlayer
|
||||
msg += beatmapLink
|
||||
if data["play_mode"] != gameModes.std:
|
||||
if data["play_mode"] != gameModes.STD:
|
||||
msg += " <{0}>".format(gameModes.getGameModeForPrinting(data["play_mode"]))
|
||||
|
||||
if data["mods"]:
|
||||
msg += ' +' + generalFunctions.readableMods(data["mods"])
|
||||
msg += ' +' + generalUtils.readableMods(data["mods"])
|
||||
|
||||
if not hasPP:
|
||||
msg += " | {0:,}".format(data["score"])
|
||||
@@ -657,9 +659,9 @@ def pp(fro, chan, message):
|
||||
return False
|
||||
if gameMode is None:
|
||||
gameMode = token.gameMode
|
||||
if gameMode == gameModes.taiko or gameMode == gameModes.ctb:
|
||||
if gameMode == gameModes.TAIKO or gameMode == gameModes.CTB:
|
||||
return "PP for your current game mode is not supported yet."
|
||||
pp = userHelper.getPP(token.userID, gameMode)
|
||||
pp = userUtils.getPP(token.userID, gameMode)
|
||||
return "You have {:,} pp".format(pp)
|
||||
|
||||
|
||||
|
@@ -1,36 +0,0 @@
|
||||
std = 0
|
||||
taiko = 1
|
||||
ctb = 2
|
||||
mania = 3
|
||||
|
||||
def getGameModeForDB(gameMode):
|
||||
"""
|
||||
Convert a gamemode number to string for database table/column
|
||||
|
||||
gameMode -- gameMode int or variable (ex: gameMode.std)
|
||||
return -- game mode readable string for db
|
||||
"""
|
||||
if gameMode == std:
|
||||
return "std"
|
||||
elif gameMode == taiko:
|
||||
return "taiko"
|
||||
elif gameMode == ctb:
|
||||
return "ctb"
|
||||
else:
|
||||
return "mania"
|
||||
|
||||
def getGameModeForPrinting(gameMode):
|
||||
"""
|
||||
Convert a gamemode number to string for showing to a user (e.g. !last)
|
||||
|
||||
gameMode -- gameMode int or variable (ex: gameMode.std)
|
||||
return -- game mode readable string for a human
|
||||
"""
|
||||
if gameMode == std:
|
||||
return "osu!"
|
||||
elif gameMode == taiko:
|
||||
return "Taiko"
|
||||
elif gameMode == ctb:
|
||||
return "CatchTheBeat"
|
||||
else:
|
||||
return "osu!mania"
|
@@ -1,30 +0,0 @@
|
||||
Nomod = 0
|
||||
NoFail = 1
|
||||
Easy = 2
|
||||
NoVideo = 4
|
||||
Hidden = 8
|
||||
HardRock = 16
|
||||
SuddenDeath = 32
|
||||
DoubleTime = 64
|
||||
Relax = 128
|
||||
HalfTime = 256
|
||||
Nightcore = 512
|
||||
Flashlight = 1024
|
||||
Autoplay = 2048
|
||||
SpunOut = 4096
|
||||
Relax2 = 8192
|
||||
Perfect = 16384
|
||||
Key4 = 32768
|
||||
Key5 = 65536
|
||||
Key6 = 131072
|
||||
Key7 = 262144
|
||||
Key8 = 524288
|
||||
keyMod = 1015808
|
||||
FadeIn = 1048576
|
||||
Random = 2097152
|
||||
LastMod = 4194304
|
||||
Key9 = 16777216
|
||||
Key10 = 33554432
|
||||
Key1 = 67108864
|
||||
Key3 = 134217728
|
||||
Key2 = 268435456
|
@@ -1,21 +0,0 @@
|
||||
USER_PUBLIC = 1
|
||||
USER_NORMAL = 2 << 0
|
||||
USER_DONOR = 2 << 1
|
||||
ADMIN_ACCESS_RAP = 2 << 2
|
||||
ADMIN_MANAGE_USERS = 2 << 3
|
||||
ADMIN_BAN_USERS = 2 << 4
|
||||
ADMIN_SILENCE_USERS = 2 << 5
|
||||
ADMIN_WIPE_USERS = 2 << 6
|
||||
ADMIN_MANAGE_BEATMAPS = 2 << 7
|
||||
ADMIN_MANAGE_SERVERS = 2 << 8
|
||||
ADMIN_MANAGE_SETTINGS = 2 << 9
|
||||
ADMIN_MANAGE_BETAKEYS = 2 << 10
|
||||
ADMIN_MANAGE_REPORTS = 2 << 11
|
||||
ADMIN_MANAGE_DOCS = 2 << 12
|
||||
ADMIN_MANAGE_BADGES = 2 << 13
|
||||
ADMIN_VIEW_RAP_LOGS = 2 << 14
|
||||
ADMIN_MANAGE_PRIVILEGES = 2 << 15
|
||||
ADMIN_SEND_ALERTS = 2 << 16
|
||||
ADMIN_CHAT_MOD = 2 << 17
|
||||
ADMIN_KICK_USERS = 2 << 18
|
||||
USER_PENDING_VERIFICATION = 2 << 19
|
@@ -1,11 +1,11 @@
|
||||
""" Contains functions used to write specific server packets to byte streams """
|
||||
from helpers import packetHelper
|
||||
from common.constants import privileges
|
||||
from common.ripple import userUtils
|
||||
from constants import dataTypes
|
||||
from helpers import userHelper
|
||||
from objects import glob
|
||||
from constants import userRanks
|
||||
from constants import packetIDs
|
||||
from constants import privileges
|
||||
from constants import userRanks
|
||||
from helpers import packetHelper
|
||||
from objects import glob
|
||||
|
||||
""" Login errors packets """
|
||||
def loginFailed():
|
||||
@@ -56,7 +56,7 @@ def userSupporterGMT(supporter, GMT):
|
||||
return packetHelper.buildPacket(packetIDs.server_supporterGMT, [[result, dataTypes.UINT32]])
|
||||
|
||||
def friendList(userID):
|
||||
friends = userHelper.getFriendList(userID)
|
||||
friends = userUtils.getFriendList(userID)
|
||||
return packetHelper.buildPacket(packetIDs.server_friendsList, [[friends, dataTypes.INT_LIST]])
|
||||
|
||||
def onlineUsers():
|
||||
@@ -95,9 +95,9 @@ def userPanel(userID, force = False):
|
||||
# Only admins and normal users are currently supported
|
||||
if username == "FokaBot":
|
||||
userRank = userRanks.MOD
|
||||
elif userHelper.isInPrivilegeGroup(userID, "community manager"):
|
||||
elif userUtils.isInPrivilegeGroup(userID, "community manager"):
|
||||
userRank = userRanks.MOD
|
||||
elif userHelper.isInPrivilegeGroup(userID, "developer"):
|
||||
elif userUtils.isInPrivilegeGroup(userID, "developer"):
|
||||
userRank = userRanks.ADMIN
|
||||
elif (userToken.privileges & privileges.USER_DONOR) > 0:
|
||||
userRank = userRanks.SUPPORTER
|
||||
@@ -150,7 +150,7 @@ def sendMessage(fro, to, message):
|
||||
[fro, dataTypes.STRING],
|
||||
[message, dataTypes.STRING],
|
||||
[to, dataTypes.STRING],
|
||||
[userHelper.getID(fro), dataTypes.SINT32]
|
||||
[userUtils.getID(fro), dataTypes.SINT32]
|
||||
])
|
||||
|
||||
def channelJoinSuccess(userID, chan):
|
||||
|
Reference in New Issue
Block a user