示例#1
0
 //Performs attempt to claim
 public bool tryClaim(string username)
 {
     if (raffleIsActive())
     {
         if (activeWinner.ToLower() == username.ToLower())
         {
             claimTimer.Stop();
             string entries = "";
             foreach (string entry in enteredViewers)
             {
                 if (entries == "")
                 {
                     entries = entry;
                 }
                 else
                 {
                     entries = entries + "|" + entry;
                 }
             }
             Objects.RaffleWin raffleWin = WebCalls.addRaffleWinner(activeWinner, raffleProperties.Raffle_Name, raffleProperties.Raffle_Donator,
                                                                    entries, raffleProperties.Raffle_Linker, claimCurrentSecond).Result;
             Common.ChatClient.SendMessage(string.Format("GIVEAWAY CLAIMED BY: {0}! You've won {1} raffles, and entered {2} (that's a win percentage of {3}%). Your claim time was {4} seconds," +
                                                         " however your average claim time is {5} seconds.", raffleWin.Winner, raffleWin.WinCount, raffleWin.EnterCount, raffleWin.WinPercentage, raffleWin.ClaimTime, raffleWin.ClaimTimeAvg), Common.DryRun);
             sendWinnerWhisper();
             if (raffleProperties.Raffle_Type == Common.GiveawayTypes.SOUND_BYTES)
             {
                 WebCalls.addSoundbyteCredits(raffleWin.Winner, raffleProperties.Soundbyte_Count);
                 Common.ChatClient.SendMessage(string.Format("[Auto] Added {0} soundbyte credits to {1}'s total.", raffleProperties.Soundbyte_Count, raffleWin.Winner), Common.DryRun);
             }
             int latestID = WebCalls.downloadRaffleID().Result;
             if (raffleProperties.Raffle_Type == Common.GiveawayTypes.EXGAMES)
             {
                 Common.ChatClient.SendMessage(string.Format("Giveaway details can be viewed here: http://burkeblack.tv/giveaways/listing.php?gid={0} .  Video on how automatic !games giveaways work: https://www.twitch.tv/burkeblack/v/30553157", latestID.ToString()));
             }
             else
             {
                 Common.ChatClient.SendMessage(string.Format("Giveaway details can be viewed here: http://burkeblack.tv/giveaways/listing.php?gid={0}", latestID.ToString()), Common.DryRun);
             }
             Common.notify("NEW GIVEAWAY CLAIM", raffleWin.Winner + " claimed " + raffleProperties.Raffle_Name);
             Common.relay(string.Format("NEW CLAIM: Winner: {0}, Name: {1}, Donator: {2}, Author: {3}", raffleWin.Winner, raffleProperties.Raffle_Name, raffleProperties.Raffle_Donator, raffleProperties.Raffle_Author));
             Common.CommandQueue.checkQueueOnce();
             return(true);
         }
         else
         {
             System.Threading.Thread.Sleep(400);
             Common.ChatClient.SendMessage(string.Format("*WARNING* [{0}] Timed out for {1} hours. [Invalid Claim])", username, invalidClaimTimeoutHours.ToString()), Common.DryRun);
             if (Common.WhisperClient != null)
             {
                 Common.WhisperClient.SendWhisper(username, string.Format("You have been timedout for {0} hours.  Do NOT try to claim a giveaway that you did not win.", invalidClaimTimeoutHours.ToString()), Common.DryRun);
             }
             Common.ChatClient.SendMessage(string.Format(".timeout {0} {1}", username, TimeoutConverter.Hours(invalidClaimTimeoutHours)), Common.DryRun);
         }
     }
     return(false);
 }