CSSPanel Support

This commit is contained in:
Sachin 2024-10-28 17:50:22 +05:30
parent d30ac80a36
commit f01beebea9
21 changed files with 762 additions and 214 deletions

View file

@ -0,0 +1,40 @@
using Dapper;
using Microsoft.Extensions.Logging;
namespace CS2_SimpleAdmin.Managers;
public class ChatManager
{
public void AddChatMessageDB(string playerSteam64, string playerName, string message, bool? team)
{
if (CS2_SimpleAdmin.Database == null) return;
Task.Run(async () =>
{
try
{
await using var connection = await CS2_SimpleAdmin.Database.GetConnectionAsync();
var sql = "INSERT INTO `sa_chatlogs` (`playerSteam64`, `playerName`, `message`, `team`, `created`, `serverId`) " +
"VALUES (@playerSteam64, @playerName, @message, @team, @created, @serverId)";
int? serverId = CS2_SimpleAdmin.ServerId;
if (serverId == null)
return;
DateTime now = DateTime.Now;
await connection.ExecuteAsync(sql, new
{
playerSteam64,
playerName,
message,
team = team ?? null,
created = now,
serverid = serverId
});
}
catch (Exception e)
{
CS2_SimpleAdmin._logger?.LogError(e.Message);
}
});
}
}