Beispiel #1
0
        private async void InteractiveJoystickSetupTestDialogControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            for (int i = 5; i > 0; i--)
            {
                this.StatusTextBlock.Text = "Testing joystick in:" + Environment.NewLine + Environment.NewLine + i.ToString();
                await Task.Delay(1000);
            }

            this.StatusTextBlock.Text = "Testing Joystick:" + Environment.NewLine + Environment.NewLine + "Up";
            await this.command.Perform(ChannelSession.GetCurrentUser(), new List <string>() { "0.0", "-1.0" });

            await Task.Delay(2500);

            this.StatusTextBlock.Text = "Testing Joystick:" + Environment.NewLine + Environment.NewLine + "Down";
            await this.command.Perform(ChannelSession.GetCurrentUser(), new List <string>() { "0.0", "1.0" });

            await Task.Delay(2500);

            this.StatusTextBlock.Text = "Testing Joystick:" + Environment.NewLine + Environment.NewLine + "Left";
            await this.command.Perform(ChannelSession.GetCurrentUser(), new List <string>() { "-1.0", "0.0" });

            await Task.Delay(2500);

            this.StatusTextBlock.Text = "Testing Joystick:" + Environment.NewLine + Environment.NewLine + "Right";
            await this.command.Perform(ChannelSession.GetCurrentUser(), new List <string>() { "1.0", "0.0" });

            await Task.Delay(2500);

            this.StatusTextBlock.Text = "Testing Complete";
            await this.command.Perform(ChannelSession.GetCurrentUser(), new List <string>() { "0.0", "0.0" });
        }
Beispiel #2
0
        public async Task PerformEvent(EventTrigger trigger)
        {
            if (this.CanPerformEvent(trigger))
            {
                UserViewModel user = trigger.User;
                if (user == null)
                {
                    user = ChannelSession.GetCurrentUser();
                }

                if (this.userEventTracking.ContainsKey(trigger.Type))
                {
                    lock (this.userEventTracking)
                    {
                        this.userEventTracking[trigger.Type].Add(user.ID);
                    }
                }

                EventCommandModel command = this.GetEventCommand(trigger.Type);
                if (command != null)
                {
                    Logger.Log(LogLevel.Debug, $"Performing event trigger: {trigger.Type}");

                    await command.Perform(new CommandParametersModel(user, platform : trigger.Platform, arguments : trigger.Arguments, specialIdentifiers : trigger.SpecialIdentifiers) { TargetUser = trigger.TargetUser });
                }
            }
        }
