예제 #1
0
        public static Log SteamCompanionJoinGiveaway(Bot bot, SteamCompanion.ScGiveaway scGiveaway)
        {
            Thread.Sleep(requestInterval);
            var data = Parse.SteamCompanionGetJoinData(scGiveaway, bot);

            if (data != null && data.Success)
            {
                if (scGiveaway.Code != null)
                {
                    var list   = new List <HttpHeader>();
                    var header = new HttpHeader
                    {
                        Name  = "X-Requested-With",
                        Value = "XMLHttpRequest"
                    };
                    list.Add(header);

                    var response = Post("https://steamcompanion.com", "/gifts/steamcompanion.php",
                                        Generate.PostData_SteamCompanion(scGiveaway.Code), list,
                                        Generate.Cookies_SteamCompanion(bot), bot.UserAgent);

                    if (response.RestResponse.Content.Split('"')[3].Split('"')[0] == "Success")
                    {
                        bot.SteamCompanion.Points = int.Parse(response.RestResponse.Content.Split(':')[2].Split(',')[0]);
                        return(Messages.GiveawayJoined("SteamCompanion", scGiveaway.Name, scGiveaway.Price,
                                                       int.Parse(response.RestResponse.Content.Split(':')[2].Split(',')[0]), 0));
                    }

                    return(Messages.GiveawayNotJoined("SteamCompanion", scGiveaway.Name, response.RestResponse.Content));
                }
            }
            return(data);
        }
예제 #2
0
        public static async Task <Log> SteamCompanionJoinGiveawayAsync(Bot bot,
                                                                       SteamCompanion.ScGiveaway scGiveaway)
        {
            var task = new TaskCompletionSource <Log>();
            await Task.Run(() =>
            {
                var result = SteamCompanionJoinGiveaway(bot, scGiveaway);
                task.SetResult(result);
            });

            return(task.Task.Result);
        }