Beispiel #1
0
        /// <summary>
        /// Timer Task that will check users that are currently in the channel to see if they
        /// are follower.
        /// </summary>
        /// <param name="theCache">Helper object</param>
        private void CheckFollowerTask(object theCache)
        {
            ChannelBackBone.FollowerCache followerCache = (ChannelBackBone.FollowerCache)theCache;
            string tempString = $"?to_id={followerCache.channel_id}";

            foreach (User user in channelArray[followerCache.channel].chatUsers.Values)
            {
                if (user.followed_at == null && user.userId != 0)
                {
                    string url = $"{tempString}&from_id={user.userId}";
                    twitchHelix.ApiQueue.Enqueue(new TwitchHelix.HelixHelper(url, followerCache.channel, ApiCallType.DoesFollowerCall));
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Timer Task that will initiate a follower tracker logic using Twitch Helix API. This will
 /// check for new users.
 /// </summary>
 /// <param name="followCache">Will hold recent followers to compare against</param>
 private async void FollowerTask(object followCache)
 {
     ChannelBackBone.FollowerCache followerCache = (ChannelBackBone.FollowerCache)followCache;
     string getFollow = $"users/follows?to_id={followerCache.channel_id}&first={followerCache.checkSize}";
     await twitchHelix.helixCall(getFollow, followerCache.channel, ApiCallType.FollowerCall);
 }
Beispiel #3
0
        /// <summary>
        /// Join logic for a specific Twitch channel. This will handled UI differentiation
        /// for channels you want to join with bot and channels you want to moderate on.
        /// </summary>
        /// <param name="channel">Referenced channel</param>
        private void joinHandler(string channel)
        {
            irc.joinRoom(channel);
            channelArray.Add(channel, new ChannelBackBone(channel));

            TabPage     newTab      = new TabPage();
            RichTextBox textDisplay = new RichTextBox();
            ListView    userView    = new ListView();

            textDisplay.TextChanged += (s, e) =>
            {
                textDisplay.SelectionStart = textDisplay.Text.Length;
                textDisplay.ScrollToCaret();
            };
            textDisplay.Name           = channel;
            textDisplay.Location       = new Point(3, 3);
            textDisplay.Size           = new Size(570, 450);
            textDisplay.BackColor      = Color.Black;
            textDisplay.ForeColor      = Color.White;
            textDisplay.LanguageOption = RichTextBoxLanguageOptions.UIFonts;

            userView.Name     = channel + listViewSuffix;
            userView.Location = new Point(575, 3);
            userView.UseCompatibleStateImageBehavior = false;
            userView.Columns.Add("Chatters", -2, HorizontalAlignment.Left);
            userView.View        = View.Details;
            userView.MouseClick += (s, e) =>
            {
                clearListItemColor(userView);
            };
            userView.Sorting = System.Windows.Forms.SortOrder.Ascending;

            int successValue;

            if (botChannels.TryGetValue(channel, out successValue))
            {
                userView.Size = new Size(155, 300);
                //grabbed from https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/threading/thread-timers

                ChannelBackBone.FollowerCache followerCache = new ChannelBackBone.FollowerCache {
                    checkSize = 50, channel = channel, channel_id = successValue
                };
                channelArray[channel].followsCache = followerCache;

                TimerCallback          timerCallback = new TimerCallback(FollowerTask);
                System.Threading.Timer followerTimer =
                    new System.Threading.Timer(timerCallback, followerCache, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(1));
                timers.Add(followerTimer);


                ChannelBackBone.FollowerCache follower2Cache = new ChannelBackBone.FollowerCache {
                    channel = channel, channel_id = successValue
                };

                TimerCallback          timer2Callback = new TimerCallback(CheckFollowerTask);
                System.Threading.Timer follower2Timer =
                    new System.Threading.Timer(timer2Callback, follower2Cache, TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(2));
                timers.Add(follower2Timer);

                TimerCallback          timer3Callback = new TimerCallback(channelArray[channel].prepareLoad);
                System.Threading.Timer dbTimer        =
                    new System.Threading.Timer(timer3Callback, null, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(3));
                timers.Add(dbTimer);

                TimerCallback          timer4Callback = new TimerCallback(channelArray[channel].pointAdder);
                System.Threading.Timer pointTimer     =
                    new System.Threading.Timer(timer4Callback, null, TimeSpan.FromSeconds(30), TimeSpan.FromMinutes(1));
                timers.Add(pointTimer);

                irc.onDBActionArgs += onDBAction;
                channelArray[channel].onDBActionArgs += onDBAction;

                ListView notificationView = new ListView();
                notificationView.Name     = channel;
                notificationView.Size     = new Size(155, 145);
                notificationView.Location = new Point(575, 305);
                notificationView.UseCompatibleStateImageBehavior = false;
                notificationView.Columns.Add("Notifications", -2, HorizontalAlignment.Left);
                notificationView.View              = View.Details;
                notificationView.MouseDoubleClick += (s, e) =>
                {
                    notificationView.Clear();
                };

                channelArray[channel].notificationLV = notificationView;

                newTab.Controls.Add(notificationView);

                ListViewGroup viewerGroup = new ListViewGroup("Followers", HorizontalAlignment.Left);
                viewerGroup.Name = "Followers";
                notificationView.Groups.Add(viewerGroup);
            }
            else
            {
                userView.Size = new Size(155, 450);
            }

            newTab.Controls.Add(textDisplay);
            newTab.Controls.Add(userView);
            newTab.Text = "#" + channel;

            chatTabControl.TabPages.Add(newTab);

            channelArray[channel].chatLV = userView;
            channelsJoined.Add(textDisplay.Name, textDisplay);
        }