Skip to content

Commit

Permalink
Merge pull request #17 from Terbau/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Terbau committed Aug 18, 2019
2 parents 4c36eb3 + 09b2aad commit 025aa21
Show file tree
Hide file tree
Showing 8 changed files with 382 additions and 47 deletions.
7 changes: 7 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ this decorator if you are in a subclass of :class:`Client`.
:param member: The member who joined.
:type member: :class:`PartyMember`

.. function:: event_party_member_leave(member)

This event is called when a member leaves the party.

:param member: The member who left the party.
:type member: :class:`PartyMember`

.. function:: event_party_member_confirmation(confirmation)

This event is called when a member asks to join the party.
Expand Down
58 changes: 58 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,64 @@ Changelog
Detailed version changes.


v0.5.0
------

Breaking update removing ``Party.leave()`` and adding many new meta related party features + important bug fixes.

Breaking Changes
~~~~~~~~~~~~~~~~

- Removed ``Party.leave()``. Use :meth:`PartyMember.leave()` instead.

New Features
~~~~~~~~~~~~

- Added :attr:`PartyMember.ready` which returns the state of a members readiness.
- Added :attr:`PartyMember.input` to check what input a party member is using.
- Added :attr:`PartyMember.assisted_challenge` to get a members currently set party-assisted challenge.
- Added :attr:`PartyMember.outfit` to get the CID of the current outfit a member has equipped.
- Added :attr:`PartyMember.outfit_variants` to get the raw variants of the current outfit a member has equipped.
- Added :attr:`PartyMember.backpack` to get the BID of a members currently equipped backpack.
- Added :attr:`PartyMember.pickaxe` to get a members currently set pickaxe.
- Added :attr:`PartyMember.emote` to get a members currently playing emote.
- Added :attr:`PartyMember.banner` to get a tuple consisting of the members currently set banner.
- Added :attr:`PartyMember.battlepass_info` to get a tuple consisting of the members battlepass info.
- Added :attr:`PartyMember.platform` to get a members platform.
- Added :attr:`Party.playlist_info` to get a tuple consisting of information about the currently set playlist.
- Added :attr:`Party.squad_fill_allowed` which returns the state of squad fill.
- Added :attr:`Party.privacy` to get the partys privacy.
- Added keyword-argument ``run_for`` to :meth:`PartyMember.set_emote()` for setting how long an emote should be playing for in seconds.

Updated
~~~~~~~

- Updated :attr:`Client.net_cl` to match the value from the Fortnite v10.10 update.
- Updated :attr:`Client.build` to match the value from the Fortnite v10.10 update.
- Updated :attr:`Client.engine_build` to match the value from the Fortnite v10.10 update.

Bug Fixes
~~~~~~~~~

- Fixed the naming of :func:`event_member_updated` not matching the docs.
- Fixed :meth:`Client.has_friend()` returning the opposite of the correct value.
- Fixed :meth:`PartyMember.create_variants()` not working like intended in some situations.
- Fixed an issue where you would get an error if you tried to initialize the client with a different default party privacy.
- Fixed an issue where :meth:`Party.set_privacy()` would raise an error causing the function to fail.
- Fixed an issue where an error were sometimes raised due to attempting to create a new party while already in a another.
- Fixed :meth:`PartyMember.set_assisted_challenge()` only taking a full path for the quest argument.
- Fixed an issue where members of a party the client is joining would not have updated metas.
- Fixed an issue where an unecessary error would be raised when sending a message to a party chat.

Miscellanious
~~~~~~~~~~~~~

- Added missing :func:`event_party_member_leave` to the event reference.
- Added "How can I fix the Incompatible net_cl error" to the faq.
- Updated the faq answer regarding two factor auhentication usage.
- Updated arena docs example for :meth:`Party.set_privacy()` to match the new arena playlist information introduced in Fortnite v10.


v0.4.1
------

Expand Down
33 changes: 31 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ Frequently Asked Questions (FAQ)
General
-------

How can I fix the "Incompatible net_cl" error?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When fortnite releases a new content update they also update a specific number named netcl needed for the party
service to work. When updating this lib I also update the net_cl to match the new one. However, since fortnite
seems to update their game every week I sometimes don't keep up and you have to find and initialize the client
with the correct one yourself.

**Guide to find netcl:**

1. Navigate to the folder where you find your fortnite logs. Usually something like this: ``C:\Users\%your_user%\AppData\Local\FortniteGame\Saved\Logs``.
2. Go into the latest log file (Typically named ``FortniteGame``).
3. Press ctrl + f and do a search for ``netcl``. You should then find a seven digit number.

**This is how you launch the client with the manual netcl:**

.. code-block::
# pass the netcl to with the net_cl keyword when initializing the client.
client = fortnitepy.Client(
email='email',
password='password',
net_cl='7605985'
)
How can I get a users K/D or Win Percentage?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -24,7 +49,7 @@ How can I set a status?
You can pass a status message for the client to use when creating
client.

