How to use the fortnitepy.Client function in fortnitepy

To help you get started, we’ve selected a few fortnitepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xMistt / fortnitepy-bot / discord / discord.py View on Github external
import fortnitepy
from discord.ext import commands
import discord

discord_bot = commands.Bot(
    command_prefix='!',
    description='My discord + fortnite bot!',
    case_insensitive=True
)

fortnite_client = fortnitepy.Client(
    email='',
    password='',
    loop=discord_bot.loop
)

@discord_bot.event
async def on_ready():
    print('Discord bot ready')
    activity = discord.Game(name="fortnite.py")
    await discord_bot.change_presence(status=discord.Status.idle, activity=activity)
    await fortnite_client.start()

@fortnite_client.event
async def event_ready():
    print('Fortnite client ready')
github Terbau / fortnitepy / examples / api_integrations / fortnite_api.py View on Github external
filename = 'device_auths.json'

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)

class MyClient(fortnitepy.Client):
    def __init__(self):
        device_auth_details = get_device_auth_details().get(email, {})
        super().__init__(
            auth=fortnitepy.AdvancedAuth(
                email=email,
                password=password,
                prompt_authorization_code=True,
                delete_existing_device_auths=True,
                **device_auth_details
            )
        )
        self.session_event = asyncio.Event()
        
    async def event_device_auth_generate(self, details, email):
        store_device_auth_details(email, details)
github Terbau / fortnitepy / examples / api_integrations / ben_bot.py View on Github external
filename = 'device_auths.json'

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)

class MyClient(fortnitepy.Client):
    def __init__(self):
        device_auth_details = get_device_auth_details().get(email, {})
        super().__init__(
            auth=fortnitepy.AdvancedAuth(
                email=email,
                password=password,
                prompt_authorization_code=True,
                delete_existing_device_auths=True,
                **device_auth_details
            )
        )
        self.session_event = asyncio.Event(loop=self.loop)
        
    async def event_device_auth_generate(self, details, email):
        store_device_auth_details(email, details)
github Terbau / fortnitepy / examples / multiple_sub_clients.py View on Github external
async def event_ready(self):
        print('Main client ready. Launching sub-accounts...')

        clients = []
        device_auths = get_device_auth_details()
        for email, password in credentials.items():
            client = fortnitepy.Client(
                auth=fortnitepy.AdvancedAuth(
                    email=email,
                    password=password,
                    prompt_authorization_code=True,
                    delete_existing_device_auths=True,
                    **device_auths.get(email, {})
                ),
                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', self.event_sub_device_auth_generate)
github Terbau / fortnitepy / examples / multiple_clients.py View on Github external
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(
github Terbau / fortnitepy / examples / multiple_sub_clients.py View on Github external
}

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)

class MyClient(fortnitepy.Client):
    def __init__(self):
        device_auths = get_device_auth_details()
        super().__init__(
            auth=fortnitepy.AdvancedAuth(
                email=email,
                password=password,
                authorization=True,
                delete_existing_device_auths=True,
                **device_auths.get(email, {})
            )
        )
        self.instances = {}

    async def event_sub_device_auth_generate(self, details, email):
        store_device_auth_details(email, details)