Exemplo n.º 1
0
async def event_party_member_join(client: fortnitepy.Client,
                                  member: fortnitepy.PartyMember):
    if member.id == client.user.id:
        if client.settings["cosmetics"]["emote"]:
            await client.user.party.me.set_emote(
                client.settings["cosmetics"]["emote"])
        elif client.settings["cosmetics"]["emoji"]:
            await client.user.party.me.set_emoji(
                client.settings["cosmetics"]["emoji"])
    else:
        if not client.has_friend(member.id):
            try:
                await client.add_friend(member.id)
            except:
                pass
Exemplo n.º 2
0
async def event_ready(client: fortnitepy.Client):
    print(f'{client.user.display_name} is now ready!')

    # Accept all inbound friend requests
    client.loop.create_task(accept_inbound(client))

    # Fetch the owners (UseID's because it's better)
    owners_id = [owner.id for owner in await client.fetch_profiles(client.settings["owners"])]
    print(f'Fetched {len(owners_id)}/{len(client.settings["owners"])} owners')
    client.settings["owners"] = owners_id

    def refresh_squad_assignments():
        part = client.user.party.meta.set_prop('RawSquadAssignments_j', {'RawSquadAssignments': client.user.party.meta.get_prop('RawSquadAssignments_j')["RawSquadAssignments"]})
        return part

    client.user.party.meta.refresh_squad_assignments = refresh_squad_assignments

    part = client.user.party.meta.set_prop('RawSquadAssignments_j', {'RawSquadAssignments': [{"memberId": client.user.id,"absoluteMemberIdx": 0}]})
    await client.user.party.patch(updated={'RawSquadAssignments_j': part})
Exemplo n.º 3
0
 def __init__(self, client: fortnitepy.Client, message):
     self.friends = client.has_friend(message.author.id)
     self.owner = message.author.id in client.settings["owners"]
     self.god_mode = True
