private static string Request(string type, string key, [NotNull] IReadOnlyDictionary <string, string> additData) { string url = $@"http://rucaptcha.com/{type}.php?key={key}&soft_id=2362&json=1"; string apiRequest = string.Empty; foreach (KeyValuePair <string, string> param in additData) { url = url + "&" + param.Key + "=" + param.Value; } for (int i = 0; i < _attepmts; i++) { if (GetResponse(ExtRequest.Get(url), out apiRequest)) { return(apiRequest); } ErrorState errorState = GetErrorInfo(apiRequest, out int timeout, out string errorText); if (errorState.HasFlag(ErrorState.Unknown)) { throw new UnknownCaptchaSolverErrorException(errorText); } if (errorState.HasFlag(ErrorState.Critical)) { throw new CaptchaSolverErrorException(apiRequest, errorText); } if (errorState.HasFlag(ErrorState.LowBet)) { throw new CaptchaSolverErrorException(apiRequest, errorText); // TODO Доработать логику с подстройкой цены } if (errorState.HasFlag(ErrorState.CaptchaNotReady)) { if (additData.TryGetValue("method", out string v) && v == "userrecaptcha") { timeout = 15000; // TODO Переделать на получение из конфига + добавить сохранение в него } else { timeout = 5000; } } if (timeout != 0) { Thread.Sleep(timeout); } } throw new Exception("Попытки истекли.\n" + apiRequest); }