示例#1
0
 public static BotUser GetUserInfo(Vk.VkLongPoolClient.Update update)
 {
     if (update.type == "message_new")
     {
         bool find = false;
         foreach (BotUser user in BotUsers)
         {
             if (user.vkid == [email protected]_id)
             {
                 find = true;
                 return(user);
             }
         }
         if (find == false)
         {
             BotUser newuser = new BotUser();
             newuser.vkid = [email protected]_id;
             newuser.last = DateTime.Now;
             BotUser.BotSecurity newsecurity = new BotUser.BotSecurity();
             newsecurity.current = 1;
             newsecurity.maximum = 3;
             newuser.security    = newsecurity;
             BotUser.Captcha captcha = new BotUser.Captcha();
             captcha.GenerateMath();
             newuser.captcha     = captcha;
             newuser.resettime   = 1000 * 60;
             newuser.needcaptcha = false;
             BotUsers.Add(newuser);
             return(newuser);
         }
     }
     return(null);
 }
示例#2
0
 public static void MSG(Vk.VkLongPoolClient.Update update)
 {
     if ([email protected]_id == 244428396)
     {
         BotUser botuser = GetUserInfo(update);
         if (botuser != null)
         {
             Console.WriteLine(botuser.needcaptcha);
             if ([email protected] == "1" && botuser.needcaptcha == false)
             {
                 vkclient.Messages.Send.Text([email protected]_id, "Сообщение обработано сервером");
                 UpdateUserInfo(update);
                 Console.WriteLine(botuser.needcaptcha);
             }
             else if ([email protected] == "2")
             {
                 vkclient.Messages.Send.Text([email protected]_id, "Сообщение обработано сервером");
             }
             else if (botuser.needcaptcha == true)
             {
                 CalcCaptcha(update);
                 Console.WriteLine(botuser.needcaptcha);
                 if (botuser.needcaptcha == false)
                 {
                     vkclient.Messages.Send.Text([email protected]_id, "Капча пройдена");
                 }
                 else
                 {
                     botuser.captcha.GenerateType();
                     Console.WriteLine(botuser.captcha.type);
                     if (botuser.captcha.type == "math")
                     {
                         botuser.captcha.GenerateMath();
                         vkclient.Messages.Send.Text([email protected]_id, "Решите капчу: " + botuser.captcha.math.Replace("+", "%2B"));
                     }
                     else if (botuser.captcha.type == "image")
                     {
                         if (File.Exists("" + botuser.vkid + ".png"))
                         {
                             File.Delete("" + botuser.vkid + ".png");
                         }
                         botuser.captcha.GenerateImage(50, 25);
                         botuser.captcha.image.Save("" + botuser.vkid + ".jpg");
                         vkclient.Messages.Send.TextAndDocument([email protected]_id, "Решите капчу: " + botuser.captcha.math.Replace("+", "%2B"), "" + botuser.vkid + ".jpg", "Captcha");
                     }
                 }
             }
         }
     }
 }
示例#3
0
        public static void UpdateUserInfo(Vk.VkLongPoolClient.Update update)
        {
            BotUser botuser = GetUserInfo(update);

            if (botuser != null)
            {
                Console.WriteLine(botuser.last);
                if (botuser.security.current >= botuser.security.maximum)
                {
                    [email protected] = [email protected]("[club190175842|@megacraftbot] ", "");
                    [email protected] = [email protected]("[club190175842|MegaCraft Manager] ", "");
                    [email protected] = [email protected]("[club190175842|SkillShop Technology] ", "");
                    if ([email protected] != botuser.captcha.otvet.ToString())
                    {
                        if (DateTime.Now >= botuser.last.AddMilliseconds(botuser.resettime))
                        {
                            botuser.security.current = 1;
                            botuser.last             = DateTime.Now;
                            botuser.needcaptcha      = false;
                        }
                        else
                        {
                            botuser.needcaptcha = true;
                        }
                    }
                    else
                    {
                        botuser.needcaptcha      = false;
                        botuser.security.current = 1;
                        botuser.last             = DateTime.Now;
                    }
                }
                else
                {
                    botuser.last = DateTime.Now;
                    botuser.security.current++;
                }
            }
            else
            {
                botuser.last = DateTime.Now;
                botuser.security.current++;
            }
        }