public static Log SteamGiftsJoinGiveaway(Bot bot, SteamGifts.SgGiveaway sgGiveaway) { Thread.Sleep(requestInterval); sgGiveaway = Parse.SteamGiftsGetJoinData(sgGiveaway, bot); if (sgGiveaway.Token != null) { var response = Post("https://www.steamgifts.com/", "/ajax.php", Generate.PostData_SteamGifts(sgGiveaway.Token, sgGiveaway.Code, "entry_insert"), new List <HttpHeader>(), Generate.Cookies_SteamGifts(bot), bot.UserAgent); if (response.RestResponse.Content != null) { var jsonresponse = JsonConvert.DeserializeObject <SteamGifts.JsonResponseJoin>(response.RestResponse.Content); if (jsonresponse.Type == "success") { bot.SteamGifts.Points = jsonresponse.Points; return(Messages.GiveawayJoined("SteamGifts", sgGiveaway.Name, sgGiveaway.Price, jsonresponse.Points, sgGiveaway.Level)); } var jresponse = JsonConvert.DeserializeObject <GameMiner.JsonResponseError>(response.RestResponse.Content); return(Messages.GiveawayNotJoined("SteamGifts", sgGiveaway.Name, jresponse.Error?.Message)); } } return(null); }
public static async Task <Log> SteamGiftsJoinGiveawayAsync(Bot bot, SteamGifts.SgGiveaway sgGiveaway) { var task = new TaskCompletionSource <Log>(); await Task.Run(() => { var result = SteamGiftsJoinGiveaway(bot, sgGiveaway); task.SetResult(result); }); return(task.Task.Result); }