Exemplo n.º 4
0
async def event_message(client: fortnitepy.Client, message: fortnitepy.PartyMessage):
    # if message.author.id in client.settings["blocked"]: return
    if message.author.id == client.user.id: return
    content = message.content.lower()
    args = content.split(" ")
    access = Access(client, message)

    if not client.has_friend(message.author.id):
        return await message.reply(f'**{message.author.display_name}**\n Check out my Youtube: LupusLeaks to get your own bot add me as a friend!')

        # Friends
    if args[0] == f'?friends' and _check_auth(client, access, "get_friends_count"):
        try:
            await message.reply(f'Total Friends: {len(client.friends)}\nFriends Online: {sum(1 for friend in client.friends.values() if friend.is_online())}')
        except:
            await message.reply('Something wen\'t wrong sorry.')

        # Restart
    # elif args[0] == f'!restart' and _check_auth(client, access, "restart_client"):
    elif args[0] == f'!restart' and access.owner:
        try:
            await message.reply('Restarting...')
            # await client.logout(close_http=True)
            sys.exit() # Glitch should auto restart the script
        except:
            await message.reply('Something wen\'t wrong sorry.')
    
        # Join
    # elif content == '!join' and client.settings["party"]["join_on_invite"]:
    elif content == '!join' and access.owner:
        if client.has_friend(message.author.id):
            try:
                await client.get_friend(message.author.id).join_party()
                await message.reply('Joined your Party.')
            except fortnitepy.PartyError:
                await message.reply('Party was not found.')
            except fortnitepy.Forbidden:
                await message.reply('The party is private.')
            except Exception as e:
                await message.reply('Something wen\'t wrong.')
        else:
            await message.reply('Can\'t join, make sure to accept my Friend Request')
            try:
                await client.add_friend(message.author.id)
            except: pass

        # Leave
    # elif (content == "!leave party" or content == "!leave") and _check_auth(client, access, "leave_party"):
    elif (content == "!leave party" or content == "!leave") and access.owner:
        try:
            await client.user.party.me.set_emote('EID_Wave')
            await asyncio.sleep(2)
        except: pass

        try:
            await client.user.party.me.leave()
            await message.reply("Successfuly left Party.")
        except Exception as e:
            await message.reply('Something wen\'t wrong, try to restart with "!restart"')

        # Stop Emote
    elif content == "!stop emote" or content == "!stopemote" and _check_auth(client, access, "stop_emote"):
        try:
            await client.user.party.me.clear_emote()
            await message.reply("Stopped Dancing!")
        except:
            await message.reply('Something wen\'t wrong sorry.')

        # Ready Up
    elif content == "!ready" and _check_auth(client, access, "ready"):
        try:
            await client.user.party.me.set_ready(True)
            await message.reply("Successfuly set my readiness to ready")
        except:
            await message.reply('Something wen\'t wrong sorry.')

        # Unready
    elif content == "!not ready" or content == "!notready" or content == "!unready" and _check_auth(client, access, "unready"):
        try:
            await client.user.party.me.set_ready(False)
            await message.reply("Successfuly set my readiness to not ready")
        except:
            await message.reply('Something wen\'t wrong sorry.')
        
        # Cosmetic Shortcuts
    elif content == "!purpleskull" and _check_auth(client, access, "cosmetic_shortcuts"):
        try:
            await client.user.party.me.set_outfit("CID_030_Athena_Commando_M_Halloween", variants=client.user.party.me.create_variants(clothing_color=1))
            await message.reply('Skin set to Skull Trooper with Purple Glow variant!')
        except:
            await message.reply('Something wen\'t wrong sorry.')

    elif content == "!pinkghoul" and _check_auth(client, access, "cosmetic_shortcuts"):
        try:
            await client.user.party.me.set_outfit("CID_029_Athena_Commando_F_Halloween", variants=client.user.party.me.create_variants(material=3))
            await message.reply('Skin set to Ghoul Trooper with Pink variant!')
        except:
            await message.reply('Something wen\'t wrong sorry.')

    elif content == "!mintyelf" and _check_auth(client, access, "cosmetic_shortcuts"):
        try:
            await client.user.party.me.set_outfit("CID_051_Athena_Commando_M_HolidayElf", variants=client.user.party.me.create_variants(material=2))
            await message.reply('Skin set to Elf with Minty variant!')
        except:
            await message.reply('Something wen\'t wrong sorry.')

    # elif content == f'!promote' and _check_auth(client, access, "promote_member"):
    elif content == f'!promote' and access.owner:
        try:
            await message.author.promote()
            await message.reply('Successfully promoted you!')
        except Exception as e:
            await message.reply('Sorry, something wen\'t wrong!')

    elif args[0] == "!match":
        party = client.user.party
        players_left = '1'
        if len(args) > 1: players_left = args[1]
        for key,value in {'Location_s': 'InGame', 'NumAthenaPlayersLeft_U': players_left, 'HasPreloadedAthena_b': True,'SpectateAPartyMemberAvailable_b': 'true'}.items():
            try:
                await party.me.patch(updated={key: party.me.meta.set_prop(key, value)})
            except: pass
        await message.reply(f'Successfully joined a match, players left: {players_left}')

    elif content == "!leave match":
        party = client.user.party
        players_left = args[1] or '1'
        for key,value in {'Location_s': 'PreLobby', 'NumAthenaPlayersLeft_U': '0', 'HasPreloadedAthena_b': False,'SpectateAPartyMemberAvailable_b': 'false'}.items():
            try:
                await party.me.patch(updated={key: party.me.meta.set_prop(key, value)})
            except: pass
        await message.reply(f'Successfully left the match')

    elif args[0] == "!skins" and _check_auth(client, access, "cosmetic_shortcuts"):
        if args[1] == "new":
            async with aiohttp.ClientSession() as session:
                new_cosmetics = await session.get("https://benbotfn.tk/api/v1/newCosmetics")
                if new_cosmetics.status == 200:
                    new_cosmetics = await new_cosmetics.json()
                    new_skins = [cosmetic for cosmetic in new_cosmetics["items"] if cosmetic["backendType"] == "AthenaCharacter"]
                    if len(new_skins) == 0:
                        await message.reply('There are no new skins!')
                    else:
                        await message.reply(f'I will now show you {len(new_skins)} new skins, please join my Discord: https://discord.gg/GPSPwh6')
                        for cosmetic in new_skins:
                            if cosmetic["backendType"] == "AthenaCharacter":
                                await client.user.party.me.set_outfit(cosmetic["id"])
                                await asyncio.sleep(0.1)

                        for cosmetic in new_skins:
                            if cosmetic["backendType"] == "AthenaCharacter":
                                await client.user.party.me.set_outfit(cosmetic["id"])
                                await asyncio.sleep(0.1)

                        for cosmetic in new_skins:
                            if cosmetic["backendType"] == "AthenaCharacter":
                                await client.user.party.me.set_outfit(cosmetic["id"])
                                await asyncio.sleep(0.1)

                        for cosmetic in new_skins:
                            if cosmetic["backendType"] == "AthenaCharacter":
                                await client.user.party.me.set_outfit(cosmetic["id"])
                                await asyncio.sleep(0.1)

                        await message.reply('Done with showing the new skin!')
    
    elif content.startswith(("!skin", "!backpack", "!pickaxe", "!emoji","!emote")) and _check_auth(client, access, "change_cosmetics"):
        # language = client.settings.language.cosmetics
        language = "en"
        cosmetic_type = ""

        if "--lang=" in content:
            content = content + " "
            language = GetValue(content,"--lang="," ")
            content = content.replace("--lang=" + language, "").strip()
            print(f'Search language = {language}')

        if args[0] == "!skin":
            cosmetic = await get_skin(GetName("!skin", content), client, language)
            cosmetic_type = "Outfit"
        elif args[0] == "!backpack":
            cosmetic = await get_backpack(GetName("!backpack", content), client, language)
            cosmetic_type = "Back Bling"
        elif args[0] == "!pickaxe":
            cosmetic = await get_pickaxe(GetName("!pickaxe", content), client, language)
            cosmetic_type = "Harvesting Tool"
        elif args[0] == "!emoji":
            cosmetic = await get_emoji(GetName("!emoji", content), client, language)
            cosmetic_type = "Emoji"
        elif args[0] == "!emote":
            cosmetic = await get_emote(GetName("!emote", content), client, language)
            cosmetic_type = "Emote"
        else:
            await message.reply('Sorry, something wen\'t wrong!')
            return

        if not cosmetic:
            await message.reply(f'No {cosmetic_type} with this name found!')
        else:
        
            variants = []

            if content.count('--') > 0: # If there are any variants
                if not cosmetic["variants"]:
                    await message.reply('This skin has no variants!')
                else:
                    for content_variant in GetValues(content):
                        c_variant_channel_name = (content_variant.split("=")[0])[2:]
                        c_variant = content_variant.split("=")[1]

                        for variant in cosmetic["variants"]:
                            if variant["types"][language].lower() == c_variant_channel_name:
                                for option in variant["options"]:
                                    if option["names"][language].lower() == c_variant:
                                        variants.append(create_variant(variant["channel"], option["tag"], item=cosmetic["backendType"]))
            
            # cosmetic_type = (args[0])[1:].capitalize()
            asset = f'{cosmetic["path"]}.{cosmetic["id"]}'

            if args[0] == "!skin":
                await client.user.party.me.set_outfit(asset=asset, variants=variants)
            elif args[0] == "!backpack":
                await client.user.party.me.set_backpack(asset=asset, variants=variants)
            elif args[0] == "!pickaxe":
                await client.user.party.me.set_pickaxe(asset=asset, variants=variants)
            elif args[0] == "!emoji":
                await client.user.party.me.clear_emote()
                await client.user.party.me.set_emoji(asset=asset)
            elif args[0] == "!emote":
                await client.user.party.me.clear_emote()
                await client.user.party.me.set_emote(asset=asset)

            await message.reply(f'{cosmetic_type} set to {cosmetic["names"][language]}')

    elif args[0] == "!playlist" and len(args) > 0:
        if client.user.party.me.leader:
            playlist = await get_playlist(content[10:],client)
            if playlist:
                await client.user.party.set_playlist(playlist=playlist["dev_name"])
                await message.reply(f'Changed Playlist to {playlist["names"]["en"]}')
            else:
                await message.reply('Coudln\'t find that playlist!')
        else:
            await message.reply('Party leader permission needed!')
    
    elif args[0] == "!level" and len(args) == 2:
        try:
            level = int(args[1])
        except:
            await message.reply('The level must be a number!')
            level = 893

        try:
            await client.user.party.me.set_banner(season_level=level)
        except:
            await message.reply('Sorry, something wen\'t wrong!')
    
    elif content == "!hide all" and access.owner:
        if not client.user.party.me.leader:
            await message.reply('Party leader permission needed!')
        else:
            party_member = await client.fetch_profile(content[6:])
            if not party_member:
                await message.reply('Couldn\'t find a user with this ID')
            else:
                part = client.user.party.meta.set_prop('RawSquadAssignments_j', {'RawSquadAssignments': [{"memberId": client.user.id,"absoluteMemberIdx": 0}]})
                await client.user.party.patch(updated={'RawSquadAssignments_j': part})

    elif content == "!show all" and access.owner:
        if not client.user.party.me.leader:
            await message.reply('Party leader permission needed!')
        else:
            party_member = await client.fetch_profile(content[6:])
            if not party_member:
                await message.reply('Couldn\'t find a user with this ID')
            else:
                assignments = []

                i = 0
                for member in client.user.party.members.values():
                    if member.leader:
                        assignments.append({'memberId': member.id,'absoluteMemberIdx': 0})
                    else:
                        i += 1
                        assignments.append({'memberId': member.id,'absoluteMemberIdx': i})

                await client.user.party.patch(updated={'RawSquadAssignments_j': client.user.party.meta.set_prop('RawSquadAssignments_j', {'RawSquadAssignments': assignments})})

    elif args[0] == "!show" and len(args) > 1 and access.owner:
        if not client.user.party.me.leader:
            await message.reply('Party leader permission needed!')
        else:
            party_member = await client.fetch_profile(content[6:])
            if not party_member:
                await message.reply('Couldn\'t find a user with this ID')
            else:
                assignments = client.user.party.meta.get_prop('RawSquadAssignments_j')["RawSquadAssignments"]
                assignments.append({'memberId': party_member.id,'absoluteMemberIdx': len(assignments) + 1})

                await client.user.party.patch(updated={'RawSquadAssignments_j': client.user.party.meta.set_prop('RawSquadAssignments_j', {'RawSquadAssignments': assignments})})
                await message.reply("")

    elif args[0] == "!hide" and len(args) > 1 and access.owner:
        if not client.user.party.me.leader:
            await message.reply('Party leader permission needed!')
        else:
            party_member = await client.fetch_profile(content[6:])
            if not party_member:
                await message.reply('Couldn\'t find a user with this ID')
            else:
                assignments = client.user.party.meta.get_prop('RawSquadAssignments_j')["RawSquadAssignments"]
                for x in assignments:
                    if x["memberId"] == party_member.id:
                        assignments.remove(x)

                await client.user.party.patch(updated={'RawSquadAssignments_j': client.user.party.meta.set_prop('RawSquadAssignments_j', {'RawSquadAssignments': assignments})})

    await message.reply('Check out my Youtube: LupusLeaks to get your own **FREE** Fortnite Lobbybot or if you need any help you can join my Discord aswell https://discord.gg/GPSPwh6 :)')
