diff --git a/Dockerfile b/Dockerfile index ac3f0c21..f81fdcf0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Dockerfile-test-env b/Dockerfile-test-env index 5cb4155b..d6e72a28 100644 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -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 diff --git a/app/dragon-bot-updated.py b/app/bot.py similarity index 94% rename from app/dragon-bot-updated.py rename to app/bot.py index 959d1771..4d30cc77 100644 --- a/app/dragon-bot-updated.py +++ b/app/bot.py @@ -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): diff --git a/app/help_methods.py b/app/help_methods.py index 355681a3..3e9d1f3d 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -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 \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'] diff --git a/ffxiv.py b/ffxiv.py deleted file mode 100644 index 4d2b8d56..00000000 --- a/ffxiv.py +++ /dev/null @@ -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))