private static IEnumerator ProcessTask(AnticaptchaTask task, Action <string> callback) { AnticaptchaResult response; do { response = AnticaptchaApiWrapper.GetTaskResult(Host, ClientKey, task); if (response == null || response.GetStatus().Equals(AnticaptchaResult.Status.ready)) { break; } if (response.GetStatus().Equals(AnticaptchaResult.Status.processing)) { yield return(new WaitForSeconds(1f)); } } while (response.GetStatus().Equals(AnticaptchaResult.Status.processing)); if (response?.GetSolution() == null) { Interface.Oxide.RootLogger.Write(LogType.Info, "Unfortunately we got the following error from the API: " + (response != null ? response.GetErrorDescription() : "/empty/")); } else { Interface.Oxide.NextTick(() => callback(response.GetSolution())); } }
static IEnumerator GetCaptcha(string url, Action <string> callback) { WWW www = new WWW(url); yield return(www); try { string base64String = Convert.ToBase64String(www.bytes); var task = AnticaptchaApiWrapper.CreateImageToTextTask( Host, ClientKey, base64String ); if (task == null) { Interface.Oxide.RootLogger.Write(LogType.Info, "Somehow task is NULL..."); } else { if (task.GetErrorDescription() != null && task.GetErrorDescription().Length > 0) { Interface.Oxide.RootLogger.Write(LogType.Info, "Unfortunately we got the following error from the API: " + task.GetErrorDescription()); } CommunityEntity.ServerInstance.StartCoroutine(ProcessTask(task, callback)); } } catch (Exception e) { Interface.Oxide.RootLogger.Write(LogType.Info, "NoCaptcha task (proxyless) failed with following error: " + e.Message + "\n" + e.StackTrace); } }