Compare commits
12 Commits
fixes
...
privileges
Author | SHA1 | Date | |
---|---|---|---|
|
7b06f2921e | ||
|
ef940771d8 | ||
|
b03d51abff | ||
|
8ef02faf36 | ||
|
d29dcd25f7 | ||
|
cd75d1ad8d | ||
|
c7c5528588 | ||
|
3b150d70cd | ||
|
d249dd593f | ||
|
78a6931805 | ||
|
555c9cca1f | ||
|
83c514b75e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ filters.txt
|
|||||||
common_funzia
|
common_funzia
|
||||||
common_refractor
|
common_refractor
|
||||||
common_memato
|
common_memato
|
||||||
|
redistest.py
|
||||||
|
2
common
2
common
Submodule common updated: d68736652c...cccd620817
@@ -4,7 +4,6 @@ import random
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from common import generalUtils
|
from common import generalUtils
|
||||||
from common.constants import actions
|
|
||||||
from common.constants import mods
|
from common.constants import mods
|
||||||
from common.log import logUtils as log
|
from common.log import logUtils as log
|
||||||
from common.ripple import userUtils
|
from common.ripple import userUtils
|
||||||
@@ -665,7 +664,7 @@ def pp(fro, chan, message):
|
|||||||
pp = userUtils.getPP(token.userID, gameMode)
|
pp = userUtils.getPP(token.userID, gameMode)
|
||||||
return "You have {:,} pp".format(pp)
|
return "You have {:,} pp".format(pp)
|
||||||
|
|
||||||
def updateBeatmap(fro, chan, message):
|
def updateBeatmap(fro, chan, to):
|
||||||
try:
|
try:
|
||||||
# Run the command in PM only
|
# Run the command in PM only
|
||||||
if chan.startswith("#"):
|
if chan.startswith("#"):
|
||||||
@@ -700,42 +699,6 @@ def updateBeatmap(fro, chan, message):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def trick(fro, chan, message):
|
|
||||||
if chan.startswith("#"):
|
|
||||||
return False
|
|
||||||
token = glob.tokens.getTokenFromUsername(fro)
|
|
||||||
if token is None or token.zingheri != 0:
|
|
||||||
return False
|
|
||||||
token.zingheri = 1
|
|
||||||
return "As you want..."
|
|
||||||
|
|
||||||
def treat(fro, chan, message):
|
|
||||||
if chan.startswith("#"):
|
|
||||||
return False
|
|
||||||
token = glob.tokens.getTokenFromUsername(fro)
|
|
||||||
if token is None or token.zingheri != 0:
|
|
||||||
return False
|
|
||||||
if token.actionID != actions.IDLE and token.actionID != actions.AFK:
|
|
||||||
log.warning(str(token.actionID))
|
|
||||||
return "You must be in the main menu to give me a treat :3"
|
|
||||||
token.zingheri = -2
|
|
||||||
token.leaveStream("zingheri")
|
|
||||||
usePP = token.gameMode == gameModes.STD or token.gameMode == gameModes.MANIA
|
|
||||||
if usePP:
|
|
||||||
currentPP = userUtils.getPP(token.userID, token.gameMode)
|
|
||||||
gift = currentPP/3
|
|
||||||
userUtils.setPP(token.userID, token.gameMode, currentPP - gift)
|
|
||||||
userUtils.setPP(999, token.gameMode, userUtils.getPP(999, token.gameMode) + gift)
|
|
||||||
else:
|
|
||||||
currentScore = userUtils.getRankedScore(token.userID, token.gameMode)
|
|
||||||
gift = currentScore/3
|
|
||||||
userUtils.setRankedScore(token.userID, token.gameMode, currentScore - gift)
|
|
||||||
userUtils.setRankedScore(999, token.gameMode, userUtils.getRankedScore(999, token.gameMode) + gift)
|
|
||||||
token.updateCachedStats()
|
|
||||||
token.enqueue(serverPackets.userStats(token.userID))
|
|
||||||
token.enqueue(serverPackets.userStats(999, True))
|
|
||||||
return "You just gave me {num:.2f} {type} as a treat, thanks! ^.^".format(num=gift, type="pp" if usePP else "score")
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Commands list
|
Commands list
|
||||||
|
|
||||||
@@ -875,12 +838,6 @@ commands = [
|
|||||||
}, {
|
}, {
|
||||||
"trigger": "!update",
|
"trigger": "!update",
|
||||||
"callback": updateBeatmap
|
"callback": updateBeatmap
|
||||||
}, {
|
|
||||||
"trigger": "trick",
|
|
||||||
"callback": trick
|
|
||||||
}, {
|
|
||||||
"trigger": "treat",
|
|
||||||
"callback": treat
|
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
# "trigger": "!acc",
|
# "trigger": "!acc",
|
||||||
|
@@ -79,6 +79,4 @@ server_userPresenceBundle = 96
|
|||||||
client_userPanelRequest = 97
|
client_userPanelRequest = 97
|
||||||
client_tournamentMatchInfoRequest = 93
|
client_tournamentMatchInfoRequest = 93
|
||||||
client_tournamentJoinMatchChannel = 108
|
client_tournamentJoinMatchChannel = 108
|
||||||
client_tournamentLeaveMatchChannel = 109
|
client_tournamentLeaveMatchChannel = 109
|
||||||
|
|
||||||
server_zingheri = 105
|
|
@@ -267,7 +267,4 @@ def notification(message):
|
|||||||
return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.STRING]])
|
return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.STRING]])
|
||||||
|
|
||||||
def banchoRestart(msUntilReconnection):
|
def banchoRestart(msUntilReconnection):
|
||||||
return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]])
|
return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]])
|
||||||
|
|
||||||
def zingheri(message):
|
|
||||||
return packetHelper.buildPacket(packetIDs.server_zingheri, [[message, dataTypes.STRING]])
|
|
@@ -4,21 +4,24 @@ from common.ripple import userUtils
|
|||||||
from constants import clientPackets
|
from constants import clientPackets
|
||||||
from constants import serverPackets
|
from constants import serverPackets
|
||||||
from objects import glob
|
from objects import glob
|
||||||
import time
|
|
||||||
|
|
||||||
def handle(userToken, packetData):
|
def handle(userToken, packetData):
|
||||||
# Get usertoken data
|
# Get usertoken data
|
||||||
userID = userToken.userID
|
userID = userToken.userID
|
||||||
username = userToken.username
|
username = userToken.username
|
||||||
|
|
||||||
|
# Update privileges
|
||||||
|
userToken.updatePrivileges()
|
||||||
|
|
||||||
# Make sure we are not banned
|
# Make sure we are not banned
|
||||||
if userUtils.isBanned(userID):
|
if userUtils.isBanned(priv=userToken.privileges):
|
||||||
userToken.enqueue(serverPackets.loginBanned())
|
userToken.enqueue(serverPackets.loginBanned())
|
||||||
return
|
return
|
||||||
|
|
||||||
# Send restricted message if needed
|
# Send restricted message if needed
|
||||||
if not userToken.restricted:
|
if not userToken.restricted:
|
||||||
if userUtils.isRestricted(userID):
|
if userUtils.isRestricted(priv=userToken.privileges):
|
||||||
userToken.setRestricted()
|
userToken.setRestricted()
|
||||||
|
|
||||||
# Change action packet
|
# Change action packet
|
||||||
@@ -46,7 +49,6 @@ if userToken.matchID != -1 and userToken.actionID != actions.MULTIPLAYING and us
|
|||||||
userToken.actionMd5 = packetData["actionMd5"]
|
userToken.actionMd5 = packetData["actionMd5"]
|
||||||
userToken.actionMods = packetData["actionMods"]
|
userToken.actionMods = packetData["actionMods"]
|
||||||
userToken.beatmapID = packetData["beatmapID"]
|
userToken.beatmapID = packetData["beatmapID"]
|
||||||
userToken.actionLatestUpdate = int(time.time())
|
|
||||||
|
|
||||||
# Enqueue our new user panel and stats to us and our spectators
|
# Enqueue our new user panel and stats to us and our spectators
|
||||||
recipients = [userToken]
|
recipients = [userToken]
|
||||||
|
@@ -64,9 +64,9 @@ def handle(tornadoRequest):
|
|||||||
|
|
||||||
# Make sure we are not banned or locked
|
# Make sure we are not banned or locked
|
||||||
priv = userUtils.getPrivileges(userID)
|
priv = userUtils.getPrivileges(userID)
|
||||||
if userUtils.isBanned(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
if userUtils.isBanned(priv=priv) == True and not userUtils.isPending(priv=priv):
|
||||||
raise exceptions.loginBannedException()
|
raise exceptions.loginBannedException()
|
||||||
if userUtils.isLocked(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
if userUtils.isLocked(priv=priv) == True and not userUtils.isPending(priv=priv):
|
||||||
raise exceptions.loginLockedException()
|
raise exceptions.loginLockedException()
|
||||||
|
|
||||||
# 2FA check
|
# 2FA check
|
||||||
@@ -195,6 +195,10 @@ def handle(tornadoRequest):
|
|||||||
location = locationHelper.getLocation(requestIP)
|
location = locationHelper.getLocation(requestIP)
|
||||||
countryLetters = locationHelper.getCountry(requestIP)
|
countryLetters = locationHelper.getCountry(requestIP)
|
||||||
country = countryHelper.getCountryID(countryLetters)
|
country = countryHelper.getCountryID(countryLetters)
|
||||||
|
|
||||||
|
# Set country in db if user has no country (first bancho login)
|
||||||
|
if userUtils.getCountry(userID) == "XX":
|
||||||
|
userUtils.setCountry(userID, countryLetters)
|
||||||
else:
|
else:
|
||||||
# Set location to 0,0 and get country from db
|
# Set location to 0,0 and get country from db
|
||||||
log.warning("Location skipped")
|
log.warning("Location skipped")
|
||||||
@@ -206,10 +210,6 @@ def handle(tornadoRequest):
|
|||||||
responseToken.setLocation(location)
|
responseToken.setLocation(location)
|
||||||
responseToken.setCountry(country)
|
responseToken.setCountry(country)
|
||||||
|
|
||||||
# Set country in db if user has no country (first bancho login)
|
|
||||||
if userUtils.getCountry(userID) == "XX":
|
|
||||||
userUtils.setCountry(userID, countryLetters)
|
|
||||||
|
|
||||||
# Send to everyone our userpanel if we are not restricted or tournament
|
# Send to everyone our userpanel if we are not restricted or tournament
|
||||||
if not responseToken.restricted:
|
if not responseToken.restricted:
|
||||||
glob.streams.broadcast("main", serverPackets.userPanel(userID))
|
glob.streams.broadcast("main", serverPackets.userPanel(userID))
|
||||||
|
@@ -256,6 +256,10 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
|||||||
|
|
||||||
# TODO: Make sure the recipient has not disabled PMs for non-friends or he's our friend
|
# TODO: Make sure the recipient has not disabled PMs for non-friends or he's our friend
|
||||||
|
|
||||||
|
# Away check
|
||||||
|
if recipientToken.awayCheck(userID):
|
||||||
|
sendMessage(to, fro, "\x01ACTION is away: {message}\x01".format(code=chr(int(1)), message=recipientToken.awayMessage))
|
||||||
|
|
||||||
# Check message templates (mods/admins only)
|
# Check message templates (mods/admins only)
|
||||||
if message in messageTemplates.templates and token.admin == True:
|
if message in messageTemplates.templates and token.admin == True:
|
||||||
sendMessage(fro, to, messageTemplates.templates[message])
|
sendMessage(fro, to, messageTemplates.templates[message])
|
||||||
@@ -278,7 +282,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
|||||||
sendMessage("FokaBot", to if isChannel else fro, fokaMessage)
|
sendMessage("FokaBot", to if isChannel else fro, fokaMessage)
|
||||||
|
|
||||||
# File and discord logs (public chat only)
|
# File and discord logs (public chat only)
|
||||||
if to.startswith("#"):
|
if to.startswith("#") and not (message.startswith("\x01ACTION is playing") and to.startswith("#spect_")):
|
||||||
log.chat("{fro} @ {to}: {message}".format(fro=username, to=to, message=str(message.encode("utf-8"))))
|
log.chat("{fro} @ {to}: {message}".format(fro=username, to=to, message=str(message.encode("utf-8"))))
|
||||||
glob.schiavo.sendChatlog("**{fro} @ {to}:** {message}".format(fro=username, to=to, message=str(message.encode("utf-8"))[2:-1]))
|
glob.schiavo.sendChatlog("**{fro} @ {to}:** {message}".format(fro=username, to=to, message=str(message.encode("utf-8"))[2:-1]))
|
||||||
return 0
|
return 0
|
||||||
@@ -357,4 +361,12 @@ def IRCPartChannel(username, channel):
|
|||||||
if not userID:
|
if not userID:
|
||||||
log.warning("{} doesn't exist".format(username))
|
log.warning("{} doesn't exist".format(username))
|
||||||
return
|
return
|
||||||
return partChannel(userID, channel)
|
return partChannel(userID, channel)
|
||||||
|
|
||||||
|
def IRCAway(username, message):
|
||||||
|
userID = userUtils.getID(username)
|
||||||
|
if not userID:
|
||||||
|
log.warning("{} doesn't exist".format(username))
|
||||||
|
return
|
||||||
|
glob.tokens.getTokenFromUserID(userID).setAwayMessage(message)
|
||||||
|
return 305 if message == "" else 306
|
@@ -296,7 +296,6 @@ class Client:
|
|||||||
# Disconnect other IRC clients from the same user
|
# Disconnect other IRC clients from the same user
|
||||||
for _, value in self.server.clients.items():
|
for _, value in self.server.clients.items():
|
||||||
if value.IRCUsername.lower() == self.IRCUsername.lower() and value != self:
|
if value.IRCUsername.lower() == self.IRCUsername.lower() and value != self:
|
||||||
print("DISCONNECTERINOOOOOOOOOOOOOOOOOOOOO")
|
|
||||||
value.disconnect(quitmsg="Connected from another client")
|
value.disconnect(quitmsg="Connected from another client")
|
||||||
return
|
return
|
||||||
elif command == "USER":
|
elif command == "USER":
|
||||||
@@ -440,7 +439,6 @@ class Client:
|
|||||||
|
|
||||||
# Send the message to bancho and reply
|
# Send the message to bancho and reply
|
||||||
if not recipientIRC.startswith("#"):
|
if not recipientIRC.startswith("#"):
|
||||||
print("PMPMPM!!!!!!!!!!")
|
|
||||||
recipientBancho = chat.fixUsernameForBancho(recipientIRC)
|
recipientBancho = chat.fixUsernameForBancho(recipientIRC)
|
||||||
else:
|
else:
|
||||||
recipientBancho = recipientIRC
|
recipientBancho = recipientIRC
|
||||||
@@ -489,10 +487,14 @@ class Client:
|
|||||||
"""(fake) PONG command handler"""
|
"""(fake) PONG command handler"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def awayHandler(self, command, arguments):
|
||||||
|
response = chat.IRCAway(self.banchoUsername, " ".join(arguments))
|
||||||
|
self.replyCode(response, "You are no longer marked as being away" if response == 305 else "You have been marked as being away")
|
||||||
|
|
||||||
def mainHandler(self, command, arguments):
|
def mainHandler(self, command, arguments):
|
||||||
"""Handler for post-login commands"""
|
"""Handler for post-login commands"""
|
||||||
handlers = {
|
handlers = {
|
||||||
#"AWAY": away_handler,
|
"AWAY": self.awayHandler,
|
||||||
#"ISON": ison_handler,
|
#"ISON": ison_handler,
|
||||||
"JOIN": self.joinHandler,
|
"JOIN": self.joinHandler,
|
||||||
#"LIST": list_handler,
|
#"LIST": list_handler,
|
||||||
@@ -518,11 +520,6 @@ class Client:
|
|||||||
self.replyCode(421, "Unknown command ({})".format(command))
|
self.replyCode(421, "Unknown command ({})".format(command))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Server:
|
class Server:
|
||||||
def __init__(self, port):
|
def __init__(self, port):
|
||||||
#self.host = socket.getfqdn("127.0.0.1")[:63]
|
#self.host = socket.getfqdn("127.0.0.1")[:63]
|
||||||
@@ -622,7 +619,7 @@ class Server:
|
|||||||
[x.socket for x in self.clients.values()
|
[x.socket for x in self.clients.values()
|
||||||
if x.writeBufferSize() > 0],
|
if x.writeBufferSize() > 0],
|
||||||
[],
|
[],
|
||||||
2)
|
1)
|
||||||
|
|
||||||
# Handle incoming connections
|
# Handle incoming connections
|
||||||
for x in iwtd:
|
for x in iwtd:
|
||||||
|
@@ -1,19 +1,12 @@
|
|||||||
"""FokaBot related functions"""
|
"""FokaBot related functions"""
|
||||||
import random
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
from common import generalUtils
|
from common import generalUtils
|
||||||
from common.constants import actions
|
from common.constants import actions
|
||||||
from common.ripple import userUtils
|
from common.ripple import userUtils
|
||||||
from constants import fokabotCommands
|
from constants import fokabotCommands
|
||||||
from objects import glob
|
|
||||||
from common.log import logUtils as log
|
|
||||||
|
|
||||||
import threading
|
|
||||||
from helpers import chatHelper as chat
|
|
||||||
from constants import serverPackets
|
from constants import serverPackets
|
||||||
|
from objects import glob
|
||||||
|
|
||||||
# Tillerino np regex, compiled only once to increase performance
|
# Tillerino np regex, compiled only once to increase performance
|
||||||
npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
||||||
@@ -42,7 +35,7 @@ def fokabotResponse(fro, chan, message):
|
|||||||
for i in fokabotCommands.commands:
|
for i in fokabotCommands.commands:
|
||||||
# Loop though all commands
|
# Loop though all commands
|
||||||
#if i["trigger"] in message:
|
#if i["trigger"] in message:
|
||||||
if generalUtils.strContains(message.lower(), i["trigger"].lower()):
|
if generalUtils.strContains(message, i["trigger"]):
|
||||||
# message has triggered a command
|
# message has triggered a command
|
||||||
|
|
||||||
# Make sure the user has right permissions
|
# Make sure the user has right permissions
|
||||||
@@ -63,23 +56,4 @@ def fokabotResponse(fro, chan, message):
|
|||||||
return i["callback"](fro, chan, message[1:])
|
return i["callback"](fro, chan, message[1:])
|
||||||
|
|
||||||
# No commands triggered
|
# No commands triggered
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def zingheriLoop():
|
|
||||||
log.debug("SONO STATI I ZINGHERI, I ZINGHERI!")
|
|
||||||
clients = glob.streams.getClients("zingheri")
|
|
||||||
for i in clients:
|
|
||||||
log.debug(str(i))
|
|
||||||
if i not in glob.tokens.tokens:
|
|
||||||
continue
|
|
||||||
token = glob.tokens.tokens[i]
|
|
||||||
if token.userID == 999:
|
|
||||||
continue
|
|
||||||
if token.zingheri == -1:
|
|
||||||
chat.sendMessage("FokaBot", token.username, "Knock knock, trick or treat?\nWho are you?\nI'm a {meme}. I'm a little {meme}.\n(reply with 'trick' or 'treat')".format(meme=random.choice(["shavit", "loctaf", "peppy", "foka", "elfo", "nano", "cupola autoportante"])))
|
|
||||||
token.zingheri = 0
|
|
||||||
elif token.zingheri == 1:
|
|
||||||
if token.actionID == actions.PLAYING and (int(time.time()) - token.actionLatestUpdate >= 25):
|
|
||||||
token.enqueue(serverPackets.zingheri("You'd better give me a treat next time ;)"))
|
|
||||||
token.leaveStream("zingheri")
|
|
||||||
threading.Timer(30, zingheriLoop).start()
|
|
@@ -1,7 +1,6 @@
|
|||||||
"""Global objects and variables"""
|
"""Global objects and variables"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from common.ddog import datadogClient
|
from common.ddog import datadogClient
|
||||||
from common.files import fileBuffer, fileLocks
|
from common.files import fileBuffer, fileLocks
|
||||||
from objects import channelList
|
from objects import channelList
|
||||||
@@ -26,7 +25,6 @@ banchoConf = None
|
|||||||
tokens = tokenList.tokenList()
|
tokens = tokenList.tokenList()
|
||||||
channels = channelList.channelList()
|
channels = channelList.channelList()
|
||||||
matches = matchList.matchList()
|
matches = matchList.matchList()
|
||||||
restarting = False
|
|
||||||
fLocks = fileLocks.fileLocks()
|
fLocks = fileLocks.fileLocks()
|
||||||
fileBuffers = fileBuffer.buffersList()
|
fileBuffers = fileBuffer.buffersList()
|
||||||
schiavo = schiavo.schiavo()
|
schiavo = schiavo.schiavo()
|
||||||
@@ -45,8 +43,8 @@ gzip = False
|
|||||||
localize = False
|
localize = False
|
||||||
sentry = False
|
sentry = False
|
||||||
irc = False
|
irc = False
|
||||||
|
restarting = False
|
||||||
|
|
||||||
startTime = int(time.time())
|
startTime = int(time.time())
|
||||||
|
|
||||||
|
|
||||||
streams = streamList.streamList()
|
streams = streamList.streamList()
|
||||||
|
@@ -30,7 +30,7 @@ class token:
|
|||||||
self.privileges = userUtils.getPrivileges(self.userID)
|
self.privileges = userUtils.getPrivileges(self.userID)
|
||||||
self.admin = userUtils.isInPrivilegeGroup(self.userID, "developer") or userUtils.isInPrivilegeGroup(self.userID, "community manager")
|
self.admin = userUtils.isInPrivilegeGroup(self.userID, "developer") or userUtils.isInPrivilegeGroup(self.userID, "community manager")
|
||||||
self.irc = irc
|
self.irc = irc
|
||||||
self.restricted = userUtils.isRestricted(self.userID)
|
self.restricted = userUtils.isRestricted(priv=self.privileges)
|
||||||
self.loginTime = int(time.time())
|
self.loginTime = int(time.time())
|
||||||
self.pingTime = self.loginTime
|
self.pingTime = self.loginTime
|
||||||
self.timeOffset = timeOffset
|
self.timeOffset = timeOffset
|
||||||
@@ -51,6 +51,7 @@ class token:
|
|||||||
self.country = 0
|
self.country = 0
|
||||||
self.location = [0,0]
|
self.location = [0,0]
|
||||||
self.awayMessage = ""
|
self.awayMessage = ""
|
||||||
|
self.sentAway = []
|
||||||
self.matchID = -1
|
self.matchID = -1
|
||||||
self.tillerino = [0,0,-1.0] # beatmap, mods, acc
|
self.tillerino = [0,0,-1.0] # beatmap, mods, acc
|
||||||
self.silenceEndTime = 0
|
self.silenceEndTime = 0
|
||||||
@@ -64,7 +65,6 @@ class token:
|
|||||||
self.actionText = ""
|
self.actionText = ""
|
||||||
self.actionMd5 = ""
|
self.actionMd5 = ""
|
||||||
self.actionMods = 0
|
self.actionMods = 0
|
||||||
self.actionLatestUpdate = self.pingTime
|
|
||||||
self.gameMode = gameModes.STD
|
self.gameMode = gameModes.STD
|
||||||
self.beatmapID = 0
|
self.beatmapID = 0
|
||||||
self.rankedScore = 0
|
self.rankedScore = 0
|
||||||
@@ -74,11 +74,6 @@ class token:
|
|||||||
self.gameRank = 0
|
self.gameRank = 0
|
||||||
self.pp = 0
|
self.pp = 0
|
||||||
|
|
||||||
# -1: Non sa dell'esistenza dei zingheri
|
|
||||||
# 0: In attesa di risposta al messaggiomem
|
|
||||||
# 1: zingheri soonTM
|
|
||||||
self.zingheri = -1
|
|
||||||
|
|
||||||
# Generate/set token
|
# Generate/set token
|
||||||
if token_ is not None:
|
if token_ is not None:
|
||||||
self.token = token_
|
self.token = token_
|
||||||
@@ -94,7 +89,6 @@ class token:
|
|||||||
|
|
||||||
# Join main stream
|
# Join main stream
|
||||||
self.joinStream("main")
|
self.joinStream("main")
|
||||||
self.joinStream("zingheri")
|
|
||||||
|
|
||||||
def enqueue(self, bytes_):
|
def enqueue(self, bytes_):
|
||||||
"""
|
"""
|
||||||
@@ -433,4 +427,24 @@ class token:
|
|||||||
|
|
||||||
def leaveAllStreams(self):
|
def leaveAllStreams(self):
|
||||||
for i in self.streams:
|
for i in self.streams:
|
||||||
self.leaveStream(i)
|
self.leaveStream(i)
|
||||||
|
|
||||||
|
def awayCheck(self, userID):
|
||||||
|
"""
|
||||||
|
Returns True if userID doesn't know that we are away
|
||||||
|
Returns False if we are not away or if userID already knows we are away
|
||||||
|
|
||||||
|
:param userID: original sender userID
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if self.awayMessage == "" or userID in self.sentAway:
|
||||||
|
return False
|
||||||
|
self.sentAway.append(userID)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def updatePrivileges(self):
|
||||||
|
"""
|
||||||
|
Force updating self.privileges from db
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
self.privileges = userUtils.getPrivileges(self.userID)
|
@@ -67,7 +67,7 @@ class streamList:
|
|||||||
return
|
return
|
||||||
self.streams[streamName].broadcast(data)
|
self.streams[streamName].broadcast(data)
|
||||||
|
|
||||||
def getClients(self, streamName):
|
'''def getClients(self, streamName):
|
||||||
"""
|
"""
|
||||||
Get all clients in a stream
|
Get all clients in a stream
|
||||||
|
|
||||||
@@ -76,4 +76,4 @@ class streamList:
|
|||||||
"""
|
"""
|
||||||
if streamName not in self.streams:
|
if streamName not in self.streams:
|
||||||
return
|
return
|
||||||
return self.streams[streamName].clients
|
return self.streams[streamName].clients'''
|
19
pep.py
19
pep.py
@@ -134,7 +134,6 @@ if __name__ == "__main__":
|
|||||||
consoleHelper.printNoNl("> Creating packets streams... ")
|
consoleHelper.printNoNl("> Creating packets streams... ")
|
||||||
glob.streams.add("main")
|
glob.streams.add("main")
|
||||||
glob.streams.add("lobby")
|
glob.streams.add("lobby")
|
||||||
glob.streams.add("zingheri")
|
|
||||||
consoleHelper.printDone()
|
consoleHelper.printDone()
|
||||||
|
|
||||||
# Start fokabot
|
# Start fokabot
|
||||||
@@ -152,11 +151,6 @@ if __name__ == "__main__":
|
|||||||
glob.tokens.spamProtectionResetLoop()
|
glob.tokens.spamProtectionResetLoop()
|
||||||
consoleHelper.printDone()
|
consoleHelper.printDone()
|
||||||
|
|
||||||
# Initialize zingheri loop
|
|
||||||
consoleHelper.printNoNl("> WOO WOO... ")
|
|
||||||
fokabot.zingheriLoop()
|
|
||||||
consoleHelper.printDone()
|
|
||||||
|
|
||||||
# Cache user ids
|
# Cache user ids
|
||||||
consoleHelper.printNoNl("> Caching user IDs... ")
|
consoleHelper.printNoNl("> Caching user IDs... ")
|
||||||
userUtils.cacheUserIDs()
|
userUtils.cacheUserIDs()
|
||||||
@@ -208,6 +202,19 @@ if __name__ == "__main__":
|
|||||||
[
|
[
|
||||||
datadogClient.periodicCheck("online_users", lambda: len(glob.tokens.tokens)),
|
datadogClient.periodicCheck("online_users", lambda: len(glob.tokens.tokens)),
|
||||||
datadogClient.periodicCheck("multiplayer_matches", lambda: len(glob.matches.matches)),
|
datadogClient.periodicCheck("multiplayer_matches", lambda: len(glob.matches.matches)),
|
||||||
|
|
||||||
|
datadogClient.periodicCheck("ram_clients", lambda: generalUtils.getTotalSize(glob.tokens)),
|
||||||
|
datadogClient.periodicCheck("ram_matches", lambda: generalUtils.getTotalSize(glob.matches)),
|
||||||
|
datadogClient.periodicCheck("ram_channels", lambda: generalUtils.getTotalSize(glob.channels)),
|
||||||
|
datadogClient.periodicCheck("ram_file_buffers", lambda: generalUtils.getTotalSize(glob.fileBuffers)),
|
||||||
|
datadogClient.periodicCheck("ram_file_locks", lambda: generalUtils.getTotalSize(glob.fLocks)),
|
||||||
|
datadogClient.periodicCheck("ram_datadog", lambda: generalUtils.getTotalSize(glob.datadogClient)),
|
||||||
|
datadogClient.periodicCheck("ram_verified_cache", lambda: generalUtils.getTotalSize(glob.verifiedCache)),
|
||||||
|
datadogClient.periodicCheck("ram_userid_cache", lambda: generalUtils.getTotalSize(glob.userIDCache)),
|
||||||
|
#datadogClient.periodicCheck("ram_pool", lambda: generalUtils.getTotalSize(glob.pool)),
|
||||||
|
datadogClient.periodicCheck("ram_irc", lambda: generalUtils.getTotalSize(glob.ircServer)),
|
||||||
|
datadogClient.periodicCheck("ram_tornado", lambda: generalUtils.getTotalSize(glob.application)),
|
||||||
|
datadogClient.periodicCheck("ram_db", lambda: generalUtils.getTotalSize(glob.db)),
|
||||||
])
|
])
|
||||||
else:
|
else:
|
||||||
consoleHelper.printColored("[!] Warning! Datadog stats tracking is disabled!", bcolors.YELLOW)
|
consoleHelper.printColored("[!] Warning! Datadog stats tracking is disabled!", bcolors.YELLOW)
|
||||||
|
@@ -3,4 +3,5 @@ tornado
|
|||||||
mysqlclient
|
mysqlclient
|
||||||
psutil
|
psutil
|
||||||
raven
|
raven
|
||||||
bcrypt
|
bcrypt>=3.1.1
|
||||||
|
dill
|
Reference in New Issue
Block a user