.. code-block::
.. code-block:: python3
client = fortnitepy.Client(
email="email@email.com,
Expand Down Expand Up @@ -55,7 +80,11 @@ have created tools to make this easier for others. One of these tools is
How can I use Two Factor Authentication when logging into the client?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Currently this is not possible in fortnitepy. This is a planned feature though!
If the user the client attempts to log in as requires two factor authentication it
will ask for the code on startup. Then just type it into console and if accepted,
the login process will continue.

Alternatively, you might pass the code when intitializing :class:`Client` with the keyword ``two_factor_code``.



Expand Down
2 changes: 1 addition & 1 deletion fortnitepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SOFTWARE.
"""

__version__ = '0.4.1'
__version__ = '0.5.0'

from .client import Client
from .friend import Friend, PendingFriend
Expand Down
2 changes: 1 addition & 1 deletion fortnitepy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async def do_refresh(self):
log.debug('Refreshing session')

if self.client.user.party is not None:
await self.client.user.party.leave()
await self.client.user.party._leave()

data = await self.grant_refresh_token(self.refresh_token)
self.launcher_access_token = data['access_token']
Expand Down
33 changes: 23 additions & 10 deletions fortnitepy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ def __init__(self, email, password, two_factor_code=None, loop=None, **kwargs):

self.status = kwargs.get('status', None)
self.platform = kwargs.get('platform', 'WIN')
self.net_cl = kwargs.get('net_cl', '7283595')
self.net_cl = kwargs.get('net_cl', '7605985')
self.party_build_id = '1:1:{0.net_cl}'.format(self)
self.default_party_config = kwargs.get('default_party_config', {})
self.build = kwargs.get('build', '++Fortnite+Release-10.0-CL-7704164')
self.engine_build = kwargs.get('engine_build', '4.23.0-7704164+++Fortnite+Release-10.0')
self.build = kwargs.get('build', '++Fortnite+Release-10.10-CL-7955722')
self.engine_build = kwargs.get('engine_build', '4.23.0-7955722+++Fortnite+Release-10.10')
self.launcher_token = kwargs.get('launcher_token',
'MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE='
)
Expand Down Expand Up @@ -220,9 +220,10 @@ def update_default_party_config(self, config):
'invite_ttl_seconds': 14400,
'chat_enabled': True,
}

try:
self.default_party_config['privacy'] = self.default_party_config['privacy'].value
except KeyError:
except (KeyError, AttributeError):
pass

default_config = {**_default_conf, **self.default_party_config}
Expand Down Expand Up @@ -321,7 +322,7 @@ async def logout(self):

try:
if self.user.party is not None:
await self.user.party.leave()
await self.user.party._leave()
except:
pass

Expand Down Expand Up @@ -363,7 +364,7 @@ async def initialize_party(self):
data = await self.http.party_lookup_user(self.user.id)
if len(data['current']) > 0:
party = Party(self, data['current'][0])
await party.leave()
await party._leave()
log.debug('Left old party')
await self._create_party()

Expand Down Expand Up @@ -658,7 +659,7 @@ def has_friend(self, id):
:class:`bool`
``True`` if user is friends with the client else ``False``
"""
return self.get_friend(id) is None
return self.get_friend(id) is not None

def is_pending(self, id):
"""Checks if the given id is a pending friend of the client.
Expand Down Expand Up @@ -1152,7 +1153,18 @@ async def _create_party(self, config=None):
else:
cf = self.default_party_config

data = await self.http.party_create(cf)
while True:
try:
data = await self.http.party_create(cf)
break
except HTTPException as exc:
print(exc.message_code)
if exc.message_code != 'errors.com.epicgames.social.party.user_has_party':
raise HTTPException(exc.response, exc.raw)

data = await self.http.party_lookup_user(self.user.id)
await self.http.party_leave(data['current'][0]['id'])

config = {**cf, **data['config']}
party = Party(self, data)
await party._update_members(data['members'])
Expand All @@ -1165,7 +1177,7 @@ def check(m):
try:
await self.wait_for('party_member_join', check=check, timeout=3)
except asyncio.TimeoutError:
await party.leave()
await party._leave()
return await self._create_party()

await party.set_privacy(config['privacy'])
Expand All @@ -1177,10 +1189,11 @@ async def join_to_party(self, party_id, party=None):
party = Party(self, party_data)
await party._update_members(party_data['members'])

await self.user.party.leave()
await self.user.party._leave()
self.user.set_party(party)

await self.http.party_join_request(party_id)
await party._update_members_meta()
asyncio.ensure_future(self.user.party.join_chat(), loop=self.loop)

async def set_status(self, status):
Expand Down

0 comments on commit 025aa21

Please sign in to comment.