Beispiel #1
0
        public async Task CaptchaAsync()
        {
            DirectoryInfo dir = new DirectoryInfo(CaptchaPath);

            FileInfo[] Files = dir.GetFiles("*.png");

            int index = Rand.Next(Files.Length);

            var message = await Context.Channel.SendFileAsync(Files[index].FullName, "Reply with text in Image.");

            var captchaState = new CaptchaState(message, Path.GetFileNameWithoutExtension(Files[index].Name));

            CaptchaService.AddCaptcha(captchaState);
        }
Beispiel #2
0
 private string GetResponse(string id)
 {
     while (true)
     {
         CaptchaState state = Check(id);
         if (state == CaptchaState.Success)
         {
             return(captcha);
         }
         else if (state == CaptchaState.NotReady)
         {
             Thread.Sleep(interval);
         }
         else if (state == CaptchaState.NoFreeWorker)
         {
             throw new NoFreeWorkerException();
         }
         else
         {
             throw new CaptchaErrorException();
         }
     }
 }
Beispiel #3
0
 public void AddCaptcha(CaptchaState cs)
 {
     Captchas.Add(cs.gameMessage.Id, cs);
 }