Пример #1
0
        private async Task <Log> JoinGiveaway(SteamTradeGiveaway giveaway)
        {
            var task = new TaskCompletionSource <Log>();
            await Task.Run(() =>
            {
                Thread.Sleep(400);
                giveaway = GetJoinData(giveaway);
                if (giveaway.LinkJoin != null)
                {
                    var response = Web.Get($"{Links.SteamTrade}{giveaway.LinkJoin}", Cookies.Generate());
                    if (response.RestResponse.StatusCode == HttpStatusCode.OK)
                    {
                        task.SetResult(Messages.GiveawayJoined("SteamTrade", giveaway.Name.Trim(), 0, 0));
                    }
                    else
                    {
                        task.SetResult(Messages.GiveawayNotJoined("SteamTrade", giveaway.Name,
                                                                  response.RestResponse.StatusCode.ToString()));
                    }
                }
                else
                {
                    task.SetResult(null);
                }
            });

            return(task.Task.Result);
        }
Пример #2
0
 private void AddGiveaways(HtmlNodeCollection nodes)
 {
     if (nodes != null)
     {
         foreach (var node in nodes)
         {
             if (node.SelectSingleNode(".//span[@class='status1']") == null)
             {
                 var name    = node.SelectSingleNode(".//td[1]/a[2]");
                 var link    = node.SelectSingleNode(".//td[1]/a[2]");
                 var storeId = node.SelectSingleNode(".//td[1]/a[1]");
                 if (name != null && link != null && storeId != null)
                 {
                     var spGiveaway = new SteamTradeGiveaway
                     {
                         Name    = node.SelectSingleNode(".//td[1]/a[2]").InnerText,
                         Link    = node.SelectSingleNode(".//td[1]/a[2]").Attributes["href"].Value,
                         StoreId = node.SelectSingleNode(".//td[1]/a[1]").Attributes["href"].Value.Split('/')[4]
                     };
                     Giveaways?.Add(spGiveaway);
                 }
             }
         }
     }
 }
Пример #3
0
        private SteamTradeGiveaway GetJoinData(SteamTradeGiveaway stGiveaway)
        {
            var response = Web.Get($"{Links.SteamTrade}{stGiveaway.Link}", Cookies.Generate());

            if (response.RestResponse.Content != string.Empty)
            {
                var htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(response.RestResponse.Content);

                var linkJoin = htmlDoc.DocumentNode.SelectSingleNode("//a[@class='inv_join']");
                if (linkJoin != null)
                {
                    stGiveaway.LinkJoin = linkJoin.Attributes["href"].Value.Trim();
                }
            }
            return(stGiveaway);
        }