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:
AsamK 2022-06-21 13:55:01 +02:00
parent 1ea4309a2a
commit 4120630309
3 changed files with 5 additions and 4 deletions

View 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),