mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 04:26:57 +00:00
pass uploaded attachments to API
This commit is contained in:
@@ -18,7 +18,7 @@ defmodule PlantIdDiscordBot.Consumer do
|
|||||||
]
|
]
|
||||||
def handle_event({:READY}) do
|
def handle_event({:READY}) do
|
||||||
# mock function depending on the environment
|
# mock function depending on the environment
|
||||||
Api.create_global_application_command(@global_application_commands)
|
# Api.create_global_application_command(@global_application_commands)
|
||||||
# TODO fix, not working
|
# TODO fix, not working
|
||||||
Api.update_status(:online, "Guess the Plant|/help")
|
Api.update_status(:online, "Guess the Plant|/help")
|
||||||
# TODO remove in prod
|
# TODO remove in prod
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
|||||||
@plantnet_api_base_url Application.compile_env(:plantid_discord_bot, :plantnet_api_base_url)
|
@plantnet_api_base_url Application.compile_env(:plantid_discord_bot, :plantnet_api_base_url)
|
||||||
@plantnet_api_key Application.compile_env(:plantid_discord_bot, :plantnet_api_key)
|
@plantnet_api_key Application.compile_env(:plantid_discord_bot, :plantnet_api_key)
|
||||||
@max_results Application.compile_env(:plantid_discord_bot, :max_results)
|
@max_results Application.compile_env(:plantid_discord_bot, :max_results)
|
||||||
|
@fileserver_url Application.compile_env(:plantid_discord_bot, :fileserver_url)
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Process /id application command.
|
Process /id application command.
|
||||||
@@ -51,9 +52,6 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO remove
|
|
||||||
Logger.debug(saved_images)
|
|
||||||
|
|
||||||
# TODO use actual image data
|
# TODO use actual image data
|
||||||
image1 =
|
image1 =
|
||||||
"https://upload.wikimedia.org/wikipedia/commons/f/ff/Prunus_cerasifera_A.jpg"
|
"https://upload.wikimedia.org/wikipedia/commons/f/ff/Prunus_cerasifera_A.jpg"
|
||||||
@@ -63,6 +61,11 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
|||||||
|
|
||||||
images = [image1, image2]
|
images = [image1, image2]
|
||||||
|
|
||||||
|
# production:
|
||||||
|
# images = Enum.map(saved_images, fn {:ok, filename} -> "#{@fileserver_url}/#{filename}" end)
|
||||||
|
|
||||||
|
Logger.debug(Enum.join(images, ", "))
|
||||||
|
|
||||||
query_uri = build_query_uri(images)
|
query_uri = build_query_uri(images)
|
||||||
|
|
||||||
case HTTPoison.get(query_uri) do
|
case HTTPoison.get(query_uri) do
|
||||||
@@ -74,7 +77,7 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
|||||||
content: response_message <> "\n#{original_images}"
|
content: response_message <> "\n#{original_images}"
|
||||||
})
|
})
|
||||||
|
|
||||||
{:ok, %HTTPoison.Response{status_code: 400}} ->
|
{:ok, %HTTPoison.Response{status_code: 400, body: body}} ->
|
||||||
Logger.error("""
|
Logger.error("""
|
||||||
Malformed request sent to the PlantNet Api from PlantIdDiscordBot.Cog.PlantNet.do_identification
|
Malformed request sent to the PlantNet Api from PlantIdDiscordBot.Cog.PlantNet.do_identification
|
||||||
Query URI: #{query_uri}
|
Query URI: #{query_uri}
|
||||||
|
|||||||
Reference in New Issue
Block a user