コード例 #1
0
async def player_history_data(player):
    async with auraxium.Client(service_id=settings.PS2_SVS_ID) as client:

        char = await client.get_by_name(ps2.Character, player)

        print(char.id)
        name = char.name()
        outfit = char.outfit()
        faction = await char.faction().resolve()
        stat = await char.stat()
        facstat = await char.stat_by_faction()

        isOnline = await char.is_online()
        prestige = char.data.prestige_level
        currency = await char.currency()
        weaponstat = await char.weapon_stat()
        stathistory = await char.stat_history(5)

        outfit = await outfit.resolve()
        print(name)
        print(outfit)
        print(currency)
        print(faction)
        print(prestige)
        print(isOnline)
        print(stat)
        print(facstat)

        player_stats_extract(stathistory, name)
コード例 #2
0
async def main():
    """Main script method."""
    client = auraxium.Client(service_id='s:example')
    char = await client.get_by_name(ps2.Character, 'Auroram')
    char_query = char.query()

    online_friends = await get_online_friends(char, client)
    print(online_friends)

    await client.close()
コード例 #3
0
    async def player_tracking_start(self, ctx, *message):
        """
        Usage: !ps2-track <player1> <player2> ...
        Attempts to begin tracking on the list of players provided
        """

        if not self.trackingdata:
            await ctx.send(
                'Tracking not running. Use ps2-tracking-start to initialise tracking'
            )
            return

        try:
            client = auraxium.Client(service_id=settings.PS2_SVS_ID)
        except:
            print('Client not opened')
            return

        #
        # Check if player exist.
        # If exists, check if already being tracked
        # If not tracked, add to tracking, else return
        #
        if any(isinstance(x, list) for x in message):

            flat_list = [item for sublist in message for item in sublist]
            print(flat_list)
        else:
            flat_list = message
        for player in flat_list:
            print(f"Finding {player}")

            char = await client.get_by_name(ps2.Character, player)
            if char == None:
                print("Player not found")
                await ctx.send('Player not found')
                continue
            else:
                print(f"{char.name()} found")
                self.membersBeingTracked_char_name.append(char.name())

            if int(char.id) in self.membersBeingTracked_id:
                print("Player already tracking")
                await ctx.send("Player already tracking")
            else:
                print("Player tracking started")
                await ctx.send("Player tracking started")
                self.membersBeingTracked_id.append(int(char.id))

                for trigger, trackingItem in self.trackingdata.items():
                    await trackingItem.add_player(char)

        await client.close()
        print('complete')
コード例 #4
0
    async def player_tracking_end(self, ctx, *message):
        """
        Usage: !ps2-untrack <player1> <player2> ...
        Attempts to end tracking on the list of players provided.
        If all players removed, calls ps2-tracking-end
        """

        try:
            client = auraxium.Client(service_id=settings.PS2_SVS_ID)
        except:
            print('Client not opened')
            return
        #
        # Check if player exist.
        # If exists, check if already being tracked
        # If not tracked, add to tracking, else return
        #
        if any(isinstance(x, list) for x in message):

            flat_list = [item for sublist in message for item in sublist]
            print(flat_list)
        else:
            flat_list = message
        for player in flat_list:
            print(player)
            print("Finding player")
            char = await client.get_by_name(ps2.Character, player)
            if char == None:
                print("Player not found")
                await ctx.send('Player not found')
                break
            else:
                print(f"{char.name()} found")

            if int(char.id) in self.membersBeingTracked_id:
                print("Player found in tracking")
                self.membersBeingTracked_id.remove(int(char.id))
                for trigger, trackingItem in self.trackingdata.items():
                    print('here')
                    await trackingItem.remove_player(char)

            else:
                print("Player not being tracked")
                await ctx.send("Player not being tracked")

        if not self.membersBeingTracked_id:
            await self.tracking_end(ctx)
        await client.close()
        print('complete')
