diff options
author | Jordan Bracco <href@random.sh> | 2022-12-20 00:21:54 +0000 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2022-12-20 19:29:41 +0100 |
commit | 2d83df8b32bff7f0028923bb5b64dc0b55f20d03 (patch) | |
tree | 1207e67b5b15f540963db05e7be89f3ca950e724 /lib/nola_web/controllers/gpt_controller.ex | |
parent | Nola rename, the end. pt 6. Refs T77. (diff) |
Nola rename: The Big Move, Refs T77
Diffstat (limited to 'lib/nola_web/controllers/gpt_controller.ex')
-rw-r--r-- | lib/nola_web/controllers/gpt_controller.ex | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/nola_web/controllers/gpt_controller.ex b/lib/nola_web/controllers/gpt_controller.ex new file mode 100644 index 0000000..038b235 --- /dev/null +++ b/lib/nola_web/controllers/gpt_controller.ex @@ -0,0 +1,33 @@ +defmodule NolaWeb.GptController do + use NolaWeb, :controller + require Logger + + plug NolaWeb.ContextPlug + + def result(conn, params = %{"id" => result_id}) do + case Nola.IRC.GptPlugin.get_result(result_id) do + {:ok, result} -> + network = Map.get(params, "network") + channel = if c = Map.get(params, "chan"), do: NolaWeb.reformat_chan(c) + render(conn, "result.html", network: network, channel: channel, result: result) + {:error, :not_found} -> + conn + |> put_status(404) + |> text("Page not found") + end + end + + def prompt(conn, params = %{"id" => prompt_id}) do + case Nola.IRC.GptPlugin.get_prompt(prompt_id) do + {:ok, prompt} -> + network = Map.get(params, "network") + channel = if c = Map.get(params, "chan"), do: NolaWeb.reformat_chan(c) + render(conn, "prompt.html", network: network, channel: channel, prompt: prompt) + {:error, :not_found} -> + conn + |> put_status(404) + |> text("Page not found") + end + end + +end |