mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-10-18 04:47:04 +02:00
CSSPanel Support
This commit is contained in:
parent
d30ac80a36
commit
f01beebea9
21 changed files with 762 additions and 214 deletions
40
CS2-SimpleAdmin/Managers/ChatManager.cs
Normal file
40
CS2-SimpleAdmin/Managers/ChatManager.cs
Normal 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue