Update BetterRelay.cs
change the http client to restclient
This commit is contained in:
parent
f7a49183da
commit
df47584011
1 changed files with 15 additions and 9 deletions
|
|
@ -11,6 +11,8 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using RestSharp;
|
||||||
|
|
||||||
namespace BetterSecondBot.BetterRelayService
|
namespace BetterSecondBot.BetterRelayService
|
||||||
{
|
{
|
||||||
|
|
@ -188,8 +190,6 @@ namespace BetterSecondBot.BetterRelayService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HttpClient HTTPclient = new HttpClient();
|
|
||||||
|
|
||||||
protected async Task<Task> TriggerRelay(string sourcetype, string name,string message, string filtervalue, string discordServerid, string discordChannelid)
|
protected async Task<Task> TriggerRelay(string sourcetype, string name,string message, string filtervalue, string discordServerid, string discordChannelid)
|
||||||
{
|
{
|
||||||
List<relay_config> Dataset = new List<relay_config>();
|
List<relay_config> Dataset = new List<relay_config>();
|
||||||
|
|
@ -264,15 +264,21 @@ namespace BetterSecondBot.BetterRelayService
|
||||||
}
|
}
|
||||||
else if (cfg.targetname == "http")
|
else if (cfg.targetname == "http")
|
||||||
{
|
{
|
||||||
Dictionary<string, string> values = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "reply", sendmessage },
|
|
||||||
};
|
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(values);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await HTTPclient.PostAsync(cfg.targetvalue, content);
|
string[] bits = cfg.targetvalue.Split("@|@");
|
||||||
|
if (bits.Length == 2)
|
||||||
|
{
|
||||||
|
var client = new RestClient(bits[0]);
|
||||||
|
var request = new RestRequest(bits[1], Method.POST);
|
||||||
|
request.AddParameter("reply", sendmessage);
|
||||||
|
request.AddHeader("content-type", "application/x-www-form-urlencoded");
|
||||||
|
_ = client.ExecutePostAsync(request).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue