summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-11-20 13:08:12 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-11-20 13:08:12 -0700
commit2b063d19cb98e82e74f8ebe95a8ab730a0285334 (patch)
tree9bc32dcfbfd74ab428532dc8d2cb7945b2f5b0e8
parenta4b89b6de436edbe907a095f867e57a0848a453e (diff)
downloadchessh-2b063d19cb98e82e74f8ebe95a8ab730a0285334.tar.gz
chessh-2b063d19cb98e82e74f8ebe95a8ab730a0285334.zip
run formatter
-rw-r--r--front/src/routes/bots.jsx5
-rw-r--r--front/src/routes/man_pages.jsx44
-rw-r--r--lib/chessh/web/web.ex1
3 files changed, 31 insertions, 19 deletions
diff --git a/front/src/routes/bots.jsx b/front/src/routes/bots.jsx
index 7f60d61..48f285a 100644
--- a/front/src/routes/bots.jsx
+++ b/front/src/routes/bots.jsx
@@ -62,7 +62,10 @@ const BotButton = ({ onSave, givenBot }) => {
return (
<div>
<ul>
- <li>It is Highly Recommend to peek at <Link to="/man-pages">the man pages</Link>.</li>
+ <li>
+ It is Highly Recommend to peek at{" "}
+ <Link to="/man-pages">the man pages</Link>.
+ </li>
</ul>
<button className="button" onClick={() => setOpen(true)}>
{givenBot ? "Update" : "+ Add"} Bot
diff --git a/front/src/routes/man_pages.jsx b/front/src/routes/man_pages.jsx
index 1b86f14..b67dd4f 100644
--- a/front/src/routes/man_pages.jsx
+++ b/front/src/routes/man_pages.jsx
@@ -108,29 +108,37 @@ export const ManPages = () => {
</div>
<div>
<ul>
- <li>Goto <Link to="/bots">/bots</Link> and create a bot, taking note of the new bot's token (keep this private!).</li>
- <li>Highly recommend <a
- href="https://ngrok.io"
- target="_blank"
- rel="noreferrer"
- >
+ <li>
+ Goto <Link to="/bots">/bots</Link> and create a bot, taking note
+ of the new bot's token (keep this private!).
+ </li>
+ <li>
+ Highly recommend{" "}
+ <a href="https://ngrok.io" target="_blank" rel="noreferrer">
ngrok
- </a> for testing.</li>
- <li>A "public" bot can be seen and played against by any player.</li>
- <li>A "private" bot can be seen and played against by the player which created it.</li>
+ </a>{" "}
+ for testing.
+ </li>
+ <li>
+ A "public" bot can be seen and played against by any player.
+ </li>
+ <li>
+ A "private" bot can be seen and played against by the player which
+ created it.
+ </li>
<li>
- A bot's "webhook" is the route that CheSSH will POST a
- JSON message to upon an update in a game it is playing. Upon a move,
- it will be immediately POST'd to with a single GameUpdate object, but
- when using the "redrive" feature (mostly for testing), an array of game that
- correspond to games in which it is still the bot's turn:
+ A bot's "webhook" is the route that CheSSH will POST a JSON
+ message to upon an update in a game it is playing. Upon a move, it
+ will be immediately POST'd to with a single GameUpdate object, but
+ when using the "redrive" feature (mostly for testing), an array of
+ game that correspond to games in which it is still the bot's turn:
<pre>{botMoveRequestSchema}</pre>
</li>
<li>
- After receiving the update, the bot must "respond" with its attempted move,
- with the plain token (no "Bearer" prefix) in its "Authorization" header, and
- a body of (given "attempted_move" is the from space appended to the destination space i.e.
- "e2e4"):
+ After receiving the update, the bot must "respond" with its
+ attempted move, with the plain token (no "Bearer" prefix) in its
+ "Authorization" header, and a body of (given "attempted_move" is
+ the from space appended to the destination space i.e. "e2e4"):
<pre>{botMoveResponseSchema}</pre>
</li>
<li>
diff --git a/lib/chessh/web/web.ex b/lib/chessh/web/web.ex
index 26385df..b18aa93 100644
--- a/lib/chessh/web/web.ex
+++ b/lib/chessh/web/web.ex
@@ -295,6 +295,7 @@ defmodule Chessh.Web.Endpoint do
Enum.find_value(conn.req_headers, fn {header, value} ->
if header === "authorization", do: value
end)
+
attempted_move = conn.body_params["attempted_move"]
bot = Repo.one(from(b in Bot, where: b.token == ^token))