mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +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.");
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -43,12 +44,14 @@ public class RemoteDeleteCommand implements JsonRpcLocalCommand {
|
|||
) 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");
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ public class SendCommand implements JsonRpcLocalCommand {
|
|||
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());
|
||||
|
@ -56,6 +57,7 @@ public class SendCommand implements JsonRpcLocalCommand {
|
|||
mut.addArgument("--message-from-stdin")
|
||||
.action(Arguments.storeTrue())
|
||||
.help("Read the message from standard input.");
|
||||
|
||||
subparser.addArgument("-a", "--attachment")
|
||||
.nargs("*")
|
||||
.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 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) {
|
||||
|
|
|
@ -31,6 +31,7 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
|||
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());
|
||||
|
@ -57,11 +58,13 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
|||
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"));
|
||||
|
|
|
@ -26,7 +26,8 @@ public class CommandUtil {
|
|||
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) {
|
||||
|
@ -39,6 +40,9 @@ public class CommandUtil {
|
|||
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");
|
||||
|
@ -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) {
|
||||
String message;
|
||||
if (!captchaProvided) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue