Add !mp invite

This commit is contained in:
Giuseppe Guerra 2017-08-06 09:45:39 +02:00
parent 5975e84f52
commit 87d6186993
2 changed files with 19 additions and 3 deletions

View File

@ -886,6 +886,22 @@ def multiplayer(fro, chan, message):
threading.Timer(1.00, _decreaseTimer, [startTime - 1]).start() threading.Timer(1.00, _decreaseTimer, [startTime - 1]).start()
return "Match starts in {} seconds".format(startTime) return "Match starts in {} seconds".format(startTime)
def mpInvite():
if len(message) < 2:
raise exceptions.invalidArgumentsException("Wrong syntax: !mp invite <username>")
username = message[1]
userID = userUtils.getIDSafe(username)
if userID is None:
raise exceptions.userNotFoundException("No such user")
token = glob.tokens.getTokenFromUserID(userID, ignoreIRC=True)
if token is None:
raise exceptions.invalidUserException("That user is not connected to bancho right now.")
_match = glob.matches.matches[getMatchIDFromChannel(chan)]
_match.invite(999, userID)
token.enqueue(serverPackets.notification("Please accept the invite you've just received from FokaBot to "
"enter your tourney match."))
return "An invite to this match has been sent to {}".format(username)
try: try:
subcommands = { subcommands = {
"make": mpMake, "make": mpMake,
@ -898,12 +914,13 @@ def multiplayer(fro, chan, message):
"host": mpHost, "host": mpHost,
"clearhost": mpClearHost, "clearhost": mpClearHost,
"start": mpStart, "start": mpStart,
"invite": mpInvite,
} }
requestedSubcommand = message[0].lower().strip() requestedSubcommand = message[0].lower().strip()
if requestedSubcommand not in subcommands: if requestedSubcommand not in subcommands:
raise exceptions.invalidArgumentsException("Invalid subcommand") raise exceptions.invalidArgumentsException("Invalid subcommand")
return subcommands[requestedSubcommand]() return subcommands[requestedSubcommand]()
except exceptions.invalidArgumentsException as e: except (exceptions.invalidArgumentsException, exceptions.userNotFoundException) as e:
return str(e) return str(e)
except exceptions.wrongChannelException: except exceptions.wrongChannelException:
return "This command only works in multiplayer chat channels" return "This command only works in multiplayer chat channels"

View File

@ -25,8 +25,7 @@ def handle(userToken, packetData):
# password = generalUtils.stringMd5(password) # password = generalUtils.stringMd5(password)
# Check password # Check password
# Always send wrong password if this is a tourney match if match.matchPassword != "" and match.matchPassword != password:
if (match.matchPassword != "" and match.matchPassword != password) or match.isTourney:
raise exceptions.matchWrongPasswordException raise exceptions.matchWrongPasswordException
# Password is correct, join match # Password is correct, join match