chat logs
This commit is contained in:
23
ReallifeGamemode.Database/Entities/Logs/Chat/ChatLogEntry.cs
Normal file
23
ReallifeGamemode.Database/Entities/Logs/Chat/ChatLogEntry.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public abstract class ChatLogEntry
|
||||||
|
{
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(UserId))]
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public string Text { get; set; }
|
||||||
|
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public DateTime Time { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class DepartmentChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class FactionChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
[ForeignKey(nameof(Faction))]
|
||||||
|
public int FactionId { get; set; }
|
||||||
|
|
||||||
|
public Faction Faction { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class GangChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class GroupChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
public int GroupId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(GroupId))]
|
||||||
|
public Group Group { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class LeaderChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class LocalChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class NewsChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs.Chat
|
||||||
|
{
|
||||||
|
public class OChatLogEntry : ChatLogEntry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
2167
ReallifeGamemode.Database/Migrations/20210419104509_ChatLogs.Designer.cs
generated
Normal file
2167
ReallifeGamemode.Database/Migrations/20210419104509_ChatLogs.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class ChatLogs : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ChatLogs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
UserId = table.Column<int>(nullable: true),
|
||||||
|
Text = table.Column<string>(nullable: true),
|
||||||
|
Time = table.Column<DateTime>(nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Discriminator = table.Column<string>(nullable: false),
|
||||||
|
FactionId = table.Column<int>(nullable: true),
|
||||||
|
GroupId = table.Column<int>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ChatLogs", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ChatLogs_Users_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ChatLogs_Factions_FactionId",
|
||||||
|
column: x => x.FactionId,
|
||||||
|
principalTable: "Factions",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ChatLogs_Groups_GroupId",
|
||||||
|
column: x => x.GroupId,
|
||||||
|
principalTable: "Groups",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ChatLogs_UserId",
|
||||||
|
table: "ChatLogs",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ChatLogs_FactionId",
|
||||||
|
table: "ChatLogs",
|
||||||
|
column: "FactionId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ChatLogs_GroupId",
|
||||||
|
table: "ChatLogs",
|
||||||
|
column: "GroupId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ChatLogs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -797,6 +797,35 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
b.ToTable("BankAccountTransactionLogs");
|
b.ToTable("BankAccountTransactionLogs");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Discriminator")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Time")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<int?>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("ChatLogs");
|
||||||
|
|
||||||
|
b.HasDiscriminator<string>("Discriminator").HasValue("ChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.CommandLogEntry", b =>
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.CommandLogEntry", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
@@ -1709,6 +1738,72 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
b.ToTable("WhitelistEntries");
|
b.ToTable("WhitelistEntries");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.DepartmentChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("DepartmentChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.FactionChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.Property<int?>("FactionId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasIndex("FactionId");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("FactionChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.GangChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("GangChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.GroupChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.Property<int?>("GroupId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasIndex("GroupId");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("GroupChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.LeaderChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("LeaderChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.LocalChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("LocalChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.NewsChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("NewsChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.OChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("OChatLogEntry");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionVehicle", b =>
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionVehicle", b =>
|
||||||
{
|
{
|
||||||
b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle");
|
b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle");
|
||||||
@@ -1912,6 +2007,13 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
.HasForeignKey("UserId");
|
.HasForeignKey("UserId");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.CommandLogEntry", b =>
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.CommandLogEntry", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
||||||
@@ -2028,6 +2130,20 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.FactionChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("FactionId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.GroupChatLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("GroupId");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupVehicle", b =>
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupVehicle", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group")
|
b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group")
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace ReallifeGamemode.Database.Models
|
|||||||
e.HasIndex(u => u.Name)
|
e.HasIndex(u => u.Name)
|
||||||
.IsUnique(true);
|
.IsUnique(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
modelBuilder.Entity<Entities.ServerVehicle>()
|
modelBuilder.Entity<Entities.ServerVehicle>()
|
||||||
.Property(sv => sv.Active)
|
.Property(sv => sv.Active)
|
||||||
@@ -87,7 +87,7 @@ namespace ReallifeGamemode.Database.Models
|
|||||||
public DbSet<Entities.FactionVehicle> FactionVehicles { get; set; }
|
public DbSet<Entities.FactionVehicle> FactionVehicles { get; set; }
|
||||||
|
|
||||||
//Shops
|
//Shops
|
||||||
public DbSet<Entities.ShopClothe> ShopClothes { get; set; }
|
public DbSet<Entities.ShopClothe> ShopClothes { get; set; }
|
||||||
public DbSet<Entities.ShopItem> ShopItems { get; set; }
|
public DbSet<Entities.ShopItem> ShopItems { get; set; }
|
||||||
public DbSet<Entities.Weapon> Weapons { get; set; }
|
public DbSet<Entities.Weapon> Weapons { get; set; }
|
||||||
public DbSet<Entities.WeaponCategory> WeaponCategories { get; set; }
|
public DbSet<Entities.WeaponCategory> WeaponCategories { get; set; }
|
||||||
@@ -100,6 +100,19 @@ namespace ReallifeGamemode.Database.Models
|
|||||||
public DbSet<Entities.Logs.CommandLogEntry> CommandLogs { get; set; }
|
public DbSet<Entities.Logs.CommandLogEntry> CommandLogs { get; set; }
|
||||||
public DbSet<Entities.Logs.LoginLogoutLogEntry> LoginLogoutLogs { get; set; }
|
public DbSet<Entities.Logs.LoginLogoutLogEntry> LoginLogoutLogs { get; set; }
|
||||||
|
|
||||||
|
// Chat Logs
|
||||||
|
|
||||||
|
public DbSet<Entities.Logs.Chat.ChatLogEntry> ChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.FactionChatLogEntry> FactionChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.DepartmentChatLogEntry> DepartmentChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.GangChatLogEntry> GangChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.GroupChatLogEntry> GroupChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.LeaderChatLogEntry> LeaderChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.LocalChatLogEntry> LocalChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.NewsChatLogEntry> NewsChatLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.Chat.OChatLogEntry> OChatLogs { get; set; }
|
||||||
|
|
||||||
|
|
||||||
//Saves
|
//Saves
|
||||||
public DbSet<Entities.ATM> ATMs { get; set; }
|
public DbSet<Entities.ATM> ATMs { get; set; }
|
||||||
public DbSet<Entities.Saves.SavedBlip> Blips { get; set; }
|
public DbSet<Entities.Saves.SavedBlip> Blips { get; set; }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using GTANetworkAPI;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using ReallifeGamemode.Database.Entities;
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using ReallifeGamemode.Database.Entities.Logs.Chat;
|
||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Business;
|
using ReallifeGamemode.Server.Business;
|
||||||
using ReallifeGamemode.Server.Classes;
|
using ReallifeGamemode.Server.Classes;
|
||||||
@@ -302,13 +303,31 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
|
[Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdAdminO(Player player, string message)
|
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);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
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 + "}");
|
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~))";
|
string publicMessage = "~b~(( " + player.GetUser().AdminLevel.GetName() + " " + player.Name + ": " + message + " ~b~))";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ReallifeGamemode.Database.Entities;
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using ReallifeGamemode.Database.Entities.Logs.Chat;
|
||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Admin;
|
using ReallifeGamemode.Server.Admin;
|
||||||
using ReallifeGamemode.Server.Extensions;
|
using ReallifeGamemode.Server.Extensions;
|
||||||
@@ -30,7 +31,15 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
|
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionF(Player player, string message)
|
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)
|
if (f == null || f.StateOwned)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
@@ -39,14 +48,31 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
|
|
||||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
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);
|
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("ga", "~m~Benutzung: ~s~/ga [Nachricht]", GreedyArg = true)]
|
[Command("ga", "~m~Benutzung: ~s~/ga [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionGA(Player player, string message)
|
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;
|
Faction f = user?.Faction;
|
||||||
if ((f == null || !f.GangOwned) && !user.IsAdmin(AdminLevel.ADMIN))
|
if ((f == null || !f.GangOwned) && !user.IsAdmin(AdminLevel.ADMIN))
|
||||||
{
|
{
|
||||||
@@ -60,13 +86,22 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
|
|
||||||
if (f?.GangOwned == true)
|
if (f?.GangOwned == true)
|
||||||
{
|
{
|
||||||
rank = player.GetUser().GetFactionRank().RankName;
|
rank = user.FactionRank.RankName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rank = "[ADMIN]";
|
rank = "[ADMIN]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var logEntry = new GangChatLogEntry()
|
||||||
|
{
|
||||||
|
Text = message,
|
||||||
|
UserId = user.Id,
|
||||||
|
};
|
||||||
|
|
||||||
|
dbContext.GangChatLogs.Add(logEntry);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
string broadcastMessage = "!{FF0000}** " + rank + " " + player.Name + ": " + message + " **";
|
string broadcastMessage = "!{FF0000}** " + rank + " " + player.Name + ": " + message + " **";
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
@@ -77,7 +112,14 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("r", "~m~Benutzung: ~s~/r [Nachricht]", GreedyArg = true)]
|
[Command("r", "~m~Benutzung: ~s~/r [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionR(Player player, string message)
|
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)
|
if (f == null || !f.StateOwned)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
@@ -86,6 +128,16 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
|
|
||||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
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 **";
|
string broadcastMessage = "!{33AA33}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
||||||
ChatService.BroadcastFaction(broadcastMessage, f);
|
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||||
}
|
}
|
||||||
@@ -93,9 +145,16 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)]
|
[Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionD(Player player, string message)
|
public void CmdFactionD(Player player, string message)
|
||||||
{
|
{
|
||||||
User u = player.GetUser();
|
if (!player.IsLoggedIn())
|
||||||
Faction f = player.GetUser()?.Faction;
|
{
|
||||||
if ((f == null || !f.StateOwned) && !u.IsAdmin(AdminLevel.ADMIN))
|
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);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
@@ -107,13 +166,22 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
|
|
||||||
if (f?.StateOwned ?? false)
|
if (f?.StateOwned ?? false)
|
||||||
{
|
{
|
||||||
factionName = u.GetFactionRank().RankName;
|
factionName = user.FactionRank.RankName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
factionName = "[ADMIN]";
|
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 **";
|
string broadcastMessage = "!{CC3333}** " + factionName + " " + player.Name + ": " + message + ", over **";
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
@@ -128,23 +196,34 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("news", "~m~Benutzung: ~s~/news [Nachricht]", GreedyArg = true)]
|
[Command("news", "~m~Benutzung: ~s~/news [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionNR(Player player, string message)
|
public void CmdFactionNR(Player player, string message)
|
||||||
{
|
{
|
||||||
Faction f = player.GetUser()?.Faction;
|
if (!player.IsLoggedIn())
|
||||||
if (f == null)
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
Faction f = user?.Faction;
|
||||||
|
if (f == null || f.Id != 9)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
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 + " **";
|
var logEntry = new NewsChatLogEntry()
|
||||||
ChatService.Broadcast(broadcastMessage);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
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
|
#endregion NewsReporter commands
|
||||||
@@ -194,7 +273,13 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionLc(Player player, string message)
|
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))
|
if ((user?.FactionId == null || user.FactionLeader == false) && !user.IsAdmin(AdminLevel.ADMIN))
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
@@ -203,10 +288,19 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
|
|
||||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
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;
|
string factionName = string.Empty;
|
||||||
if (user.FactionLeader)
|
if (user.FactionLeader)
|
||||||
{
|
{
|
||||||
factionName = player.GetUser().Faction.Name;
|
factionName = user.Faction.Name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Text.RegularExpressions;
|
using GTANetworkAPI;
|
||||||
using GTANetworkAPI;
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using ReallifeGamemode.Database.Entities.Logs.Chat;
|
||||||
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Extensions;
|
using ReallifeGamemode.Server.Extensions;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
|
|
||||||
@@ -12,14 +14,33 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("gc", "~m~Benutzung: ~s~/gc [Nachricht]", GreedyArg = true)]
|
[Command("gc", "~m~Benutzung: ~s~/gc [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdGroupG(Player player, string message)
|
public void CmdGroupG(Player player, string message)
|
||||||
{
|
{
|
||||||
Database.Entities.Group group = player.GetUser().Group;
|
if(!player.IsLoggedIn())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
Group group = user?.Group;
|
||||||
if (group == null)
|
if (group == null)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
|
||||||
|
var logEntry = new GroupChatLogEntry()
|
||||||
|
{
|
||||||
|
Text = message,
|
||||||
|
UserId = user.Id,
|
||||||
|
GroupId = user.Group.Id
|
||||||
|
};
|
||||||
|
|
||||||
|
dbContext.GroupChatLogs.Add(logEntry);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
message = System.Text.RegularExpressions.Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||||
message = $"{player.Name}: {message}";
|
message = $"{player.Name}: {message}";
|
||||||
|
|
||||||
ChatService.BroadcastGroup(message, group);
|
ChatService.BroadcastGroup(message, group);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using ReallifeGamemode.Database.Entities.Logs.Chat;
|
||||||
|
using ReallifeGamemode.Database.Models;
|
||||||
|
using ReallifeGamemode.Server.Extensions;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
@@ -9,8 +12,25 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
[ServerEvent(Event.ChatMessage)]
|
[ServerEvent(Event.ChatMessage)]
|
||||||
public void ChatEvent(Player player, string message)
|
public void ChatEvent(Player player, string message)
|
||||||
{
|
{
|
||||||
|
if(!player.IsLoggedIn())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||||
if (serverMsg.Trim().Length == 0) return;
|
if (serverMsg.Trim().Length == 0) return;
|
||||||
|
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
|
||||||
|
var logEntry = new LocalChatLogEntry()
|
||||||
|
{
|
||||||
|
Text = serverMsg,
|
||||||
|
UserId = player.GetUser(dbContext).Id
|
||||||
|
};
|
||||||
|
|
||||||
|
dbContext.LocalChatLogs.Add(logEntry);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
NAPI.Player.GetPlayersInRadiusOfPlayer(25, player).ForEach(p =>
|
NAPI.Player.GetPlayersInRadiusOfPlayer(25, player).ForEach(p =>
|
||||||
{
|
{
|
||||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
||||||
|
|||||||
Reference in New Issue
Block a user