Compare commits
2 Commits
privileges
...
fixes
Author | SHA1 | Date | |
---|---|---|---|
|
4cbaaafba5 | ||
|
fe283ff293 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,4 +6,3 @@ filters.txt
|
|||||||
common_funzia
|
common_funzia
|
||||||
common_refractor
|
common_refractor
|
||||||
common_memato
|
common_memato
|
||||||
redistest.py
|
|
||||||
|
2
common
2
common
Submodule common updated: cccd620817...d68736652c
@@ -4,6 +4,7 @@ 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
|
||||||
@@ -664,7 +665,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, to):
|
def updateBeatmap(fro, chan, message):
|
||||||
try:
|
try:
|
||||||
# Run the command in PM only
|
# Run the command in PM only
|
||||||
if chan.startswith("#"):
|
if chan.startswith("#"):
|
||||||
@@ -699,6 +700,42 @@ def updateBeatmap(fro, chan, to):
|
|||||||
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
|
||||||
|
|
||||||
@@ -838,6 +875,12 @@ commands = [
|
|||||||
}, {
|
}, {
|
||||||
"trigger": "!update",
|
"trigger": "!update",
|
||||||
"callback": updateBeatmap
|
"callback": updateBeatmap
|
||||||
|
}, {
|
||||||
|
"trigger": "trick",
|
||||||
|
"callback": trick
|
||||||
|
}, {
|
||||||
|
"trigger": "treat",
|
||||||
|
"callback": treat
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
# "trigger": "!acc",
|
# "trigger": "!acc",
|
||||||
|
@@ -80,3 +80,5 @@ client_userPanelRequest = 97
|
|||||||
client_tournamentMatchInfoRequest = 93
|
client_tournamentMatchInfoRequest = 93
|
||||||
client_tournamentJoinMatchChannel = 108
|
client_tournamentJoinMatchChannel = 108
|
||||||
client_tournamentLeaveMatchChannel = 109
|
client_tournamentLeaveMatchChannel = 109
|
||||||
|
|
||||||
|
server_zingheri = 105
|
@@ -268,3 +268,6 @@ def notification(message):
|
|||||||
|
|
||||||
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,24 +4,21 @@ 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(priv=userToken.privileges):
|
if userUtils.isBanned(userID):
|
||||||
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(priv=userToken.privileges):
|
if userUtils.isRestricted(userID):
|
||||||
userToken.setRestricted()
|
userToken.setRestricted()
|
||||||
|
|
||||||
# Change action packet
|
# Change action packet
|
||||||
@@ -49,6 +46,7 @@ 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(priv=priv) == True and not userUtils.isPending(priv=priv):
|
if userUtils.isBanned(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||||
raise exceptions.loginBannedException()
|
raise exceptions.loginBannedException()
|
||||||
if userUtils.isLocked(priv=priv) == True and not userUtils.isPending(priv=priv):
|
if userUtils.isLocked(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||||
raise exceptions.loginLockedException()
|
raise exceptions.loginLockedException()
|
||||||
|
|
||||||
# 2FA check
|
# 2FA check
|
||||||
@@ -195,10 +195,6 @@ 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")
|
||||||
@@ -210,6 +206,10 @@ 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,10 +256,6 @@ 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])
|
||||||
@@ -282,7 +278,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("#") and not (message.startswith("\x01ACTION is playing") and to.startswith("#spect_")):
|
if to.startswith("#"):
|
||||||
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
|
||||||
@@ -362,11 +358,3 @@ def IRCPartChannel(username, channel):
|
|||||||
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,6 +296,7 @@ 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":
|
||||||
@@ -439,6 +440,7 @@ 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
|
||||||
@@ -487,14 +489,10 @@ 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": self.awayHandler,
|
#"AWAY": away_handler,
|
||||||
#"ISON": ison_handler,
|
#"ISON": ison_handler,
|
||||||
"JOIN": self.joinHandler,
|
"JOIN": self.joinHandler,
|
||||||
#"LIST": list_handler,
|
#"LIST": list_handler,
|
||||||
@@ -520,6 +518,11 @@ 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]
|
||||||
@@ -619,7 +622,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],
|
||||||
[],
|
[],
|
||||||
1)
|
2)
|
||||||
|
|
||||||
# Handle incoming connections
|
# Handle incoming connections
|
||||||
for x in iwtd:
|
for x in iwtd:
|
||||||
|
@@ -1,12 +1,19 @@
|
|||||||
"""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 constants import serverPackets
|
|
||||||
from objects import glob
|
from objects import glob
|
||||||
|
from common.log import logUtils as log
|
||||||
|
|
||||||
|
import threading
|
||||||
|
from helpers import chatHelper as chat
|
||||||
|
from constants import serverPackets
|
||||||
|
|
||||||
# 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*)")
|
||||||
@@ -35,7 +42,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, i["trigger"]):
|
if generalUtils.strContains(message.lower(), i["trigger"].lower()):
|
||||||
# message has triggered a command
|
# message has triggered a command
|
||||||
|
|
||||||
# Make sure the user has right permissions
|
# Make sure the user has right permissions
|
||||||
@@ -57,3 +64,22 @@ def fokabotResponse(fro, chan, message):
|
|||||||
|
|
||||||
# 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,6 +1,7 @@
|
|||||||
"""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
|
||||||
@@ -25,6 +26,7 @@ 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()
|
||||||
@@ -43,8 +45,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(priv=self.privileges)
|
self.restricted = userUtils.isRestricted(self.userID)
|
||||||
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,7 +51,6 @@ 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
|
||||||
@@ -65,6 +64,7 @@ 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,6 +74,11 @@ 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_
|
||||||
@@ -89,6 +94,7 @@ 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_):
|
||||||
"""
|
"""
|
||||||
@@ -428,23 +434,3 @@ 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,6 +134,7 @@ 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
|
||||||
@@ -151,6 +152,11 @@ 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()
|
||||||
@@ -202,19 +208,6 @@ 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,5 +3,4 @@ tornado
|
|||||||
mysqlclient
|
mysqlclient
|
||||||
psutil
|
psutil
|
||||||
raven
|
raven
|
||||||
bcrypt>=3.1.1
|
bcrypt
|
||||||
dill
|
|
Reference in New Issue
Block a user