The ascension of the Madonna (the 15th of August is approaching)
This commit is contained in:
parent
7f283d9aa2
commit
cb2d1e74f7
|
@ -63,7 +63,7 @@ def faq(fro, chan, message):
|
||||||
def roll(fro, chan, message):
|
def roll(fro, chan, message):
|
||||||
maxPoints = 100
|
maxPoints = 100
|
||||||
if len(message) >= 1:
|
if len(message) >= 1:
|
||||||
if message[0].isdigit() == True and int(message[0]) > 0:
|
if message[0].isdigit() and int(message[0]) > 0:
|
||||||
maxPoints = int(message[0])
|
maxPoints = int(message[0])
|
||||||
|
|
||||||
points = random.randrange(0,maxPoints)
|
points = random.randrange(0,maxPoints)
|
||||||
|
|
|
@ -61,9 +61,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(userID) and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||||
raise exceptions.loginBannedException()
|
raise exceptions.loginBannedException()
|
||||||
if userUtils.isLocked(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
if userUtils.isLocked(userID) and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||||
raise exceptions.loginLockedException()
|
raise exceptions.loginLockedException()
|
||||||
|
|
||||||
# 2FA check
|
# 2FA check
|
||||||
|
@ -75,7 +75,7 @@ def handle(tornadoRequest):
|
||||||
|
|
||||||
# Verify this user (if pending activation)
|
# Verify this user (if pending activation)
|
||||||
firstLogin = False
|
firstLogin = False
|
||||||
if priv & privileges.USER_PENDING_VERIFICATION > 0 or userUtils.hasVerifiedHardware(userID) == False:
|
if priv & privileges.USER_PENDING_VERIFICATION > 0 or not userUtils.hasVerifiedHardware(userID):
|
||||||
if userUtils.verifyUser(userID, clientData):
|
if userUtils.verifyUser(userID, clientData):
|
||||||
# Valid account
|
# Valid account
|
||||||
log.info("Account {} verified successfully!".format(userID))
|
log.info("Account {} verified successfully!".format(userID))
|
||||||
|
@ -176,7 +176,7 @@ def handle(tornadoRequest):
|
||||||
|
|
||||||
# Output channels info
|
# Output channels info
|
||||||
for key, value in glob.channels.channels.items():
|
for key, value in glob.channels.channels.items():
|
||||||
if value.publicRead == True and value.hidden == False:
|
if value.publicRead and not value.hidden:
|
||||||
responseToken.enqueue(serverPackets.channelInfo(key))
|
responseToken.enqueue(serverPackets.channelInfo(key))
|
||||||
|
|
||||||
# Send friends list
|
# Send friends list
|
||||||
|
|
|
@ -17,7 +17,7 @@ class handler(requestsManager.asyncRequestHandler):
|
||||||
data = {"message": "unknown error"}
|
data = {"message": "unknown error"}
|
||||||
try:
|
try:
|
||||||
# Get online users count
|
# Get online users count
|
||||||
data["result"] = -1 if glob.restarting == True else 1
|
data["result"] = -1 if glob.restarting else 1
|
||||||
|
|
||||||
# Status code and message
|
# Status code and message
|
||||||
statusCode = 200
|
statusCode = 200
|
||||||
|
|
|
@ -106,7 +106,7 @@ class handler(requestsManager.asyncRequestHandler):
|
||||||
packetData = requestData[pos:(pos+dataLength+7)]
|
packetData = requestData[pos:(pos+dataLength+7)]
|
||||||
|
|
||||||
# Console output if needed
|
# Console output if needed
|
||||||
if glob.outputPackets == True and packetID != 4:
|
if glob.outputPackets and packetID != 4:
|
||||||
log.debug("Incoming packet ({})({}):\n\nPacket code: {}\nPacket length: {}\nSingle packet data: {}\n".format(requestTokenString, userToken.username, str(packetID), str(dataLength), str(packetData)))
|
log.debug("Incoming packet ({})({}):\n\nPacket code: {}\nPacket length: {}\nSingle packet data: {}\n".format(requestTokenString, userToken.username, str(packetID), str(dataLength), str(packetData)))
|
||||||
|
|
||||||
# Event handler
|
# Event handler
|
||||||
|
@ -179,7 +179,7 @@ class handler(requestsManager.asyncRequestHandler):
|
||||||
# Process/ignore packet
|
# Process/ignore packet
|
||||||
if packetID != 4:
|
if packetID != 4:
|
||||||
if packetID in eventHandler:
|
if packetID in eventHandler:
|
||||||
if userToken.restricted == False or (userToken.restricted == True and packetID in packetsRestricted):
|
if userToken.restricted == False or (userToken.restricted and packetID in packetsRestricted):
|
||||||
eventHandler[packetID]()
|
eventHandler[packetID]()
|
||||||
else:
|
else:
|
||||||
log.warning("Ignored packet id from {} ({}) (user is restricted)".format(requestTokenString, packetID))
|
log.warning("Ignored packet id from {} ({}) (user is restricted)".format(requestTokenString, packetID))
|
||||||
|
|
|
@ -43,7 +43,7 @@ def joinChannel(userID = 0, channel = "", token = None, toIRC = True, force=Fals
|
||||||
token.joinChannel(channelObject)
|
token.joinChannel(channelObject)
|
||||||
|
|
||||||
# Send channel joined (IRC)
|
# Send channel joined (IRC)
|
||||||
if glob.irc == True and toIRC == True:
|
if glob.irc and not toIRC:
|
||||||
glob.ircServer.banchoJoinChannel(token.username, channel)
|
glob.ircServer.banchoJoinChannel(token.username, channel)
|
||||||
|
|
||||||
# Console output
|
# Console output
|
||||||
|
@ -124,7 +124,7 @@ def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = Fal
|
||||||
|
|
||||||
# Delete temporary channel if everyone left
|
# Delete temporary channel if everyone left
|
||||||
if "chat/{}".format(channelObject.name) in glob.streams.streams:
|
if "chat/{}".format(channelObject.name) in glob.streams.streams:
|
||||||
if channelObject.temp == True and len(glob.streams.streams["chat/{}".format(channelObject.name)].clients) - 1 == 0:
|
if channelObject.temp and len(glob.streams.streams["chat/{}".format(channelObject.name)].clients) - 1 == 0:
|
||||||
glob.channels.removeChannel(channelObject.name)
|
glob.channels.removeChannel(channelObject.name)
|
||||||
|
|
||||||
# Force close tab if needed
|
# Force close tab if needed
|
||||||
|
@ -133,7 +133,7 @@ def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = Fal
|
||||||
token.enqueue(serverPackets.channelKicked(channelClient))
|
token.enqueue(serverPackets.channelKicked(channelClient))
|
||||||
|
|
||||||
# IRC part
|
# IRC part
|
||||||
if glob.irc == True and toIRC == True:
|
if glob.irc and toIRC:
|
||||||
glob.ircServer.banchoPartChannel(token.username, channel)
|
glob.ircServer.banchoPartChannel(token.username, channel)
|
||||||
|
|
||||||
# Console output
|
# Console output
|
||||||
|
@ -228,7 +228,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
||||||
raise exceptions.channelUnknownException()
|
raise exceptions.channelUnknownException()
|
||||||
|
|
||||||
# Make sure the channel is not in moderated mode
|
# Make sure the channel is not in moderated mode
|
||||||
if glob.channels.channels[to].moderated == True and token.admin == False:
|
if glob.channels.channels[to].moderated and not token.admin:
|
||||||
raise exceptions.channelModeratedException()
|
raise exceptions.channelModeratedException()
|
||||||
|
|
||||||
# Make sure we are in the channel
|
# Make sure we are in the channel
|
||||||
|
@ -238,7 +238,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
||||||
raise exceptions.channelNoPermissionsException()
|
raise exceptions.channelNoPermissionsException()
|
||||||
|
|
||||||
# Make sure we have write permissions
|
# Make sure we have write permissions
|
||||||
if glob.channels.channels[to].publicWrite == False and token.admin == False:
|
if not glob.channels.channels[to].publicWrite and not token.admin:
|
||||||
raise exceptions.channelNoPermissionsException()
|
raise exceptions.channelNoPermissionsException()
|
||||||
|
|
||||||
# Add message in buffer
|
# Add message in buffer
|
||||||
|
@ -258,7 +258,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
||||||
# raise exceptions.userTournamentException()
|
# raise exceptions.userTournamentException()
|
||||||
|
|
||||||
# Make sure the recipient is not restricted or we are FokaBot
|
# Make sure the recipient is not restricted or we are FokaBot
|
||||||
if recipientToken.restricted == True and fro.lower() != "fokabot":
|
if recipientToken.restricted and fro.lower() != "fokabot":
|
||||||
raise exceptions.userRestrictedException()
|
raise exceptions.userRestrictedException()
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -268,14 +268,14 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
||||||
sendMessage(to, fro, "\x01ACTION is away: {}\x01".format(recipientToken.awayMessage))
|
sendMessage(to, fro, "\x01ACTION is away: {}\x01".format(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:
|
||||||
sendMessage(fro, to, messageTemplates.templates[message])
|
sendMessage(fro, to, messageTemplates.templates[message])
|
||||||
|
|
||||||
# Everything seems fine, send packet
|
# Everything seems fine, send packet
|
||||||
recipientToken.enqueue(packet)
|
recipientToken.enqueue(packet)
|
||||||
|
|
||||||
# Send the message to IRC
|
# Send the message to IRC
|
||||||
if glob.irc == True and toIRC == True:
|
if glob.irc and toIRC:
|
||||||
messageSplitInLines = message.encode("latin-1").decode("utf-8").split("\n")
|
messageSplitInLines = message.encode("latin-1").decode("utf-8").split("\n")
|
||||||
for line in messageSplitInLines:
|
for line in messageSplitInLines:
|
||||||
if line == messageSplitInLines[:1] and line == "":
|
if line == messageSplitInLines[:1] and line == "":
|
||||||
|
@ -287,7 +287,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
||||||
token.spamProtection()
|
token.spamProtection()
|
||||||
|
|
||||||
# Fokabot message
|
# Fokabot message
|
||||||
if isChannel == True or to.lower() == "fokabot":
|
if isChannel or to.lower() == "fokabot":
|
||||||
fokaMessage = fokabot.fokabotResponse(token.username, to, message)
|
fokaMessage = fokabot.fokabotResponse(token.username, to, message)
|
||||||
if fokaMessage:
|
if fokaMessage:
|
||||||
sendMessage("FokaBot", to if isChannel else fro, fokaMessage)
|
sendMessage("FokaBot", to if isChannel else fro, fokaMessage)
|
||||||
|
|
|
@ -57,5 +57,5 @@ class banchoConfig:
|
||||||
glob.streams.broadcast("main", serverPackets.mainMenuIcon(glob.banchoConf.config["menuIcon"]))
|
glob.streams.broadcast("main", serverPackets.mainMenuIcon(glob.banchoConf.config["menuIcon"]))
|
||||||
glob.streams.broadcast("main", serverPackets.channelInfoEnd())
|
glob.streams.broadcast("main", serverPackets.channelInfoEnd())
|
||||||
for key, value in glob.channels.channels.items():
|
for key, value in glob.channels.channels.items():
|
||||||
if value.publicRead == True and value.hidden == False:
|
if value.publicRead and not value.hidden:
|
||||||
glob.streams.broadcast("main", serverPackets.channelInfo(key))
|
glob.streams.broadcast("main", serverPackets.channelInfo(key))
|
|
@ -141,7 +141,7 @@ class token:
|
||||||
"""
|
"""
|
||||||
if channelObject.name in self.joinedChannels:
|
if channelObject.name in self.joinedChannels:
|
||||||
raise exceptions.userAlreadyInChannelException()
|
raise exceptions.userAlreadyInChannelException()
|
||||||
if channelObject.publicRead == False and self.admin == False:
|
if not channelObject.publicRead and not self.admin:
|
||||||
raise exceptions.channelNoPermissionsException()
|
raise exceptions.channelNoPermissionsException()
|
||||||
self.joinedChannels.append(channelObject.name)
|
self.joinedChannels.append(channelObject.name)
|
||||||
self.joinStream("chat/{}".format(channelObject.name))
|
self.joinStream("chat/{}".format(channelObject.name))
|
||||||
|
|
|
@ -183,7 +183,7 @@ class tokenList:
|
||||||
timeoutLimit = int(time.time()) - 100
|
timeoutLimit = int(time.time()) - 100
|
||||||
for key, value in self.tokens.items():
|
for key, value in self.tokens.items():
|
||||||
# Check timeout (fokabot is ignored)
|
# Check timeout (fokabot is ignored)
|
||||||
if value.pingTime < timeoutLimit and value.userID != 999 and value.irc == False and value.tournament == False:
|
if value.pingTime < timeoutLimit and value.userID != 999 and not value.irc and not value.tournament:
|
||||||
# That user has timed out, add to disconnected tokens
|
# That user has timed out, add to disconnected tokens
|
||||||
# We can't delete it while iterating or items() throws an error
|
# We can't delete it while iterating or items() throws an error
|
||||||
timedOutTokens.append(key)
|
timedOutTokens.append(key)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user