mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add -u flag to send to username
This commit is contained in:
parent
37c65ca6b4
commit
3602ef9be9
4 changed files with 29 additions and 4 deletions
|
@ -34,6 +34,7 @@ public class RemoteDeleteCommand implements JsonRpcLocalCommand {
|
||||||
.help("Specify the timestamp of the message to delete.");
|
.help("Specify the timestamp of the message to delete.");
|
||||||
subparser.addArgument("-g", "--group-id", "--group").help("Specify the recipient group ID.").nargs("*");
|
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("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());
|
subparser.addArgument("--note-to-self").action(Arguments.storeTrue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +44,14 @@ public class RemoteDeleteCommand implements JsonRpcLocalCommand {
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
||||||
final var recipientStrings = ns.<String>getList("recipient");
|
final var recipientStrings = ns.<String>getList("recipient");
|
||||||
|
final var usernameStrings = ns.<String>getList("username");
|
||||||
final var groupIdStrings = ns.<String>getList("group-id");
|
final var groupIdStrings = ns.<String>getList("group-id");
|
||||||
|
|
||||||
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
|
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
|
||||||
isNoteToSelf,
|
isNoteToSelf,
|
||||||
recipientStrings,
|
recipientStrings,
|
||||||
groupIdStrings);
|
groupIdStrings,
|
||||||
|
usernameStrings);
|
||||||
|
|
||||||
final long targetTimestamp = ns.getLong("target-timestamp");
|
final long targetTimestamp = ns.getLong("target-timestamp");
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||||
subparser.help("Send a message to another user or group.");
|
subparser.help("Send a message to another user or group.");
|
||||||
subparser.addArgument("recipient").help("Specify the recipients' phone number.").nargs("*");
|
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("-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")
|
subparser.addArgument("--note-to-self")
|
||||||
.help("Send the message to self without notification.")
|
.help("Send the message to self without notification.")
|
||||||
.action(Arguments.storeTrue());
|
.action(Arguments.storeTrue());
|
||||||
|
@ -56,6 +57,7 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||||
mut.addArgument("--message-from-stdin")
|
mut.addArgument("--message-from-stdin")
|
||||||
.action(Arguments.storeTrue())
|
.action(Arguments.storeTrue())
|
||||||
.help("Read the message from standard input.");
|
.help("Read the message from standard input.");
|
||||||
|
|
||||||
subparser.addArgument("-a", "--attachment")
|
subparser.addArgument("-a", "--attachment")
|
||||||
.nargs("*")
|
.nargs("*")
|
||||||
.help("Add an attachment. "
|
.help("Add an attachment. "
|
||||||
|
@ -106,11 +108,13 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||||
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
||||||
final var recipientStrings = ns.<String>getList("recipient");
|
final var recipientStrings = ns.<String>getList("recipient");
|
||||||
final var groupIdStrings = ns.<String>getList("group-id");
|
final var groupIdStrings = ns.<String>getList("group-id");
|
||||||
|
final var usernameStrings = ns.<String>getList("username");
|
||||||
|
|
||||||
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
|
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
|
||||||
isNoteToSelf,
|
isNoteToSelf,
|
||||||
recipientStrings,
|
recipientStrings,
|
||||||
groupIdStrings);
|
groupIdStrings,
|
||||||
|
usernameStrings);
|
||||||
|
|
||||||
final var isEndSession = Boolean.TRUE.equals(ns.getBoolean("end-session"));
|
final var isEndSession = Boolean.TRUE.equals(ns.getBoolean("end-session"));
|
||||||
if (isEndSession) {
|
if (isEndSession) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
||||||
subparser.help("Send reaction to a previously received or sent message.");
|
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("-g", "--group-id", "--group").help("Specify the recipient group ID.").nargs("*");
|
||||||
subparser.addArgument("recipient").help("Specify the recipients' phone number.").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")
|
subparser.addArgument("--note-to-self")
|
||||||
.help("Send the reaction to self without notification.")
|
.help("Send the reaction to self without notification.")
|
||||||
.action(Arguments.storeTrue());
|
.action(Arguments.storeTrue());
|
||||||
|
@ -57,11 +58,13 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
||||||
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
||||||
final var recipientStrings = ns.<String>getList("recipient");
|
final var recipientStrings = ns.<String>getList("recipient");
|
||||||
final var groupIdStrings = ns.<String>getList("group-id");
|
final var groupIdStrings = ns.<String>getList("group-id");
|
||||||
|
final var usernameStrings = ns.<String>getList("username");
|
||||||
|
|
||||||
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
|
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
|
||||||
isNoteToSelf,
|
isNoteToSelf,
|
||||||
recipientStrings,
|
recipientStrings,
|
||||||
groupIdStrings);
|
groupIdStrings,
|
||||||
|
usernameStrings);
|
||||||
|
|
||||||
final var emoji = ns.getString("emoji");
|
final var emoji = ns.getString("emoji");
|
||||||
final var isRemove = Boolean.TRUE.equals(ns.getBoolean("remove"));
|
final var isRemove = Boolean.TRUE.equals(ns.getBoolean("remove"));
|
||||||
|
|
|
@ -26,7 +26,8 @@ public class CommandUtil {
|
||||||
final Manager m,
|
final Manager m,
|
||||||
final boolean isNoteToSelf,
|
final boolean isNoteToSelf,
|
||||||
final List<String> recipientStrings,
|
final List<String> recipientStrings,
|
||||||
final List<String> groupIdStrings
|
final List<String> groupIdStrings,
|
||||||
|
final List<String> usernameStrings
|
||||||
) throws UserErrorException {
|
) throws UserErrorException {
|
||||||
final var recipientIdentifiers = new HashSet<RecipientIdentifier>();
|
final var recipientIdentifiers = new HashSet<RecipientIdentifier>();
|
||||||
if (isNoteToSelf) {
|
if (isNoteToSelf) {
|
||||||
|
@ -39,6 +40,9 @@ public class CommandUtil {
|
||||||
if (groupIdStrings != null) {
|
if (groupIdStrings != null) {
|
||||||
recipientIdentifiers.addAll(CommandUtil.getGroupIdentifiers(groupIdStrings));
|
recipientIdentifiers.addAll(CommandUtil.getGroupIdentifiers(groupIdStrings));
|
||||||
}
|
}
|
||||||
|
if (usernameStrings != null) {
|
||||||
|
recipientIdentifiers.addAll(CommandUtil.getUsernameIdentifiers(usernameStrings));
|
||||||
|
}
|
||||||
|
|
||||||
if (recipientIdentifiers.isEmpty()) {
|
if (recipientIdentifiers.isEmpty()) {
|
||||||
throw new UserErrorException("No recipients given");
|
throw new UserErrorException("No recipients given");
|
||||||
|
@ -102,6 +106,17 @@ public class CommandUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
public static String getCaptchaRequiredMessage(final CaptchaRequiredException e, final boolean captchaProvided) {
|
||||||
String message;
|
String message;
|
||||||
if (!captchaProvided) {
|
if (!captchaProvided) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue