Esempio n. 1
0
        // Function that is run on first host, returns true if successful, false if failed
        private bool firstHost()
        {
            switch (startType)
            {
            case StartType.RANDOM:
                Common.ChatClient.SendMessage("Multihost started. Discovering a random online multihost streamer...", Common.DryRun);
                List <Host> onlineHosts = WebCalls.getOnlineMultihostStreamers(hosts).Result;
                if (onlineHosts.Count != 0)
                {
                    currentHost = onlineHosts[new Random().Next(0, onlineHosts.Count - 1)];
                    if (currentHost.Information != "")
                    {
                        Common.ChatClient.SendMessage(string.Format("We'll kick things off with '{0}'. {1}", currentHost.Streamer, currentHost.Information), Common.DryRun);
                    }
                    else
                    {
                        Common.ChatClient.SendMessage(string.Format("We'll kick things off with '{0}'.", currentHost.Streamer), Common.DryRun);
                    }
                    Common.ChatClient.SendMessage(multihostInfo);
                }
                else
                {
                    Common.ChatClient.SendMessage("No online hosts detected.  Multihost random function failed.", Common.DryRun);
                    return(false);
                }
                break;

            case StartType.SET_HOST:
                foreach (Host streamer in hosts)
                {
                    if (streamer.Streamer.ToLower() == setHostName.ToLower())
                    {
                        currentHost = streamer;
                        if (streamer.Information != "")
                        {
                            Common.ChatClient.SendMessage(string.Format("Multihost started with '{0}'. {1}", streamer.Streamer, streamer.Information), Common.DryRun);
                        }
                        else
                        {
                            Common.ChatClient.SendMessage(string.Format("Multihost started with '{0}'.", streamer.Streamer), Common.DryRun);
                        }
                        currentHost = streamer;
                        hostStreamer(streamer);
                        return(true);
                    }
                }
                Host newHost = new Host(setHostName, "");
                hosts.Add(newHost);
                currentHost = newHost;
                Common.ChatClient.SendMessage(string.Format("Multihost started with '{0}'.", newHost.Streamer), Common.DryRun);
                hostStreamer(newHost);
                Common.ChatClient.SendMessage(multihostInfo);
                break;

            case StartType.MANUAL:
                Common.ChatClient.SendMessage(string.Format("Multihost started, remaining on the current host! Use !extend to extend the host by {0} minutes. Use !remaining to see how many minutes remain in the host!", extendDuration), Common.DryRun);
                break;
            }
            return(true);
        }
Esempio n. 2
0
 // Donation timer tick event
 private void donationTimerTick(object sender, ElapsedEventArgs e)
 {
     if (Common.StreamRefresher.isOnline())
     {
         List <Objects.RecentDonation> recentDonations = WebCalls.downloadRecentDonations().Result;
         //Check to see if query failed
         if (recentDonations == null)
         {
             return;
         }
         if (recentDonations.Count > 0)
         {
             foreach (Objects.RecentDonation donation in recentDonations)
             {
                 Common.ChatClient.SendMessage(string.Format("NEW DONATION! {0} donated ${1} with the message '{2}'. Thanks for supporting the Black Crew!",
                                                             donation.Username, donation.Amount, donation.Message));
             }
             foreach (Objects.RecentDonation donation in Common.RecentDonations)
             {
                 recentDonations.Add(donation);
             }
             Common.RecentDonations = recentDonations;
         }
     }
 }
Esempio n. 3
0
        // Method that runs update process
        public static void processUpdateRequest()
        {
            if (Common.Raffle != null && Common.Raffle.raffleIsActive())
            {
                Console.WriteLine("Update request placed in command queue.");
                return;
            }
            UpdateDetails details = WebCalls.downloadUpdateDetails().Result;

            if (!details.RequestSuccessful || !details.UpdateAvailable)
            {
                Console.WriteLine("RequestSuccessful: " + details.RequestSuccessful + ", UpdateAvailable: " + details.UpdateAvailable);
                return;
            }
            Console.WriteLine("Downloading new bot and updater...");
            WebCalls.downloadFile(details.DownloadLocation, "bot.exe");
            Console.WriteLine("new bot downloaded");
            WebCalls.downloadFile(details.UpdaterLocation, "updater.exe");
            Console.WriteLine("Finished! Starting updater and exiting.");
            System.Diagnostics.ProcessStartInfo pInfo = new System.Diagnostics.ProcessStartInfo();
            pInfo.FileName               = "updater.exe";
            pInfo.ErrorDialog            = true;
            pInfo.UseShellExecute        = false;
            pInfo.RedirectStandardOutput = true;
            pInfo.RedirectStandardError  = true;
            pInfo.WorkingDirectory       = Path.GetDirectoryName("updater.exe");
            System.Diagnostics.Process.Start(pInfo);
            Environment.Exit(1);
        }
