Beispiel #1
0
        public static Log GameMinerJoinGiveaway(Bot bot, GameMiner.GmGiveaway gmGiveaway)
        {
            Thread.Sleep(requestInterval);
            var response = Post("http://gameminer.net/",
                                "/giveaway/enter/" + gmGiveaway.Id + "?" + (gmGiveaway.IsSandbox ? "sandbox" : "coal") + "_page=" +
                                gmGiveaway.Page, Generate.PostData_GameMiner(bot.GameMiner.Cookies.Xsrf), new List <HttpHeader>(),
                                Generate.Cookies_GameMiner(bot), bot.UserAgent);

            if (response.RestResponse.Content != "")
            {
                try
                {
                    var jsonresponse =
                        JsonConvert.DeserializeObject <GameMiner.JsonResponse>(response.RestResponse.Content);
                    if (jsonresponse.Status == "ok")
                    {
                        bot.GameMiner.Coal = jsonresponse.Coal;
                        return(Messages.GiveawayJoined("GameMiner", gmGiveaway.Name, gmGiveaway.Price, jsonresponse.Coal,
                                                       0));
                    }
                    var jresponse =
                        JsonConvert.DeserializeObject <GameMiner.JsonResponseError>(response.RestResponse.Content);
                    return(Messages.GiveawayNotJoined("GameMiner", gmGiveaway.Name, jresponse.Error.Message));
                }
                catch (JsonReaderException)
                {
                    return(Messages.GiveawayNotJoined("GameMiner", gmGiveaway.Name, response.RestResponse.Content));
                }
            }
            return(Messages.GiveawayNotJoined("GameMiner", gmGiveaway.Name, "Content is empty"));
        }
Beispiel #2
0
        public static async Task <Log> GameMinerJoinGiveawayAsync(Bot bot, GameMiner.GmGiveaway gmGiveaway)
        {
            var task = new TaskCompletionSource <Log>();
            await Task.Run(() =>
            {
                var result = GameMinerJoinGiveaway(bot, gmGiveaway);
                task.SetResult(result);
            });

            return(task.Task.Result);
        }