Beispiel #3
0
        public override async Task Initialize()
        {
            if (this.CurrentBossUserID > 0)
            {
                UserModel user = await ChannelSession.Connection.GetUser(this.CurrentBossUserID);

                if (user != null)
                {
                    this.CurrentBoss = new UserViewModel(user);
                }
                else
                {
                    this.CurrentBossUserID = 0;
                }
            }

            if (this.CurrentBossUserID == 0)
            {
                this.CurrentBoss = await ChannelSession.GetCurrentUser();

                this.CurrentHealth = this.StartingHealth;
            }
            this.CurrentBossUserID = this.CurrentBoss.ID;

            GlobalEvents.OnFollowOccurred      -= GlobalEvents_OnFollowOccurred;
            GlobalEvents.OnHostOccurred        -= GlobalEvents_OnHostOccurred;
            GlobalEvents.OnSubscribeOccurred   -= GlobalEvents_OnSubscribeOccurred;
            GlobalEvents.OnResubscribeOccurred -= GlobalEvents_OnResubscribeOccurred;
            GlobalEvents.OnDonationOccurred    -= GlobalEvents_OnDonationOccurred;
            GlobalEvents.OnSparkUseOccurred    -= GlobalEvents_OnSparkUseOccurred;
            GlobalEvents.OnEmberUseOccurred    -= GlobalEvents_OnEmberUseOccurred;

            if (this.FollowBonus > 0.0)
            {
                GlobalEvents.OnFollowOccurred += GlobalEvents_OnFollowOccurred;
            }
            if (this.HostBonus > 0.0)
            {
                GlobalEvents.OnHostOccurred += GlobalEvents_OnHostOccurred;
            }
            if (this.SubscriberBonus > 0.0)
            {
                GlobalEvents.OnSubscribeOccurred   += GlobalEvents_OnSubscribeOccurred;
                GlobalEvents.OnResubscribeOccurred += GlobalEvents_OnResubscribeOccurred;
            }
            if (this.DonationBonus > 0.0)
            {
                GlobalEvents.OnDonationOccurred += GlobalEvents_OnDonationOccurred;
            }
            if (this.SparkBonus > 0.0)
            {
                GlobalEvents.OnSparkUseOccurred += GlobalEvents_OnSparkUseOccurred;
            }
            if (this.EmberBonus > 0.0)
            {
                GlobalEvents.OnEmberUseOccurred += GlobalEvents_OnEmberUseOccurred;
            }

            await base.Initialize();
        }
        private async void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            this.PlayButton.Visibility = Visibility.Collapsed;
            this.StopButton.Visibility = Visibility.Visible;

            this.EditButton.IsEnabled   = false;
            this.DeleteButton.IsEnabled = false;
            this.EnableDisableToggleSwitch.IsEnabled = false;

            CommandBase command = this.GetCommandFromCommandButtons <CommandBase>(this);

            if (command != null)
            {
                await command.PerformAndWait(ChannelSession.GetCurrentUser(), new List <string>() { "@" + ChannelSession.GetCurrentUser().UserName });

                if (command is PermissionsCommandBase)
                {
                    PermissionsCommandBase permissionCommand = (PermissionsCommandBase)command;
                    permissionCommand.ResetCooldown(ChannelSession.GetCurrentUser());
                }
                this.SwitchToPlay();
            }

            this.RaiseEvent(new RoutedEventArgs(CommandButtonsControl.PlayClickedEvent, this));
        }
        private async void SendChatMessageButton_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(this.ChatMessageTextBox.Text))
            {
                string message = this.ChatMessageTextBox.Text;

                if (message.Contains(SpecialIdentifierStringBuilder.SpecialIdentifierHeader))
                {
                    SpecialIdentifierStringBuilder spReplacement = new SpecialIdentifierStringBuilder(message, Guid.NewGuid());
                    await spReplacement.ReplaceCommonSpecialModifiers(await ChannelSession.GetCurrentUser());

                    message = spReplacement.ToString();
                }

                if (messageHistory.Contains(message))
                {
                    // Remove so we can move to the end
                    messageHistory.Remove(message);
                }

                messageHistory.Add(message);
                activeMessageHistory = messageHistory.Count;

                this.ChatMessageTextBox.Text = string.Empty;

                if (ChatAction.WhisperRegex.IsMatch(message))
                {
                    Match whisperRegexMatch = ChatAction.WhisperRegex.Match(message);

                    message = message.Substring(whisperRegexMatch.Value.Length);

                    Match  usernNameMatch = ChatAction.UserNameTagRegex.Match(whisperRegexMatch.Value);
                    string username       = usernNameMatch.Value;
                    username = username.Trim();
                    username = username.Replace("@", "");

                    await this.Window.RunAsyncOperation(async() =>
                    {
                        ChatMessageEventModel response = await ChannelSession.Chat.WhisperWithResponse(username, message, ShouldSendAsStreamer());
                        if (response != null)
                        {
                            await this.AddMessage(ChatMessageViewModel.CreateChatMessageViewModel(response));
                        }
                    });
                }
                else if (ChatAction.ClearRegex.IsMatch(message))
                {
                    await ChannelSession.Chat.ClearMessages();
                }
                else
                {
                    await this.Window.RunAsyncOperation((Func <Task>)(async() =>
                    {
                        await ChannelSession.Chat.SendMessage(message, ShouldSendAsStreamer());
                    }));
                }

                this.ChatMessageTextBox.Focus();
            }
        }
Beispiel #6
0
        public async Task PerformEvent(EventTypeEnum type, CommandParametersModel parameters)
        {
            if (this.CanPerformEvent(type, parameters))
            {
                UserViewModel user = parameters.User;
                if (user == null)
                {
                    user = ChannelSession.GetCurrentUser();
                }

                if (this.userEventTracking.ContainsKey(type))
                {
                    lock (this.userEventTracking)
                    {
                        this.userEventTracking[type].Add(user.ID);
                    }
                }

                await ChannelSession.Services.User.AddOrUpdateActiveUser(user);

                user.UpdateLastActivity();

                EventCommandModel command = this.GetEventCommand(type);
                if (command != null)
                {
                    Logger.Log(LogLevel.Debug, $"Performing event trigger: {type}");

                    await ChannelSession.Services.Command.Queue(command, parameters);
                }
            }
        }
 public virtual async Task TestPerform(Dictionary <string, string> specialIdentifiers)
 {
     await this.Perform(new CommandParametersModel(ChannelSession.GetCurrentUser(), StreamingPlatformTypeEnum.All, new List <string>()
     {
         "@" + ChannelSession.GetCurrentUser().Username
     }, specialIdentifiers) { TargetUser = ChannelSession.GetCurrentUser() });
 }
        public override Task LoadTestData()
        {
            UserViewModel user    = ChannelSession.GetCurrentUser();
            List <Guid>   userIDs = new List <Guid>(ChannelSession.Settings.UserData.Keys.Take(20));

            for (int i = userIDs.Count; i < 20; i++)
            {
                userIDs.Add(user.ID);
            }

            foreach (Guid userID in userIDs)
            {
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Chatters))
                {
                    this.viewers.Add(userID);
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Subscribers))
                {
                    this.subs.Add(userID);
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Moderators))
                {
                    this.mods.Add(userID);
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Followers))
                {
                    this.follows.Add(userID);
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Hosts))
                {
                    this.hosts.Add(userID);
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Raids))
                {
                    this.raids[userID] = 10;
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.NewSubscribers))
                {
                    this.newSubs.Add(userID);
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Resubscribers))
                {
                    this.resubs[userID] = 5;
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.GiftedSubs))
                {
                    this.giftedSubs[userID] = 5;
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Donations))
                {
                    this.donations[userID] = 12.34;
                }
                if (this.SectionTemplates.ContainsKey(OverlayEndCreditsSectionTypeEnum.Bits))
                {
                    this.bits[userID] = 123;
                }
            }
            return(Task.FromResult(0));
        }
 public override async Task LoadTestData()
 {
     for (int i = 0; i < 5; i++)
     {
         this.testGameQueueList.Add(await ChannelSession.GetCurrentUser());
         this.gameQueueUpdated = true;
         await Task.Delay(1500);
     }
 }
Beispiel #10
0
        public bool CanPerformEvent(EventTypeEnum type, CommandParametersModel parameters)
        {
            UserViewModel user = (parameters.User != null) ? parameters.User : ChannelSession.GetCurrentUser();

            if (EventService.singleUseTracking.Contains(type) && this.userEventTracking.ContainsKey(type))
            {
                return(!this.userEventTracking[type].Contains(user.ID));
            }
            return(true);
        }
 public static CommandParametersModel GetTestParameters(Dictionary <string, string> specialIdentifiers)
 {
     return(new CommandParametersModel(ChannelSession.GetCurrentUser(), StreamingPlatformTypeEnum.All, new List <string>()
     {
         "@" + ChannelSession.GetCurrentUser().Username
     }, specialIdentifiers)
     {
         TargetUser = ChannelSession.GetCurrentUser()
     });
 }
Beispiel #12
0
        public bool CanPerformEvent(EventTrigger trigger)
        {
            UserViewModel user = (trigger.User != null) ? trigger.User : ChannelSession.GetCurrentUser();

            if (!EventService.singleUseTracking.Contains(trigger.Type))
            {
                return(true);
            }
            return(!this.userEventTracking[trigger.Type].Contains(user.ID));
        }
Beispiel #13
0
        public async Task AddOrUpdateActiveUser(UserViewModel user)
        {
            if (!user.IsAnonymous)
            {
                bool newUser = !this.activeUsers.ContainsKey(user.ID);

                this.activeUsers[user.ID] = user;

                if (!string.IsNullOrEmpty(user.TwitchID))
                {
                    this.platformUserIDLookups[StreamingPlatformTypeEnum.Twitch][user.TwitchID] = user.ID;
                }
                if (!string.IsNullOrEmpty(user.TwitchUsername))
                {
                    this.platformUsernameLookups[StreamingPlatformTypeEnum.Twitch][user.TwitchUsername] = user.ID;
                }

                if (UserService.SpecialUserAccounts.Contains(user.Username.ToLower()))
                {
                    user.IgnoreForQueries = true;
                }
                else if (ChannelSession.GetCurrentUser().ID.Equals(user.ID))
                {
                    user.IgnoreForQueries = true;
                }
                else if (ChannelSession.TwitchBotNewAPI != null && ChannelSession.TwitchBotNewAPI.id.Equals(user.TwitchID))
                {
                    user.IgnoreForQueries = true;
                }
                else if (user.Data.IsCurrencyRankExempt)
                {
                    user.IgnoreForQueries = true;
                }
                else
                {
                    user.IgnoreForQueries = false;

                    if (newUser)
                    {
                        if (user.Data.ViewingMinutes == 0)
                        {
                            await ChannelSession.Services.Events.PerformEvent(EventTypeEnum.ChatUserFirstJoin, new CommandParametersModel(user));
                        }

                        CommandParametersModel parameters = new CommandParametersModel(user);
                        if (ChannelSession.Services.Events.CanPerformEvent(EventTypeEnum.ChatUserJoined, parameters))
                        {
                            user.LastSeen = DateTimeOffset.Now;
                            user.Data.TotalStreamsWatched++;
                            await ChannelSession.Services.Events.PerformEvent(EventTypeEnum.ChatUserJoined, parameters);
                        }
                    }
                }
            }
        }
        public override async Task Enable()
        {
            this.DamageTaken = false;
            this.NewBoss     = false;

            if (this.CurrentBossID != Guid.Empty)
            {
                UserDataModel userData = await ChannelSession.Settings.GetUserDataByID(this.CurrentBossID);

                if (userData != null)
                {
                    this.CurrentBoss = new UserViewModel(userData);
                }
                else
                {
                    this.CurrentBossID = Guid.Empty;
                }
            }

            if (this.CurrentBoss == null)
            {
                this.CurrentBoss   = ChannelSession.GetCurrentUser();
                this.CurrentHealth = this.CurrentStartingHealth = this.StartingHealth;
            }
            this.CurrentBossID = this.CurrentBoss.ID;

            if (this.FollowBonus > 0.0)
            {
                GlobalEvents.OnFollowOccurred += GlobalEvents_OnFollowOccurred;
            }
            if (this.HostBonus > 0.0)
            {
                GlobalEvents.OnHostOccurred += GlobalEvents_OnHostOccurred;
            }
            if (this.RaidBonus > 0.0)
            {
                GlobalEvents.OnRaidOccurred += GlobalEvents_OnRaidOccurred;
            }
            if (this.SubscriberBonus > 0.0)
            {
                GlobalEvents.OnSubscribeOccurred          += GlobalEvents_OnSubscribeOccurred;
                GlobalEvents.OnResubscribeOccurred        += GlobalEvents_OnResubscribeOccurred;
                GlobalEvents.OnSubscriptionGiftedOccurred += GlobalEvents_OnSubscriptionGiftedOccurred;
            }
            if (this.DonationBonus > 0.0)
            {
                GlobalEvents.OnDonationOccurred += GlobalEvents_OnDonationOccurred;
            }
            if (this.BitsBonus > 0.0)
            {
                GlobalEvents.OnBitsOccurred += GlobalEvents_OnBitsOccurred;
            }

            await base.Enable();
        }
Beispiel #15
0
        public override async Task LoadTestData()
        {
            UserViewModel user = await ChannelSession.GetCurrentUser();

            List <UserViewModel> users = new List <UserViewModel>();

            for (int i = 0; i < this.TotalToShow; i++)
            {
                users.Add(user);
            }
            await this.AddGameQueueUsers(users);
        }
Beispiel #16
0
        public async Task SendMessage(string message, bool sendAsStreamer = false, StreamingPlatformTypeEnum platform = StreamingPlatformTypeEnum.All)
        {
            if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch))
            {
                await this.TwitchChatService.SendMessage(message, sendAsStreamer);

                if (sendAsStreamer || ChannelSession.TwitchBotConnection == null)
                {
                    UserViewModel user = ChannelSession.GetCurrentUser();
                    await this.AddMessage(new TwitchChatMessageViewModel(user, message));
                }
            }
        }
Beispiel #17
0
        private async void TestButton_Click(object sender, RoutedEventArgs e)
        {
            Button      button  = (Button)sender;
            ChatCommand command = (ChatCommand)button.DataContext;

            await this.window.RunAsyncOperation(async() =>
            {
                await command.Perform(ChannelSession.GetCurrentUser(), new List <string>()
                {
                    "@" + ChannelSession.GetCurrentUser().UserName
                });
            });
        }
        private async Task WidgetsBackgroundUpdate()
        {
            await BackgroundTaskWrapper.RunBackgroundTask(this.backgroundThreadCancellationTokenSource, async (tokenSource) =>
            {
                tokenSource.Token.ThrowIfCancellationRequested();

                UserViewModel user = await ChannelSession.GetCurrentUser();

                foreach (var widgetGroup in ChannelSession.Settings.OverlayWidgets.GroupBy(ow => ow.OverlayName))
                {
                    IOverlayService overlay = this.GetOverlay(widgetGroup.Key);
                    if (overlay != null)
                    {
                        overlay.StartBatching();
                        foreach (OverlayWidget widget in widgetGroup)
                        {
                            try
                            {
                                if (widget.IsEnabled)
                                {
                                    bool isInitialized = widget.Item.IsInitialized;

                                    if (!isInitialized)
                                    {
                                        await widget.Item.Initialize();
                                    }

                                    if (!isInitialized || !widget.DontRefresh)
                                    {
                                        OverlayItemBase item = await widget.Item.GetProcessedItem(user, new List <string>(), new Dictionary <string, string>());
                                        if (item != null)
                                        {
                                            await overlay.SendItem(item, widget.Position, new OverlayItemEffects());
                                        }
                                    }
                                }
                                else
                                {
                                    await widget.Item.Disable();
                                }
                            }
                            catch (Exception ex) { Logger.Log(ex); }
                        }
                        await overlay.EndBatching();
                    }
                }

                await Task.Delay(ChannelSession.Settings.OverlayWidgetRefreshTime * 1000);
            });
        }
Beispiel #19
0
 private async void ReviewCommandButton_Click(object sender, RoutedEventArgs e)
 {
     if (!this.viewModel.CommandDetails.Username.Equals(ChannelSession.GetCurrentUser().Username, StringComparison.CurrentCultureIgnoreCase))
     {
         CommunityCommandsReviewCommandDialogControl dialogControl = new CommunityCommandsReviewCommandDialogControl();
         if (bool.Equals(await DialogHelper.ShowCustom(dialogControl), true))
         {
             if (await DialogHelper.ShowConfirmation(MixItUp.Base.Resources.CommunityCommandsReviewAgreement))
             {
                 await this.viewModel.ReviewCommand(dialogControl.Rating, dialogControl.Review);
             }
         }
     }
 }
 public async Task RunEventCommand(EventCommand command, UserViewModel user, IEnumerable <string> arguments = null, Dictionary <string, string> extraSpecialIdentifiers = null)
 {
     if (command != null)
     {
         if (user != null)
         {
             await command.Perform(user, arguments : arguments, extraSpecialIdentifiers : extraSpecialIdentifiers);
         }
         else
         {
             await command.Perform(await ChannelSession.GetCurrentUser(), arguments : arguments, extraSpecialIdentifiers : extraSpecialIdentifiers);
         }
     }
 }
        private async Task WidgetsBackgroundUpdate(CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            UserViewModel user = ChannelSession.GetCurrentUser();

            foreach (var widgetGroup in ChannelSession.Settings.OverlayWidgets.GroupBy(ow => ow.OverlayName))
            {
                IOverlayEndpointService overlay = this.GetOverlay(widgetGroup.Key);
                if (overlay != null)
                {
                    overlay.StartBatching();
                    foreach (OverlayWidgetModel widget in widgetGroup)
                    {
                        try
                        {
                            if (!widget.Item.IsInitialized)
                            {
                                await widget.Initialize();
                            }

                            if (widget.IsEnabled)
                            {
                                if (!widget.Item.IsEnabled)
                                {
                                    await widget.Enable();
                                }
                                else if (widget.SupportsRefreshUpdating && widget.RefreshTime > 0 && (this.updateSeconds % widget.RefreshTime) == 0)
                                {
                                    await widget.UpdateItem();
                                }
                            }
                            else
                            {
                                if (widget.Item.IsEnabled)
                                {
                                    await widget.Disable();
                                }
                            }
                        }
                        catch (Exception ex) { Logger.Log(ex); }
                    }
                    await overlay.EndBatching();
                }
            }

            this.updateSeconds++;
        }
