]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/SendCommand.java
Remove fallback to reading stdin if no message body is given
[signal-cli] / src / main / java / org / asamk / signal / commands / SendCommand.java
index 23a7fb37667eb42b760a08eebc9f2b265f9330d3..57c0c5e9c66c6e6e1045bf118e6c430b863c6f8a 100644 (file)
@@ -120,13 +120,15 @@ public class SendCommand implements JsonRpcLocalCommand {
 
         var messageText = ns.getString("message");
         final var readMessageFromStdin = ns.getBoolean("message-from-stdin") == Boolean.TRUE;
-        if (readMessageFromStdin || (messageText == null && sticker == null)) {
+        if (readMessageFromStdin) {
             logger.debug("Reading message from stdin...");
             try {
                 messageText = IOUtils.readAll(System.in, IOUtils.getConsoleCharset());
             } catch (IOException e) {
                 throw new UserErrorException("Failed to read message from stdin: " + e.getMessage());
             }
+        } else if (messageText == null) {
+            messageText = "";
         }
 
         List<String> attachments = ns.getList("attachment");
@@ -169,7 +171,7 @@ public class SendCommand implements JsonRpcLocalCommand {
         }
 
         try {
-            var results = m.sendMessage(new Message(messageText == null ? "" : messageText,
+            var results = m.sendMessage(new Message(messageText,
                     attachments,
                     mentions,
                     Optional.ofNullable(quote),