Skip to content

Commit

Permalink
Add support for Uptime Kuma heartbeat push
Browse files Browse the repository at this point in the history
Closes #186
  • Loading branch information
Erisa committed Jan 5, 2024
1 parent 7f064c1 commit 769594c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -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
CLIPTALK_WEBHOOK=https://discord.com
UPTIME_KUMA_PUSH_URL=
15 changes: 15 additions & 0 deletions Events/HeartbeatEvent.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
1 change: 1 addition & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 769594c

Please sign in to comment.