summaryrefslogtreecommitdiff
path: root/lib/chessh/ssh/client
diff options
context:
space:
mode:
authorSimponic <loganhunt@simponic.xyz>2023-02-01 14:57:14 -0700
committerGitHub <noreply@github.com>2023-02-01 14:57:14 -0700
commitfe5f5b77fcc3ef24516866561f9b54ac07663ad6 (patch)
treeba63998ec306983d87594195d60ecb0abb6ea5d1 /lib/chessh/ssh/client
parent324d041d5c5cbcdf0083dcd802144a57443789f6 (diff)
downloadchessh-fe5f5b77fcc3ef24516866561f9b54ac07663ad6.tar.gz
chessh-fe5f5b77fcc3ef24516866561f9b54ac07663ad6.zip
Discord notifs (#14)
* Add role id to config * Add discord notifications for games * Fix discord discriminant tests
Diffstat (limited to 'lib/chessh/ssh/client')
-rw-r--r--lib/chessh/ssh/client/game/game.ex14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/chessh/ssh/client/game/game.ex b/lib/chessh/ssh/client/game/game.ex
index 4a79d05..fc48d6f 100644
--- a/lib/chessh/ssh/client/game/game.ex
+++ b/lib/chessh/ssh/client/game/game.ex
@@ -77,7 +77,7 @@ defmodule Chessh.SSH.Client.Game do
) do
{:allow, _count} ->
# Starting a new game
- {:ok, %Game{} = game} =
+ {:ok, %Game{id: game_id} = game} =
Game.changeset(
%Game{},
Map.merge(
@@ -92,6 +92,12 @@ defmodule Chessh.SSH.Client.Game do
)
|> Repo.insert()
+ GenServer.cast(
+ :discord_notifier,
+ {:schedule_notification, {:game_created, game_id},
+ Application.get_env(:chessh, DiscordNotifications)[:game_created_notif_delay_ms]}
+ )
+
init([
%State{
state
@@ -403,6 +409,12 @@ defmodule Chessh.SSH.Client.Game do
:syn.publish(:games, {:game, game_id}, {:new_move, attempted_move})
+ GenServer.cast(
+ :discord_notifier,
+ {:schedule_notification, {:move_reminder, game_id},
+ Application.get_env(:chessh, DiscordNotifications)[:game_move_notif_delay_ms]}
+ )
+
_ ->
nil
end