Esempio n. 4
0
        //Rotates to next ONLINE host in multihost list
        private bool nextHost()
        {
            if (TwitchLib.TwitchApi.BroadcasterOnline("burkeblack").Result)
            {
                Common.ChatClient.SendMessage("[Multihost] Burke detected as being online.  Multihost stopped.");
                rotator.Stop();
                return(false);
            }
            Host nextHost;

            refreshHostsList();
            List <Host> onlineHosts = WebCalls.getOnlineMultihostStreamers(hosts).Result;

            if (onlineHosts.Count != 0)
            {
                if (currentHost != null && TwitchLib.TwitchApi.BroadcasterOnline(currentHost.Streamer).Result)
                {
                    int multiIndex       = 0;
                    int currentHostIndex = 0;
                    foreach (Host host in onlineHosts)
                    {
                        if (currentHost.Streamer == host.Streamer)
                        {
                            currentHostIndex = multiIndex;
                        }
                        multiIndex++;
                    }
                    if (currentHostIndex == onlineHosts.Count - 1)
                    {
                        nextHost = onlineHosts[0];
                    }
                    else
                    {
                        nextHost = onlineHosts[currentHostIndex + 1];
                    }
                }
                else
                {
                    nextHost = onlineHosts[new Random().Next(0, onlineHosts.Count - 1)];
                }
                if (nextHost.Information != "")
                {
                    Common.ChatClient.SendMessage(string.Format("Next host: {0}. {1}", nextHost.Streamer, nextHost.Information), Common.DryRun);
                }
                else
                {
                    Common.ChatClient.SendMessage(string.Format("Next host: {0}.", nextHost.Streamer), Common.DryRun);
                }
                Common.ChatClient.SendMessage(string.Format("Use !extend to extend the host by {0} minutes. Use !remaining to see how many minutes remain in the host!", extendDuration), Common.DryRun);
                curMinute = 0;
                hostStreamer(nextHost);
                return(true);
            }
            else
            {
                Common.ChatClient.SendMessage("There are no multihost channels online at the moment.  Will try again on next rotation.", Common.DryRun);
                curMinute = 0;
                return(false);
            }
        }
Esempio n. 5
0
 // Public method to add user to notifyMe list
 public void notifyMe(string username)
 {
     WebCalls.addNotifyUser(username);
     usersToNotify.Add(username);
     if (Common.WhisperClient != null)
     {
         Common.WhisperClient.SendWhisper(username, "You will now be notified via a whisper when Burke goes live! burkeEpic To remove yourself from this list, whisper !removeme", Common.DryRun);
     }
 }
Esempio n. 6
0
 // Public method to remove user from notifyMe list
 public void removeMe(string username)
 {
     WebCalls.removeNotifyUser(username);
     usersToNotify.Remove(username);
     if (Common.WhisperClient != null)
     {
         Common.WhisperClient.SendWhisper(username, "You will no longer be notified when Burke goes live. :( To be notified again, whisper !notifyme", Common.DryRun);
     }
 }
Esempio n. 7
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);
 }
Esempio n. 8
0
 // Offline timer tick event
 public void offlineAllocatorTick(object sender, ElapsedEventArgs e)
 {
     if (Common.StreamRefresher.isOnline())
     {
         offlineAllocator.Stop();
         onlineAllocator.Start();
     }
     if (!WebCalls.distibuteDoubloons(1).Result)
     {
         Common.ChatClient.SendMessage("Failed to distributre doubloons.");
     }
 }
Esempio n. 9
0
 // Public function to guess next hosted streamer, returns true if successful, false if failed
 public bool guess()
 {
     if (currentHost == null)
     {
         Common.ChatClient.SendMessage("Cannot guess the host of a manually assigned host, or a host that does not exist in the multihost list.");
         return(false);
     }
     if (TwitchLib.TwitchApi.BroadcasterOnline(currentHost.Streamer).Result)
     {
         refreshHostsList();
         List <Host> onlineHosts = WebCalls.getOnlineMultihostStreamers(hosts).Result;
         int         curIndex    = 0;
         foreach (Host host in onlineHosts)
         {
             if (currentHost.Streamer.ToLower() == host.Streamer.ToLower())
             {
                 if (curIndex == onlineHosts.Count - 1)
                 {
                     if (onlineHosts[0].Information != "")
                     {
                         Common.ChatClient.SendMessage(string.Format("The next host will be {0}. {1}", onlineHosts[0].Streamer, onlineHosts[1].Information), Common.DryRun);
                     }
                     else
                     {
                         Common.ChatClient.SendMessage(string.Format("The next host will be {0}.", onlineHosts[0].Streamer), Common.DryRun);
                     }
                 }
                 else
                 {
                     if (onlineHosts[curIndex + 1].Information != "")
                     {
                         Common.ChatClient.SendMessage(string.Format("The next host will be {0}. {1}", onlineHosts[curIndex + 1].Streamer, onlineHosts[curIndex + 1].Information), Common.DryRun);
                     }
                     else
                     {
                         Common.ChatClient.SendMessage(string.Format("The next host will be {0}.", onlineHosts[curIndex + 1].Streamer), Common.DryRun);
                     }
                 }
                 return(true);
             }
             curIndex++;
         }
         Common.ChatClient.SendMessage("Current online host was not found in multihost list.  Next host will be random online multihost streamer.", Common.DryRun);
         return(false);
     }
     else
     {
         Common.ChatClient.SendMessage("The current host is not online.  The next host will be a random online multihost streamer.", Common.DryRun);
         return(false);
     }
 }
Esempio n. 10
0
 // Method called if updater.exe exists, and announces changes if instructed to do so
 public static void afterUpdate()
 {
     if (File.Exists("updater.exe"))
     {
         File.Delete("updater.exe");
         Common.UpdateDatas = new Common.UpdateData(WebCalls.downloadUpdateDetails().Result);
         Common.notify("Update successful!", "Changes: " + Common.UpdateDatas.Details.Changes);
         Console.WriteLine("Waiting for connected state...");
         while (!Events.connected)
         {
         }
         Console.WriteLine("Connected to chat confirmed!");
         if (Common.UpdateDatas.Details.Announce)
         {
             Common.ChatClient.SendMessage(string.Format("Updated! Changes: {0}", Common.UpdateDatas.Details.Changes), Common.DryRun);
         }
     }
 }
Esempio n. 11
0
 // Handles subscription event
 public static void handleSubscription(TwitchLib.TwitchChatClient.OnSubscriberArgs e)
 {
     Common.RecentSub = e.Subscriber;
     if (e.Subscriber.Months > 0)
     {
         WebCalls.addSoundbyteCredits(e.Subscriber.Name, resubSoundbytes);
         WebCalls.addDoubloons(e.Subscriber.Name, resubDoubloons);
         Common.ChatClient.SendMessage(string.Format("Welcome back returning crewmember {0}, of {1} months!!! burkeAhoy burkeFlag burkeAhoy burkeFlag",
                                                     e.Subscriber.Name, e.Subscriber.Months), Common.DryRun);
         Common.ChatClient.SendMessage(string.Format("Enjoy your resub booty of {0} doubloons and {1} sound byte credits, {2}!",
                                                     resubDoubloons, resubSoundbytes, e.Subscriber.Name), Common.DryRun);
     }
     else
     {
         WebCalls.addSoundbyteCredits(e.Subscriber.Name, newSubSoundbytes);
         WebCalls.addDoubloons(e.Subscriber.Name, newSubDoubloons);
         Common.ChatClient.SendMessage(string.Format("Welcome aboard matey! Please welcome the latest crewmember to the BurkeBlack crew, {0}! burkeAhoy burkeFlag burkeAhoy burkeFlag", e.Subscriber.Name), Common.DryRun);
         Common.ChatClient.SendMessage(string.Format("Enjoy your subscription booty of 100 doubloons and 5 sound byte credits, {0}!", e.Subscriber.Name), Common.DryRun);
     }
 }
 // messageCountUploader timer tick event
 private void messageCountUploaderTick(object sender, ElapsedEventArgs e)
 {
     if (userMessages.Count > 0)
     {
         string uploadStr = "";
         foreach (UserMessages userMessage in userMessages)
         {
             if (uploadStr == "")
             {
                 uploadStr = string.Format("{0},{1}", userMessage.Username, userMessage.Messages);
             }
             else
             {
                 uploadStr = string.Format("{0}|{1},{2}", uploadStr, userMessage.Username, userMessage.Messages);
             }
         }
         WebCalls.uploadChatMessageCounts(uploadStr);
         userMessages.Clear();
     }
 }
Esempio n. 13
0
 // Process message from event
 public void processMessage(TwitchLib.TwitchChatClient.OnMessageReceivedArgs e)
 {
     if (connectedMsgReceived)
     {
         if (e.ChatMessage.Message.ToLower().Contains("ahoy"))
         {
             if (!isFraud(e.ChatMessage.Username))
             {
                 if (first == null)
                 {
                     first = new ahoyReward(e.ChatMessage.Username, firstReward);
                     WebCalls.addDoubloons(first.Username, first.Reward);
                     Common.ChatClient.SendMessage(string.Format("/me rewarded {0} some doubloons ({1}) for the first Ahoy message! [auto] ", first.Username, first.Reward));
                     Common.relay(String.Format("[ahoy] First ahoy reward ({0} doubloons) awarded to: {1}", first.Reward, first.Username));
                 }
                 else if (second == null)
                 {
                     second = new ahoyReward(e.ChatMessage.Username, secondReward);
                     WebCalls.addDoubloons(second.Username, second.Reward);
                     Common.ChatClient.SendMessage(string.Format("/me rewarded {0} some doubloons ({1}) for the second Ahoy message! [auto] ", second.Username, second.Reward));
                     Common.relay(String.Format("[ahoy] Second ahoy reward ({0} doubloons) awarded to: {1}", second.Reward, second.Username));
                 }
                 else
                 {
                     third = new ahoyReward(e.ChatMessage.Username, thirdReward);
                     WebCalls.addDoubloons(third.Username, third.Reward);
                     Common.ChatClient.SendMessage(string.Format("/me rewarded {0} some doubloons ({1}) for the third Ahoy message! [auto] ", third.Username, third.Reward));
                     connectedMsgReceived = false;
                     Common.relay(String.Format("[ahoy] Third ahoy reward ({0} doubloons) awarded to: {1}", third.Reward, third.Username));
                 }
             }
         }
     }
     else
     {
         if (e.ChatMessage.Username.ToLower() == "burke_listener" && e.ChatMessage.Message.ToLower().Contains("connected!") && !e.ChatMessage.Message.ToLower().Contains("disconnect"))
         {
             connectedMsgReceived = true;
         }
     }
 }
Esempio n. 14
0
        // Multihost constructor using JSON data from API
        public Multihost(JToken multihostProperties)
        {
            switch (multihostProperties.SelectToken("start_type").ToString())
            {
            case "manual":
                startType = StartType.MANUAL;
                break;

            case "set_host":
                startType   = StartType.SET_HOST;
                setHostName = multihostProperties.SelectToken("set_host_name").ToString();
                break;

            case "random":
                startType = StartType.RANDOM;
                break;

            default:
                Common.ChatClient.SendMessage(string.Format("Host start type '{0}' is not valid. Defaulting to random.", multihostProperties.SelectToken("start_type").ToString()), Common.DryRun);
                return;
            }
            hosts            = WebCalls.downloadMultihostStreamers().Result;
            rotator.Elapsed += rotatorTick;
        }
