using System.Collections.Generic;
using System.Threading;
using TGS.Interface;
namespace TGS.Server.ChatCommands
{
///
/// A command heard by a
///
abstract class ChatCommand : Command
{
///
/// for the
///
public static ThreadLocal CommandInfo { get; private set; } = new ThreadLocal();
///
/// If set to , the cannot be invoked by a non-admin or outside an admin chat channel
///
public bool RequiresAdmin { get; protected set; }
///
/// Shorthand for accessing
///
protected Instance Instance { get { return CommandInfo.Value.Server; } }
///
public override ExitCode DoRun(IList parameters)
{
if (RequiresAdmin)
{
var Info = CommandInfo.Value;
if (!Info.IsAdmin)
{
OutputProc("You are not authorized to use that command!");
return ExitCode.BadCommand;
}
if (!Info.IsAdminChannel)
{
OutputProc("Use this command in an admin channel!");
return ExitCode.BadCommand;
}
}
return base.DoRun(parameters);
}
}
}