Committing v1 of the ffxiv api
This commit is contained in:
parent
6771718975
commit
f4335fdad7
@ -5,4 +5,4 @@ ADD app/requirements.txt /requirements.txt
|
|||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
ADD app /app
|
ADD app /app
|
||||||
CMD python /app/dragon-bot-updated.py
|
CMD python /app/bot.py
|
||||||
|
@ -14,4 +14,4 @@ RUN printf "\n\nTesting your python code for errors\n\n" && \
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n"
|
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
|
||||||
|
@ -134,6 +134,16 @@ async def eight_ball(ctx):
|
|||||||
|
|
||||||
await ctx.send(result)
|
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')
|
@bot.command(name='purge')
|
||||||
async def purge(ctx):
|
async def purge(ctx):
|
||||||
def is_me(m):
|
def is_me(m):
|
@ -42,6 +42,11 @@ def get_help_message(method):
|
|||||||
' If there is only one option, it will give you a yes or no',
|
' 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'
|
'\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': [
|
'define': [
|
||||||
'Returns a definiton of a word from urban dictionary',
|
'Returns a definiton of a word from urban dictionary',
|
||||||
'\nUsage: !define loli'
|
'\nUsage: !define loli'
|
||||||
@ -163,7 +168,7 @@ def get_help_message(method):
|
|||||||
|
|
||||||
def get_help_embed(client):
|
def get_help_embed(client):
|
||||||
categories = {
|
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'],
|
'util': ['corona', '8ball', 'decide', 'info', 'icon', 'wallpaper', 'stock', 'tts', 'issue'],
|
||||||
'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
|
'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
|
||||||
'admin': ['emoji', 'cleanup']
|
'admin': ['emoji', 'cleanup']
|
||||||
|
103
ffxiv.py
103
ffxiv.py
@ -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))
|
|
Loading…
x
Reference in New Issue
Block a user