Esempio n. 15
0
 // Function to replace various message place holders with data retrieved internally or externally
 private string messageReplacements(string message)
 {
     if (message.Contains("[recent_twitch]"))
     {
         TwitchLib.TwitchAPIClasses.TwitchVideo recentVideo = TwitchLib.TwitchApi.GetChannelVideos("burkeblack", 1).Result[0];
         if (recentVideo == null)
         {
             return(message.Replace("[recent_twitch]", "Not Available - query failed"));
         }
         TimeSpan ts       = new TimeSpan(0, 0, recentVideo.Length);
         string   duration = string.Format("{0}:{1}", ts.Minutes, ts.Seconds);
         message = message.Replace("[recent_twitch]", string.Format("{0} [Views: {1}] [Duration: {2}] - {3}", recentVideo.Title, recentVideo.Views, duration, recentVideo.Url));
     }
     if (message.Contains("[recent_youtube]"))
     {
         Objects.YoutubeVideo recentVideo = WebCalls.getBurkesLatestYTVideo().Result;
         if (recentVideo == null)
         {
             return(message.Replace("[recent_youtube]", "Not Available - query failed"));
         }
         message = message.Replace("[recent_youtube]", string.Format("{0} [Views: {1}] - http://youtu.be/{2}", recentVideo.Title, recentVideo.Views, recentVideo.VideoID));
     }
     return(message);
 }
Esempio n. 16
0
        private void postRaid()
        {
            if (postRaidFired)
            {
                return;
            }
            else
            {
                postRaidFired = true;
            }
            if (participants.Count != 0)
            {
                Common.RaidClient.Disconnect();
                if (boarders.Count == 0 || gunners.Count == 0)
                {
                    Common.ChatClient.SendMessage(string.Format("The raid has ended! There were {0} ( R) ) boarders and {1} ( burkeShip burkeFire burkeFire ) gunners!! In total, there were {2} participants in this raid, with boarder {3} and gunner {4} leading the charge! Your doubloon counts will be updated shortly!", boarders.Count, gunners.Count, participants.Count, boarders[0], gunners[0]), Common.DryRun);
                }
                else
                {
                    Common.ChatClient.SendMessage(string.Format("The raid has ended! There were {0} ( R) ) boarders and {1} ( burkeShip burkeFire burkeFire ) gunners!! In total, there were {2} participants in this raid! Your doubloon counts will be updated shortly!", boarders.Count, gunners.Count, participants.Count), Common.DryRun);
                }

                if (WebCalls.distibuteDoubloons(participants.Count).Result)
                {
                    Common.ChatClient.SendMessage("[Auto] Doubloon counts updated successfully!");
                }
                else
                {
                    Common.ChatClient.SendMessage("[Auto] Doubloon counts FAILED TO UPDATE");
                }
            }
            else
            {
                Common.ChatClient.SendMessage("No one participated in the raid! :(", Common.DryRun);
            }
        }
Esempio n. 17
0
 //Downloads users that meet doubloons criteria
 private async Task <List <string> > downloadDoubloonEntries(int doubloons, List <string> entries)
 {
     return(await WebCalls.downloadDoubloonEntries(doubloons, entries));
 }
Esempio n. 18
0
 // Public method to refresh multihosts list
 public void refreshHostsList()
 {
     hosts = WebCalls.downloadMultihostStreamers().Result;
 }
Esempio n. 19
0
 //Downloads previous blocked viewers (for whatever reason)
 private async Task <List <string> > downloadBlockedViewers(string donator)
 {
     return(await WebCalls.downloadBlockedViewers(donator));
 }
