fix
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master Build queued... Details
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good Details

feature/task-38-roles
L_DelOff 2024-11-24 17:56:15 +03:00
parent 68d0fb2ced
commit a648865083
2 changed files with 23 additions and 18 deletions

View File

@ -24,6 +24,7 @@ public class CpuTemp extends CommandTemplate {
@Override @Override
public String executeCommandSpecificHost(String serverName) { public String executeCommandSpecificHost(String serverName) {
try {
Optional<SshServer> server = sshService.getAllSshServers() Optional<SshServer> server = sshService.getAllSshServers()
.stream() .stream()
.filter(x -> x.getName().equals(serverName)) .filter(x -> x.getName().equals(serverName))
@ -39,5 +40,10 @@ public class CpuTemp extends CommandTemplate {
log.error("Ошибка при выполнении команды 'CPUtemp'. Искомый сервер ({}) не найден", serverName); log.error("Ошибка при выполнении команды 'CPUtemp'. Искомый сервер ({}) не найден", serverName);
return null; return null;
} }
} catch (NumberFormatException e) {
log.error("Ошибка при выполнении команды 'CPUtemp'" ,e.getMessage());
return "Сервер " + serverName + " не поддерживает команду 'CPUtemp'";
}
} }
} }

View File

@ -45,10 +45,9 @@ public class TelegramBotKeyboard implements UiFormer {
private ArrayList<KeyboardRow> formKeyboard(User user) { private ArrayList<KeyboardRow> formKeyboard(User user) {
Role role = user.getRole(); Role role = user.getRole();
Map<String, CommandTemplate> commands = applicationContext.getBeansOfType(CommandTemplate.class); Map<String, CommandTemplate> commands = applicationContext.getBeansOfType(CommandTemplate.class);
if (List.of(ADMIN, USER).contains(role)) { commands.remove("firstUseCommand");
commands.remove("/start"); commands.remove("switchToMainMenu");
commands.remove("Not found");
}
int buttonOnLine = 3; int buttonOnLine = 3;
ArrayList<KeyboardRow> keyboardRows = new ArrayList<>(); ArrayList<KeyboardRow> keyboardRows = new ArrayList<>();