mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 14:06:41 +01:00
ValueTask ICommand
This commit is contained in:
@@ -47,19 +47,19 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
public ValueTask<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--ACTIVE"))
|
||||
return Task.FromResult(new MessageContent
|
||||
return ValueTask.FromResult(new MessageContent
|
||||
{
|
||||
Text = byondManager.ActiveVersion == null ? "None!" : String.Format(CultureInfo.InvariantCulture, "{0}.{1}", byondManager.ActiveVersion.Major, byondManager.ActiveVersion.Minor),
|
||||
});
|
||||
if (watchdog.Status == WatchdogStatus.Offline)
|
||||
return Task.FromResult(new MessageContent
|
||||
return ValueTask.FromResult(new MessageContent
|
||||
{
|
||||
Text = "Server offline!",
|
||||
});
|
||||
return Task.FromResult(new MessageContent
|
||||
return ValueTask.FromResult(new MessageContent
|
||||
{
|
||||
Text = watchdog.ActiveCompileJob?.ByondVersion ?? "None!",
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
public ValueTask<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
if (handler == null)
|
||||
throw new InvalidOperationException("SetHandler() has not been called!");
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
/// <param name="arguments">The text after <see cref="Name"/> with leading whitespace trimmed.</param>
|
||||
/// <param name="user">The <see cref="ChatUser"/> who invoked the command.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="MessageContent"/> to send to the invoker.</returns>
|
||||
Task<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in a <see cref="MessageContent"/> to send to the invoker.</returns>
|
||||
ValueTask<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
public bool AdminOnly => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(new MessageContent
|
||||
public ValueTask<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => ValueTask.FromResult(new MessageContent
|
||||
{
|
||||
Text = Kek,
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
/// <inheritdoc />
|
||||
// TODO: Decomplexify
|
||||
#pragma warning disable CA1506
|
||||
public async Task<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
public async ValueTask<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<Models.TestMerge> results = null;
|
||||
var splits = arguments.Split(' ');
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
public async ValueTask<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
string result;
|
||||
if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--REPO"))
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(new MessageContent
|
||||
public ValueTask<MessageContent> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => ValueTask.FromResult(new MessageContent
|
||||
{
|
||||
Text = assemblyInformationProvider.VersionString,
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <param name="arguments">Everything typed after <paramref name="commandName"/> minus leading spaces.</param>
|
||||
/// <param name="sender">The sending <see cref="ChatUser"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="MessageContent"/> text to send back.</returns>
|
||||
Task<MessageContent> HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in the <see cref="MessageContent"/> text to send back.</returns>
|
||||
ValueTask<MessageContent> HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MessageContent> HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken)
|
||||
public async ValueTask<MessageContent> HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken)
|
||||
{
|
||||
using (await SemaphoreSlimContext.Lock(synchronizationSemaphore, cancellationToken))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user