tgstation-server  4.4.0
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;
9 
10 namespace Tgstation.Server.Host.Components.Chat.Commands
11 {
15  sealed class ByondCommand : ICommand
16  {
18  public string Name => "byond";
19 
21  public string HelpText => "Displays the running Byond version. Use --active for the version used in future deployments";
22 
24  public bool AdminOnly => false;
25 
30 
34  readonly IWatchdog watchdog;
35 
41  public ByondCommand(IByondManager byondManager, IWatchdog watchdog)
42  {
43  this.byondManager = byondManager ?? throw new ArgumentNullException(nameof(byondManager));
44  this.watchdog = watchdog ?? throw new ArgumentNullException(nameof(watchdog));
45  }
46 
48  public Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
49  {
50  if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--ACTIVE"))
51  return Task.FromResult(byondManager.ActiveVersion == null ? "None!" : String.Format(CultureInfo.InvariantCulture, "{0}.{1}", byondManager.ActiveVersion.Major, byondManager.ActiveVersion.Minor));
52  if (watchdog.Status == WatchdogStatus.Offline)
53  return Task.FromResult("Server offline!");
54  return Task.FromResult(watchdog.ActiveCompileJob.ByondVersion);
55  }
56  }
57 }
readonly IByondManager byondManager
The IByondManager for the ByondCommand
Definition: ByondCommand.cs:29
WatchdogStatus
The current status of the watchdog.
Task< string > Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
Invoke the ICommand
Definition: ByondCommand.cs:48
For managing the BYOND installation
Represents a tgs_chat_user datum
Definition: ChatUser.cs:10
For displaying the installed Byond version
Definition: ByondCommand.cs:15
readonly IWatchdog watchdog
The IWatchdog for the ByondCommand
Definition: ByondCommand.cs:34
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:15
ByondCommand(IByondManager byondManager, IWatchdog watchdog)
Construct a ByondCommand
Definition: ByondCommand.cs:41