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):
|
||||
maxPoints = 100
|
||||
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])
|
||||
|
||||
points = random.randrange(0,maxPoints)
|
||||
|
|
|
@ -61,9 +61,9 @@ def handle(tornadoRequest):
|
|||
|
||||
# Make sure we are not banned or locked
|
||||
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()
|
||||
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()
|
||||
|
||||
# 2FA check
|
||||
|
@ -75,7 +75,7 @@ def handle(tornadoRequest):
|
|||
|
||||
# Verify this user (if pending activation)
|
||||
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):
|
||||
# Valid account
|
||||
log.info("Account {} verified successfully!".format(userID))
|
||||
|
@ -176,7 +176,7 @@ def handle(tornadoRequest):
|
|||
|
||||
# Output channels info
|
||||
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))
|
||||
|
||||
# Send friends list
|
||||
|
|
|
@ -17,7 +17,7 @@ class handler(requestsManager.asyncRequestHandler):
|
|||
data = {"message": "unknown error"}
|
||||
try:
|
||||
# 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
|
||||
statusCode = 200
|
||||
|
|
|
@ -106,7 +106,7 @@ class handler(requestsManager.asyncRequestHandler):
|
|||
packetData = requestData[pos:(pos+dataLength+7)]
|
||||
|
||||
# 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)))
|
||||
|
||||
# Event handler
|
||||
|
@ -179,7 +179,7 @@ class handler(requestsManager.asyncRequestHandler):
|
|||
# Process/ignore packet
|
||||
if packetID != 4:
|
||||
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]()
|
||||
else:
|
||||
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)
|
||||
|
||||
# Send channel joined (IRC)
|
||||
if glob.irc == True and toIRC == True:
|
||||
if glob.irc and not toIRC:
|
||||
glob.ircServer.banchoJoinChannel(token.username, channel)
|
||||
|
||||
# Console output
|
||||
|
@ -124,7 +124,7 @@ def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = Fal
|
|||
|
||||
# Delete temporary channel if everyone left
|
||||
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)
|
||||
|
||||
# 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))
|
||||
|
||||
# IRC part
|
||||
if glob.irc == True and toIRC == True:
|
||||
if glob.irc and toIRC:
|
||||
glob.ircServer.banchoPartChannel(token.username, channel)
|
||||
|
||||
# Console output
|
||||
|
@ -228,7 +228,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
|||
raise exceptions.channelUnknownException()
|
||||
|
||||
# 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()
|
||||
|
||||
# Make sure we are in the channel
|
||||
|
@ -238,7 +238,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
|||
raise exceptions.channelNoPermissionsException()
|
||||
|
||||
# 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()
|
||||
|
||||
# Add message in buffer
|
||||
|
@ -258,7 +258,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
|||
# raise exceptions.userTournamentException()
|
||||
|
||||
# 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()
|
||||
|
||||
# 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))
|
||||
|
||||
# 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])
|
||||
|
||||
# Everything seems fine, send packet
|
||||
recipientToken.enqueue(packet)
|
||||
|
||||
# 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")
|
||||
for line in messageSplitInLines:
|
||||
if line == messageSplitInLines[:1] and line == "":
|
||||
|
@ -287,7 +287,7 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
|
|||
token.spamProtection()
|
||||
|
||||
# Fokabot message
|
||||
if isChannel == True or to.lower() == "fokabot":
|
||||
if isChannel or to.lower() == "fokabot":
|
||||
fokaMessage = fokabot.fokabotResponse(token.username, to, message)
|
||||
if 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.channelInfoEnd())
|
||||
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))
|
|
@ -141,7 +141,7 @@ class token:
|
|||
"""
|
||||
if channelObject.name in self.joinedChannels:
|
||||
raise exceptions.userAlreadyInChannelException()
|
||||
if channelObject.publicRead == False and self.admin == False:
|
||||
if not channelObject.publicRead and not self.admin:
|
||||
raise exceptions.channelNoPermissionsException()
|
||||
self.joinedChannels.append(channelObject.name)
|
||||
self.joinStream("chat/{}".format(channelObject.name))
|
||||
|
|
|
@ -183,7 +183,7 @@ class tokenList:
|
|||
timeoutLimit = int(time.time()) - 100
|
||||
for key, value in self.tokens.items():
|
||||
# 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
|
||||
# We can't delete it while iterating or items() throws an error
|
||||
timedOutTokens.append(key)
|
||||
|
|
Loading…
Reference in New Issue
Block a user