mirror of
https://github.com/MCMi460/3DS-RPC.git
synced 2025-06-18 21:45:37 -04:00
backend: Replace add_friend_by_principal_id with sync_friend
This commit is contained in:
parent
9851c74c26
commit
e33db2d7a6
@ -120,25 +120,13 @@ async def main_friends_loop(friends_client: friends.FriendsClientV1, session: Se
|
|||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
await friends_client.update_comment('3dsrpc.com')
|
await friends_client.update_comment('3dsrpc.com')
|
||||||
|
|
||||||
print('Cleaning friends list out from previous runs...')
|
# Synchronize our current roster of friends.
|
||||||
removables = await friends_client.get_all_friends()
|
|
||||||
for friend in removables:
|
|
||||||
time.sleep(delay / quicker)
|
|
||||||
await friends_client.remove_friend_by_principal_id(friend.pid)
|
|
||||||
print('Removed %s friends' % str(len(removables)))
|
|
||||||
|
|
||||||
# Add our current roster of friends.
|
|
||||||
#
|
#
|
||||||
# The add_friend_by_principal_ids method is not yet
|
# We expect the remote NEX implementation to remove all existing
|
||||||
# implemented on Pretendo, so this is a hotfix for now.
|
# relationships, and replace them with the 100 PIDs specified.
|
||||||
|
# As of writing, both Nintendo and Pretendo support this.
|
||||||
all_friend_pids: list[int] = [ f.pid for f in current_rotation ]
|
all_friend_pids: list[int] = [ f.pid for f in current_rotation ]
|
||||||
if network == NetworkType.PRETENDO:
|
await friends_client.sync_friend(0, all_friend_pids, [])
|
||||||
for friend_pid in all_friend_pids:
|
|
||||||
time.sleep(delay / quicker)
|
|
||||||
await friends_client.add_friend_by_principal_id(0, friend_pid)
|
|
||||||
else:
|
|
||||||
time.sleep(delay)
|
|
||||||
await friends_client.add_friend_by_principal_ids(0, all_friend_pids)
|
|
||||||
|
|
||||||
# Query all successful friends.
|
# Query all successful friends.
|
||||||
current_friends_list: [friends.FriendRelationship] = await friends_client.get_all_friends()
|
current_friends_list: [friends.FriendRelationship] = await friends_client.get_all_friends()
|
||||||
@ -273,11 +261,6 @@ async def main_friends_loop(friends_client: friends.FriendsClientV1, session: Se
|
|||||||
)
|
)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
# Lastly, remove all of our added friends.
|
|
||||||
for friend in added_friends:
|
|
||||||
time.sleep(delay / quicker)
|
|
||||||
await friends_client.remove_friend_by_principal_id(friend.pid)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user