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:
@@ -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_key Application.compile_env(:plantid_discord_bot, :plantnet_api_key)
|
||||
@max_results Application.compile_env(:plantid_discord_bot, :max_results)
|
||||
@fileserver_url Application.compile_env(:plantid_discord_bot, :fileserver_url)
|
||||
|
||||
@doc """
|
||||
Process /id application command.
|
||||
@@ -51,9 +52,6 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
||||
})
|
||||
end
|
||||
|
||||
# TODO remove
|
||||
Logger.debug(saved_images)
|
||||
|
||||
# TODO use actual image data
|
||||
image1 =
|
||||
"https://upload.wikimedia.org/wikipedia/commons/f/ff/Prunus_cerasifera_A.jpg"
|
||||
@@ -63,6 +61,11 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
||||
|
||||
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)
|
||||
|
||||
case HTTPoison.get(query_uri) do
|
||||
@@ -74,7 +77,7 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
||||
content: response_message <> "\n#{original_images}"
|
||||
})
|
||||
|
||||
{:ok, %HTTPoison.Response{status_code: 400}} ->
|
||||
{:ok, %HTTPoison.Response{status_code: 400, body: body}} ->
|
||||
Logger.error("""
|
||||
Malformed request sent to the PlantNet Api from PlantIdDiscordBot.Cog.PlantNet.do_identification
|
||||
Query URI: #{query_uri}
|
||||
|
||||
Reference in New Issue
Block a user