diff --git a/.env-example b/.env-example index 09e1e14b..4dff6783 100644 --- a/.env-example +++ b/.env-example @@ -4,4 +4,5 @@ CLIPTOK_ANTIPHISHING_ENDPOINT=useyourimagination RAVY_API_TOKEN=goodluckfindingone CLOUDFLARED_TOKEN=ignoreifnotrelevant USERNAME_CHECK_ENDPOINT=https://api.example.com/username -CLIPTALK_WEBHOOK=https://discord.com \ No newline at end of file +CLIPTALK_WEBHOOK=https://discord.com +UPTIME_KUMA_PUSH_URL= \ No newline at end of file diff --git a/Events/HeartbeatEvent.cs b/Events/HeartbeatEvent.cs new file mode 100644 index 00000000..216bcd58 --- /dev/null +++ b/Events/HeartbeatEvent.cs @@ -0,0 +1,15 @@ +namespace Cliptok.Events +{ + public class HeartbeatEvent + { + public static async Task OnHeartbeat(DiscordClient client, HeartbeatEventArgs e) + { + if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL"))) + { + var response = await Program.httpClient.GetAsync(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL") + client.Ping); + client.Logger.LogDebug("Heartbeat ping sent: {status} {content}", (int)response.StatusCode, await response.Content.ReadAsStringAsync()); + return; + } + } + } +} diff --git a/Program.cs b/Program.cs index a4ac647d..a7125ffd 100644 --- a/Program.cs +++ b/Program.cs @@ -151,6 +151,7 @@ static async Task Main(string[] _) discord.ThreadListSynced += ThreadEvents.Discord_ThreadListSynced; discord.ThreadMemberUpdated += ThreadEvents.Discord_ThreadMemberUpdated; discord.ThreadMembersUpdated += ThreadEvents.Discord_ThreadMembersUpdated; + discord.Heartbeated += HeartbeatEvent.OnHeartbeat; discord.GuildBanRemoved += UnbanEvent.OnUnban;