/// <summary> /// Executes the specified command asynchronously. /// </summary> /// <param name="c">The command argument information.</param> /// <returns><c>true</c> if the command was successfully executed, otherwise <c>false</c>.</returns> public async Task <bool> ExecAsync(Cmd c) { if (_sst.IsMonitoringServer) { StatusMessage = "^2[SUCCESS]^7 Stopping SST server monitoring. To restart, use the GUI or IRC."; await SendServerTell(c, StatusMessage); Log.Write(string.Format("Owner {0} issued command to stop SST server monitoring. Stopping.", c.FromUser), _logClassType, _logPrefix); _sst.StopMonitoring(); return(true); } // Should not happen StatusMessage = "^1[ERROR]^3 Unable to stop SST server monitoring."; await SendServerTell(c, StatusMessage); Log.Write(string.Format( "Owner {0} issued command to stop SST server monitoring. Unable to stop.", c.FromUser), _logClassType, _logPrefix); return(false); }
/// <summary> /// Executes the specified command asynchronously. /// </summary> /// <param name="c">The cmd args.</param> public async Task <bool> ExecAsync(Cmd c) { if (!c.Args[1].Equals("start") && !c.Args[1].Equals("stop") && !c.Args[1].Equals("reset") && !c.Args[1].Equals("status")) { DisplayArgLengthError(c); return(false); } var qlw = new QlWindowUtils(); if (!qlw.QuakeLiveConsoleWindowExists()) { _irc.SendIrcNotice(c.FromUser, "[ERROR] A running instance of Quake Live could not be found."); Log.Write(string.Format( "{0} attempted to use {1} command but a running instance of Quake Live could not be found. Ignoring.", c.FromUser, c.CmdName), _logClassType, _logPrefix); return(false); } if (c.Args[1].Equals("start")) { if (_sst.IsMonitoringServer) { _irc.SendIrcNotice(c.FromUser, "[ERROR] Your QL server is already being monitored."); Log.Write(string.Format( "{0} attempted to start server monitoring but server is already being monitored. Ignoring.", c.FromUser), _logClassType, _logPrefix); return(false); } _irc.SendIrcMessage(_irc.IrcSettings.ircChannel, "\u0002[SUCCESS]\u0002 Attempting to start QL server monitoring."); await _sst.BeginMonitoring(); // Give it time to complete initilization, then show status. await Task.Delay(11000); ShowMonitorStatus(); } else if (c.Args[1].Equals("stop")) { if (!_sst.IsMonitoringServer) { _irc.SendIrcNotice(c.FromUser, "[ERROR] No QL server is currently being monitored."); Log.Write(string.Format( "{0} attempted to stop server monitoring but server is not currently being monitored. Ignoring.", c.FromUser), _logClassType, _logPrefix); return(false); } _sst.StopMonitoring(); _irc.SendIrcMessage(_irc.IrcSettings.ircChannel, "\u0002[SUCCESS]\u0002 Stopped monitoring your QL server."); } else if (c.Args[1].Equals("reset")) { if (_sst.IsMonitoringServer) { Log.Write(string.Format( "{0} reset server monitoring for actively monitored server; now stopping server monitoring.", c.FromUser), _logClassType, _logPrefix); _irc.SendIrcMessage(_irc.IrcSettings.ircChannel, "\u0002[SUCCESS]\u0002 Your QL server was being monitored; now stopping this monitoring."); _sst.StopMonitoring(); } else { Log.Write(string.Format( "{0} reset server monitoring for non-actively monitored server; now starting server monitoring.", c.FromUser), _logClassType, _logPrefix); _irc.SendIrcMessage(_irc.IrcSettings.ircChannel, "\u0002[SUCCESS]\u0002 Your QL server was not being monitored; now starting monitoring."); await _sst.BeginMonitoring(); } } else if (c.Args[1].Equals("status")) { ShowMonitorStatus(); } return(true); }