Beispiel #22
0
        private async Task WidgetsBackgroundUpdate()
        {
            long updateSeconds = 0;
            await BackgroundTaskWrapper.RunBackgroundTask(this.backgroundThreadCancellationTokenSource, async (tokenSource) =>
            {
                tokenSource.Token.ThrowIfCancellationRequested();

                UserViewModel user = await ChannelSession.GetCurrentUser();

                foreach (var widgetGroup in ChannelSession.Settings.OverlayWidgets.GroupBy(ow => ow.OverlayName))
                {
                    IOverlayService overlay = this.GetOverlay(widgetGroup.Key);
                    if (overlay != null)
                    {
                        overlay.StartBatching();
                        foreach (OverlayWidgetModel widget in widgetGroup)
                        {
                            try
                            {
                                if (widget.IsEnabled)
                                {
                                    if (!widget.Item.IsInitialized)
                                    {
                                        await widget.Initialize();
                                    }
                                    else if (widget.SupportsRefreshUpdating && widget.RefreshTime > 0 && (updateSeconds % widget.RefreshTime) == 0)
                                    {
                                        await widget.UpdateItem();
                                    }
                                }
                                else
                                {
                                    if (widget.Item.IsInitialized)
                                    {
                                        await widget.Disable();
                                    }
                                }
                            }
                            catch (Exception ex) { Logger.Log(ex); }
                        }
                        await overlay.EndBatching();
                    }
                }

                await Task.Delay(1000);
                updateSeconds++;
            });
        }
 private async void PlayActionButton_Click(object sender, RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation(async() =>
     {
         ActionBase action = this.GetAction();
         if (action != null)
         {
             await action.Perform(ChannelSession.GetCurrentUser(), new List <string>()
             {
                 "@" + ChannelSession.GetCurrentUser().UserName
             });
         }
         else
         {
             await MessageBoxHelper.ShowMessageDialog("Required action information is missing");
         }
     });
 }
Beispiel #24
0
 private async void PlayActionButton_Click(object sender, RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation((System.Func <System.Threading.Tasks.Task>)(async() =>
     {
         ActionBase action = this.GetAction();
         if (action != null)
         {
             UserViewModel currentUser = ChannelSession.GetCurrentUser();
             await action.Perform(currentUser, StreamingPlatformTypeEnum.None, new List <string>()
             {
                 "@" + currentUser.Username
             }, new Dictionary <string, string>());
         }
         else
         {
             await DialogHelper.ShowMessage("Required action information is missing");
         }
     }));
 }
Beispiel #25
0
        private bool ShouldIncludeUser(UserViewModel user)
        {
            if (user == null)
            {
                return(false);
            }

            if (user.ID.Equals(ChannelSession.GetCurrentUser()?.ID))
            {
                return(false);
            }

            if (ChannelSession.TwitchBotConnection != null && string.Equals(user.TwitchID, ChannelSession.TwitchBotNewAPI?.id))
            {
                return(false);
            }

            return(true);
        }
        private async void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            this.PlayButton.Visibility = Visibility.Collapsed;
            this.StopButton.Visibility = Visibility.Visible;

            this.EditButton.IsEnabled   = false;
            this.DeleteButton.IsEnabled = false;
            this.EnableDisableToggleSwitch.IsEnabled = false;

            if (this.DataContext != null && this.DataContext is CommandBase)
            {
                CommandBase command = (CommandBase)this.DataContext;
                await command.PerformAndWait(ChannelSession.GetCurrentUser(), new List <string>() { "@" + ChannelSession.GetCurrentUser().UserName });

                this.SwitchToPlay();
            }

            this.RaiseEvent(new RoutedEventArgs(CommandButtonsControl.PlayClickedEvent, this));
        }
        public PreMadeChatCommandControlViewModel(PreMadeChatCommand command)
        {
            this.command = command;

            this.setting = ChannelSession.Settings.PreMadeChatCommandSettings.FirstOrDefault(c => c.Name.Equals(this.command.Name));
            if (this.setting == null)
            {
                this.setting = new PreMadeChatCommandSettings(this.command);
                ChannelSession.Settings.PreMadeChatCommandSettings.Add(this.setting);
            }

            this.TestCommand = this.CreateCommand(async(parameter) =>
            {
                UserViewModel currentUser = await ChannelSession.GetCurrentUser();
                await command.Perform(currentUser, new List <string>()
                {
                    "@" + currentUser.UserName
                });
            });
        }
