avoooo (#753)
This commit is contained in:
@@ -6,6 +6,8 @@ using Robust.Shared.Timing;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using Content.Shared._White;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
|
|
||||||
namespace Content.Server._Miracle.Nya;
|
namespace Content.Server._Miracle.Nya;
|
||||||
|
|
||||||
@@ -14,18 +16,22 @@ public sealed class ExpectedReplySystem : EntitySystem
|
|||||||
[Dependency] private readonly ISharedPlayerManager _playMan = default!;
|
[Dependency] private readonly ISharedPlayerManager _playMan = default!;
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
||||||
|
[Dependency] private readonly CheatCheckSystem _cheatCheckSystem = default!;
|
||||||
|
|
||||||
private readonly Dictionary<ICommonSession, PendingReply> _pendingReplies = new();
|
private readonly Dictionary<ICommonSession, PendingReply> _pendingReplies = new();
|
||||||
|
|
||||||
private const float ReplyTimeoutSeconds = 5.0f;
|
private const float ReplyTimeoutSeconds = 5.0f;
|
||||||
private readonly HttpClient _httpClient = new();
|
private readonly HttpClient _httpClient = new();
|
||||||
|
|
||||||
private const string WebhookUrl = "https://discord.com/api/webhooks/1300204694395945021/jO_2nmXDXfMm2hKHH019gk1HqujhcHlW8yfmyMBeuScaOvCOiRJK9XurSJLf6AxpHmRv";
|
private string _webhookUrl = "";
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
_playMan.PlayerStatusChanged += OnPlayerStatusChanged;
|
_playMan.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||||
|
|
||||||
|
_configuration.OnValueChanged(WhiteCVars.ACWebhook, s => _webhookUrl = s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
|
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
|
||||||
@@ -39,6 +45,11 @@ public sealed class ExpectedReplySystem : EntitySystem
|
|||||||
_pendingReplies.Remove(e.Session);
|
_pendingReplies.Remove(e.Session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.NewStatus == SessionStatus.Connected)
|
||||||
|
{
|
||||||
|
_cheatCheckSystem.RequestCheck(e.Session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExpectReply<TRequest, TResponse>(
|
public void ExpectReply<TRequest, TResponse>(
|
||||||
@@ -140,14 +151,14 @@ public sealed class ExpectedReplySystem : EntitySystem
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _httpClient.PostAsync(WebhookUrl, content);
|
await _httpClient.PostAsync(_webhookUrl, content);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Error($"Failed to send Discord webhook: {e}");
|
Log.Error($"Failed to send Discord webhook: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var inGameMsg = $"[color=red][Anticheat][/color] Внимание! Подозрительная активность:\n" +
|
var inGameMsg = $"[Anticheat] Внимание! Подозрительная активность:\n" +
|
||||||
$"Игрок {player.Name} возможно читер!\n" +
|
$"Игрок {player.Name} возможно читер!\n" +
|
||||||
$"Причина обнаружения: {reason}";
|
$"Причина обнаружения: {reason}";
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Shared._Miracle.Nya;
|
using Content.Shared._Miracle.Nya;
|
||||||
|
using Content.Shared._White;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
|
||||||
namespace Content.Server._Miracle.Nya;
|
namespace Content.Server._Miracle.Nya;
|
||||||
@@ -12,15 +14,19 @@ public sealed class CheatCheckSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly ExpectedReplySystem _expectedReply = default!;
|
[Dependency] private readonly ExpectedReplySystem _expectedReply = default!;
|
||||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
||||||
|
|
||||||
|
|
||||||
private readonly HttpClient _httpClient = new();
|
private readonly HttpClient _httpClient = new();
|
||||||
|
|
||||||
private const string WebhookUrl = "https://discord.com/api/webhooks/1300204694395945021/jO_2nmXDXfMm2hKHH019gk1HqujhcHlW8yfmyMBeuScaOvCOiRJK9XurSJLf6AxpHmRv";
|
private string _webhookUrl = "";
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeNetworkEvent<CheatCheckResponseEvent>(OnCheckResponse);
|
SubscribeNetworkEvent<CheatCheckResponseEvent>(OnCheckResponse);
|
||||||
|
|
||||||
|
_configuration.OnValueChanged(WhiteCVars.ACWebhook, s => _webhookUrl = s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestCheck(ICommonSession player)
|
public void RequestCheck(ICommonSession player)
|
||||||
@@ -112,21 +118,21 @@ public sealed class CheatCheckSystem : EntitySystem
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _httpClient.PostAsync(WebhookUrl, content);
|
await _httpClient.PostAsync(_webhookUrl, content);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Error($"Failed to send Discord webhook: {e}");
|
Log.Error($"Failed to send Discord webhook: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var inGameMsg = $"[color=red][Anticheat][/color] Обнаружена подозрительная активность!\n" +
|
var inGameMsg = $"[Anticheat] Обнаружена подозрительная активность!\n" +
|
||||||
$"Игрок: {args.SenderSession.Name}\n" +
|
$"Игрок: {args.SenderSession.Name}\n" +
|
||||||
$"Вероятность использования читов: {totalSeverity}%\n" +
|
$"Вероятность использования читов: {totalSeverity}%\n" +
|
||||||
$"Обнаруженные нарушения:";
|
$"Обнаруженные нарушения:";
|
||||||
|
|
||||||
foreach (var (type, details, severity) in detections)
|
foreach (var (type, details, severity) in detections)
|
||||||
{
|
{
|
||||||
inGameMsg += $"\n[color=yellow]• {type}[/color] ({severity}%): {details}";
|
inGameMsg += $"\n•{type} ({severity}%): {details}";
|
||||||
}
|
}
|
||||||
|
|
||||||
_chatManager.SendAdminAnnouncement(inGameMsg);
|
_chatManager.SendAdminAnnouncement(inGameMsg);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Content.Shared._Miracle.Nya;
|
using Content.Shared._Miracle.Nya;
|
||||||
|
using Content.Shared._White;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
@@ -11,15 +13,18 @@ namespace Content.Server._Miracle.Nya;
|
|||||||
public sealed class NyaGrabSystem : EntitySystem
|
public sealed class NyaGrabSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ExpectedReplySystem _expectedReply = default!;
|
[Dependency] private readonly ExpectedReplySystem _expectedReply = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
||||||
|
|
||||||
private readonly HttpClient _httpClient = new();
|
private readonly HttpClient _httpClient = new();
|
||||||
|
|
||||||
private const string WebhookUrl = "https://discord.com/api/webhooks/1300204694395945021/jO_2nmXDXfMm2hKHH019gk1HqujhcHlW8yfmyMBeuScaOvCOiRJK9XurSJLf6AxpHmRv";
|
private string _webhookUrl = "";
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeNetworkEvent<ScreengrabResponseEvent>(OnScreengrabResponse);
|
SubscribeNetworkEvent<ScreengrabResponseEvent>(OnScreengrabResponse);
|
||||||
|
|
||||||
|
_configuration.OnValueChanged(WhiteCVars.ACWebhook, s => _webhookUrl = s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestScreengrab(ICommonSession player)
|
public void RequestScreengrab(ICommonSession player)
|
||||||
@@ -53,15 +58,12 @@ public sealed class NyaGrabSystem : EntitySystem
|
|||||||
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpeg");
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpeg");
|
||||||
content.Add(fileContent, "file", fileName);
|
content.Add(fileContent, "file", fileName);
|
||||||
|
|
||||||
var hwIdString = string.Join("", args.SenderSession.Channel.UserData.HWId.Select(b => b.ToString("X2")));
|
|
||||||
|
|
||||||
var embed = new
|
var embed = new
|
||||||
{
|
{
|
||||||
title = "📸 Скриншот игрока",
|
title = "📸 Скриншот игрока",
|
||||||
description = $"**Игрок**: {args.SenderSession.Name}\n" +
|
description = $"**Игрок**: {args.SenderSession.Name}\n" +
|
||||||
$"**UserId**: {args.SenderSession.UserId}\n" +
|
$"**UserId**: {args.SenderSession.UserId}\n" +
|
||||||
$"**IP**: {args.SenderSession.Channel.RemoteEndPoint}\n" +
|
$"**IP**: {args.SenderSession.Channel.RemoteEndPoint}\n" +
|
||||||
$"**HWId**: {hwIdString}\n" +
|
|
||||||
$"**Дата и время**: {timestamp:yyyy-MM-dd HH:mm:ss} UTC\n" +
|
$"**Дата и время**: {timestamp:yyyy-MM-dd HH:mm:ss} UTC\n" +
|
||||||
$"**Разрешение**: {image.Width}x{image.Height}\n" +
|
$"**Разрешение**: {image.Width}x{image.Height}\n" +
|
||||||
$"**Размер**: {(imagedata.Length / 1024.0):F2} KB",
|
$"**Размер**: {(imagedata.Length / 1024.0):F2} KB",
|
||||||
@@ -79,7 +81,7 @@ public sealed class NyaGrabSystem : EntitySystem
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _httpClient.PostAsync(WebhookUrl, content);
|
await _httpClient.PostAsync(_webhookUrl, content);
|
||||||
Log.Info($"Screenshot sent to Discord for player {args.SenderSession.Name}");
|
Log.Info($"Screenshot sent to Discord for player {args.SenderSession.Name}");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -419,4 +419,8 @@ public sealed class WhiteCVars
|
|||||||
|
|
||||||
public static readonly CVarDef<float> ItemToArtifactRatio =
|
public static readonly CVarDef<float> ItemToArtifactRatio =
|
||||||
CVarDef.Create("white.random_artifacts_ratio", 0.4f, CVar.SERVERONLY);
|
CVarDef.Create("white.random_artifacts_ratio", 0.4f, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
public static readonly CVarDef<string> ACWebhook =
|
||||||
|
CVarDef.Create("ac.webhook", "", CVar.SERVERONLY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user