mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-09-27 20:17:04 +02:00
anti-dll webhook change
This commit is contained in:
commit
e964097a55
1 changed files with 40 additions and 11 deletions
|
|
@ -10,14 +10,17 @@ using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Capabilities;
|
using CounterStrikeSharp.API.Core.Capabilities;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using AntiDLL.API;
|
using AntiDLL.API;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
public class PluginConfig : IBasePluginConfig
|
public class PluginConfig : IBasePluginConfig
|
||||||
{
|
{
|
||||||
[JsonPropertyName("ConfigVersion")] public int Version { get; set; } = 1;
|
[JsonPropertyName("ConfigVersion")] public int Version { get; set; } = 2;
|
||||||
[JsonPropertyName("Reason")] public string Reason { get; set; } = "Invalid event detected!";
|
[JsonPropertyName("Reason")] public string Reason { get; set; } = "Invalid event detected!";
|
||||||
[JsonPropertyName("Duration")] public int Duration { get; set; } = 0;
|
[JsonPropertyName("Duration")] public int Duration { get; set; } = 0;
|
||||||
[JsonPropertyName("CommandToExecute")] public string CommandToExecute { get; set; } = "css_addban {steamid64} {duration} {reason}";
|
[JsonPropertyName("CommandToExecute")] public string CommandToExecute { get; set; } = "css_addban {steamid64} {duration} {reason}";
|
||||||
[JsonPropertyName("BanType")] public string BanType { get; set; } = "auto";
|
[JsonPropertyName("BanType")] public string BanType { get; set; } = "auto";
|
||||||
|
[JsonPropertyName("WebhookUrl")] public string WebhookUrl { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginConfig>
|
public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginConfig>
|
||||||
|
|
@ -117,6 +120,7 @@ public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginCo
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Logger.LogInformation("Detected \"{eventName}\" for \"{player}({steamid})\"", eventName, player.PlayerName, player.SteamID.ToString());
|
Logger.LogInformation("Detected \"{eventName}\" for \"{player}({steamid})\"", eventName, player.PlayerName, player.SteamID.ToString());
|
||||||
|
_ = SendWebhook(eventName, player.PlayerName, player.SteamID.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PunishPlayer(CCSPlayerController player)
|
private void PunishPlayer(CCSPlayerController player)
|
||||||
|
|
@ -150,4 +154,29 @@ public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginCo
|
||||||
antidll.OnDetection -= OnDetection;
|
antidll.OnDetection -= OnDetection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Discord Webhook
|
||||||
|
private async Task SendWebhook(string eventName, string playerName, string steamid)
|
||||||
|
{
|
||||||
|
var webhookUrl = Config.WebhookUrl;
|
||||||
|
if (string.IsNullOrEmpty(webhookUrl))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var payload = new
|
||||||
|
{
|
||||||
|
content = $"Detected \"{eventName}\" for \"{playerName}({steamid})\""
|
||||||
|
};
|
||||||
|
|
||||||
|
var json = JsonSerializer.Serialize(payload);
|
||||||
|
|
||||||
|
using var client = new HttpClient();
|
||||||
|
using var content = new StringContent(json, System.Text.Encoding.UTF8, new MediaTypeHeaderValue("application/json"));
|
||||||
|
|
||||||
|
var response = await client.PostAsync(webhookUrl, content);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
Logger.LogError("Failed to forward event to webhook: {response}", response.ReasonPhrase);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue