-
Notifications
You must be signed in to change notification settings - Fork 52
/
multiple_clients.py
92 lines (76 loc) · 2.81 KB
/
multiple_clients.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""This example makes use of multiple accounts. If captcha is enforced for
the accounts, you will only have to enter the authorization code the first time
you run this script.
NOTE: This example uses AdvancedAuth and stores the details in a file.
It is important that this file is moved whenever the script itself is moved
because it relies on the stored details. However, if the file is nowhere to
be found, it will simply use email and password or prompt you to enter a
new authorization code to generate a new file.
"""
import fortnitepy
import asyncio
import functools
import os
import json
instances = {}
filename = 'device_auths.json'
credentials = {
"email1": "password1",
"email2": "password2",
"email3": "password3",
"email4": "password4",
"email5": "password5",
"email6": "password6",
"email7": "password7",
"email8": "password8",
"email9": "password9",
"email10": "password10",
}
def get_device_auth_details():
if os.path.isfile(filename):
with open(filename, 'r') as fp:
return json.load(fp)
return {}
def store_device_auth_details(email, details):
existing = get_device_auth_details()
existing[email] = details
with open(filename, 'w') as fp:
json.dump(existing, fp)
async def event_sub_device_auth_generate(details, email):
store_device_auth_details(email, details)
async def event_sub_ready(client):
instances[client.user.id] = client
print('{0.user.display_name} ready.'.format(client))
async def event_sub_friend_request(request):
print('{0.client.user.display_name} received a friend request.'.format(request))
await request.accept()
async def event_sub_party_member_join(member):
print("{0.display_name} joined {0.client.user.display_name}'s party.".format(member))
clients = []
device_auths = get_device_auth_details()
for email, password in credentials.items():
authentication = fortnitepy.AdvancedAuth(
email=email,
password=password,
prompt_authorization_code=True,
delete_existing_device_auths=True,
**device_auths.get(email, {})
)
client = fortnitepy.Client(
auth=authentication,
default_party_member_config=fortnitepy.DefaultPartyMemberConfig(
meta=(
functools.partial(fortnitepy.ClientPartyMember.set_outfit, 'CID_175_Athena_Commando_M_Celestial'), # galaxy skin
)
)
)
# register events here
client.add_event_handler('device_auth_generate', event_sub_device_auth_generate)
client.add_event_handler('friend_request', event_sub_friend_request)
client.add_event_handler('party_member_join', event_sub_party_member_join)
clients.append(client)
fortnitepy.run_multiple(
clients,
ready_callback=event_sub_ready,
all_ready_callback=lambda: print('All clients ready')
)