예제 #1
0
 async def psn(self, ctx, player: str):
     apex = ApexLegends("af6873a1-ef18-4ea4-aced-143ba5b6eb5d")
     try:
         player = apex.player(player, plat=2)
     except:
         await ctx.send('Player not found')
         return
     embed = discord.Embed(colour=discord.Colour.blue())
     embed.set_footer(
         text=
         'the stat tracking right now is ass so I can only show damage and kills if you have the banner'
     )
     embed.set_thumbnail(url=player.legends[0].icon)
     embed.set_author(
         name=player.username + ' | ' + player.legends[0].legend_name,
         icon_url=
         'https://cdn.gearnuke.com/wp-content/uploads/2019/02/apex-legends-logo-768x432.jpg'
     )
     embed.add_field(name='Level:', value=player.level, inline=False)
     # for legend in player.legends:
     #   embed.add_field(name=legend.legend_name, value='Stats:', inline=False)
     for a in dir(player.legends[0]):
         if a == 'damage' or 'kills' in a:
             name = a + ':'
             embed.add_field(name=name.capitalize(),
                             value=player.legends[0].__dict__[a],
                             inline=True)
     await ctx.send(embed=embed)
예제 #2
0
 async def apex_get_legends(self, player):
     """
     returns Apex player legends object of requested player
     :param: object self: discord client
     :param: string player: player string
     :sends an apex player legends object
     """
     # try:
     #     async with AsyncLegends(self.tamago.apex_api_key) as apexData:
     #         player_data = await apexData.player(player, platform=Platform.PC)
     #     return player_data.legends
     # except ApexExceptions.UnknownPlayerError:
     #   raise ApexUnkownPlayerError(f'Unknown Apex Player: {player}')
     try:
         apex = ApexLegends(self.tamago.apex_api_key)
         player_data = apex.player(player, platform=Platform.PC)
         return player_data.legends
     except ApexExceptions.UnknownPlayerError:
       raise ApexUnkownPlayerError(f'Unknown Apex Player: {player}')
예제 #3
0
from apex_legends import ApexLegends

apex = ApexLegends("f1b30488-6b83-4295-9659-d9ef2a15c2fb")


def search(id):
    try:
        player = apex.player(id)
        return str(player)

    except:
        return -1
예제 #4
0
from apex_legends import ApexLegends

apex = ApexLegends("af6873a1-ef18-4ea4-aced-143ba5b6eb5d")

player = apex.player('SirMammington')

print(player)

# for legend in player.legends:
#     print(legend.legend_name)
#     print(legend.icon)
#     print(legend.damage)
#     print(legend.kills)
b = {}
for legend in player.legends:
    for a in dir(legend):
        if a == 'damage' or 'kills' in a:
            b[a] = player.__dict__[a]
# b.append([player.__dict__[a] for a in dir(legend) if a == 'damage' or 'kills' in a])
print(b)
print(player.__dict__.keys())
print(player.legends[0].__dict__.keys())
print(player.legends[0].__dict__['specific2'])
예제 #5
0
import json
import pytest
import requests_mock
from furl import furl
from unittest.mock import Mock, patch

from apex_legends import ApexLegends
from apex_legends.base import Client
from apex_legends.domain import Platform, Player


api = ApexLegends('apikey')
BASE_URL = Client.BASE_URL


@pytest.fixture()
def mock():
    with requests_mock.Mocker() as mock:
        yield mock


@pytest.fixture()
def player_response():
    with open('tests/player_response.json') as json_file:
        yield json.load(json_file)


@pytest.fixture()
def player_sessions_response():
    with open('tests/player_sessions_response.json') as json_file:
        yield json.load(json_file)