Exemplo n.º 5
0
async def add_event_handlers(client: fortnitepy.Client):
    # Start, Logout, Auth Refresh
    async def _ready():
        await event_ready(client)

    client.add_event_handler("ready", _ready)

    async def _logout():
        await event_logout(client)

    client.add_event_handler("logout", _logout)

    async def _auth_refresh():
        await event_auth_refresh(client)

    client.add_event_handler("auth_refresh", _auth_refresh)

    # Device Auth
    async def _device_auth_generate(details, email):
        pass  # await event_device_auth_generate(client, email, details)

    client.add_event_handler("device_auth_generate", _device_auth_generate)

    # Message
    async def _friend_message(message):
        await event_message(client, message)

    client.add_event_handler('friend_message', _friend_message)

    async def _party_message(message):
        await event_message(client, message)

    client.add_event_handler('party_message', _party_message)

    # Friends
    async def _friend_add(friend):
        await event_friend_add(client, friend)

    client.add_event_handler('friend_add', _friend_add)

    async def _friend_remove(friend):
        await event_friend_remove(client, friend)

    client.add_event_handler('friend_remove', _friend_remove)

    async def _friend_request(request):
        await event_friend_request(client, request)

    client.add_event_handler('friend_request', _friend_request)

    # Party

    # Accept /Decline Party invitation
    async def _party_invite(invitation):
        await event_party_invite(client, invitation)

    client.add_event_handler('party_invite', _party_invite)

    # Send a message if someone promotes
    async def _party_member_promote(old_leader, new_leader):
        await event_party_member_promote(client, old_leader, new_leader)

    client.add_event_handler('party_member_promote', _party_member_promote)

    # Send a welcome message
    async def _party_member_join(member):
        await event_party_member_join(client, member)

    client.add_event_handler('party_member_join', _party_member_join)

    async def _party_member_leave(member):
        await event_party_member_leave(client, member)

    client.add_event_handler('party_member_leave', _party_member_leave)