Beispiel #28
0
        public PreMadeChatCommandControlViewModel(PreMadeChatCommandModelBase command)
        {
            this.command = command;

            this.setting = ChannelSession.Settings.PreMadeChatCommandSettings.FirstOrDefault(c => c.Name.Equals(this.command.Name));
            if (this.setting == null)
            {
                this.setting = new PreMadeChatCommandSettingsModel(this.command);
                ChannelSession.Settings.PreMadeChatCommandSettings.Add(this.setting);
            }

            this.TestCommand = this.CreateCommand(async() =>
            {
                UserViewModel currentUser = ChannelSession.GetCurrentUser();
                await ChannelSession.Services.Command.Queue(command, new CommandParametersModel(currentUser, arguments: new List <string>()
                {
                    "@" + currentUser.Username
                }));
            });
        }
Beispiel #29
0
        public PreMadeChatCommandControlViewModel(PreMadeChatCommandModelBase command)
        {
            this.command = command;

            this.setting = ChannelSession.Settings.PreMadeChatCommandSettings.FirstOrDefault(c => c.Name.Equals(this.command.Name));
            if (this.setting == null)
            {
                this.setting = new PreMadeChatCommandSettingsModel(this.command);
                ChannelSession.Settings.PreMadeChatCommandSettings.Add(this.setting);
            }

            this.TestCommand = this.CreateCommand((System.Func <object, System.Threading.Tasks.Task>)(async(parameter) =>
            {
                UserViewModel currentUser = ChannelSession.GetCurrentUser();
                await command.Perform(new CommandParametersModel(currentUser, arguments: new List <string>()
                {
                    "@" + currentUser.Username
                }));
            }));
        }
Beispiel #30
0
        private async Task AddOrUpdateUser(UserViewModel user)
        {
            if (!user.IsAnonymous)
            {
                this.usersByID[user.ID] = user;

                if (!string.IsNullOrEmpty(user.TwitchID) && !string.IsNullOrEmpty(user.TwitchUsername))
                {
                    this.usersByTwitchID[user.TwitchID]          = user;
                    this.usersByTwitchLogin[user.TwitchUsername] = user;
                }

                if (UserService.SpecialUserAccounts.Contains(user.Username.ToLower()))
                {
                    user.IgnoreForQueries = true;
                }
                else if (ChannelSession.GetCurrentUser().ID.Equals(user.ID))
                {
                    user.IgnoreForQueries = true;
                }
                else if (ChannelSession.TwitchBotNewAPI != null && ChannelSession.TwitchBotNewAPI.id.Equals(user.TwitchID))
                {
                    user.IgnoreForQueries = true;
                }
                else
                {
                    user.IgnoreForQueries = false;
                    if (user.Data.ViewingMinutes == 0)
                    {
                        await ChannelSession.Services.Events.PerformEvent(new EventTrigger(EventTypeEnum.ChatUserFirstJoin, user));
                    }

                    if (ChannelSession.Services.Events.CanPerformEvent(new EventTrigger(EventTypeEnum.ChatUserJoined, user)))
                    {
                        user.LastSeen = DateTimeOffset.Now;
                        user.Data.TotalStreamsWatched++;
                        await ChannelSession.Services.Events.PerformEvent(new EventTrigger(EventTypeEnum.ChatUserJoined, user));
                    }
                }
            }
        }