Committing v1 of the ffxiv api

This commit is contained in:
Luke Robles 2020-08-12 09:30:59 -07:00
parent 13e23c946a
commit 5203062dd3
5 changed files with 18 additions and 106 deletions

View File

@ -5,4 +5,4 @@ ADD app/requirements.txt /requirements.txt
RUN pip install -r requirements.txt
ADD app /app
CMD python /app/dragon-bot-updated.py
CMD python /app/bot.py

View File

@ -14,4 +14,4 @@ RUN printf "\n\nTesting your python code for errors\n\n" && \
WORKDIR /app
RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n"
CMD python /app/dragon-bot-updated.py
CMD python /app/bot.py

View File

@ -134,6 +134,16 @@ async def eight_ball(ctx):
await ctx.send(result)
@bot.command(name='ffxiv')
async def ffxiv(ctx):
import ffxiv
try:
ffxiv_embed = ffxiv.parse_message(ctx.message.content)
await ctx.send(embed=ffxiv_embed)
except Exception:
await ctx.send('I encountered an error while searching for that player')
@bot.command(name='purge')
async def purge(ctx):
def is_me(m):

View File

@ -42,6 +42,11 @@ def get_help_message(method):
' If there is only one option, it will give you a yes or no',
'\nUsage: !decide cake or pie\n!decide should I do my homework'
],
'ffxiv': [
'Pulls a characters data from the lodestone API\n',
'Usage: !ffxiv <First name> <last name> <server>\n',
'eg: !ffxiv Slamsong Bardley Adamantoise'
]
'define': [
'Returns a definiton of a word from urban dictionary',
'\nUsage: !define loli'
@ -163,7 +168,7 @@ def get_help_message(method):
def get_help_embed(client):
categories = {
'fun': ['clap', 'redanda', 'birb', 'youtube', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'meme', 'homepage', 'pout', 'roll', 'smug', 'quake', 'wink',],
'fun': ['ffxiv', 'clap', 'redanda', 'birb', 'youtube', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'meme', 'homepage', 'pout', 'roll', 'smug', 'quake', 'wink',],
'util': ['corona', '8ball', 'decide', 'info', 'icon', 'wallpaper', 'stock', 'tts', 'issue'],
'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
'admin': ['emoji', 'cleanup']

103
ffxiv.py
View File

@ -1,103 +0,0 @@
import asyncio
import logging
import json
import pprint
import aiohttp
import xivapi
pp = pprint.PrettyPrinter(indent=4)
async def fetch_example_results(session):
client = xivapi.Client(session=session, api_key="189ab21cd81c4516b768aad19be1d0a92cf463254550463f982ac4172f138f67")
# Search Lodestone for a character
character = await client.character_search(
world="Exodus",
forename="Pizza",
surname="Rolls"
)
# Get a character by Lodestone ID with extended data & include their Free Company information, if it has been synced.
character2 = await client.character_by_id(
lodestone_id=character['Results'][0]['ID'],
extended=True,
include_freecompany=True
)
pp.pprint(json.dumps(character2))
# # Search Lodestone for a free company
# freecompany = await client.freecompany_search(
# world="gilgamesh",
# name="Elysium"
# )
# # Fuzzy search XIVAPI game data for a recipe by name. Results will be in English.
# recipe = await client.index_search(
# name="Crimson Cider",
# indexes=["Recipe"],
# columns=["ID", "Name", "Icon", "ItemResult.Description"],
# string_algo="fuzzy"
# )
# # Fuzzy search XIVAPI game data for a recipe by name. Results will be in French.
# recipe = await client.index_search(
# name="Cidre carmin",
# indexes=["Recipe"],
# columns=["ID", "Name", "Icon", "ItemResult.Description"],
# string_algo="fuzzy",
# language="fr"
# )
# # Get an item by its ID (Omega Rod) and return the data in German
# item = await client.index_by_id(
# index="Item",
# content_id=23575,
# columns=["ID", "Name", "Icon", "ItemUICategory.Name"],
# language="de"
# )
# # Get non-npc actions matching a given term (Defiance)
# action = await client.index_search(
# name="Defiance",
# indexes=["Action", "PvPAction", "CraftAction"],
# columns=["ID", "Name", "Icon", "Description", "ClassJobCategory.Name", "ClassJobLevel", "ActionCategory.Name"],
# filters=["ClassJobLevel>=0", "ClassJobCategory.ID>0"],
# string_algo="fuzzy"
# )
# # Search ingame data for matches against a given query. Includes item, minion, mount & achievement descriptions, quest dialog & more.
# lore = await client.lore_search(
# query="Shiva",
# language="fr"
# )
# # Search for an item using specific filters
# filters = [
# Filter("LevelItem", "gte", 100)
# ]
# sort = Sort("Name", True)
# item = await client.index_search(
# name="Omega Rod",
# indexes=["Item"],
# columns=["ID", "Name", "Icon", "Description", "LevelItem"],
# filters=filters,
# sort=sort,
# language="de"
# )
# Get all categories of posts from the Lodestone (cached evert 15 minutes)
lodestone = await client.lodestone_all()
await session.close()
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(message)s', datefmt='%H:%M')
loop = asyncio.get_event_loop()
session = aiohttp.ClientSession(loop=loop)
loop.run_until_complete(fetch_example_results(session))