chat logs
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Entities.Logs.Chat;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Admin;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
@@ -30,7 +31,15 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionF(Player player, string message)
|
||||
{
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
User user = player.GetUser();
|
||||
|
||||
Faction f = user?.Faction;
|
||||
if (f == null || f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -39,14 +48,31 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{02FCFF}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " **";
|
||||
var logEntry = new FactionChatLogEntry()
|
||||
{
|
||||
Text = message,
|
||||
UserId = user.Id,
|
||||
FactionId = user.Faction.Id,
|
||||
};
|
||||
|
||||
dbContext.FactionChatLogs.Add(logEntry);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string broadcastMessage = "!{02FCFF}** " + user.FactionRank.RankName + " " + player.Name + ": " + message + " **";
|
||||
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||
}
|
||||
|
||||
[Command("ga", "~m~Benutzung: ~s~/ga [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionGA(Player player, string message)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User user = player.GetUser(dbContext);
|
||||
Faction f = user?.Faction;
|
||||
if ((f == null || !f.GangOwned) && !user.IsAdmin(AdminLevel.ADMIN))
|
||||
{
|
||||
@@ -60,13 +86,22 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (f?.GangOwned == true)
|
||||
{
|
||||
rank = player.GetUser().GetFactionRank().RankName;
|
||||
rank = user.FactionRank.RankName;
|
||||
}
|
||||
else
|
||||
{
|
||||
rank = "[ADMIN]";
|
||||
}
|
||||
|
||||
var logEntry = new GangChatLogEntry()
|
||||
{
|
||||
Text = message,
|
||||
UserId = user.Id,
|
||||
};
|
||||
|
||||
dbContext.GangChatLogs.Add(logEntry);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string broadcastMessage = "!{FF0000}** " + rank + " " + player.Name + ": " + message + " **";
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
@@ -77,7 +112,14 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("r", "~m~Benutzung: ~s~/r [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionR(Player player, string message)
|
||||
{
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User user = player.GetUser(dbContext);
|
||||
Faction f = user?.Faction;
|
||||
if (f == null || !f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -86,6 +128,16 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
var logEntry = new FactionChatLogEntry()
|
||||
{
|
||||
Text = message,
|
||||
UserId = user.Id,
|
||||
Faction = user.Faction,
|
||||
};
|
||||
|
||||
dbContext.FactionChatLogs.Add(logEntry);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string broadcastMessage = "!{33AA33}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
||||
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||
}
|
||||
@@ -93,9 +145,16 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionD(Player player, string message)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if ((f == null || !f.StateOwned) && !u.IsAdmin(AdminLevel.ADMIN))
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User user = player.GetUser(dbContext);
|
||||
Faction f = user?.Faction;
|
||||
if ((f == null || !f.StateOwned) && !user.IsAdmin(AdminLevel.ADMIN))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -107,13 +166,22 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (f?.StateOwned ?? false)
|
||||
{
|
||||
factionName = u.GetFactionRank().RankName;
|
||||
factionName = user.FactionRank.RankName;
|
||||
}
|
||||
else
|
||||
{
|
||||
factionName = "[ADMIN]";
|
||||
}
|
||||
|
||||
var logEntry = new DepartmentChatLogEntry()
|
||||
{
|
||||
Text = message,
|
||||
UserId = user.Id,
|
||||
};
|
||||
|
||||
dbContext.DepartmentChatLogs.Add(logEntry);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string broadcastMessage = "!{CC3333}** " + factionName + " " + player.Name + ": " + message + ", over **";
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
@@ -128,23 +196,34 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("news", "~m~Benutzung: ~s~/news [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionNR(Player player, string message)
|
||||
{
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if (f == null)
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User user = player.GetUser(dbContext);
|
||||
|
||||
Faction f = user?.Faction;
|
||||
if (f == null || f.Id != 9)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
if (player.GetUser().Faction.Id == 9)
|
||||
{
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{ff9531}** News Reporter" + " " + player.Name + ": " + message + " **";
|
||||
ChatService.Broadcast(broadcastMessage);
|
||||
}
|
||||
else
|
||||
var logEntry = new NewsChatLogEntry()
|
||||
{
|
||||
return;
|
||||
}
|
||||
Text = message,
|
||||
UserId = user.Id,
|
||||
};
|
||||
|
||||
dbContext.NewsChatLogs.Add(logEntry);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string broadcastMessage = "!{ff9531}** News Reporter" + " " + player.Name + ": " + message + " **";
|
||||
ChatService.Broadcast(broadcastMessage);
|
||||
}
|
||||
|
||||
#endregion NewsReporter commands
|
||||
@@ -194,7 +273,13 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionLc(Player player, string message)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User user = player.GetUser(dbContext);
|
||||
if ((user?.FactionId == null || user.FactionLeader == false) && !user.IsAdmin(AdminLevel.ADMIN))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -203,10 +288,19 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
var logEntry = new LeaderChatLogEntry()
|
||||
{
|
||||
Text = message,
|
||||
UserId = user.Id,
|
||||
};
|
||||
|
||||
dbContext.LeaderChatLogs.Add(logEntry);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string factionName = string.Empty;
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
factionName = player.GetUser().Faction.Name;
|
||||
factionName = user.Faction.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user