diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index a958bcc..0f6b554 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -886,6 +886,22 @@ def multiplayer(fro, chan, message): threading.Timer(1.00, _decreaseTimer, [startTime - 1]).start() return "Match starts in {} seconds".format(startTime) + def mpInvite(): + if len(message) < 2: + raise exceptions.invalidArgumentsException("Wrong syntax: !mp invite ") + 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: subcommands = { "make": mpMake, @@ -898,12 +914,13 @@ def multiplayer(fro, chan, message): "host": mpHost, "clearhost": mpClearHost, "start": mpStart, + "invite": mpInvite, } requestedSubcommand = message[0].lower().strip() if requestedSubcommand not in subcommands: raise exceptions.invalidArgumentsException("Invalid subcommand") return subcommands[requestedSubcommand]() - except exceptions.invalidArgumentsException as e: + except (exceptions.invalidArgumentsException, exceptions.userNotFoundException) as e: return str(e) except exceptions.wrongChannelException: return "This command only works in multiplayer chat channels" diff --git a/events/joinMatchEvent.py b/events/joinMatchEvent.py index 362fddc..b388ad1 100644 --- a/events/joinMatchEvent.py +++ b/events/joinMatchEvent.py @@ -25,8 +25,7 @@ def handle(userToken, packetData): # password = generalUtils.stringMd5(password) # Check password - # Always send wrong password if this is a tourney match - if (match.matchPassword != "" and match.matchPassword != password) or match.isTourney: + if match.matchPassword != "" and match.matchPassword != password: raise exceptions.matchWrongPasswordException # Password is correct, join match