예제 #1
0
        public static Log SteamPortalJoinGiveaway(Bot bot, SteamPortal.SpGiveaway spGiveaway)
        {
            Thread.Sleep(requestInterval);
            if (spGiveaway.Code != null)
            {
                var list   = new List <HttpHeader>();
                var header = new HttpHeader
                {
                    Name  = "X-Requested-With",
                    Value = "XMLHttpRequest"
                };
                list.Add(header);

                var response = Post("http://steamportal.net/", "page/join",
                                    Generate.PostData_SteamPortal(spGiveaway.Code), list,
                                    Generate.Cookies_SteamPortal(bot), bot.UserAgent);
                var jresponse =
                    JsonConvert.DeserializeObject <SteamPortal.JsonJoin>(response.RestResponse.Content.Replace(".", ""));
                if (jresponse.Error == 0)
                {
                    bot.SteamPortal.Points = jresponse.target_h.my_coins;
                    return(Messages.GiveawayJoined("SteamPortal", spGiveaway.Name, spGiveaway.Price,
                                                   jresponse.target_h.my_coins, 0));
                }
                return(Messages.GiveawayNotJoined("SteamPortal", spGiveaway.Name, "Error"));
            }
            return(null);
        }
예제 #2
0
        public static async Task <Log> SteamPortalJoinGiveawayAsync(Bot bot,
                                                                    SteamPortal.SpGiveaway spGiveaway)
        {
            var task = new TaskCompletionSource <Log>();
            await Task.Run(() =>
            {
                var result = SteamPortalJoinGiveaway(bot, spGiveaway);
                task.SetResult(result);
            });

            return(task.Task.Result);
        }