### Internal Start Sequence Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Performs the initial asynchronous setup for the client, including registering methods and dispatching the 'before_start' event if required. ```python async def _start(self, dispatch_ready: bool = True) -> None: await self.init() if self._first_start: self.register_methods() if dispatch_ready: await self.dispatch_and_wait_event('before_start') ``` -------------------------------- ### Start Client Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Starts the client and logs into the specified user. Can be used as an async context manager or a coroutine. It dispatches the `event_ready` event if `dispatch_ready` is true. ```APIDOC ## Client Start ### Description Starts the client and logs into the specified user. This method can be used as a coroutine or an async context manager. It dispatches the `event_ready` event when the client is ready if `dispatch_ready` is set to `True`. ### Method `start(dispatch_ready: bool = True)` ### Endpoint N/A ### Parameters #### Query Parameters - **dispatch_ready** (bool) - Optional - Defaults to `True`. Whether or not the client should dispatch the ready event when ready. ### Request Example As an async context manager: ```python async with client.start(): user = await client.fetch_user('Ninja') print(user.display_name) ``` As a coroutine: ```python start_future = await client.start() await start_future ``` ### Response #### Success Response (200) Returns a `StartContext` object which can be awaited or used as an async context manager. #### Response Example ```python # Example of awaiting the future returned by start() async with client.start() as future: user = await client.fetch_user('Ninja') print(user.display_name) await future # This line will block until the client is closed. ``` ### Raises - **AuthException**: Raised if invalid credentials in any form were passed or some other misc failure. - **HTTPException**: A request error occurred while logging in. ``` -------------------------------- ### Start Client as Async Context Manager Source: https://rebootpy.readthedocs.io/en/latest/api.html Use the `start()` method as an async context manager to begin the client's operation. Code within the `async with` block executes after the client is ready. Awaiting the returned future will block until the client is closed. ```python async with client.start(): user = await client.fetch_user(‘Ninja’) print(user.display_name) ``` ```python async with client.start() as future: user = await client.fetch_user('Ninja') print(user.display_name) await future # Nothing after this line will run. ``` -------------------------------- ### POST /start Source: https://rebootpy.readthedocs.io/en/latest/api.html Starts the client and logs into the specified user. ```APIDOC ## POST /start ### Description Starts the client and logs into the specified user. This method is a coroutine and can be used as an async context manager. ### Parameters - **dispatch_ready** (bool) - Optional - Whether the client should dispatch the ready event when ready. ``` -------------------------------- ### Start Client as Async Context Manager Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Provides an asynchronous context manager for starting the client and logging in. It can be used to manage the client's lifecycle within an `async with` block, optionally awaiting a future that completes when the client is ready. ```python def start(self, dispatch_ready: bool = True) -> StartContext: """|coro| Starts the client and logs into the specified user. This method can be used as a coroutine or an async context manager, depending on your needs. How to use as an async context manager: :: async with client.start(): user = await client.fetch_user('Ninja') print(user.display_name) If you want to use it as an async context manager, but also keep the client running forever, you can await the return of start like this: :: async with client.start() as future: user = await client.fetch_user('Ninja') print(user.display_name) await future # Nothing after this line will run. .. warning:: This method is blocking if you await it as a coroutine or you await the return future. This means that no code coming after will run until the client is closed. When the client is ready it will dispatch :meth:`event_ready`. Parameters ---------- dispatch_ready: :class:`bool` Whether or not the client should dispatch the ready event when ready. Raises ------ AuthException Raised if invalid credentials in any form was passed or some other misc failure. HTTPException A request error occurred while logging in. """ return StartContext(self, dispatch_ready=dispatch_ready) ``` -------------------------------- ### run Source: https://rebootpy.readthedocs.io/en/latest/ext/commands/api.html Starts the event loop and calls `start()`. Use `start()` directly if an asyncio loop is already set up. This function is blocking. ```APIDOC ## POST /run ### Description Starts the loop and then calls `start()` for you. If your program already has an asyncio loop setup, you should use `start()` instead. This function is blocking and should be the last function to run. ### Method POST ### Endpoint /run ### Raises - **AuthException** – Raised if invalid credentials in any form was passed or some other misc failure. - **HTTPException** – A request error occurred while logging in. ``` -------------------------------- ### Start the Client Source: https://rebootpy.readthedocs.io/en/latest/api.html Starts the client and logs in the user. This method can be used as a coroutine or an async context manager. It is blocking if awaited directly or via its return future. ```python async with client.start(): user = await client.fetch_user(‘Ninja’) print(user.display_name) ``` ```python async with client.start() as future: user = await client.fetch_user('Ninja') print(user.display_name) await future # Nothing after this line will run. ``` -------------------------------- ### Client Start API Source: https://rebootpy.readthedocs.io/en/latest/ext/commands/api.html Starts the client and logs into the specified user. This method can be used as a coroutine or an async context manager. ```APIDOC ## async start(_dispatch_ready =True_) ### Description Starts the client and logs into the specified user. This method can be used as a coroutine or an async context manager. ### Method async ### Endpoint N/A (Client method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python async with client.start(): user = await client.fetch_user('Ninja') print(user.display_name) ``` ### Response #### Success Response (200) None (dispatches `event_ready()`) #### Response Example None ``` -------------------------------- ### Basic rebootpy Bot Example Source: https://rebootpy.readthedocs.io/en/latest/intro.html A fundamental example demonstrating how to create a rebootpy client, handle device authentication, and respond to events like being ready, friend requests, and friend messages. It uses AdvancedAuth for login. ```python import rebootpy import json import os filename = 'device_auths.json' class MyClient(rebootpy.Client): def __init__(self): device_auth_details = self.get_device_auth_details() # this auth instance will login via device auth if its present but if its # not, it'll open device code in the browser for you to input email & pass super().__init__( auth=rebootpy.AdvancedAuth( prompt_device_code=True, **device_auth_details ) ) def get_device_auth_details(self): if os.path.isfile(filename): with open(filename, 'r') as fp: return json.load(fp) return {} def store_device_auth_details(self, details): with open(filename, 'w') as fp: json.dump(details, fp) async def event_device_auth_generate(self, details): self.store_device_auth_details(details) async def event_ready(self): print(f'Client ready as {self.user.display_name}') async def event_friend_request(self, request): await request.accept() async def event_friend_message(self, message): print(f'{message.author.display_name}: {message.content}') await message.reply('Thanks for your message!') bot = MyClient() bot.run() ``` -------------------------------- ### Run Client Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Starts the asyncio event loop and calls the `start()` method. This is a blocking function and should be the last function to run. ```APIDOC ## Client Run ### Description Starts the asyncio event loop and calls the `start()` method. This is a blocking function and should be the last function to run. It catches `KeyboardInterrupt` for graceful shutdown. ### Method `run()` ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ### Raises - **AuthException**: Raised if invalid credentials are provided or other authentication failures occur. - **HTTPException**: Raised if a request error occurs during login. ``` -------------------------------- ### Start Multiple Clients Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Starts multiple clients concurrently with configurable timeouts and lifecycle callbacks. This function is blocking and should be the final call in the application. ```python async def start_multiple(clients: List['BasicClient'], *, gap_timeout: float = 0.2, shutdown_on_error: bool = True, ready_callback: Optional[MaybeCoro] = None, error_callback: Optional[MaybeCoro] = None, all_ready_callback: Optional[MaybeCoro] = None, before_start: Optional[Awaitable] = None, before_close: Optional[Awaitable] = None ) -> None: """|coro| Starts multiple clients at the same time. .. warning:: This function is blocking and should be the last function to run. .. info:: Due to throttling by epicgames on login, the clients are started with a 0.2 second gap. You can change this value with the gap_timeout keyword argument. Parameters ---------- clients: List[:class:`BasicClient`] A list of the clients you wish to start. gap_timeout: :class:`float` The time to sleep between starting clients. Defaults to ``0.2``. shutdown_on_error: :class:`bool` If the function should cancel all other start tasks if one of the tasks fails. You can catch the error by try excepting. ready_callback: Optional[Union[Callable[:class:`BasicClient`], Awaitable[:class:`BasicClient`]]] A callable/async callback taking a single parameter ``client``. The callback is called whenever a client is ready. error_callback: Optional[Union[Callable[:class:`BasicClient`, Exception], Awaitable[:class:`BasicClient`, Exception]]] A callable/async callback taking two parameters, :class:`BasicClient` and an exception. The callback is called whenever a client fails logging in. The callback is not called if ``shutdown_on_error`` is ``True``. all_ready_callback: Optional[Union[Callable, Awaitable]] A callback/async callback that is called whenever all clients have finished logging in, regardless if one of the clients failed logging in. That means that the callback is always called when all clients are either logged in or raised an error. before_start: Optional[Awaitable] An async callback that is called when just before the clients are beginning to start. This must be a coroutine as all the clients wait to start until this callback is finished processing so you can do heavy start stuff like opening database connections, sessions etc. before_close: Optional[Awaitable] An async callback that is called when the clients are beginning to close. This must be a coroutine as all the clients wait to close until this callback is finished processing so you can do heavy close stuff like closing database connections, sessions etc. Raises ------ AuthException Raised if invalid credentials in any form was passed or some other misc failure. ValueError Two or more clients with the same authentication identifier was passed. This means that you attemted to start two or more clients with the same credentials. HTTPException A request error occurred while logging in. """ # noqa loop = asyncio.get_running_loop() async def waiter(client): _, pending = await asyncio.wait( (loop.create_task(client.wait_until_ready()), loop.create_task(client.wait_until_closed())), return_when=asyncio.FIRST_COMPLETED ) for task in pending: task.cancel() async def all_ready_callback_runner(): ``` -------------------------------- ### Fetch Ranked Stats Example Source: https://rebootpy.readthedocs.io/en/latest/api.html Example of how to fetch a user's ranked stats for a specific season. If no season is provided, it defaults to the current season. ```python # get my C5S3 ranked stats async def get_6v_ranked_stats(): print(f'Fetching ranked stats for C5S3') user = await bot.fetch_user('6v.') ranks = await user.fetch_ranked_stats( season=rebootpy.Season.C5S3 ) for rank in ranks: print(f'{rank.ranking_type.name} - {rank.current_division.name}') # Example output: # Fetching ranked stats for C5S3 # BATTLE_ROYALE - DIAMOND_2 # ROCKET_RACING - UNRANKED # ZERO_BUILD - UNREAL ``` -------------------------------- ### Run Client with Asyncio Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Starts the asyncio event loop and runs the client's start sequence. This method is blocking and should be the last function called. It handles KeyboardInterrupt for graceful shutdown. ```python def run(self) -> None: """This function starts the loop and then calls :meth:`start` for you. If your program already has an asyncio loop setup, you should use :meth:`start()` instead. .. warning:: This function is blocking and should be the last function to run. Raises ------ AuthException Raised if invalid credentials in any form was passed or some other misc failure. HTTPException A request error occurred while logging in. """ async def runner(): async with self.start() as start_future: await start_future try: asyncio.run(runner()) except KeyboardInterrupt: # StartContext automatically closes for us, so we just catch # the KeyboardInterrupt wihtout doing anything more here. pass ``` -------------------------------- ### start_multiple Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Starts multiple clients concurrently with configurable timeouts and lifecycle callbacks. ```APIDOC ## start_multiple ### Description Starts multiple clients at the same time. This function is blocking and should be the last function to run. Clients are started with a gap timeout to avoid throttling. ### Parameters - **clients** (List[BasicClient]) - Required - A list of the clients you wish to start. - **gap_timeout** (float) - Optional - The time to sleep between starting clients. Defaults to 0.2. - **shutdown_on_error** (bool) - Optional - If the function should cancel all other start tasks if one of the tasks fails. - **ready_callback** (Optional[Union[Callable, Awaitable]]) - Optional - Callback called whenever a client is ready. - **error_callback** (Optional[Union[Callable, Awaitable]]) - Optional - Callback called whenever a client fails logging in. - **all_ready_callback** (Optional[Union[Callable, Awaitable]]) - Optional - Callback called when all clients have finished logging in. - **before_start** (Optional[Awaitable]) - Optional - Async callback called just before clients begin to start. - **before_close** (Optional[Awaitable]) - Optional - Async callback called when clients are beginning to close. ### Raises - **AuthException** - Raised if invalid credentials were passed. - **ValueError** - Raised if two or more clients with the same authentication identifier were passed. - **HTTPException** - A request error occurred while logging in. ``` -------------------------------- ### Invoke a command Source: https://rebootpy.readthedocs.io/en/latest/_sources/ext/commands/commands.rst.txt Example of how a user invokes a command via a prefix. ```none $foo abc ``` -------------------------------- ### Start the Client as an Async Context Manager Source: https://rebootpy.readthedocs.io/en/latest/ext/commands/api.html Demonstrates using the client as an async context manager to fetch user information upon startup. ```python async with client.start(): user = await client.fetch_user(‘Ninja’) print(user.display_name) ``` ```python async with client.start() as future: user = await client.fetch_user('Ninja') print(user.display_name) await future # Nothing after this line will run. ``` -------------------------------- ### Get Match Start Time Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/party.html Retrieves the UTC timestamp when the match started from 'Default:UtcTimeStartedMatchAthena_s'. ```python return self.get_prop('Default:UtcTimeStartedMatchAthena_s') ``` -------------------------------- ### Implement extension setup and teardown Source: https://rebootpy.readthedocs.io/en/latest/_sources/ext/commands/extensions.rst.txt Use extension_setup for initialization and cog_teardown for cleanup tasks when an extension is unloaded. ```python3 def extension_setup(bot): print('I am being loaded!') def cog_teardown(bot): print('I am being unloaded!') ``` -------------------------------- ### Get Match Started Time Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/party.html Retrieves the UTC time when the party member's match started. Returns None if the member is not currently in a match. ```APIDOC ## GET /api/party/member/match_started_at ### Description Retrieves the UTC time when the party member's match started. ### Method GET ### Endpoint /api/party/member/match_started_at ### Parameters None ### Request Body None ### Response #### Success Response (200) - **match_started_at** (optional[datetime.datetime]) - The time in UTC that the member's match started. None if not in a match. #### Response Example ```json "2023-10-27T10:30:00Z" ``` ``` -------------------------------- ### Get Account Stats v2 Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/http.html Fetches statistics for a specific user ID. Optional start and end times can be provided to filter the data. ```python params = {} if start_time: params['startTime'] = start_time if end_time: params['endTime'] = end_time r = StatsproxyPublicService( '/statsproxy/api/statsv2/account/{user_id}', user_id=user_id ) return await self.get(r, params=params) ``` -------------------------------- ### StartContext Class for Client Initialization Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Manages the asynchronous startup and shutdown of the client. Use `async with` for automatic resource management. ```python class StartContext: def __init__(self, client: 'BasicClient', dispatch_ready: bool = True) -> None: self.client = client self.dispatch_ready = dispatch_ready async def start(self) -> asyncio.Task: await self.client.init() task = asyncio.create_task( self.client._start(dispatch_ready=self.dispatch_ready) ) await asyncio.wait( (asyncio.create_task(self.client.wait_until_ready()), task), return_when=asyncio.FIRST_COMPLETED, ) return task async def __aenter__(self) -> asyncio.Task: return await self.start() async def __aexit__(self, *args) -> None: if not self.client._closing and not self.client._closed: await self.client.close() def __await__(self) -> None: async def awaiter(): task = await self.start() return await task return awaiter().__await__() ``` -------------------------------- ### Calculate Win Percentage Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/stats.html Calculates the win percentage for a given game mode. The example demonstrates how to get the win percentage for a user in zero build squads. ```python def get_winpercentage(self, data: dict) -> float: """Gets the winpercentage of a gamemode Usage: :: # get my winpercentage in zero build squads on kbm touch async def get_6v_zb_squad_winpercentage(): user = await client.fetch_user('6v.') stats = await client.fetch_br_stats(user.id) ``` -------------------------------- ### Input and output examples for keyword-only arguments Source: https://rebootpy.readthedocs.io/en/latest/_sources/ext/commands/commands.rst.txt Demonstrates how keyword-only arguments handle input. ```none $test hello world ``` ```none hello world ``` ```none $test "hello world" ``` ```none "hello world" ``` -------------------------------- ### Input and output examples for variable arguments Source: https://rebootpy.readthedocs.io/en/latest/_sources/ext/commands/commands.rst.txt Demonstrates how variable arguments are parsed. ```none $test hello there friend ``` ```none 3 arguments: hello, there, friend ``` ```none $test hello there "my friend" ``` ```none 3 arguments: hello, there, my friend ``` ```none $test ``` ```none 0 arguments: ``` -------------------------------- ### HTTP GET Request Method Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/http.html Defines the asynchronous GET method for making HTTP requests. It calls the internal `fn_request` method with the 'GET' method type. ```python async def get(self, route: Union[Route, str], auth: Optional[str] = None, **kwargs: Any) -> Any: return await self.fn_request('GET', route, auth, **kwargs) ``` -------------------------------- ### Prepare Help Command Environment Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/help.html Clears the paginator and initializes the help command context. ```python async def prepare_help_command(self, ctx: Context, command: Command) -> None: self.paginator.clear() await super().prepare_help_command(ctx, command) ``` -------------------------------- ### Input and output examples for positional arguments Source: https://rebootpy.readthedocs.io/en/latest/_sources/ext/commands/commands.rst.txt Demonstrates how user input is parsed into positional arguments. ```none $test hello ``` ```none hello ``` ```none $test "hello world" ``` ```none hello world ``` ```none $test hello world ``` ```none hello ``` -------------------------------- ### Install rebootpy on Linux Source: https://rebootpy.readthedocs.io/en/latest/_sources/intro.rst.txt Use this command to install rebootpy on Linux systems. Requires Python 3.5 or higher. ```sh python3 -m pip install rebootpy ``` -------------------------------- ### Install rebootpy on Windows Source: https://rebootpy.readthedocs.io/en/latest/_sources/intro.rst.txt Use this command to install rebootpy on Windows systems. Requires Python 3.5 or higher. ```sh py -3 -m pip install rebootpy ``` -------------------------------- ### Initialize Client Loop and HTTP Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Sets up the asyncio loop, creates an HTTP client with default headers, and initializes authentication. This is part of the client's internal startup process. ```python self.loop = asyncio.get_running_loop() self._exception_future = self.loop.create_future() self._ready_event = asyncio.Event() self._closed_event = asyncio.Event() self._reauth_lock = LockEvent() self._reauth_lock.failed = False self.http = HTTPClient( self ) self.http.add_header('Accept-Language', 'en-EN') self.auth.initialize(self) ``` -------------------------------- ### HelpCommand Class Initialization and Lifecycle Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/help.html Handles the creation, copying, and registration of the help command within a bot instance. ```python def __new__(cls, *args: list, **kwargs: dict) -> 'HelpCommand': # To prevent race conditions of a single instance while also allowing # for settings to be passed the original arguments passed must be # assigned to allow for easier copies (which will be made when the # help command is actually called) # see discord.py issue 2123 self = super().__new__(cls) # Shallow copies cannot be used in this case since it is not unusual # to pass instances that need state, e.g. Paginator or what have you # into the function. The keys can be safely copied as-is since they're # 99.99% certain of being string keys deepcopy = copy.deepcopy self.__original_kwargs__ = { k: deepcopy(v) for k, v in kwargs.items() } self.__original_args__ = deepcopy(args) return self def __init__(self, **options: dict) -> None: self.show_hidden = options.pop('show_hidden', False) self.verify_checks = options.pop('verify_checks', True) self.command_attrs = attrs = options.pop('command_attrs', {}) attrs.setdefault('name', 'help') attrs.setdefault('help', 'Shows this message') self.context = None self._command_impl = None def copy(self) -> 'HelpCommand': o = self.__class__(*self.__original_args__, **self.__original_kwargs__) o._command_impl = self._command_impl return o def _add_to_bot(self, bot: 'Bot') -> None: command = _HelpCommandImpl(self, **self.command_attrs) bot.add_command(command) self._command_impl = command def _remove_from_bot(self, bot: 'Bot') -> None: bot.remove_command(self._command_impl.name) self._command_impl._eject_cog() self._command_impl = None ``` -------------------------------- ### BasicClient Initialization Source: https://rebootpy.readthedocs.io/en/latest/api.html How to initialize the BasicClient with authentication and configuration options. ```APIDOC ## BasicClient Initialization ### Description Initializes a new instance of the BasicClient for making simple requests. ### Parameters - **auth** (Auth) - Required - The authentication method to use. - **http_connector** (aiohttp.BaseConnector) - Optional - The connector for http connection pooling. - **http_retry_config** (HTTPRetryConfig) - Optional - Configuration for http retries. - **build** (str) - Optional - The build used by Fortnite. - **os** (str) - Optional - The os version string for the user agent. - **cache_users** (bool) - Optional - Whether to cache User objects (default: True). - **kill_other_sessions** (bool) - Optional - Whether to kill other existing sessions (default: True). ``` -------------------------------- ### wait_for Event Example Source: https://rebootpy.readthedocs.io/en/latest/api.html An example demonstrating how to wait for specific events, such as a friend message or a party member promotion, with timeout and custom checks. ```APIDOC ## Event Handling Examples ### Description Examples of using `client.wait_for` to handle specific events with custom checks and timeouts. #### Example 1: Waiting for a friend message reply ```python @client.event async def event_friend_message(message): await message.reply('Say hello!') def check_function(m): return m.author.id == message.author.id msg = await client.wait_for('message', check=check_function, timeout=60) await msg.reply('Hello {0.author.display_name}!'.format(msg)) ``` #### Example 2: Waiting for party member promotion ```python @client.event async def event_party_member_join(member): if member.id != client.user.id: return def check(m): return m.id == client.user.id try: await client.wait_for('party_member_promote', check=check, timeout=120) except asyncio.TimeoutError: await member.party.send('You took too long to promote me!') await member.party.set_custom_key('my_custom_key_123') ``` ### Parameters for `client.wait_for` * **event** (str) - Required - The name of the event to wait for (e.g., 'message', 'party_member_promote'). * **check** (_Optional_ _[__Callable_ _]_) - A predicate function to filter events. Defaults to a function that always returns True. * **timeout** (int) - Optional - The maximum time in seconds to wait. Defaults to None (wait indefinitely). ### Raises * **asyncio.TimeoutError** - If the timeout is reached before the event is received. ``` -------------------------------- ### Initialize Authentication with Options Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/auth.html Use this constructor to set up authentication with various options like prompting for codes, handling invalid or throttled responses, and managing existing device authentications. Note that `prompt_exchange_code` and `prompt_authorization_code` cannot both be True. ```python def __init__(self, exchange_code: Optional[StrOrMaybeCoro] = None, authorization_code: Optional[StrOrMaybeCoro] = None, device_id: Optional[str] = None, account_id: Optional[str] = None, secret: Optional[str] = None, prompt_exchange_code: bool = False, prompt_authorization_code: bool = False, prompt_device_code: bool = True, open_link_in_browser: bool = True, prompt_code_if_invalid: bool = False, prompt_code_if_throttled: bool = False, delete_existing_device_auths: bool = False, **kwargs: Any) -> None: super().__init__(**kwargs) self.exchange_code = exchange_code self.authorization_code = authorization_code self.device_id = device_id self.account_id = account_id self.secret = secret self.delete_existing_device_auths = delete_existing_device_auths self.prompt_exchange_code = prompt_exchange_code self.prompt_authorization_code = prompt_authorization_code self.prompt_device_code = prompt_device_code self.open_link_in_browser = open_link_in_browser if self.prompt_exchange_code and self.prompt_authorization_code: raise ValueError('Both prompt_exchange_code and ' \ 'prompt_authorization_code cannot be True at ' \ 'the same time.') self.prompt_code_if_invalid = prompt_code_if_invalid self.prompt_code_if_throttled = prompt_code_if_throttled self.kwargs = kwargs self._used_auth = None ``` -------------------------------- ### Setup Client User Data Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Retrieves account information and external authentication data concurrently. ```python async def _setup_client_user(self, priority: int = 0): tasks = [ self.http.account_get_by_user_id( self.auth.account_id, priority=priority ), self.http.account_get_multiple_by_user_id( [self.auth.account_id], priority=priority ), self.http.account_get_external_auths_by_id( self.auth.account_id, priority=priority ), ] data, ext_data, extra_ext_data, *_ = await asyncio.gather(*tasks) data['externalAuths'] = ext_data[0]['externalAuths'] or [] data['extraExternalAuths'] = extra_ext_data self.user = ClientUser(self, data) ``` -------------------------------- ### Example Party Member Configuration Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/party.html Demonstrates how to configure a party member with custom outfit and banner settings using functools.partial. This is useful for setting up default attributes when a client joins a party. ```python from rebootpy import ClientPartyMember from functools import partial [ partial(ClientPartyMember.set_outfit, 'CID_175_Athena_Commando_M_Celestial'), partial(ClientPartyMember.set_banner, icon="OtherBanner28", season_level=100) ] ``` -------------------------------- ### Run the Client (Blocking) Source: https://rebootpy.readthedocs.io/en/latest/api.html The `run()` method starts the client's event loop and calls `start()`. This function is blocking and should be the last one executed in your program. It can raise `AuthException` or `HTTPException`. ```python client.run() ``` -------------------------------- ### Prepare Help Command Callback Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/help.html A low-level asynchronous method to prepare the help command's state before processing. The default implementation does nothing. Called inside the help command callback body. ```python async def prepare_help_command(self, ctx: Context, command: Optional[Command] = None) -> None: """|coro| A low level method that can be used to prepare the help command before it does anything. For example, if you need to prepare some state in your subclass before the command does its processing then this would be the place to do it. The default implementation does nothing. .. note:: This is called *inside* the help command callback body. So all the usual rules that happen inside apply here as well. Parameters ----------- ctx: :class:`Context` The invocation context. command: Optional[:class:`str`] The argument passed to the help command. """ pass ``` -------------------------------- ### Create Party Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/http.html Initializes a new party with specific configuration settings. ```python async def party_create(self, config: dict, **kwargs: Any) -> dict: _chat_enabled = str(config['chat_enabled']).lower() payload = { 'config': { 'discoverability': config['discoverability'], 'join_confirmation': config['join_confirmation'], 'joinability': config['joinability'], 'max_size': config['max_size'] }, 'join_info': { 'connection': { 'id': str(self.client.xmpp.local_jid), 'meta': { 'urn:epic:conn:platform_s': self.client.platform.value } }, 'meta': { 'urn:epic:member:dn_s': self.client.user.display_name } }, 'meta': { 'urn:epic:cfg:accepting-members_b': False, 'urn:epic:cfg:build-id_s': str(self.client.party_build_id), 'urn:epic:cfg:can-join_b': True, ``` -------------------------------- ### GET /lightswitch/api/service/bulk/status Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/http.html Retrieve the status of services. ```APIDOC ## GET /lightswitch/api/service/bulk/status ### Description Retrieves the status of one or more services. ### Method GET ### Endpoint /lightswitch/api/service/bulk/status ### Parameters #### Query Parameters - **serviceId** (string) - Optional - The ID of the service to check. ``` -------------------------------- ### Client Initialization Parameters Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Parameters for initializing the Client class, including authentication, connectors, status, and platform settings. ```python class Client(BasicClient): """Represents the client connected to Fortnite and EpicGames' services. Parameters ---------- auth: :class:`Auth` The authentication method to use. You can read more about available authentication methods :ref:`here `. http_connector: :class:`aiohttp.BaseConnector` The connector to use for http connection pooling. ws_connector: :class:`aiohttp.BaseConnector` The connector to use for websocket connection pooling. This could be the same as the above connector. status: :class:`str` The status you want the client to send with its presence to friends. Defaults to: ``{current_playlist}``. .. note:: There are 3 variables you can use in status, you can also use these later on if you set status past initalisation. * ``{party_size}`` - Amount of players in the party. * ``{party_max_size}`` - Max size of the party. * ``{current_playlist}`` - Uses the same formatting as the normal client e.g. ``Battle Royale``. away: :class:`AwayStatus` The away status the client should use for its presence. Defaults to :attr:`AwayStatus.ONLINE`. platform: :class:`.Platform` The platform you want the client to display as its source. Defaults to :attr:`Platform.WINDOWS`. net_cl: :class:`str` The current net cl used by the current Fortnite build. Named **netCL** in official logs. Defaults to an empty string which is the recommended usage as of ``v0.9.0`` since you then won't need to update it when a new update is pushed by Fortnite. party_version: :class:`int` The party version the client should use. This value determines which version should be able to join the party. If a user attempts to join the clients party with a different party version than the client, then an error will be visible saying something by the lines of "Their party of Fortnite is older/newer than yours". If you experience this error I recommend incrementing the default set value by one since the library in that case most likely has yet to be updated. Defaults to ``3`` (As of November 3rd 2020). default_party_config: :class:`DefaultPartyConfig` The party configuration used when creating parties. If not specified, the client will use the default values specified in the data class. default_party_member_config: :class:`DefaultPartyMemberConfig` The party member configuration used when creating parties. If not specified, the client will use the default values specified in the data class. http_retry_config: Optional[:class:`HTTPRetryConfig`] The config to use for http retries. build: :class:`str` The build used by Fortnite. Defaults to a valid but maybe outdated value. os: :class:`str` The os version string to use in the user agent. Defaults to ``Windows/10.0.17134.1.768.64bit`` which is valid no matter which platform you have set. service_host: :class:`str` The host used by Fortnite's XMPP services. service_domain: :class:`str` The domain used by Fortnite's XMPP services. service_port: :class:`int` The port used by Fortnite's XMPP services. cache_users: :class:`bool` Whether or not the library should cache :class:`User` objects. Disable ``` -------------------------------- ### Context.get_destination Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/context.html Gets the destination for sending messages. ```APIDOC ## Context.get_destination ### Description Gets the destination for sending messages. Returns the party if available, otherwise the author. ### Method `def get_destination(self) -> Union[ClientParty, Friend]` ### Response #### Success Response (Union[ClientParty, Friend]) - **destination** (Union[ClientParty, Friend]) - The ClientParty or Friend object to which messages should be sent. ``` -------------------------------- ### Initialize Client Class Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html The constructor initializes the client with authentication and various configuration settings, including party and event processing defaults. ```python def __init__(self, auth: Auth, **kwargs: Any) -> None: super().__init__(auth=auth, **kwargs) self.status = kwargs.get('status', '{current_playlist}') # noqa self.away = kwargs.get('away', AwayStatus.ONLINE) self.platform = kwargs.get('platform', Platform.WINDOWS) self.net_cl = kwargs.get('net_cl', '') self.party_version = kwargs.get('party_version', 3) self.party_build_id = '1:{0.party_version}:{0.net_cl}'.format(self) self.default_party_config = kwargs.get('default_party_config', DefaultPartyConfig()) # noqa self.default_party_member_config = kwargs.get('default_party_member_config', DefaultPartyMemberConfig()) # noqa self.service_host = kwargs.get('xmpp_host', 'prod.ol.epicgames.com') self.service_domain = kwargs.get('xmpp_domain', 'xmpp-service-prod.ol.epicgames.com') # noqa self.service_port = kwargs.get('xmpp_port', 5222) self.fetch_user_data_in_events = kwargs.get('fetch_user_data_in_events', True) # noqa self.wait_for_member_meta_in_events = kwargs.get('wait_for_member_meta_in_events', True) # noqa self.leave_party_at_shutdown = kwargs.get('leave_party_at_shutdown', True) # noqa self.supports_non_eg1 = False self.xmpp = XMPPClient(self, ws_connector=kwargs.get('ws_connector')) self.websocket = WebsocketClient(self) self.party = None self.auto_update_status = '{current_playlist}' in self.status self.current_status_playlist = 'Battle Royale' self.private_key = None self.public_key_b64 = None self.key_data = {} self._listeners = {} self._events = {} self._friends = {} self._pending_friends = {} self._blocked_users = {} self._presences = {} self._join_party_lock = None self._internal_join_party_lock = None self._join_confirmation = False self._refresh_times = [] self.setup_internal() ``` -------------------------------- ### GET /playlists Source: https://rebootpy.readthedocs.io/en/latest/api.html Fetches all registered Fortnite playlists. ```APIDOC ## GET /playlists ### Description Fetches all playlists registered on Fortnite, including historical gamemodes that are no longer active. ### Method GET ### Endpoint /playlists ### Response #### Success Response (200) - **playlists** (list) - A list of Playlist objects. ``` -------------------------------- ### Initialize FortniteHelpCommand Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/help.html Initializes the FortniteHelpCommand with various options for customizing help message display. Options include DM preferences, pagination settings, and text formatting for titles, lines, and footers. ```python def __init__(self, **options: dict) -> None: self.dm_help = options.pop('dm_help', False) self.paginator = options.pop('paginator', None) self.commands_title = options.pop('commands_title', 'Commands:') self.cog_title = options.pop('cog_title', 'Category:') self.usage_title = options.pop('usage_title', 'Usage:') self.description_title = options.pop('description_title', 'Description:') # noqa self.help_title = options.pop('help_title', 'Help:') self.sub_commands_title = options.pop('sub_commands_title', 'Sub Commands:') # noqa self.no_category = options.pop('no_category_heading', 'No Category') self.height = options.pop('height', 15) self.width = options.pop('width', 60) self.indent = options.pop('indent', 4) self.title_prefix = options.pop('title_prefix', ' +') self.title_suffix = options.pop('title_suffix', '+') self.title_char = options.pop('title_char', '=') self.line_prefix = options.pop('line_prefix', ' ') self.line_suffix = options.pop('line_suffix', '') self.footer_prefix = options.pop('footer_prefix', ' +') self.footer_suffix = options.pop('footer_suffix', '+') self.footer_char = options.pop('footer_char', '=') if self.paginator is None: self.paginator = Paginator() super().__init__(**options) ``` -------------------------------- ### GET /leaderboard Source: https://rebootpy.readthedocs.io/en/latest/api.html Fetches the leaderboard for a specific stat. ```APIDOC ## GET /leaderboard ### Description Fetches the leaderboard for a stat. Note that only stats with 'placetop1' or 'wins' are valid. ### Parameters #### Query Parameters - **stat** (str) - Required - The stat string created via StatsV2.create_stat(). ### Response #### Success Response (200) - **data** (List[Dict[str, Union[str, int]]]) - List of dictionaries containing account and value data. #### Response Example [ { "account": "4480a7397f824fe4b407077fb9397fbb", "value": 5082 } ] ``` -------------------------------- ### POST /api/help/prepare Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/help.html Prepares the help command before execution. This method can be overridden to customize pre-command state. ```APIDOC ## POST /api/help/prepare ### Description A low-level method that can be used to prepare the help command before it does anything. For example, if you need to prepare some state in your subclass before the command does its processing then this would be the place to do it. The default implementation does nothing. .. note:: This is called *inside* the help command callback body. So all the usual rules that happen inside apply here as well. ### Method POST ### Endpoint /api/help/prepare ### Parameters #### Path Parameters - **ctx** (Context) - Required - The invocation context. - **command** (Optional[str]) - Optional - The argument passed to the help command. ### Request Example { "ctx": "invocation context details", "command": "help command argument" } ### Response #### Success Response (200) - **status** (string) - Indicates successful preparation. #### Response Example { "status": "prepared" } ``` -------------------------------- ### GET /party/api/v1/Fortnite/parties/{party_id} Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/http.html Looks up party details. ```APIDOC ## GET /party/api/v1/Fortnite/parties/{party_id} ### Description Retrieves information about a specific party. ### Method GET ### Endpoint /party/api/v1/Fortnite/parties/{party_id} ### Parameters #### Path Parameters - **party_id** (string) - Required - The ID of the party to look up. ``` -------------------------------- ### Command Preparation Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/core.html The `prepare` method orchestrates the setup for command execution, including checks, argument parsing, cooldown preparation, and hook calls. ```APIDOC ## prepare(ctx: Context) ### Description Prepares the command for invocation by performing necessary checks, parsing arguments, managing cooldowns, and executing before hooks. ### Method async def prepare(self, ctx: Context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get Island Tagline Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/creative.html Retrieve the tagline of the island. ```python return self._tagline ``` -------------------------------- ### Construct Command Help Content Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/ext/commands/help.html Formats command metadata including cog name, usage, description, and help text into a list of strings. ```python def construct_command_help(self, command: Command) -> List[str]: fmt = {} if command.cog: fmt[self.cog_title] = command.cog.qualified_name fmt[self.usage_title] = self.get_command_signature(command) if command.description: fmt[self.description_title] = command.description result = [] for title, value in fmt.items(): lines = self.construct_category(title, value) result.extend(lines) if command.help: title = self.help_title value = command.help lines = self.construct_category(title, value, raw=True) result.extend(lines) return result ``` -------------------------------- ### Utility Function for Starting Client Source: https://rebootpy.readthedocs.io/en/latest/_modules/rebootpy/client.html Handles the asynchronous startup of a BasicClient, including error handling and shutdown. ```python async def _start_client(client: 'BasicClient', *, shutdown_on_error: bool = True, after: Optional[MaybeCoro] = None, error_after: Optional[MaybeCoro] = None, ) -> None: loop = asyncio.get_running_loop() if not isinstance(client, BasicClient): raise TypeError( 'client must be an instance derived from rebootpy.BasicClient' ) async def starter(): try: await client.start() except Exception as e: return e tasks = ( loop.create_task(starter()), loop.create_task(client.wait_until_ready()) ) try: done, pending = await asyncio.wait( tasks, return_when=asyncio.FIRST_COMPLETED ) except asyncio.CancelledError: for task in tasks: task.cancel() else: done_task = done.pop() e = done_task.result() if e is not None: await client.close() identifier = client.auth.identifier if shutdown_on_error: if e.args: e.args = ('{0} - {1}'.format(identifier, e.args[0]),) else: ```