Fix foka responding to commands even if the command is not at the beginning of the message

This commit is contained in:
Giuseppe Guerra
2017-08-02 00:02:38 +02:00
parent 2cf1cdf1fd
commit 3373bc9581
5 changed files with 58 additions and 12 deletions

View File

@@ -757,6 +757,32 @@ def report(fro, chan, message):
token.enqueue(serverPackets.notification(msg))
return False
def multiplayer(fro, chan, message):
def mpMake():
return "Not implemented yet."
def mpClose():
myToken = glob.tokens.getTokenFromUsername(fro)
if myToken.matchID == -1:
return "You're not in a multiplayer match"
glob.matches.disposeMatch(myToken.matchID)
return "Multiplayer match #{} disposed successfully".format(myToken.matchID)
try:
subcommands = {
"make": mpMake,
"clear": mpClose
}
requestedSubcommand = message[0].lower().strip()
if requestedSubcommand not in subcommands:
raise exceptions.invalidArgumentsException("Invalid subcommand")
return subcommands[requestedSubcommand]()
except exceptions.invalidArgumentsException as e:
return str(e)
except:
raise
"""
Commands list
@@ -891,6 +917,11 @@ commands = [
}, {
"trigger": "!update",
"callback": updateBeatmap
}, {
"trigger": "!mp",
"privileges": privileges.ADMIN_MANAGE_SERVERS, # TODO: replace with admin tournament privilege
"syntax": "<subcommand>",
"callback": multiplayer
}
#
# "trigger": "!acc",