Added a webhook for hits with configurable URL to RL General Settings. For now it's just for custom made backedns, I will expand it later on with discord and telegram hooks.

This commit is contained in:
ruri
2019-09-07 17:13:01 +02:00
parent 31a349db22
commit cd7b3046aa
6 changed files with 83 additions and 0 deletions
+18
View File
@@ -1,4 +1,5 @@
using Extreme.Net;
using Newtonsoft.Json;
using RuriLib.LS;
using RuriLib.Models;
using RuriLib.ViewModels;
@@ -862,6 +863,23 @@ namespace RuriLib.Runner
RaiseFoundHit(hit);
}
// Call the webhook
if (Settings.General.WebhookEnabled)
{
HttpRequest request = new HttpRequest();
try
{
var toSend = new WebhookFormat(data, hitType, capturedData.ToCaptureString(), DateTime.Now, Config.Settings.Name, Config.Settings.Author);
var json = JsonConvert.SerializeObject(toSend);
//wc.UploadStringAsync(new Uri(Settings.General.WebhookURL), json);
request.PostAsync(Settings.General.WebhookURL, json, "application/json");
}
catch
{
RaiseMessageArrived(LogLevel.Error, $"Could not register the hit to webhook {Settings.General.WebhookURL}");
}
}
// Wait time
if (Settings.General.WaitTime > 0)
Thread.Sleep(Settings.General.WaitTime);