private void CommandButtons_EditClicked(object sender, RoutedEventArgs e)
        {
            TwitchChannelPointsCommandModel command = ((CommandListingButtonsControl)sender).GetCommandFromCommandButtons <TwitchChannelPointsCommandModel>();

            if (command != null)
            {
                CommandEditorWindow window = CommandEditorWindow.GetCommandEditorWindow(command);
                window.CommandSaved += Window_CommandSaved;
                window.ForceShow();
            }
        }
 private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation(async() =>
     {
         TwitchChannelPointsCommandModel command = ((CommandListingButtonsControl)sender).GetCommandFromCommandButtons <TwitchChannelPointsCommandModel>();
         if (command != null)
         {
             ChannelSession.TwitchChannelPointsCommands.Remove(command);
             ChannelSession.Settings.RemoveCommand(command);
             this.viewModel.RemoveCommand(command);
             await ChannelSession.SaveSettings();
         }
     });
 }
Esempio n. 3
0
        private async void PubSub_OnChannelPointsRedeemed(object sender, PubSubChannelPointsRedemptionEventModel packet)
        {
            PubSubChannelPointsRedeemedEventModel redemption = packet.redemption;

            UserViewModel user = ChannelSession.Services.User.GetActiveUserByPlatformID(StreamingPlatformTypeEnum.Twitch, redemption.user.id);

            if (user == null)
            {
                user = await UserViewModel.Create(redemption.user);
            }

            List <string> arguments = null;
            Dictionary <string, string> eventCommandSpecialIdentifiers = new Dictionary <string, string>();

            eventCommandSpecialIdentifiers["rewardname"] = redemption.reward.title;
            eventCommandSpecialIdentifiers["rewardcost"] = redemption.reward.cost.ToString();
            if (!string.IsNullOrEmpty(redemption.user_input))
            {
                eventCommandSpecialIdentifiers["message"] = redemption.user_input;
                arguments = new List <string>(redemption.user_input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
            }

            if (string.IsNullOrEmpty(await ChannelSession.Services.Moderation.ShouldTextBeModerated(user, redemption.user_input)))
            {
                await ChannelSession.Services.Events.PerformEvent(EventTypeEnum.TwitchChannelPointsRedeemed, new CommandParametersModel(user, arguments, eventCommandSpecialIdentifiers));

                TwitchChannelPointsCommandModel command = ChannelSession.Services.Command.TwitchChannelPointsCommands.FirstOrDefault(c => string.Equals(c.ChannelPointRewardID.ToString(), redemption.reward.id, StringComparison.CurrentCultureIgnoreCase));
                if (command == null)
                {
                    command = ChannelSession.Services.Command.TwitchChannelPointsCommands.FirstOrDefault(c => string.Equals(c.Name, redemption.reward.title, StringComparison.CurrentCultureIgnoreCase));
                }

                if (command != null)
                {
                    Dictionary <string, string> channelPointSpecialIdentifiers = new Dictionary <string, string>(eventCommandSpecialIdentifiers);
                    await ChannelSession.Services.Command.Queue(command, new CommandParametersModel(user, platform : StreamingPlatformTypeEnum.Twitch, arguments : arguments, specialIdentifiers : channelPointSpecialIdentifiers));
                }
            }
            await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, string.Format("{0} Redeemed {1}", user.FullDisplayName, redemption.reward.title), ChannelSession.Settings.AlertChannelPointsColor));
        }
 public TwitchChannelPointsCommandEditorWindowViewModel(TwitchChannelPointsCommandModel existingCommand) : base(existingCommand)
 {
 }
Esempio n. 5
0
 public TwitchChannelPointsCommandEditorWindowViewModel(TwitchChannelPointsCommandModel existingCommand)
     : base(existingCommand)
 {
     this.existingChannelPointRewardID = existingCommand.ChannelPointRewardID;
 }