]> nmode's Git Repositories - signal-cli/commitdiff
Add more information for CaptchaRequiredException
authorAsamK <asamk@gmx.de>
Sat, 13 Feb 2021 17:40:27 +0000 (18:40 +0100)
committerAsamK <asamk@gmx.de>
Sat, 13 Feb 2021 17:40:27 +0000 (18:40 +0100)
src/main/java/org/asamk/signal/commands/RegisterCommand.java

index da652f7d58bac5b11e08564a1871714c17b05f54..f7736018048c51f01c8849a575674479d2ae3b4b 100644 (file)
@@ -22,13 +22,21 @@ public class RegisterCommand implements RegistrationCommand {
 
     @Override
     public int handleCommand(final Namespace ns, final RegistrationManager m) {
 
     @Override
     public int handleCommand(final Namespace ns, final RegistrationManager m) {
+        final boolean voiceVerification = ns.getBoolean("voice");
+        final String captcha = ns.getString("captcha");
+
         try {
         try {
-            final boolean voiceVerification = ns.getBoolean("voice");
-            final String captcha = ns.getString("captcha");
             m.register(voiceVerification, captcha);
             return 0;
         } catch (CaptchaRequiredException e) {
             m.register(voiceVerification, captcha);
             return 0;
         } catch (CaptchaRequiredException e) {
-            System.err.println("Captcha invalid or required for verification (" + e.getMessage() + ")");
+            if (captcha == null) {
+                System.err.println("Captcha required for verification, use --captcha CAPTCHA");
+                System.err.println("To get the token, go to https://signalcaptchas.org/registration/generate.html");
+                System.err.println("Check the developer tools (F12) console for a failed redirect to signalcaptcha://");
+                System.err.println("Everything after signalcaptcha:// is the captcha token.");
+            } else {
+                System.err.println("Invalid captcha given.");
+            }
             return 1;
         } catch (IOException e) {
             System.err.println("Request verify error: " + e.getMessage());
             return 1;
         } catch (IOException e) {
             System.err.println("Request verify error: " + e.getMessage());