mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Remove fallback to reading stdin if no message body is given
To read a message from stdin, use the `--message-from-stdin` flag
This commit is contained in:
parent
1ea4309a2a
commit
4120630309
3 changed files with 5 additions and 4 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue