diff --git a/text/src/main/java/com/halushko/kinocat/text/UserMessageHandler.java b/text/src/main/java/com/halushko/kinocat/text/UserMessageHandler.java index ac7b9935..3e15ed04 100644 --- a/text/src/main/java/com/halushko/kinocat/text/UserMessageHandler.java +++ b/text/src/main/java/com/halushko/kinocat/text/UserMessageHandler.java @@ -52,6 +52,7 @@ protected void getDeliverCallbackPrivate(SmartJson rabbitMessage) { log.debug("[UserMessageHandler] Command {} found", text); SmartJson message = new SmartJson(userId, command.getFinalCommand()); message.addValue("ARG", command.getArguments()); + message.addValue("SCRIPT", command.getScript()); RabbitUtils.postMessage(message, command.getQueue()); } log.debug("[UserMessageHandler] Finish DeliverCallbackPrivate for {}", getQueue()); diff --git a/torrent/src/main/java/com/halushko/kinocat/torrent/entities/CommonTorrentEntity.java b/torrent/src/main/java/com/halushko/kinocat/torrent/entities/CommonTorrentEntity.java index cac50993..115cd663 100644 --- a/torrent/src/main/java/com/halushko/kinocat/torrent/entities/CommonTorrentEntity.java +++ b/torrent/src/main/java/com/halushko/kinocat/torrent/entities/CommonTorrentEntity.java @@ -12,13 +12,14 @@ public class CommonTorrentEntity { public final String id; private final double percentDone; - private final String status; + private final int status; public final String name; private final long totalSize; public CommonTorrentEntity(Map map){ val torrent = new SmartJson(map); - this.status = getStatusIcon(torrent.getValue("status")); + String status = torrent.getValue("status"); + this.status = status.isEmpty() ? -1 : Integer.parseInt(status); this.name = torrent.getValue("name"); String percentDone = torrent.getValue("percentDone"); this.percentDone = percentDone.isEmpty() ? 0.0 : Double.parseDouble(percentDone); @@ -56,8 +57,8 @@ protected String getGigabytesLeft() { : " % (" + Math.round((totalSize - (long) (totalSize * percentDone)) / 1000000.0) / 1000.0 + " Gb left)"; } - protected String getStatusIcon(String status) { - return switch (status != null ? Integer.parseInt(status) : -1) { + protected String getStatusIcon() { + return switch (status) { case 0 -> "⏸"; case 1 -> "\uD83D\uDD51♾"; case 2 -> "♾"; diff --git a/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java b/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java index bb4e1e56..bc86608f 100644 --- a/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java +++ b/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java @@ -26,8 +26,8 @@ public TorrentCommands() { @Override protected void executeRequest(SmartJson message) { long chatId = message.getUserId(); - String requestBodyFormat = ResourceReader.readResourceContent(String.format("transmission_requests/%s", message.getText().split(" ")[0])); String torrentId = message.getValue("ARG"); + String requestBodyFormat = ResourceReader.readResourceContent(String.format("transmission_requests/%s", message.getValue("SCRIPT"))); String requestBody = String.format(requestBodyFormat, torrentId); log.debug("[executeRequest] Request body:\n{}", requestBody);