.help("Specify the timestamp of the message to delete.");
subparser.addArgument("-g", "--group-id", "--group").help("Specify the recipient group ID.").nargs("*");
subparser.addArgument("recipient").help("Specify the recipients' phone number.").nargs("*");
+ subparser.addArgument("-u", "--username").help("Specify the recipient username or username link.").nargs("*");
subparser.addArgument("--note-to-self").action(Arguments.storeTrue());
}
) throws CommandException {
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
+ final var usernameStrings = ns.<String>getList("username");
final var groupIdStrings = ns.<String>getList("group-id");
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
isNoteToSelf,
recipientStrings,
- groupIdStrings);
+ groupIdStrings,
+ usernameStrings);
final long targetTimestamp = ns.getLong("target-timestamp");
subparser.help("Send a message to another user or group.");
subparser.addArgument("recipient").help("Specify the recipients' phone number.").nargs("*");
subparser.addArgument("-g", "--group-id", "--group").help("Specify the recipient group ID.").nargs("*");
+ subparser.addArgument("-u", "--username").help("Specify the recipient username or username link.").nargs("*");
subparser.addArgument("--note-to-self")
.help("Send the message to self without notification.")
.action(Arguments.storeTrue());
mut.addArgument("--message-from-stdin")
.action(Arguments.storeTrue())
.help("Read the message from standard input.");
+
subparser.addArgument("-a", "--attachment")
.nargs("*")
.help("Add an attachment. "
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");
+ final var usernameStrings = ns.<String>getList("username");
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
isNoteToSelf,
recipientStrings,
- groupIdStrings);
+ groupIdStrings,
+ usernameStrings);
final var isEndSession = Boolean.TRUE.equals(ns.getBoolean("end-session"));
if (isEndSession) {
subparser.help("Send reaction to a previously received or sent message.");
subparser.addArgument("-g", "--group-id", "--group").help("Specify the recipient group ID.").nargs("*");
subparser.addArgument("recipient").help("Specify the recipients' phone number.").nargs("*");
+ subparser.addArgument("-u", "--username").help("Specify the recipient username or username link.").nargs("*");
subparser.addArgument("--note-to-self")
.help("Send the reaction to self without notification.")
.action(Arguments.storeTrue());
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");
+ final var usernameStrings = ns.<String>getList("username");
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
isNoteToSelf,
recipientStrings,
- groupIdStrings);
+ groupIdStrings,
+ usernameStrings);
final var emoji = ns.getString("emoji");
final var isRemove = Boolean.TRUE.equals(ns.getBoolean("remove"));
final Manager m,
final boolean isNoteToSelf,
final List<String> recipientStrings,
- final List<String> groupIdStrings
+ final List<String> groupIdStrings,
+ final List<String> usernameStrings
) throws UserErrorException {
final var recipientIdentifiers = new HashSet<RecipientIdentifier>();
if (isNoteToSelf) {
if (groupIdStrings != null) {
recipientIdentifiers.addAll(CommandUtil.getGroupIdentifiers(groupIdStrings));
}
+ if (usernameStrings != null) {
+ recipientIdentifiers.addAll(CommandUtil.getUsernameIdentifiers(usernameStrings));
+ }
if (recipientIdentifiers.isEmpty()) {
throw new UserErrorException("No recipients given");
}
}
+ public static Set<RecipientIdentifier.Username> getUsernameIdentifiers(Collection<String> usernameIdStrings) {
+ if (usernameIdStrings == null) {
+ return Set.of();
+ }
+ final var usernameIds = new HashSet<RecipientIdentifier.Username>();
+ for (final var usernameIdString : usernameIdStrings) {
+ usernameIds.add(new RecipientIdentifier.Username(usernameIdString));
+ }
+ return usernameIds;
+ }
+
public static String getCaptchaRequiredMessage(final CaptchaRequiredException e, final boolean captchaProvided) {
String message;
if (!captchaProvided) {