コード例 #5
0
    async def KD(self, ctx, character):
        if character == None: return
        else:
            async with auraxium.Client() as cli:
                char = await cli.get_by_name(ps2.leaderboard, f'{character}')

                status = await char.is_online()
                if status == True: status = "Online"
                else: status = "Offline"

                faction = await char.faction()
                outfit = await char.outfit()
                world = await char.world()
                stat = await char.stat()
            await ctx.send(f'``[{outfit}] {char.name()}``\nFaction = {faction}\nStatus = {status}\nWorld = {world}\n')
            await ctx.send(f'stat {stat}')
            asyncio.get_event_loop().run_until_complete(main())
コード例 #6
0
async def main(name):
    async with auraxium.Client(service_id=settings.PS2_SVS_ID) as client:

        char = await client.get_by_name(ps2.Character, name)
        help(char)
        print(char.name())
        print(char.data.prestige_level)

        # NOTE: Any methods that might incur network traffic are asynchronous.
        # If the data type has been cached locally, no network communication
        # is required.

        # This will only generate a request once per faction, as the faction
        # data type is cached forever by default.
        print(await char.faction())

        # The online status is never cached as it is bound to change at any
        # moment.
        print(await char.is_online())

        print(await char.stat_by_faction())
コード例 #7
0
    async def paritycheck(self, ctx):
        # Get outfit name from db
        async with dbPool.acquire() as conn:
            outfit_name = await conn.fetchval(
                "SELECT outfit_name FROM guilds WHERE guild_id = $1;",
                ctx.guild.id)
        if outfit_name is None:
            raise NoOutfitNameError("No outfit name set")

        # Inform user of delay
        await ctx.reply("`Getting data, this may take some time...`")

        # Initialize embed object
        embed = discord.Embed(title="Checkresults")

        # Get census api data
        async with auraxium.Client(
            service_id=botSettings['censusToken']) as client:
            outfit = await client.get_by_name(ps2.Outfit, outfit_name)
            if outfit is None:
                raise InvalidOutfitNameError(
                    "The outfit name you have specified does not seem to be valid"
                )

            outfit_member_list = await outfit.members()
            outfit_character_list = [
                await i.character() for i in outfit_member_list
            ]

        # Compare guild layout to outfit layout
        for guild_member in ctx.guild.members:
            matched_member = None
            matched_character = None
            # Leaving this in in case determining the role is ever necessary
            # matched_role = None

            # Match member and character object by discord username
            for outfit_member, outfit_character in zip(outfit_member_list,
                                                       outfit_character_list):
                if outfit_character.name() in (guild_member.name,
                                               guild_member.nick):
                    matched_character = outfit_character
                    matched_member = outfit_member
                    break

            if matched_character is None:
                embed.add_field(name=guild_member.name,
                                value="Name does not match any outfit member.",
                                inline=False)
                continue

            for role in guild_member.roles:
                if role.name == matched_member.data.rank:
                    # Leaving this in in case determining the role is ever necessary
                    # matched_role = role
                    continue

            embed.add_field(name=guild_member.name,
                            value="No Role matching outfit rank.",
                            inline=False)

        # Reply with results and delete delay message
        await ctx.reply(embed=embed)
コード例 #8
0
ファイル: playerinfo.py プロジェクト: lvl-6/ps2-buddy
# ./lib/api/playerinfo.py
#
# Author: John C <lvl-6.github.io>
# Created: 13/10/2020
#
# Description:
# Responsible for getting info regarding players (i.e. not general map data),
# and returning in a format the bot can understand.
#
###############################################################################

import asyncio
import auraxium
from auraxium import ps2

client = auraxium.Client()


async def basic_info(
    name: str,
    client: auraxium.Client = client,
):
    # Get the character data as an object (auraxium.ps2.Character)
    char = await client.get_by_name(ps2.Character, name)

    # Print info
    print("Name:\t\t" + char.name())
    print("Faction:\t" + str(await char.faction()))
    outfit = await char.outfit()
    print("Outfit:\t\t" + str(outfit.name()))
    print("Online:\t\t" + str(await char.is_online()))