перенос файлов сервера из папки White в _White
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaAdminWhoCommand : IPandaCommand
|
||||
{
|
||||
public string Name => "adminwho";
|
||||
public Type RequestMessageType => typeof(UtkaAdminWhoRequest);
|
||||
public void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if(baseMessage is not UtkaAdminWhoRequest message) return;
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var adminManager = IoCManager.Resolve<IAdminManager>();
|
||||
|
||||
var admins = adminManager.ActiveAdmins.ToList();
|
||||
|
||||
var adminsList = new List<string>();
|
||||
|
||||
foreach (var admin in admins)
|
||||
{
|
||||
var adminData = adminManager.GetAdminData(admin)!;
|
||||
|
||||
if (adminData.Stealth)
|
||||
continue;
|
||||
|
||||
adminsList.Add(admin.Name);
|
||||
}
|
||||
|
||||
var toUtkaMessage = new UtkaAdminWhoResponse()
|
||||
{
|
||||
Admins = adminsList
|
||||
};
|
||||
|
||||
Response(context, toUtkaMessage);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Net;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaAsayCommand : IPandaCommand
|
||||
{
|
||||
public string Name => "asay";
|
||||
public Type RequestMessageType => typeof(UtkaAsayRequest);
|
||||
public void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaAsayRequest message) return;
|
||||
if(string.IsNullOrWhiteSpace(message.Message) || string.IsNullOrWhiteSpace(message.ACkey)) return;
|
||||
|
||||
var ckey = message.ACkey;
|
||||
var chatManager = IoCManager.Resolve<IChatManager>();
|
||||
|
||||
chatManager.SendHookAdminChat(ckey, message.Message);
|
||||
|
||||
Response(context);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondAsync("Success", HttpStatusCode.OK);
|
||||
}
|
||||
}
|
||||
152
Content.Server/_White/PandaSocket/Commands/PandaBanCommand.cs
Normal file
152
Content.Server/_White/PandaSocket/Commands/PandaBanCommand.cs
Normal file
@@ -0,0 +1,152 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Database;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Players.PlayTimeTracking;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaBanCommand : IPandaCommand
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IServerDbManager _db = default!;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly PandaWebManager _pandaWeb = default!;
|
||||
|
||||
private const ILocalizationManager LocalizationManager = default!;
|
||||
|
||||
public string Name => "ban";
|
||||
public Type RequestMessageType => typeof(UtkaBanRequest);
|
||||
public async void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaBanRequest message) return;
|
||||
|
||||
var plyMgr = IoCManager.Resolve<IPlayerManager>();
|
||||
var locator = IoCManager.Resolve<IPlayerLocator>();
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var locatedPlayer = await locator.LookupIdByNameOrIdAsync(message.ACkey!);
|
||||
if (locatedPlayer == null)
|
||||
{
|
||||
UtkaSendResponse(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var player = locatedPlayer.UserId;
|
||||
|
||||
var target = message.Ckey!;
|
||||
var reason = message.Reason!;
|
||||
var minutes = (uint) message.Duration!;
|
||||
var isGlobalBan = (bool) message.Global!;
|
||||
|
||||
var located = await locator.LookupIdByNameOrIdAsync(target);
|
||||
if (located == null)
|
||||
{
|
||||
UtkaSendResponse(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var targetUid = located.UserId;
|
||||
var targetHWid = located.LastHWId;
|
||||
var targetAddr = located.LastAddress;
|
||||
|
||||
if (player == targetUid)
|
||||
{
|
||||
UtkaSendResponse(context, false);
|
||||
return;
|
||||
}
|
||||
|
||||
DateTimeOffset? expires = null;
|
||||
if (minutes > 0)
|
||||
{
|
||||
expires = DateTimeOffset.Now + TimeSpan.FromMinutes(minutes);
|
||||
}
|
||||
|
||||
(IPAddress, int)? addrRange = null;
|
||||
if (targetAddr != null)
|
||||
{
|
||||
if (targetAddr.IsIPv4MappedToIPv6)
|
||||
targetAddr = targetAddr.MapToIPv4();
|
||||
|
||||
// Ban /64 for IPv4, /32 for IPv4.
|
||||
var cidr = targetAddr.AddressFamily == AddressFamily.InterNetworkV6 ? 64 : 32;
|
||||
addrRange = (targetAddr, cidr);
|
||||
}
|
||||
|
||||
var serverName = _cfg.GetCVar(CCVars.AdminLogsServerName);
|
||||
|
||||
if (isGlobalBan)
|
||||
{
|
||||
serverName = "unknown";
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntitySystemManager>().TryGetEntitySystem<GameTicker>(out var ticker);
|
||||
int? roundId = ticker == null || ticker.RoundId == 0 ? null : ticker.RoundId;
|
||||
var playtime = (await _db.GetPlayTimes(targetUid)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall)?.TimeSpent ?? TimeSpan.Zero;
|
||||
|
||||
var banDef = new ServerBanDef(
|
||||
null,
|
||||
targetUid,
|
||||
addrRange,
|
||||
targetHWid,
|
||||
DateTimeOffset.Now,
|
||||
expires,
|
||||
roundId,
|
||||
playtime,
|
||||
reason,
|
||||
NoteSeverity.High,
|
||||
player,
|
||||
null,
|
||||
serverName);
|
||||
|
||||
UtkaSendResponse(context, true);
|
||||
|
||||
await _db.AddServerBanAsync(banDef);
|
||||
|
||||
if (plyMgr.TryGetSessionById(targetUid, out var targetPlayer))
|
||||
{
|
||||
var msg = banDef.FormatBanMessage(_cfg, LocalizationManager);
|
||||
targetPlayer.ConnectedClient.Disconnect(msg);
|
||||
}
|
||||
|
||||
var banlist = await _db.GetServerBansAsync(null, targetUid, null);
|
||||
var banId = banlist[^1].Id;
|
||||
|
||||
var utkaBanned = new UtkaBannedEvent()
|
||||
{
|
||||
Ckey = message.Ckey,
|
||||
ACkey = message.ACkey,
|
||||
Bantype = "server",
|
||||
Duration = message.Duration,
|
||||
Global = message.Global,
|
||||
Reason = message.Reason,
|
||||
Rid = EntitySystem.Get<GameTicker>().RoundId,
|
||||
BanId = banId
|
||||
};
|
||||
|
||||
_pandaWeb.SendBotPostMessage(utkaBanned);
|
||||
_entMan.EventBus.RaiseEvent(EventSource.Local, utkaBanned);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
|
||||
private void UtkaSendResponse(IPandaStatusHandlerContext context, bool banned)
|
||||
{
|
||||
var utkaResponse = new UtkaBanResponse()
|
||||
{
|
||||
Banned = banned
|
||||
};
|
||||
|
||||
Response(context, utkaResponse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaJobBanCommand : IPandaCommand
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public string Name => "jobban";
|
||||
public Type RequestMessageType => typeof(UtkaJobBanRequest);
|
||||
public void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaJobBanRequest message) return;
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var target = message.Ckey!;
|
||||
var job = message.Type!;
|
||||
var reason = message.Reason!;
|
||||
var minutes = (uint) message.Duration!;
|
||||
var isGlobalBan = (bool) message.Global!;
|
||||
var admin = message.ACkey!;
|
||||
|
||||
var banManager = IoCManager.Resolve<IBanManager>();
|
||||
|
||||
if (_prototypeManager.TryIndex<DepartmentPrototype>(job, out var departmentProto))
|
||||
banManager.UtkaCreateDepartmentBan(admin, target, departmentProto, reason, minutes, isGlobalBan, context);
|
||||
|
||||
else
|
||||
banManager.UtkaCreateJobBan(admin, target, job, reason, minutes, isGlobalBan, context);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
48
Content.Server/_White/PandaSocket/Commands/PandaPmCommand.cs
Normal file
48
Content.Server/_White/PandaSocket/Commands/PandaPmCommand.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Net;
|
||||
using Content.Server.Administration.Systems;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
using Robust.Server.Player;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaPmCommand : IPandaCommand
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public string Name => "discordpm";
|
||||
public Type RequestMessageType => typeof(UtkaPmRequest);
|
||||
public void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaPmRequest message) return;
|
||||
var _bwoink = EntitySystem.Get<BwoinkSystem>();
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var toUtkaMessage = new UtkaPmResponse();
|
||||
|
||||
if(string.IsNullOrWhiteSpace(message.Message) || string.IsNullOrWhiteSpace(message.Sender) || string.IsNullOrWhiteSpace(message.Receiver))
|
||||
{
|
||||
toUtkaMessage.Message = false;
|
||||
Response(context, toUtkaMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_playerManager.TryGetUserId(message.Receiver, out var reciever))
|
||||
{
|
||||
toUtkaMessage.Message = false;
|
||||
Response(context, toUtkaMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
_bwoink.SendUtkaBwoinkMessage(reciever, message.Sender, message.Message);
|
||||
|
||||
toUtkaMessage.Message = true;
|
||||
|
||||
Response(context, toUtkaMessage);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaRestartRoundCommand : IPandaCommand
|
||||
{
|
||||
public string Name => "restartround";
|
||||
public Type RequestMessageType => typeof(UtkaRestartRoundRequest);
|
||||
public void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaRestartRoundRequest message) return;
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
EntitySystem.Get<GameTicker>().RestartRound();
|
||||
|
||||
var response = new UtkaRestartRoundResponse()
|
||||
{
|
||||
Restarted = true
|
||||
};
|
||||
|
||||
Response(context, response);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Net;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaSendOOCCommand : IPandaCommand
|
||||
{
|
||||
public string Name => "ooc";
|
||||
public Type RequestMessageType => typeof(UtkaOOCRequest);
|
||||
public async void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaOOCRequest message) return;
|
||||
if(string.IsNullOrWhiteSpace(message.Message) || string.IsNullOrWhiteSpace(message.CKey)) return;
|
||||
|
||||
var chatSystem = IoCManager.Resolve<IChatManager>();
|
||||
chatSystem.SendHookOOC($"{message.CKey}", $"{message.Message}");
|
||||
|
||||
Response(context);
|
||||
}
|
||||
|
||||
public async void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
await context.RespondAsync("Success", HttpStatusCode.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.AlertLevel;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Maps;
|
||||
using Content.Server.RoundEnd;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaStatusCommand : IPandaCommand
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
|
||||
|
||||
public string Name => "status";
|
||||
public Type RequestMessageType => typeof(UtkaStatusRequest);
|
||||
public void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaStatusRequest message) return;
|
||||
|
||||
var _gameTicker = EntitySystem.Get<GameTicker>();
|
||||
var _roundEndSystem = EntitySystem.Get<RoundEndSystem>();
|
||||
var _station = EntitySystem.Get<StationSystem>();
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
|
||||
var players = Filter.GetAllPlayers().ToList().Count;
|
||||
|
||||
var admins = _adminManager.ActiveAdmins.Select(x => x.Name).ToList().Count;
|
||||
|
||||
var shuttleData = string.Empty;
|
||||
|
||||
shuttleData = _roundEndSystem.ExpectedCountdownEnd == null ? "idle" : "called";
|
||||
|
||||
var roundDuration = _gameTicker.RoundDuration().TotalSeconds;
|
||||
|
||||
string? gameMap = null;
|
||||
string? stationCode = null;
|
||||
foreach (var station in _station.GetStations())
|
||||
{
|
||||
if (!_entMan.TryGetComponent(station, out AlertLevelComponent? alert) || stationCode != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (alert is { CurrentLevel: not null })
|
||||
{
|
||||
stationCode = alert.CurrentLevel;
|
||||
|
||||
var map = _gameMapManager.GetSelectedMap();
|
||||
gameMap = map?.MapName ?? Loc.GetString("discord-round-unknown-map");
|
||||
}
|
||||
}
|
||||
|
||||
var toUtkaMessage = new UtkaStatusResponse()
|
||||
{
|
||||
Players = players,
|
||||
Admins = admins,
|
||||
Map = gameMap,
|
||||
ShuttleStatus = shuttleData,
|
||||
RoundDuration = roundDuration,
|
||||
StationCode = stationCode
|
||||
};
|
||||
|
||||
Response(context, toUtkaMessage);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Database;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaUnJobBanCommand : IPandaCommand
|
||||
{
|
||||
public string Name => "unjobban";
|
||||
public Type RequestMessageType => typeof(UtkaUnJobBanRequest);
|
||||
public async void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaUnJobBanRequest message) return;
|
||||
|
||||
var dbMan = IoCManager.Resolve<IServerDbManager>();
|
||||
var locator = IoCManager.Resolve<IPlayerLocator>();
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var located = await locator.LookupIdByNameOrIdAsync(message.ACkey!);
|
||||
if (located == null)
|
||||
{
|
||||
UtkaSendResponse(false, context);
|
||||
return;
|
||||
}
|
||||
|
||||
var player = located.UserId;
|
||||
|
||||
var ban = await dbMan.GetServerRoleBanAsync(message.Bid!.Value);
|
||||
if (ban == null || ban.Unban != null)
|
||||
{
|
||||
UtkaSendResponse(false, context);
|
||||
return;
|
||||
}
|
||||
|
||||
var adminData = await dbMan.GetAdminDataForAsync(player);
|
||||
if (adminData?.AdminRank == null || ban.ServerName != "unknown" && adminData.AdminServer is not (null or "unknown") && adminData.AdminServer != ban.ServerName)
|
||||
{
|
||||
UtkaSendResponse(false, context);
|
||||
return;
|
||||
}
|
||||
|
||||
await dbMan.AddServerRoleUnbanAsync(new ServerRoleUnbanDef(message.Bid!.Value, player, DateTimeOffset.Now));
|
||||
|
||||
UtkaSendResponse(true, context);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
|
||||
private void UtkaSendResponse(bool unbanned, IPandaStatusHandlerContext context)
|
||||
{
|
||||
var utkaResponse = new UtkaUnJobBanResponse()
|
||||
{
|
||||
Unbanned = unbanned
|
||||
};
|
||||
|
||||
Response(context, utkaResponse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Database;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaUnbanCommand : IPandaCommand
|
||||
{
|
||||
public string Name => "unban";
|
||||
public Type RequestMessageType => typeof(UtkaUnbanRequest);
|
||||
public async void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaUnbanRequest message) return;
|
||||
|
||||
var dbMan = IoCManager.Resolve<IServerDbManager>();
|
||||
var locator = IoCManager.Resolve<IPlayerLocator>();
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var located = await locator.LookupIdByNameOrIdAsync(message.ACkey!);
|
||||
if (located == null)
|
||||
{
|
||||
UtkaSendResponse(false, context);
|
||||
return;
|
||||
}
|
||||
var player = located.UserId;
|
||||
|
||||
var banId = (int) message.Bid!;
|
||||
var ban = await dbMan.GetServerBanAsync(banId);
|
||||
|
||||
if (ban == null || ban.Unban != null)
|
||||
{
|
||||
UtkaSendResponse(false, context);
|
||||
return;
|
||||
}
|
||||
|
||||
var adminData = await dbMan.GetAdminDataForAsync(player);
|
||||
if (adminData?.AdminRank == null || ban.ServerName != "unknown" && adminData.AdminServer is not (null or "unknown") && adminData.AdminServer != ban.ServerName)
|
||||
{
|
||||
UtkaSendResponse(false, context);
|
||||
return;
|
||||
}
|
||||
|
||||
await dbMan.AddServerUnbanAsync(new ServerUnbanDef(banId, player, DateTimeOffset.Now));
|
||||
|
||||
UtkaSendResponse(true, context);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
|
||||
private void UtkaSendResponse(bool unbanned, IPandaStatusHandlerContext context)
|
||||
{
|
||||
var utkaResponse = new UtkaUnbanResponse()
|
||||
{
|
||||
Unbanned = unbanned
|
||||
};
|
||||
|
||||
Response(context, utkaResponse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Linq;
|
||||
using Content.Server._White.PandaSocket.Interfaces;
|
||||
using Content.Server._White.PandaSocket.Main;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.PandaSocket.Commands;
|
||||
|
||||
public sealed class PandaWhoCommand : IPandaCommand
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
public string Name => "who";
|
||||
public Type RequestMessageType => typeof(UtkaWhoRequest);
|
||||
public void Execute(IPandaStatusHandlerContext context, PandaBaseMessage baseMessage)
|
||||
{
|
||||
if (baseMessage is not UtkaWhoRequest) return;
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var players = Filter.GetAllPlayers().ToList();
|
||||
var playerNames = players
|
||||
.Where(player => player.Status != SessionStatus.Disconnected)
|
||||
.Select(x => x.Name);
|
||||
|
||||
var toUtkaMessage = new UtkaWhoResponse()
|
||||
{
|
||||
Players = playerNames.ToList()
|
||||
};
|
||||
|
||||
Response(context, toUtkaMessage);
|
||||
}
|
||||
|
||||
public void Response(IPandaStatusHandlerContext context, PandaBaseMessage? message = null)
|
||||
{
|
||||
context.RespondJsonAsync(message!);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user