A "public" bot can be seen and played against by any player.
-
A "private" bot can be seen and played against by the player which created it.
- 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:
+ Goto /bots and create a bot, taking note
+ of the new bot's token (keep this private!).
+
+ A "public" bot can be seen and played against by any player.
+
+
+ A "private" bot can be seen and played against by the player which
+ created it.
+
+
+ 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:
{botMoveRequestSchema}
- 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"):
{botMoveResponseSchema}
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))