Example #1
0
 def __init__(self, bot):
     self.bot = bot
     self.api = core.PUBGAPI(self.API_KEY)
Example #2
0
"""Module to ease interaction with PlayerUnknown's Battlegrounds."""

import warnings
from functools import lru_cache

from pypubg import core

from games import config

API = core.PUBGAPI(config['GAMES']['PUBG_API_KEY'])


def get_stats(name, api=API):
    """Get the full stats for a given player name.

    :param name: the account name of the player to retrieve
    :param api: (optional) an instance of `pypubg.core.PUBGAPI` to use
    :returns: the full stats dict for a given player

    """
    return api.player(name)


def extract_stat(region, desired_field):
    """Safely extract a statistic from a region's stats.

    :param region: the region block from the full stats lookup
    :param desired_field: the name of the field to retrieve
    :returns: the given stat, or -1 if not found

    """
Example #3
0
 def retrieve_stats(key, player, mode, region):
     # Setup the api connection
     api = core.PUBGAPI(key)
     # Get the Raw Stats for the player
     p_stats = api.player_mode_stats(player, game_mode=mode, game_region=region)
     return p_stats
Example #4
0
import discord
from discord.ext import commands
import pypubg
import os
from pypubg import core
import asyncio
import requests
import aiohttp
import json

api = core.PUBGAPI("ecb0deba-710c-411f-9342-630875d48a9e")
bot = commands.Bot(command_prefix='!')
client = discord.Client()


@bot.event
@asyncio.coroutine
def on_ready():
    print("Pronto quando vocĂȘ estiver!")
    print("Estou rondando com o bot " + bot.user.name)
    print("ID: " + bot.user.id)
    print(api.player("Galapahall"))
    yield from bot.change_presence(game=discord.Game(name='!rank'))


@asyncio.coroutine
def get_stats_resp(username):
    headers = {"TRN-Api-Key": "ecb0deba-710c-411f-9342-630875d48a9e"}
    r = yield from aiohttp.get("https://pubgtracker.com/api/profile/pc/" + username, headers=headers)
    return r
Example #5
0
 async def pubgstats(self, ctx, pubgplayer: str):
     'Shows PUBG Stats (NOT WORKING ATM)'
     api = core.PUBGAPI('fa1607e6-538f-4c4d-96e1-5347c9163aaa')
     await ctx.send(api.player(pubgplayer))
Example #6
0
 def __init__(self, statbot):
     self.statbot = statbot
     self.api = core.PUBGAPI(secrets.PUBG_STATS_TOKEN)