diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index 6a97b2b..e8d4064 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -821,6 +821,27 @@ def multiplayer(fro, chan, message): except: raise +def switchServer(fro, chan, message): + # Get target user ID + target = message[0] + newServer = message[1] + targetUserID = userUtils.getIDSafe(target) + userID = userUtils.getID(fro) + + # Make sure the user exists + if not targetUserID: + return "{}: user not found".format(target) + + # Connect the user to the end server + userToken = glob.tokens.getTokenFromUserID(userID, ignoreIRC=True, _all=False) + userToken.enqueue(serverPackets.switchServer(newServer)) + + # Disconnect the user from the origin server + # userToken.kick() + return "{} has been connected to {}".format(target, newServer) + + + """ Commands list @@ -961,6 +982,11 @@ commands = [ "privileges": privileges.ADMIN_MANAGE_SERVERS, # TODO: replace with admin tournament privilege "syntax": "", "callback": multiplayer + }, { + "trigger": "!switchserver", + "privileges": privileges.ADMIN_MANAGE_SERVERS, + "syntax": " ", + "callback": switchServer } # # "trigger": "!acc", diff --git a/constants/packetIDs.py b/constants/packetIDs.py index dfec010..19721b7 100644 --- a/constants/packetIDs.py +++ b/constants/packetIDs.py @@ -78,5 +78,6 @@ server_userSilenced = 94 server_userPresenceBundle = 96 client_userPanelRequest = 97 client_tournamentMatchInfoRequest = 93 +server_switchServer = 107 client_tournamentJoinMatchChannel = 108 client_tournamentLeaveMatchChannel = 109 \ No newline at end of file diff --git a/constants/serverPackets.py b/constants/serverPackets.py index 101d0cd..bf5a1f5 100644 --- a/constants/serverPackets.py +++ b/constants/serverPackets.py @@ -264,6 +264,8 @@ def playerFailed(slotID): def matchTransferHost(): return packetHelper.buildPacket(packetIDs.server_matchTransferHost) +def switchServer(address): + return packetHelper.buildPacket(packetIDs.server_switchServer, [[address, dataTypes.STRING]]) """ Other packets """ def notification(message):