import org.asamk.signal.OutputType;
import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.OutputType;
import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.api.CaptchaRequiredException;
+import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
+import org.asamk.signal.manager.api.RateLimitException;
+import org.asamk.signal.output.JsonWriter;
+import org.asamk.signal.util.DateUtils;
) throws UserErrorException, IOErrorException {
try {
m.register(voiceVerification, captcha);
) throws UserErrorException, IOErrorException {
try {
m.register(voiceVerification, captcha);
+ } catch (RateLimitException e) {
+ String message = "Rate limit reached";
+ if (e.getNextAttemptTimestamp() > 0) {
+ message += "\nNext attempt may be tried at " + DateUtils.formatTimestamp(e.getNextAttemptTimestamp());
+ }
+ throw new UserErrorException(message);
- Captcha required for verification, use --captcha CAPTCHA
- To get the token, go to https://signalcaptchas.org/registration/generate.html
- Check the developer tools (F12) console for a failed redirect to signalcaptcha://
- Everything after signalcaptcha:// is the captcha token.""";
+ Captcha required for verification, use --captcha CAPTCHA
+ To get the token, go to https://signalcaptchas.org/registration/generate.html
+ Check the developer tools (F12) console for a failed redirect to signalcaptcha://
+ Everything after signalcaptcha:// is the captcha token.""";
- throw new IOErrorException("Request verify error: " + e.getMessage(), e);
+ throw new IOErrorException("Failed to register: %s (%s)".formatted(e.getMessage(),
+ e.getClass().getSimpleName()), e);