feat(wip): add ffxiv features, which may not be super useful for now
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
# This example requires the 'message_content' intent.
|
||||
|
||||
import discord
|
||||
import requests
|
||||
import glob, random
|
||||
import openai
|
||||
import os
|
||||
import urllib
|
||||
from config import load_config
|
||||
|
||||
# ===== API KEYS & PATHS =======
|
||||
@@ -13,6 +15,11 @@ from config import load_config
|
||||
pyon_path = "/root/hanyuu_pics/VRChat_Hanyuu/*"
|
||||
# pyon_path = "C:/Users/Luka/Pictures/VRChat_Hanyuu/*"
|
||||
|
||||
# ===== FFXIV WORLD -> ID MAP (need to be updated)
|
||||
ffxiv_dc_id_map = {
|
||||
"Sagittarius": 400
|
||||
}
|
||||
|
||||
# ====== MODEL PARAMETERS ========
|
||||
|
||||
temperature = 1
|
||||
@@ -109,7 +116,36 @@ async def on_message(message):
|
||||
)
|
||||
await message.channel.send(response['choices'][0]['message']['content'])
|
||||
|
||||
if message.content.lower().startswith('hanyuu'):
|
||||
### ==== FFXIV API ====
|
||||
if message.content.lower().startswith('hanyuuffmb '):
|
||||
query_list = message.content[11:].split()
|
||||
if not query_list[0]:
|
||||
response = "Something went wrong, and I could not get your query! Auau!"
|
||||
else:
|
||||
world_dc = query_list[0]
|
||||
print(requests.get("https://xivapi.com/World").json())
|
||||
world_list = requests.get("https://xivapi.com/World").json()['Results'] # problem: does not do fuzzy search of world name + this API is flawed and not complete!
|
||||
print("World dc: " + world_dc)
|
||||
print("Query list: ")
|
||||
for query in query_list:
|
||||
print(query)
|
||||
world_dc_id = [world for world in world_list if world['Name'] == world_dc][0]['ID']
|
||||
item_name = ''.join(str(x) for x in query_list[1:])
|
||||
|
||||
item_id = requests.get("https://xivapi.com/search", params={"string": urllib.parse.quote(item_name)})
|
||||
|
||||
base_url = 'https://universalis.app/api/v2/' + world_dc_id + '/' + item_id
|
||||
|
||||
response = requests.get(base_url, params=None).json()
|
||||
|
||||
if response.status_code == 200:
|
||||
hanyuu_response = f"Here are the 3 lowest price listings for {item_name} in {world_dc}:\n"
|
||||
listings = response.listings[:3]
|
||||
for listing in listings:
|
||||
hanyuu_response += f" {listing['pricePerUnit']} x{listing['quantity']} sold by {listing['retainerName']}\n"
|
||||
await message.channel.send(hanyuu_response)
|
||||
|
||||
elif message.content.lower().startswith('hanyuu'):
|
||||
response = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
temperature=temperature,
|
||||
|
||||
Reference in New Issue
Block a user