http relay target plus faster at home

This commit is contained in:
Madpeterz 2021-02-14 20:25:40 +00:00
parent 997b3259da
commit ddc6ceada8
3 changed files with 26 additions and 13 deletions

View file

@ -131,7 +131,7 @@ namespace BetterSecondbot.BetterAtHome
return;
}
long dif = helpers.UnixTimeNow() - LastLoginEvent;
if (dif < 60)
if (dif < 25)
{
controler.Bot.SetBetterAtHomeAction("Waiting for login lockout");
return;
@ -150,7 +150,7 @@ namespace BetterSecondbot.BetterAtHome
return;
}
long dif = helpers.UnixTimeNow() - LastLoginEvent;
if (dif < 60)
if (dif < 25)
{
controler.Bot.SetBetterAtHomeAction("Waiting for Login cooldown");
return;

View file

@ -9,6 +9,7 @@ using OpenMetaverse;
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Http;
namespace BetterSecondBot.BetterRelayService
{
@ -164,6 +165,8 @@ namespace BetterSecondBot.BetterRelayService
superV.MessageEvent += DiscordMessageHandler;
}
protected HttpClient HTTPclient = new HttpClient();
protected async void TriggerRelay(string sourcetype, string name,string message, string filtervalue, string discordServerid, string discordChannelid)
{
List<relay_config> Dataset = new List<relay_config>();
@ -186,14 +189,9 @@ namespace BetterSecondBot.BetterRelayService
{
relay_packet packet = new relay_packet();
packet.source_message = message;
packet.source_name = sourcetype;
packet.source_user = name;
packet.target_name = cfg.targetname;
packet.target_value = cfg.targetvalue;
packet.unixtime = helpers.UnixTimeNow().ToString();
if (sourcetype == "discord")
{
packet.discord_serverid = discordServerid;
packet.discord_channelid = discordChannelid;
}
sendmessage = JsonConvert.SerializeObject(packet);
@ -212,6 +210,23 @@ namespace BetterSecondBot.BetterRelayService
}
}
}
else if (cfg.targetname == "http")
{
Dictionary<string, string> values = new Dictionary<string, string>
{
{ "reply", sendmessage },
};
var content = new FormUrlEncodedContent(values);
try
{
await HTTPclient.PostAsync(cfg.targetvalue, content).ConfigureAwait(true);
}
catch (Exception e)
{
LogFormater.Crit("[BetterRelay] HTTP failed: " + e.Message + "");
}
}
else if (cfg.targetname == "localchat")
{
int chan = 0;
@ -290,13 +305,8 @@ namespace BetterSecondBot.BetterRelayService
public class relay_packet
{
public string source_name = "";
public string source_user = "";
public string source_message = "";
public string target_name = "";
public string target_value = "";
public string discord_serverid = "notused";
public string discord_channelid = "notused";
public string unixtime = "";
}
}

View file

@ -190,4 +190,7 @@ To config the relay please use the settings below.
target-config: avatar uuid
groupchat
target-config: group uuid
target-config: group uuid
http
target-config: full url