public async Task StopById(string serverId, IChatResponseToken icrt, string containerId) { var messageId = await icrt.Respond($"Stopping game server {containerId}."); var success = await StopAndRemove(containerId); if (success) { await icrt.Update(messageId, $"Game server {containerId} removed."); } else { await icrt.Update(messageId, "No servers to stop found."); } }
internal async void HandleUpdate(object sender, JSONMessage e) { var milliseconds = DateTime.UtcNow.Subtract(_lastUpdatedTime).TotalMilliseconds; _logger.LogDebug($"Status:{e.Status}, Message:{e.ProgressMessage}"); if (milliseconds > 1500) { _lastUpdatedTime = DateTime.UtcNow; var timeTaken = _lastUpdatedTime.Subtract(_startTime); // Update the message. Don't hang the thread. await _icrt.Update(_initialMessageID, $"Current status is: {e.Status} \n Taken: {timeTaken.Seconds}s so far."); } }
public async Task Stop(string serverId, IChatResponseToken icrt, GameServer gameServer) { var allContainers = await GetAllContainersRanByServer(serverId); var gameContainers = allContainers.Where(x => x.Image.Contains(gameServer.ContainerName)).ToList(); if (gameContainers.Any() == false) { await icrt.Respond("No servers to stop found."); return; } if (gameContainers.Count() == 1) { var messageId = await icrt.Respond($"Stopping game server {gameServer.ServerName}."); await StopAndRemove(gameContainers[0].ID); await icrt.Update(messageId, $"Game server {gameServer.ServerName} removed."); _logger.LogInformation($"{gameServer.ServerName} for ServerId:{serverId} stopped and removed."); } if (gameContainers.Count() > 1) { string runningContainerIds = ""; foreach (var cont in gameContainers) { runningContainerIds += $"{cont.ID} {cont.Image} {cont.Created} \n"; } await icrt.Respond($"Which container would you like me to stop? `-stop *containerid*`\n Containers: {runningContainerIds}"); } }