using System.Text.RegularExpressions;
using GTANetworkAPI;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Services;

namespace ReallifeGamemode.Server.Commands
{
  internal class GroupCommands : Script
  {
    #region Chat Commands

    [Command("gc", "~m~Benutzung: ~s~/gc [Nachricht]", GreedyArg = true)]
    public void CmdGroupG(Player player, string message)
    {
      Database.Entities.Group group = player.GetUser().Group;
      if (group == null)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
      message = $"{player.Name}: {message}";

      ChatService.BroadcastGroup(message, group);
    }

    #endregion Chat Commands
  }
}
