コード例 #1
0
ファイル: Web.cs プロジェクト: hyperspeed2016/KryBot
        public static async Task <Log> PlayBlinkJoinGiveawayAsync(Bot bot, PlayBlink.PbGiveaway pbGiveaway)
        {
            var task = new TaskCompletionSource <Log>();
            await Task.Run(() =>
            {
                var result = PlayBlinkJoinGiveaway(bot, pbGiveaway);
                task.SetResult(result);
            });

            return(task.Task.Result);
        }
コード例 #2
0
ファイル: Web.cs プロジェクト: hyperspeed2016/KryBot
        public static Log PlayBlinkJoinGiveaway(Bot bot, PlayBlink.PbGiveaway pbGiveaway)
        {
            Thread.Sleep(1000);
            if (pbGiveaway.Id != null)
            {
                var list   = new List <HttpHeader>();
                var header = new HttpHeader
                {
                    Name  = "X-Requested-With",
                    Value = "XMLHttpRequest"
                };
                list.Add(header);

                var response = Post("http://playblink.com/", $"?do=blink&game={pbGiveaway.Id}&captcha=1",
                                    Generate.PostData_PlayBlink(pbGiveaway.Id), list,
                                    Generate.Cookies_PlayBlink(bot), bot.UserAgent);

                if (response.RestResponse.StatusCode == HttpStatusCode.OK)
                {
                    if (response.RestResponse.Content != "")
                    {
                        var htmldoc = new HtmlDocument();
                        htmldoc.LoadHtml(response.RestResponse.Content);

                        bot.PlayBlink.Points = bot.PlayBlink.Points - pbGiveaway.Price;

                        var message = htmldoc.DocumentNode.SelectSingleNode("//div[@class='msgbox success']");
                        if (message != null)
                        {
                            return(Messages.GiveawayJoined("PlayBlink", pbGiveaway.Name, pbGiveaway.Price,
                                                           bot.PlayBlink.Points, 0));
                        }

                        var error = htmldoc.DocumentNode.SelectSingleNode("//div[@class='msgbox error']");
                        if (error != null)
                        {
                            return(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name, error.InnerText));
                        }

                        var captcha = htmldoc.DocumentNode.SelectSingleNode("//div[@class='flash_rules']");
                        if (captcha != null)
                        {
                            return(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name, "Captcha"));
                        }
                    }
                    return(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name, "Error"));
                }
                return(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name, "Error"));
            }
            return(null);
        }