Esempio n. 20
0
            // RaffleProperties constructor accepts JSON data from API
            public RaffleProperties(JToken giveawayProperties)
            {
                raffleLength = int.Parse(giveawayProperties.SelectToken("raffle_length").ToString());
                if (raffleLength < 3)
                {
                    raffleLength = 3;
                }
                raffleClaimLength = int.Parse(giveawayProperties.SelectToken("raffle_claim_length").ToString());
                if (raffleClaimLength < 1)
                {
                    raffleClaimLength = 1;
                }
                raffleMinimumEntries = int.Parse(giveawayProperties.SelectToken("raffle_min_entries").ToString());
                raffleFilterAmount   = int.Parse(giveawayProperties.SelectToken("raffle_filter_amount").ToString());
                raffleSteamID        = int.Parse(giveawayProperties.SelectToken("raffle_steam_id").ToString());
                raffleSoundbyteCount = int.Parse(giveawayProperties.SelectToken("raffle_soundbyte_count").ToString());
                raffleDonator        = giveawayProperties.SelectToken("raffle_donator").ToString();
                raffleAuthor         = giveawayProperties.SelectToken("raffle_author").ToString();
                raffleName           = giveawayProperties.SelectToken("raffle_name").ToString();
                raffleLinker         = giveawayProperties.SelectToken("raffle_linker").ToString();
                if (giveawayProperties.SelectToken("raffle_sub_only").ToString() == "true")
                {
                    subOnly = true;
                }
                if (giveawayProperties.SelectToken("raffle_follower_only").ToString() == "true")
                {
                    followerOnly = true;
                }
                previousWinners = WebCalls.downloadPreviousWinners().Result;
                blockedViewers  = downloadBlockedViewers(raffleDonator).Result;
                if (giveawayProperties.SelectToken("kappa_entry") != null)
                {
                    if (giveawayProperties.SelectToken("kappa_entry").ToString() == "true")
                    {
                        kappaEntry = true;
                    }
                }

                switch (giveawayProperties.SelectToken("raffle_type").ToString())
                {
                case "exgames":
                    raffleType   = Common.GiveawayTypes.EXGAMES;
                    exGamesCount = WebCalls.downloadExGamesCount().Result;
                    break;

                case "steam_trade":
                    raffleType = Common.GiveawayTypes.STEAMTRADE;
                    break;

                case "steam_gift":
                    raffleType = Common.GiveawayTypes.STEAMGIFT;
                    break;

                case "steam_code":
                    raffleType = Common.GiveawayTypes.STEAMCODE;
                    break;

                case "origin_code":
                    raffleType = Common.GiveawayTypes.ORIGINCODE;
                    break;

                case "humblebundle":
                    raffleType = Common.GiveawayTypes.HUMBLEBUNDLE;
                    break;

                case "code":
                    raffleType = Common.GiveawayTypes.SERIALCODE;
                    break;

                case "logitech":
                    raffleType = Common.GiveawayTypes.LOGITECH;
                    break;

                case "soundbyte":
                    raffleType = Common.GiveawayTypes.SOUND_BYTES;
                    break;

                case "other":
                    raffleType      = Common.GiveawayTypes.OTHER;
                    raffleTypeOther = giveawayProperties.SelectToken("raffle_type_other").ToString();
                    break;

                default:
                    Common.ChatClient.SendMessage(string.Format("ERROR: Raffle type '' is not valid and KrakenBot2 cannot proceed [Fatal] [Restarting]", giveawayProperties.SelectToken("raffle_type").ToString()));
                    System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\KrakenBot2.exe");
                    Environment.Exit(0);
                    break;
                }
                switch (giveawayProperties.SelectToken("raffle_filter").ToString())
                {
                case "doubloons":
                    raffleFilter = Filters.DOUBLOONS;
                    break;

                case "minutes":
                    raffleFilter = Filters.MINUTES;
                    break;

                case "none":
                    raffleFilter = Filters.NONE;
                    break;
                }
            }
Esempio n. 21
0
 //Downloads the ID of a given raffle so as to return a URL with the giveaway results
 private async Task <int> downloadRaffleID()
 {
     return(await WebCalls.downloadRaffleID());
 }
Esempio n. 22
0
 //Downloads users that meet minutes watched criteria
 private async Task <List <string> > downloadMinuteEntries(int minutes, List <string> entries)
 {
     return(await WebCalls.downloadMinuteEntries(minutes, entries));
 }
Esempio n. 23
0
 //Downloads number of !games available
 private async Task <int> downloadExGamesCount()
 {
     return(await WebCalls.downloadExGamesCount());
 }
