mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
parent
4485188789
commit
c3e1d4fc75
3 changed files with 15 additions and 5 deletions
|
@ -54,6 +54,12 @@ Use the verify command to complete the verification.
|
||||||
*-v*, *--voice*::
|
*-v*, *--voice*::
|
||||||
The verification should be done over voice, not SMS.
|
The verification should be done over voice, not SMS.
|
||||||
|
|
||||||
|
*--captcha*::
|
||||||
|
The captcha token, required if registration failed with a captcha required error.
|
||||||
|
To get the token, go to https://signalcaptchas.org/registration/generate.html
|
||||||
|
Check the developer tools for a redirect starting with signalcaptcha://
|
||||||
|
Everything after signalcaptcha:// is the captcha token.
|
||||||
|
|
||||||
=== verify
|
=== verify
|
||||||
|
|
||||||
Verify the number using the code received via SMS or voice.
|
Verify the number using the code received via SMS or voice.
|
||||||
|
|
|
@ -16,15 +16,19 @@ public class RegisterCommand implements LocalCommand {
|
||||||
subparser.addArgument("-v", "--voice")
|
subparser.addArgument("-v", "--voice")
|
||||||
.help("The verification should be done over voice, not sms.")
|
.help("The verification should be done over voice, not sms.")
|
||||||
.action(Arguments.storeTrue());
|
.action(Arguments.storeTrue());
|
||||||
|
subparser.addArgument("--captcha")
|
||||||
|
.help("The captcha token, required if registration failed with a captcha required error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int handleCommand(final Namespace ns, final Manager m) {
|
public int handleCommand(final Namespace ns, final Manager m) {
|
||||||
try {
|
try {
|
||||||
m.register(ns.getBoolean("voice"));
|
final boolean voiceVerification = ns.getBoolean("voice");
|
||||||
|
final String captcha = ns.getString("captcha");
|
||||||
|
m.register(voiceVerification, captcha);
|
||||||
return 0;
|
return 0;
|
||||||
} catch (CaptchaRequiredException e) {
|
} catch (CaptchaRequiredException e) {
|
||||||
System.err.println("Captcha required for verification (" + e.getMessage() + ")");
|
System.err.println("Captcha invalid or required for verification (" + e.getMessage() + ")");
|
||||||
return 1;
|
return 1;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Request verify error: " + e.getMessage());
|
System.err.println("Request verify error: " + e.getMessage());
|
||||||
|
|
|
@ -298,7 +298,7 @@ public class Manager implements Closeable {
|
||||||
return account.isRegistered();
|
return account.isRegistered();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(boolean voiceVerification) throws IOException {
|
public void register(boolean voiceVerification, String captcha) throws IOException {
|
||||||
account.setPassword(KeyUtils.createPassword());
|
account.setPassword(KeyUtils.createPassword());
|
||||||
|
|
||||||
// Resetting UUID, because registering doesn't work otherwise
|
// Resetting UUID, because registering doesn't work otherwise
|
||||||
|
@ -306,9 +306,9 @@ public class Manager implements Closeable {
|
||||||
accountManager = createSignalServiceAccountManager();
|
accountManager = createSignalServiceAccountManager();
|
||||||
|
|
||||||
if (voiceVerification) {
|
if (voiceVerification) {
|
||||||
accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.absent(), Optional.absent());
|
accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.fromNullable(captcha), Optional.absent());
|
||||||
} else {
|
} else {
|
||||||
accountManager.requestSmsVerificationCode(false, Optional.absent(), Optional.absent());
|
accountManager.requestSmsVerificationCode(false, Optional.fromNullable(captcha), Optional.absent());
|
||||||
}
|
}
|
||||||
|
|
||||||
account.setRegistered(false);
|
account.setRegistered(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue