chat logs

This commit is contained in:
hydrant
2021-04-19 14:15:08 +02:00
parent f0b2eca560
commit 8485102e49
17 changed files with 2662 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Entities.Logs.Chat;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Business;
using ReallifeGamemode.Server.Classes;
@@ -302,13 +303,31 @@ namespace ReallifeGamemode.Server.Commands
[Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
public void CmdAdminO(Player player, string message)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
if(!player.IsLoggedIn())
{
return;
}
using var dbContext = new DatabaseContext();
User user = player.GetUser(dbContext);
if (!user.IsAdmin(AdminLevel.SUPPORTER))
{
ChatService.NotAuthorized(player);
return;
}
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
var logEntry = new OChatLogEntry()
{
Text = message,
UserId = user.Id,
};
dbContext.OChatLogs.Add(logEntry);
dbContext.SaveChanges();
message = Regex.Replace(message, "#([0-9A-Fa-f]{6})", m => "!{" + m.Groups[0].Value + "}");
string publicMessage = "~b~(( " + player.GetUser().AdminLevel.GetName() + " " + player.Name + ": " + message + " ~b~))";