1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
defmodule LSGWeb.GptController do
use LSGWeb, :controller
require Logger
plug LSGWeb.ContextPlug
def result(conn, params = %{"id" => result_id}) do
case LSG.IRC.GptPlugin.get_result(result_id) do
{:ok, result} ->
network = Map.get(params, "network")
channel = if c = Map.get(params, "chan"), do: LSGWeb.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 LSG.IRC.GptPlugin.get_prompt(prompt_id) do
{:ok, prompt} ->
network = Map.get(params, "network")
channel = if c = Map.get(params, "chan"), do: LSGWeb.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
|