How to use the fortnitepy.user.User 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 Terbau / fortnitepy / fortnitepy / client.py View on Github external
def store_user(self, data: dict, *, try_cache: bool = True) -> User:
        try:
            user_id = data.get(
                'accountId',
                data.get('id', data.get('account_id'))
            )

            if try_cache:
                return self._users.get(user_id, silent=False)
        except KeyError:
            pass

        u = User(self, data)
        if self.cache_users:
            self._users.set(u.id, u)
        return u
github Terbau / fortnitepy / fortnitepy / client.py View on Github external
Parameters
        ----------
        user_id: :class:`str`
            The id of the user.

        Returns
        -------
        Optional[:class:`User`]
            The user if found, else ``None``
        """
        user = self._users.get(user_id)
        if user is None:
            friend = self.get_friend(user_id)
            if friend is not None:
                user = User(self, friend.get_raw())
                if self.cache_users:
                    self._users.set(user.id, user)
        return user
github Terbau / fortnitepy / fortnitepy / client.py View on Github external
raw: :class:`bool`
            If set to True it will return the data as you would get it from
            the api request. *Defaults to ``False``*

        Raises
        ------
        HTTPException
            An error occured while requesting the user.

        Returns
        -------
        List[:class:`User`]
            A list containing all payloads found for this user.
        """
        res = await self.http.account_graphql_get_by_display_name(display_name)
        return [User(self, account) for account in res['account']]
github Terbau / fortnitepy / fortnitepy / client.py View on Github external
async def fetch_profile_by_display_name(self, display_name, *,
                                            cache: bool = False,
                                            raw: bool = False
                                            ) -> Optional[User]:
        """|coro|

        Fetches a profile from the passed display name

        Parameters
        ----------
        display_name: :class:`str`
            The display name of the user you want to fetch the profile for.
        cache: :class:`bool`
            If set to True it will try to get the profile from the friends or
            user cache.

            .. note::

                Setting this parameter to False will make it an api call.
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
else:
            deleted.append(
                self.delete_prop('urn:epic:cfg:not-accepting-members-reason_i')
            )

        if self.party.edit_lock.locked():
            self.deleted_cache.extend(deleted)

        return updated, deleted

    def set_voicechat_implementation(self, value: str) -> Dict[str, str]:
        key = 'VoiceChat:implementation_s'
        return {key: self.set_prop(key, value)}


class PartyMemberBase(User):
    def __init__(self, client: 'Client',
                 party: 'PartyBase',
                 data: str) -> None:
        super().__init__(client=client, data=data)

        self._party = party
        self._assignment_version = 0

        self._joined_at = self.client.from_iso(data['joined_at'])
        self.meta = PartyMemberMeta(self, meta=data.get('meta'))
        self._update(data)

    @property
    def party(self) -> 'PartyBase':
        """Union[:class:`Party`, :class:`ClientParty`]: The party this member
        is a part of.
github Terbau / fortnitepy / fortnitepy / user.py View on Github external
super().__init__(client, data)

    def __repr__(self) -> str:
        return (''.format(self))

    async def unblock(self) -> None:
        """|coro|

        Unblocks this friend.
        """
        await self.client.unblock_user(self.id)


class ProfileSearchEntryUser(User):
    """Represents a user entry in a profile search.

    Parameters
    ----------
    matches: List[Tuple[:class:`str`, :class:`ProfileSearchPlatform`]]
        | A list of tuples containing the display name the user matched
        and the platform the display name is from.
        | Example: ``[('Tfue', ProfileSearchPlatform.EPIC_GAMES)]``
    match_type: :class:`ProfileSearchMatchType`
        The type of match this user matched by.
    mutual_friend_count: :class:`int`
        The amount of **epic** mutual friends the client has with the user.
    """
    def __init__(self, client: 'Client',
                 profile_data: dict,
                 search_data: dict) -> None:
github Terbau / fortnitepy / fortnitepy / user.py View on Github external
self.matches = [(d['value'], ProfileSearchPlatform(d['platform']))
                        for d in search_data['matches']]
        self.match_type = ProfileSearchMatchType(search_data['matchType'])
        self.mutual_friend_count = search_data['epicMutuals']

    def __str__(self) -> str:
        return self.matches[0][0]

    def __repr__(self) -> str:
        return (''.format(self))


class SacSearchEntryUser(User):
    """Represents a user entry in a support a creator code search.

    Parameters
    ----------
    slug: :class:`str`
        The slug (creator code) that matched.
    active: :class:`bool`
        Wether or not the creator code is active or not.
    verified: :class:`bool`
        Wether or not the creator code is verified or not.
    """
    def __init__(self, client: 'Client',
                 profile_data: dict,
                 search_data: dict) -> None:
        super().__init__(client, profile_data)