From 47d3f28f16bdd1eb7ad99b91f7963fd2c4b8f9bf Mon Sep 17 00:00:00 2001 From: Simponic Date: Wed, 1 Feb 2023 22:55:06 -0700 Subject: Discord threads (#16) * Add initial support for discord threads * Finish thread creation --- lib/chessh/ssh/client/game/game.ex | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/chessh/ssh') diff --git a/lib/chessh/ssh/client/game/game.ex b/lib/chessh/ssh/client/game/game.ex index d6b0b5b..6b2ef60 100644 --- a/lib/chessh/ssh/client/game/game.ex +++ b/lib/chessh/ssh/client/game/game.ex @@ -396,7 +396,7 @@ defmodule Chessh.SSH.Client.Game do {:ok, status} -> {:ok, fen} = :binbo.get_fen(binbo_pid) - {:ok, _new_game} = + {:ok, %Game{status: after_move_status}} = game |> Game.changeset( Map.merge( @@ -413,11 +413,18 @@ 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]} - ) + if after_move_status == :continue do + GenServer.cast( + :discord_notifier, + {:schedule_notification, {:move_reminder, game_id}, + Application.get_env(:chessh, DiscordNotifications)[:game_move_notif_delay_ms]} + ) + else + GenServer.cast( + :discord_notifier, + {:schedule_notification, {:cleanup_thread, game_id}, 0} + ) + end _ -> nil -- cgit v1.2.3-70-g09d2