Ejemplo n.º 1
0
        private void AddGiveaways(HtmlNodeCollection nodes)
        {
            if (nodes != null)
            {
                foreach (var node in nodes)
                {
                    if (node.SelectSingleNode(".//a[@class='button grey']") == null)
                    {
                        var level   = node.SelectSingleNode(".//div[@class='min_level tooltip']");
                        var name    = node.SelectSingleNode(".//div[@class='name']/div");
                        var storeId = node.SelectSingleNode("//div[@class='description']/a");
                        var id      = node.SelectSingleNode(".//a[@class='blink button blue']");
                        if (level != null && name != null && storeId != null && id != null)
                        {
                            var pbGiveaway = new PlayBlinkGiveaway
                            {
                                Level   = int.Parse(level.InnerText.Replace("L", "")),
                                Name    = name.InnerText,
                                StoreId = storeId.Attributes["href"].Value.Split('/')[4],
                                Id      = id.Attributes["id"].Value.Replace("blink_", "")
                            };

                            var price =
                                node.SelectSingleNode(".//div[@class='stats']/table/tr[3]/td/div[2]") ??
                                node.SelectSingleNode(".//div[@class='stats']/table/tr[3]");

                            pbGiveaway.Price =
                                int.Parse(price.InnerText.Replace("Point(s)", "").Replace("Entrance Fee:", "").Trim());

                            if (pbGiveaway.Price <= Points && pbGiveaway.Level <= Level)
                            {
                                Giveaways?.Add(pbGiveaway);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private async Task <Log> JoinGiveaway(PlayBlinkGiveaway pbGiveaway)
        {
            var task = new TaskCompletionSource <Log>();
            await Task.Run(() =>
            {
                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 = Web.Post($"{Links.PlayBlinkJoin}&game={pbGiveaway.Id}",
                                            GenerateJoinData(pbGiveaway.Id), list,
                                            Cookies.Generate());

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

                            Points = Points - pbGiveaway.Price;

                            var message = htmldoc.DocumentNode.SelectSingleNode("//div[@class='msgbox success']");
                            if (message != null)
                            {
                                task.SetResult(Messages.GiveawayJoined("PlayBlink", pbGiveaway.Name, pbGiveaway.Price,
                                                                       Points));
                            }
                            else
                            {
                                var error = htmldoc.DocumentNode.SelectSingleNode("//div[@class='msgbox error']");
                                if (error != null)
                                {
                                    task.SetResult(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name,
                                                                              error.InnerText));
                                }
                                else
                                {
                                    var captcha = htmldoc.DocumentNode.SelectSingleNode("//div[@class='flash_rules']");
                                    if (captcha != null)
                                    {
                                        task.SetResult(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name,
                                                                                  "Captcha"));
                                    }
                                }
                            }
                        }
                        else
                        {
                            task.SetResult(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name, "Error"));
                        }
                    }
                    else
                    {
                        task.SetResult(Messages.GiveawayNotJoined("PlayBlink", pbGiveaway.Name, "Error"));
                    }
                }
                else
                {
                    task.SetResult(null);
                }
            });

            return(task.Task.Result);
        }