Ejemplo n.º 1
0
 def __init__(self, bot):
     self.bot = bot
     self._last_member = None
     global client
     client = pyxivapi.XIVAPIClient( 
         session=aiohttp.ClientSession(), 
         api_key="c043b7f2b76c40a8b709aa41f9bdf013fa4aea2b66474698b9a7adec941ec142"
     )
Ejemplo n.º 2
0
    async def __ainit__(self, *args, **kwargs):
        self.session = aiohttp.ClientSession()
        self.request = requests.Request(self, self.session)
        db = await asyncpg.create_pool(config.__credentials__)
        self.pool = db
        self.pyxivapi = pyxivapi.XIVAPIClient(api_key=config.__xivapikey__)

        with open("schema.sql") as f:
            await self.pool.execute(f.read())
Ejemplo n.º 3
0
async def find(client, nameStr):
    client = pyxivapi.XIVAPIClient(api_key=APIKEY)
    spell = await client.index_search(
        name=nameStr,
        indexes=["Action", "PvPAction", "CraftAction"],
        columns=[
            "ID", "Name", "Icon", "Description", "ClassJobCategory.Name",
            "ClassJobLevel", "ActionCategory.Name"
        ],
        string_algo="match")
    print(spell)
    await client.session.close()
Ejemplo n.º 4
0
async def make(client):
    client = pyxivapi.XIVAPIClient(api_key=APIKEY)
    data = {}
    data["blueAction"] = []
    data["Action"] = []
    for i in range(11383, 11432):
        spell = await client.index_by_id(
            content_id=i,
            index="Action",
            columns=["Name", "ClassJobCategory.Name"],
            language="en")
        data["blueAction"].append({str(i): spell["Name"]})
        print(spell["Name"])
        time.sleep(0.25)
    for i in range(18295, 18326):
        spell = await client.index_by_id(
            content_id=i,
            index="Action",
            columns=["Name", "ClassJobCategory.Name"],
            language="en")
        data["blueAction"].append({str(i): spell["Name"]})
        print(spell["Name"])
        time.sleep(0.25)
    for i in range(23264, 23291):
        spell = await client.index_by_id(
            content_id=i,
            index="Action",
            columns=["Name", "ClassJobCategory.Name"],
            language="en")
        data["blueAction"].append({str(i): spell["Name"]})
        print(spell["Name"])
        time.sleep(0.25)
    for i in range(7559, 7563):
        spell = await client.index_by_id(content_id=i,
                                         index="Action",
                                         columns=["Name"],
                                         language="en")
        data["Action"].append({str(i): spell["Name"]})
        print(spell["Name"])
        time.sleep(0.25)

    data["blueActionNumber"] = len(data["blueAction"])

    with open('actions.txt', 'w') as outfile:
        json.dump(data, outfile, indent=4)

    await client.session.close()
Ejemplo n.º 5
0
async def get_player_img(world, forename, surname):
    img = ''
    client = pyxivapi.XIVAPIClient(api_key=xivapi_key)
    # Search Lodestone for a character
    character = await client.character_search(world=world,
                                              forename=forename,
                                              surname=surname)
    id = character['Results'][0]['ID']

    character = await client.character_by_id(lodestone_id=id,
                                             extended=False,
                                             include_freecompany=False)

    img = character['Character']['Portrait']

    await client.session.close()
    return img
Ejemplo n.º 6
0
async def ME(ctx):
    botSend = ctx.message.channel

    print(ctx.message.content)

    if ctx.channel == bot.get_channel(562693696038895626):
        xiv = pyxivapi.XIVAPIClient(api_key=config.xivApiKey)

        msg = ctx.message.content.split()

        print(msg)

        fName = msg[1]
        lName = msg[2]

        character = await xiv.character_search(world="Sargatanas",
                                               forename=fName,
                                               surname=lName)
        await xiv.session.close()

        await botSend.send(character)
Ejemplo n.º 7
0
    async def get_player_info(world, forename, surname):
        client = pyxivapi.XIVAPIClient(api_key=xivapi_key)
        # store ids
        '''
        with open('ids.json') as json_file:
            ids = json.load(json_file)
        '''
        #ids = {}
        written_id = world + " " + forename + " " + surname
        written_id = written_id.lower()

        if (written_id in ids):
            id = ids[written_id]
        else:
            # Search Lodestone for a character
            character = await client.character_search(world=world,
                                                      forename=forename,
                                                      surname=surname)
            # TODO Check for error
            id = character['Results'][0]['ID']
            ids[written_id] = id
            with open('ids.json', 'w') as outfile:
                json.dump(ids, outfile, indent=4)
            #name = character['Results'][0]['Name']
            #server = character['Results'][0]['Server']

        character = await client.character_by_id(lodestone_id=id,
                                                 extended=False,
                                                 include_freecompany=True,
                                                 include_classjobs=True)

        name = character['Character']['Name']
        server = character['Character']['Server'] + " (" + character[
            'Character']['DC'] + ")"
        img = character['Character']['Portrait']
        race = character['Character']['Race']
        clan = character['Character']['Tribe']
        deity = character['Character']['GuardianDeity']
        #fc_id = character['Character']['FreeCompanyID']
        jobs = character['Character']['ClassJobs']
        active_class = character['Character']['ActiveClassJob'][
            'UnlockedState']['Name']
        exp_lvl = character['Character']['ActiveClassJob']['ExpLevel']
        exp_lvl_max = character['Character']['ActiveClassJob']['ExpLevelMax']
        active_class_lvl = character['Character']['ActiveClassJob']['Level']
        #print(character['FreeCompany']['Name'])
        if character['FreeCompany'] == None:
            fc_name = "-"
        else:
            fc_name = character['FreeCompany']['Name']

        if character['Character']['GrandCompany'] == None:
            gc = -1
            gc_rank = -1
        else:
            gc = character['Character']['GrandCompany']['NameID']
            gc_rank = character['Character']['GrandCompany']['RankID']

        await client.session.close()
        return Player(name, img, server, race, clan, deity, gc, gc_rank, jobs,
                      active_class, exp_lvl, exp_lvl_max, active_class_lvl,
                      fc_name)
Ejemplo n.º 8
0
import base64
import hashlib
import pyxivapi
import shelve

from discord.ext import commands
from discord.utils import get

ACHIEVEMENTS_ROLE_MAP = {2476: 794964126140465222}
CHARACTER_DB_FILENAME = 'characters.db'
LODESTONE_URL = 'https://na.finalfantasyxiv.com/lodestone/character/{id}/'

bot = commands.Bot(command_prefix='.', help_command=None)
characters = shelve.open(CHARACTER_DB_FILENAME, writeback=True)
xivapi = pyxivapi.XIVAPIClient(api_key='')


@bot.event
async def on_ready():
    print('Connected and loaded states of {numUsers} users.'.format(
        numUsers=len(characters)))


@bot.command()
async def help(ctx):
    response = '```'
    response += (
        '.register world first last\n'
        '\tgoes through registration workflow to verify your character'
        ' is actually yours\n'
        '\tExample: .register zalera liam galt\n')