Esempio n. 24
0
        // Async drawing function, accepts param bool indicating a redraw, returns bool indicating success
        private async Task <bool> processDrawAsync(bool redraw = false)
        {
            //Validate drawing process
            if (redraw == true)
            {
                enteredViewers.Remove(activeWinner);
            }
            if (enteredViewers.Count < raffleProperties.Raffle_Minimum_Entries)
            {
                claimTimer.Stop();
                Common.ChatClient.SendMessage(string.Format("/me GIVEAWAY ERROR: Entry count below minimum ({0}) required for giveaway to proceed. [FATAL]", raffleProperties.Raffle_Minimum_Entries), Common.DryRun);
                return(false);
            }
            //Check filters
            List <string> filteredEntries = null;
            List <string> masterList      = enteredViewers;

            switch (raffleProperties.Raffle_Filter)
            {
            case RaffleProperties.Filters.DOUBLOONS:
                filteredEntries = await WebCalls.downloadDoubloonEntries(raffleProperties.Raffle_Filter_Amount, enteredViewers);

                masterList = filteredEntries;
                break;

            case RaffleProperties.Filters.MINUTES:
                filteredEntries = await WebCalls.downloadMinuteEntries(raffleProperties.Raffle_Filter_Amount, enteredViewers);

                masterList = filteredEntries;
                break;

            case RaffleProperties.Filters.NONE:
                break;
            }
            //Validate filters
            if (raffleProperties.Raffle_Filter != RaffleProperties.Filters.NONE && (filteredEntries == null || filteredEntries.Count < raffleProperties.Raffle_Minimum_Entries))
            {
                Common.ChatClient.SendMessage("/me GIVEAWAY ERROR: Filtered raffle entry results failed or falls below minimum required entries.  Resorting to original entry list [NON-FATAL]", Common.DryRun);
                masterList = enteredViewers;
            }
            //Draw winner and perform follower/sub only checks
            bool   resultFound = false;
            string winner      = "";
            //Create local list of non-blocked users
            List <string> drawFromList = new List <string>();

            foreach (string entry in masterList)
            {
                if (!raffleProperties.Blocked_Viewers.Contains(entry))
                {
                    drawFromList.Add(entry);
                }
            }
            while (resultFound == false)
            {
                if (drawFromList.Count < raffleProperties.Raffle_Minimum_Entries)
                {
                    resultFound = true;
                    Common.ChatClient.SendMessage("/me GIVEAWAY ERROR: Entry count has fallen below required minimum entry count. [FATAL]", Common.DryRun);
                    return(false);
                }

                winner = drawFromList[new Random().Next(0, drawFromList.Count)];
                if (raffleProperties.Follower_Only)
                {
                    if (!await TwitchLib.TwitchApi.UserFollowsChannel(winner, "burkeblack"))
                    {
                        drawFromList.Remove(winner);
                        Common.ChatClient.SendMessage(string.Format("Winner ({0}) does not follow BurkeBlack! Redrawing..."), Common.DryRun);
                        continue;
                    }
                }
                if (raffleProperties.Sub_Only)
                {
                    if (!TwitchLib.TwitchApi.ChannelHasUserSubscribed(winner, "burkeblack", Properties.Settings.Default.BurkeOAuth).Result)
                    {
                        drawFromList.Remove(winner);
                        Common.ChatClient.SendMessage(string.Format("Winner ({0}) is not subscribed BurkeBlack! Redrawing..."), Common.DryRun);
                        continue;
                    }
                }
                resultFound = true;
            }
            if (!redraw)
            {
                Common.ChatClient.SendMessage(string.Format("/me GIVEAWAY WINNER: {0} (out of {1} total entries, draw percentage: {2}%)", winner, masterList.Count, (Math.Round(((double)1 / masterList.Count), 2) * 100)), Common.DryRun);
            }
            else
            {
                Common.ChatClient.SendMessage(string.Format("/me GIVEAWAY REDRAW WINNER: {0} (out of {1} total entries, draw percentage: {2}%)", winner, masterList.Count, (Math.Round(((double)1 / masterList.Count), 2) * 100)), Common.DryRun);
            }
            Common.ChatClient.SendMessage(string.Format("/me You have {0} minutes to claim your giveaway, {1}. Use !claim to claim. Use !pass to pass on the giveaway and have the bot draw a new winner.", raffleProperties.Raffle_Claim_Length, winner), Common.DryRun);
            claimCurrentSecond = 0;
            activeWinner       = winner;
            claimTimer.Start();
            Common.initialize("Claim timer started.");
            return(true);
        }
Esempio n. 25
0
 // Notify swifty via push notificaiton
 public static void notify(string title, string descriptor)
 {
     WebCalls.notifySwifty(title, descriptor);
 }