mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Added Discord notification #865
This commit is contained in:
parent
4c797733ca
commit
43dbe854a6
18 changed files with 336 additions and 26 deletions
33
src/Ombi.Api.Discord/DiscordApi.cs
Normal file
33
src/Ombi.Api.Discord/DiscordApi.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Api.Discord.Models;
|
||||
|
||||
namespace Ombi.Api.Discord
|
||||
{
|
||||
public class DiscordApi : IDiscordApi
|
||||
{
|
||||
public DiscordApi()
|
||||
{
|
||||
Api = new Api();
|
||||
}
|
||||
|
||||
private string Endpoint => "https://discordapp.com/api/"; //webhooks/270828242636636161/lLysOMhJ96AFO1kvev0bSqP-WCZxKUh1UwfubhIcLkpS0DtM3cg4Pgeraw3waoTXbZii
|
||||
private Api Api { get; }
|
||||
|
||||
public async Task SendMessage(string message, string webhookId, string webhookToken, string username = null)
|
||||
{
|
||||
var request = new Request(Endpoint, $"webhooks/{webhookId}/{webhookToken}", HttpMethod.Post);
|
||||
|
||||
var body = new DiscordWebhookBody
|
||||
{
|
||||
content = message,
|
||||
username = username
|
||||
};
|
||||
request.AddJsonBody(body);
|
||||
|
||||
request.AddHeader("Content-Type", "application/json");
|
||||
|
||||
await Api.Request(request);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue