mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 00:46:08 -06:00
added support for discord.
This commit is contained in:
parent
c791070126
commit
8fd49e20d5
@ -327,7 +327,15 @@ namespace CarCareTracker.Helper
|
||||
return;
|
||||
}
|
||||
var httpClient = new HttpClient();
|
||||
httpClient.PostAsJsonAsync(webhookURL, webHookPayload);
|
||||
if (webhookURL.StartsWith("discord://"))
|
||||
{
|
||||
webhookURL = webhookURL.Replace("discord://", "https://"); //cleanurl
|
||||
//format to discord
|
||||
httpClient.PostAsJsonAsync(webhookURL, DiscordWebHook.FromWebHookPayload(webHookPayload));
|
||||
} else
|
||||
{
|
||||
httpClient.PostAsJsonAsync(webhookURL, webHookPayload);
|
||||
}
|
||||
}
|
||||
public static string GetImportModeIcon(ImportMode importMode)
|
||||
{
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
namespace CarCareTracker.Models
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace CarCareTracker.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// WebHookPayload Object
|
||||
@ -18,6 +20,20 @@
|
||||
public string Username { get; set; } = "";
|
||||
public string Action { get; set; } = "";
|
||||
}
|
||||
public class DiscordWebHook
|
||||
{
|
||||
public string Username { get { return "LubeLogger"; } }
|
||||
[JsonPropertyName("avatar_url")]
|
||||
public string AvatarUrl { get { return "https://hargata.github.io/hargata/lubelogger_logo_small.png"; } }
|
||||
public string Content { get; set; } = "";
|
||||
public static DiscordWebHook FromWebHookPayload(WebHookPayload webHookPayload)
|
||||
{
|
||||
return new DiscordWebHook
|
||||
{
|
||||
Content = webHookPayload.Action,
|
||||
};
|
||||
}
|
||||
}
|
||||
public class WebHookPayload: WebHookPayloadBase
|
||||
{
|
||||
private static string GetFriendlyActionType(string actionType)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user