#Create a matchmake session matchmake_session = matchmaking.MatchmakeSession() matchmake_session.player_min = 2 matchmake_session.player_max = 12 matchmake_session.participation_policy = 98 matchmake_session.game_mode = 3 matchmake_session.attribs[4] = 0x403 #DLCs enabled matchmake_session.matchmake_system = matchmaking.MatchmakeSystem.FRIENDS session_id = matchmaker.create_matchmake_session(matchmake_session, "", 1).gid #Tell friends we're playing MK8 and have created a room application_data = b"\0\0\x20\x03\0\0\0\0\0\0\0\0\x18" + struct.pack( "<I", pid) + b"\0\0\0" presence = friends.NintendoPresenceV2() presence.flags = 0x1EE presence.is_online = True presence.game_key.title_id = MK8.TITLE_ID_EUR presence.game_key.title_version = MK8.LATEST_VERSION presence.message = "I'm a Python client" presence.unk2 = 2 presence.unk3 = 2 presence.game_server_id = MK8.GAME_SERVER_ID presence.unk4 = 3 presence.pid = pid presence.gathering_id = session_id presence.application_data = application_data friends_client.update_presence(presence)
async def main(): nas = nnas.NNASClient() nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION) nas.set_title(Friends.TITLE_ID_EUR, Friends.LATEST_VERSION) nas.set_locale(REGION, COUNTRY, LANGUAGE) access_token = await nas.login(USERNAME, PASSWORD) nex_token = await nas.get_nex_token(access_token.token, Friends.GAME_SERVER_ID) pid = await nas.get_pid(USERNAME) mii = await nas.get_mii(pid) s = settings.load("friends") s.configure(Friends.ACCESS_KEY, Friends.NEX_VERSION) async with backend.connect(s, nex_token.host, nex_token.port) as be: async with be.login(str(nex_token.pid), nex_token.password) as client: nna_info = friends.NNAInfo() nna_info.principal_info.pid = pid nna_info.principal_info.nnid = USERNAME nna_info.principal_info.mii.name = mii.name nna_info.principal_info.mii.data = mii.data #NintendoPresenceV2 tells the server about your online status, which #game you're currently playing, etc. This will be shown to your friends #in their friend list (unless you disabled this feature). presence = friends.NintendoPresenceV2() friends_client = friends.FriendsClientV2(client) response = await friends_client.update_and_get_all_information( nna_info, presence, BIRTHDAY) if response.comment.text: print("Your status message: %s (last changed on %s)" % (response.comment.text, response.comment.changed)) else: print("You don't have a status message") if response.friends: print("Friends:") for friend in response.friends: principal_info = friend.nna_info.principal_info print("\tNNID:", principal_info.nnid) print("\tName:", principal_info.mii.name) presence = friend.presence print("\tOnline:", ["No", "Yes"][presence.is_online]) if presence.game_key.title_id: print("\tPlaying: %016X (v%i)" % (presence.game_key.title_id, presence.game_key.title_version)) if friend.comment.text: print("\tStatus: %s (last changed on %s)" % (friend.comment.text, friend.comment.changed)) print("\tFriend since:", friend.befriended) print("\tLast online:", friend.last_online) print("\t" + "-" * 40) print() else: print("You don't have any friends") if response.sent_requests: print("Friend requests sent:") print_requests(response.sent_requests) else: print("You haven't sent any friend requests") if response.received_requests: print("Friend requests received:") print_requests(response.received_requests) else: print("You haven't received any friend requests") if response.blacklist: print("Blacklist:") for item in response.blacklist: principal_info = item.principal_info print("\tWho: %s (%s)" % (principal_info.nnid, principal_info.mii.name)) if item.game_key.title_id: print("\tGame: %016X (%i)" % (item.game_key.title_id, item.game_key.title_version)) print("\tSince:", item.since) print("\t" + "-" * 40) else: print("You haven't blacklisted any users")
principal_preference, comment, friends, requests_sent, requests_received, \ blacklist, unk1, notifications, unk2 = client.get_all_information( friends.NNAInfo( friends.PrincipalBasicInfo( pid, USERNAME, #Pid and nnid #If you change mii name or data here it will also be changed on Nintendo's servers friends.MiiV2(mii.name, 0, 0, mii.data, common.DateTime(0)), 2 ), 0x5E, 0x0B ), #NintendoPresenceV2 tells the server about your online status, which #game you're currently playing, etc. This will be shown to your friends #in their friend list (unless you disabled this feature). friends.NintendoPresenceV2( 0, 0, friends.GameKey(0, 0), 0, None, 0, 0, 0, 0, 0, 0, b"", 3, 3, 3 ), #Enter your birthday here common.DateTime.make(31, 12, 2000, 0, 0, 0) ) #Now print everything def print_requests(requests): for request in requests: principal_info = request.principal_info message = request.message print("\tWho: %s (%s)" % (principal_info.nnid, principal_info.mii.name)) print("\tMessage:", message.message)
#and the participation policy set to 98 0, 0, 0, 2, 12, 98, 0, 0, 0, "", 3, [0, 0, 0, 0, 0x403, 0], #game mode = 3, flags = 0x403 (DLCs enabled) True, #Open participation matchmaking.MatchmakeSystem.FRIENDS, #Only friends will join b"", 0, b"", 100, 0 ) session_id, session_key = matchmaker.create_matchmake_session( matchmake_session, "", 1 ) #Tell friends we're playing MK8 and have created a room application_data = b"\0\0\x20\x03\0\0\0\0\0\0\0\0\x18" + struct.pack("<I", pid) + b"\0\0\0" presence = friends.NintendoPresenceV2( 0x1EE, True, friends.GameKey(MK8.TITLE_ID_EUR, MK8.LATEST_VERSION), 0, "I'm a Python client", 2, 2, MK8.GAME_SERVER_ID, 3, pid, session_id, application_data, 3, 3, 3 ) friends_client.update_presence(presence) input("Press enter to disconnect and exit\n") #Tell friends we've gone offline presence = friends.NintendoPresenceV2( 0, False, friends.GameKey(0, 0), 0, "", 0, 0, 0, 0, 0, 0, b"", 0, 0, 0 ) friends_client.update_presence(presence) #Disconnect from servers game_backend.close() friends_backend.close()