mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 07:04:57 +01:00
Split the service and server functions
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TGS.Server.ChatCommands
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ChatCommand"/>s generated by DreamDaemon via the API
|
||||
/// </summary>
|
||||
sealed class ServerChatCommand : ChatCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// The help text for the <see cref="ServerChatCommand"/>
|
||||
/// </summary>
|
||||
readonly string HelpText;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="ServerChatCommand"/>
|
||||
/// </summary>
|
||||
/// <param name="name">The invocation of the <see cref="ServerChatCommand"/></param>
|
||||
/// <param name="helpText">The help text of the <see cref="ServerChatCommand"/></param>
|
||||
/// <param name="adminOnly">If set to <see langword="true"/>, the <see cref="ServerChatCommand"/> cannot be invoked by a non-admin or outside an admin chat channel</param>
|
||||
/// <param name="requiredParameters">The number of parameters the <see cref="ServerChatCommand"/> requires</param>
|
||||
public ServerChatCommand(string name, string helpText, bool adminOnly, int requiredParameters)
|
||||
{
|
||||
Keyword = name;
|
||||
RequiresAdmin = adminOnly;
|
||||
HelpText = helpText;
|
||||
RequiredParameters = requiredParameters;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return HelpText;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
var res = Instance.SendCommand(String.Format("{0};sender={1};custom={2}", Keyword, CommandInfo.Value.Speaker, Helpers.SanitizeTopicString(String.Join(" ", parameters))));
|
||||
if (res != "SUCCESS" && !String.IsNullOrWhiteSpace(res))
|
||||
OutputProc(res);
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user