Exemplo n.º 6
0
def load_defaults(client: fortnitepy.Client):
    settings = client.settings
    emoji_and_emote = False
    backpack_and_pet = False
    party_member = []
    party = {}

    party_member.append(
        partial(fortnitepy.ClientPartyMember.set_banner,
                season_level=893,
                color="DefaultColor43",
                icon="OtherBanner28"))

    # platform
    if not settings["platform"].upper() in fortnitepy.Platform.__members__:
        client.platform = fortnitepy.Platform.WINDOWS
        print(
            f'No such a Platform "{settings["platform"]}", switched to Windows'
        )
    else:
        client.platform = fortnitepy.Platform[settings["platform"].upper()]

    # cosmetics
    # Skin
    if settings["cosmetics"]["skin"]:
        variants = settings["cosmetics_variants"]["skin"] if (
            type(settings["cosmetics_variants"]["skin"]) == list
            and len(settings["cosmetics_variants"]["skin"]) > 0) else []
        if cosmetic_is_id(settings["cosmetics"]["skin"], "AthenaCharacter"):
            party_member.append(
                partial(fortnitepy.ClientPartyMember.set_outfit,
                        asset=settings["cosmetics"]["skin"],
                        variants=variants))
            print(
                f'Set default CharacterID to {settings["cosmetics"]["skin"]}.')
        else:
            skin = fetch_cosmetic(settings["cosmetics"]["skin"], "en",
                                  "AthenaCharacter")
            if skin:
                party_member.append(
                    partial(fortnitepy.ClientPartyMember.set_outfit,
                            asset=f'{skin["path"]}.{skin["id"]}',
                            variants=variants))
                print(f'Set default Character to {skin["names"]["en"]}.')
            else:
                print(
                    f'Could not find the skin {settings["cosmetics"]["skin"]}.'
                )

        # Pickaxe
    if settings["cosmetics"]["pickaxe"]:
        variants = settings["cosmetics_variants"]["pickaxe"] if (
            type(settings["cosmetics_variants"]["pickaxe"]) == list
            and len(settings["cosmetics_variants"]["pickaxe"]) > 0) else []
        if cosmetic_is_id(settings["cosmetics"]["pickaxe"],
                          "AthenaPetCarrier"):
            party_member.append(
                partial(fortnitepy.ClientPartyMember.set_outfit,
                        asset=settings["cosmetics"]["pickaxe"],
                        variants=variants))
            print(
                f'Set default Pickaxe ID to {settings["cosmetics"]["pickaxe"]}.'
            )
        else:
            pickaxe = fetch_cosmetic(settings["cosmetics"]["pickaxe"], "en",
                                     "AthenaPetCarrier")
            if pickaxe:
                party_member.append(
                    partial(fortnitepy.ClientPartyMember.set_outfit,
                            asset=f'{pickaxe["path"]}.{pickaxe["id"]}',
                            variants=variants))
                print(f'Set default Pickaxe to {pickaxe["name"]}.')
            else:
                print(
                    f'Could not find the pickaxe {settings["cosmetics"]["pickaxe"]}.'
                )

        # Just so we need to check it once only, (set it to id automatically)
    if settings["cosmetics"]["backpack"] and settings["cosmetics"]["pet"]:
        print(
            'You can\'t set Backpack and Pet, please check your settings file.'
        )
        backpack_and_pet = True

        # Backpack
    if settings["cosmetics"]["backpack"]:
        variants = settings["cosmetics_variants"]["backpack"] if (
            type(settings["cosmetics_variants"]["backpack"]) == list
            and len(settings["cosmetics_variants"]["backpack"]) > 0) else []
        if cosmetic_is_id(settings["cosmetics"]["backpack"], "AthenaBackpack"):
            party_member.append(
                partial(fortnitepy.ClientPartyMember.set_backpack,
                        asset=settings["cosmetics"]["backpack"],
                        variants=variants))
            print(
                f'Set default BackpackID to {settings["cosmetics"]["backpack"]}.'
            )
            if backpack_and_pet:
                print(
                    'Automatically removed Pet to be executed when joining a Party'
                )
                client.settings["cosmetics"]["pet"] = ""
        else:
            backpack = fetch_cosmetic(settings["cosmetics"]["backpack"], "en",
                                      "AthenaBackpack")
            if backpack:
                party_member.append(
                    partial(fortnitepy.ClientPartyMember.set_backpack,
                            asset=f'{backpack["path"]}.{backpack["id"]}',
                            variants=variants))
                print(f'Set default Backpack to {backpack["name"]}.')
                if backpack_and_pet:
                    print(
                        'Automatically removed Pet to be executed when joining a Party'
                    )
                    client.settings["cosmetics"]["pet"] = ""
            else:
                print(
                    f'Could not find the backpack {settings["cosmetics"]["backpack"]}.'
                )

        # Pet
    if settings["cosmetics"]["pet"]:
        variants = settings["cosmetics_variants"]["pet"] if (
            type(settings["cosmetics_variants"]["pet"]) == list
            and len(settings["cosmetics_variants"]["pet"]) > 0) else []
        if cosmetic_is_id(settings["cosmetics"]["pet"], "AthenaPetCarrier"):
            party_member.append(
                partial(fortnitepy.ClientPartyMember.set_pet,
                        asset=settings["cosmetics"]["pet"],
                        variants=variants))
            print(f'Set default petID to {settings["cosmetics"]["pet"]}.')
        else:
            pet = fetch_cosmetic(settings["cosmetics"]["pet"], "en",
                                 "AthenaPetCarrier")
            if pet:
                party_member.append(
                    partial(fortnitepy.ClientPartyMember.set_pet,
                            asset=f'{pet["path"]}.{pet["id"]}',
                            variants=variants))
                print(f'Set default pet to {pet["name"]}.')
            else:
                print(
                    f'Could not find the pet {settings["cosmetics"]["pet"]}.')

        # Just so we need to check it once only, (set it to id automatically)
    if settings["cosmetics"]["emote"] and settings["cosmetics"]["emoji"]:
        print(
            'You can\'t set Emoji and Emote, please check your settings file.')
        emoji_and_emote = True

    if settings["cosmetics"]["emote"]:
        if cosmetic_is_id(settings["cosmetics"]["emote"], "AthenaDance"):
            print(f'Set default Emote to {settings["cosmetics"]["emote"]}')
            if emoji_and_emote:
                print(
                    'Automatically removed Emoji to be executed when joining a Party'
                )
                client.settings["cosmetics"]["emoji"] = ""
        else:
            emote = fetch_cosmetic(settings["cosmetics"]["emote"], "en",
                                   "AthenaDance")
            if emote:
                client.settings["cosmetics"][
                    "emote"] = f'{emote["path"]}.{emote["id"]}'
                if emoji_and_emote:
                    print(
                        'Automatically removed Emoji to be executed when joining a Party'
                    )
                    client.settings["cosmetics"]["emoji"] = ""
            else:
                print(
                    f'Could not find the emote {settings["cosmetics"]["emote"]}.'
                )
                client.settings["cosmetics"][
                    "emote"] = ""  # "Remove" it so auto set emote works

    if settings["cosmetics"]["emoji"]:
        if cosmetic_is_id(settings["cosmetics"]["emoji"], "AthenaEmoji"):
            print(f'Set default Emoji to {settings["cosmetics"]["emoji"]}')
        else:
            emoji = fetch_cosmetic(settings["cosmetics"]["emoji"], "en",
                                   "AthenaEmoji")
            if emoji:
                client.settings["cosmetics"][
                    "emoji"] = f'{emoji["path"]}.{emoji["id"]}'
            else:
                print(
                    f'Could not find the emoji {settings["cosmetics"]["emoji"]}.'
                )

    client.default_party_config = party
    client.default_party_member_config = party_member