tgstation-server  4.3.2
The /tg/station 13 server suite
ByondCommand.cs
Go to the documentation of this file.
1 using System;
2 using System.Globalization;
3 using System.Linq;
4 using System.Threading;
5 using System.Threading.Tasks;
8 
9 namespace Tgstation.Server.Host.Components.Chat.Commands
10 {
14  sealed class ByondCommand : ICommand
15  {
17  public string Name => "byond";
18 
20  public string HelpText => "Displays the running Byond version. Use --active for the version used in future deployments";
21 
23  public bool AdminOnly => false;
24 
29 
33  readonly IWatchdog watchdog;
34 
40  public ByondCommand(IByondManager byondManager, IWatchdog watchdog)
41  {
42  this.byondManager = byondManager ?? throw new ArgumentNullException(nameof(byondManager));
43  this.watchdog = watchdog ?? throw new ArgumentNullException(nameof(watchdog));
44  }
45 
47  public Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
48  {
49  if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--ACTIVE"))
50  return Task.FromResult(byondManager.ActiveVersion == null ? "None!" : String.Format(CultureInfo.InvariantCulture, "{0}.{1}", byondManager.ActiveVersion.Major, byondManager.ActiveVersion.Minor));
51  if (!watchdog.Running)
52  return Task.FromResult("Server offline!");
53  return Task.FromResult(watchdog.ActiveCompileJob.ByondVersion);
54  }
55  }
56 }
readonly IByondManager byondManager
The IByondManager for the ByondCommand
Definition: ByondCommand.cs:28
Task< string > Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
Invoke the ICommand
Definition: ByondCommand.cs:47
For managing the BYOND installation
Represents a tgs_chat_user datum
Definition: ChatUser.cs:10
For displaying the installed Byond version
Definition: ByondCommand.cs:14
readonly IWatchdog watchdog
The IWatchdog for the ByondCommand
Definition: ByondCommand.cs:33
Represents a command that can be invoked by talking to chat bots
Definition: ICommand.cs:9
Runs and monitors the twin server controllers
Definition: IWatchdog.cs:14
ByondCommand(IByondManager byondManager, IWatchdog watchdog)
Construct a ByondCommand
Definition: ByondCommand.cs:40