예제 #1
0
        public StreamPassModel(StreamPassModel copy)
            : this()
        {
            this.Name = copy.Name + " COPY";
            this.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.Name, maxLength: 15);
            this.Permission        = copy.Permission;
            this.MaxLevel          = copy.MaxLevel;
            this.PointsForLevelUp  = copy.PointsForLevelUp;
            this.SubMultiplier     = copy.SubMultiplier;

            this.StartDate = copy.StartDate;
            this.EndDate   = copy.EndDate;

            this.ViewingRateAmount  = copy.ViewingRateAmount;
            this.ViewingRateMinutes = copy.ViewingRateMinutes;
            this.MinimumActiveRate  = copy.MinimumActiveRate;
            this.FollowBonus        = copy.FollowBonus;
            this.HostBonus          = copy.HostBonus;
            this.SubscribeBonus     = copy.SubscribeBonus;
            this.DonationBonus      = copy.DonationBonus;
            this.BitsBonus          = copy.BitsBonus;

            this.DefaultLevelUpCommandID = this.DuplicateCommand(copy.DefaultLevelUpCommandID);
            this.CustomLevelUpCommands.Clear();
            foreach (var kvp in copy.CustomLevelUpCommands)
            {
                this.CustomLevelUpCommands[kvp.Key] = this.DuplicateCommand(kvp.Value);
            }
        }
        public async Task Save()
        {
            if (this.inventory == null)
            {
                this.inventory = new InventoryModel();
                ChannelSession.Settings.Inventory[this.inventory.ID] = this.inventory;
            }

            this.inventory.Name              = this.Name;
            this.inventory.DefaultMaxAmount  = this.DefaultItemMaxAmount;
            this.inventory.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.inventory.Name);
            this.inventory.Items             = new Dictionary <Guid, InventoryItemModel>(this.Items.ToDictionary(i => i.ID, i => i));

            this.inventory.ShopEnabled = this.ShopEnabled;
            this.inventory.ShopCommand = this.ShopCommandText;
            if (this.SelectedShopCurrency != null)
            {
                this.inventory.ShopCurrencyID = this.SelectedShopCurrency.ID;
            }
            this.inventory.ItemsBoughtCommand = this.ShopBuyCommand;
            this.inventory.ItemsSoldCommand   = this.ShopSellCommand;

            this.inventory.TradeEnabled       = this.TradeEnabled;
            this.inventory.TradeCommand       = this.TradeCommandText;
            this.inventory.ItemsTradedCommand = this.TradeCommand;

            await ChannelSession.SaveSettings();
        }
        public async Task Save()
        {
            if (this.Currency == null)
            {
                this.Currency = new CurrencyModel();
                ChannelSession.Settings.Currency[this.Currency.ID] = this.Currency;
            }

            this.Currency.Name      = this.Name;
            this.Currency.IsPrimary = this.IsPrimary;
            this.Currency.MaxAmount = (this.MaxAmount != 0 && this.MaxAmount != int.MaxValue) ? this.MaxAmount : int.MaxValue;

            this.Currency.AcquireAmount          = this.OnlineRateAmount;
            this.Currency.AcquireInterval        = this.OnlineRateInterval;
            this.Currency.OfflineAcquireAmount   = this.OfflineRateAmount;
            this.Currency.OfflineAcquireInterval = this.OfflineRateInterval;

            this.Currency.SpecialTracking = CurrencySpecialTrackingEnum.None;
            if (this.OnlineRate == CurrencyAcquireRateTypeEnum.Bits)
            {
                this.Currency.SpecialTracking = CurrencySpecialTrackingEnum.Bits;
            }

            this.Currency.RegularBonus     = this.RegularBonus;
            this.Currency.SubscriberBonus  = this.SubscriberBonus;
            this.Currency.ModeratorBonus   = this.ModeratorBonus;
            this.Currency.OnFollowBonus    = this.OnFollowBonus;
            this.Currency.OnHostBonus      = this.OnHostBonus;
            this.Currency.OnSubscribeBonus = this.OnSubscribeBonus;

            this.Currency.MinimumActiveRate = this.MinimumActiveRate;
            this.Currency.ResetInterval     = this.AutomaticResetRate;
            this.Currency.ResetStartCadence = this.AutomaticResetStartTime;

            this.Currency.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.Currency.Name);

            if (this.IsRank)
            {
                this.Currency.Ranks = this.Ranks.ToList();
                this.Currency.RankChangedCommand = this.RankChangedCommand;
                this.Currency.RankDownCommand    = this.RankDownCommand;
            }
            else
            {
                this.Currency.Ranks.Clear();
                this.Currency.RankChangedCommand = null;
                this.Currency.RankDownCommand    = null;
            }

            await ChannelSession.SaveSettings();
        }
 private void CurrencyNameTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
 {
     if (!string.IsNullOrEmpty(this.CurrencyNameTextBox.Text))
     {
         this.specialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.CurrencyNameTextBox.Text);
         this.UserAmountSpecialIdentifierTextBlock.Text = string.Format("$user{0}", this.specialIdentifier);
         this.UserRankSpecialIdentifierTextBlock.Text   = string.Format("$user{0}rank", this.specialIdentifier);
     }
     else
     {
         this.specialIdentifier = null;
         this.UserAmountSpecialIdentifierTextBlock.Text = "";
         this.UserRankSpecialIdentifierTextBlock.Text   = "";
     }
 }
예제 #5
0
        public async Task Save()
        {
            if (this.IsNew)
            {
                this.StreamPass = new StreamPassModel();
                ChannelSession.Settings.StreamPass[this.StreamPass.ID] = this.StreamPass;
            }

            this.StreamPass.Name = this.Name;
            this.StreamPass.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.Name, maxLength: 15);
            this.StreamPass.Permission        = this.Permission;
            this.StreamPass.MaxLevel          = this.MaxLevel;
            this.StreamPass.PointsForLevelUp  = this.PointsForLevelUp;
            this.StreamPass.SubMultiplier     = this.SubMultiplier;

            this.StreamPass.StartDate = this.StartDate;
            this.StreamPass.EndDate   = this.EndDate;

            this.StreamPass.ViewingRateAmount  = this.ViewingRateAmount;
            this.StreamPass.ViewingRateMinutes = this.ViewingRateMinutes;
            this.StreamPass.MinimumActiveRate  = this.MinimumActiveRate;
            this.StreamPass.FollowBonus        = this.FollowBonus;
            this.StreamPass.HostBonus          = this.HostBonus;
            this.StreamPass.SubscribeBonus     = this.SubscribeBonus;
            this.StreamPass.DonationBonus      = this.DonationBonus;
            this.StreamPass.BitsBonus          = this.BitsBonus;

            this.StreamPass.DefaultLevelUpCommand = this.DefaultLevelUpCommand;
            this.StreamPass.CustomLevelUpCommands.Clear();
            foreach (StreamPassCustomLevelUpCommandViewModel customCommand in this.CustomLevelUpCommands)
            {
                this.StreamPass.CustomLevelUpCommands[customCommand.Level] = customCommand.CommandID;
            }

            await ChannelSession.SaveSettings();
        }
        private async void SaveButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            await this.RunAsyncOperation(async() =>
            {
                if (string.IsNullOrEmpty(this.NameTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog(string.Format("A {0} name must be specified", this.CurrencyRankIdentifierString));
                    return;
                }

                if (this.NameTextBox.Text.Any(c => char.IsDigit(c)))
                {
                    await MessageBoxHelper.ShowMessageDialog("The name can not contain any number digits in it");
                    return;
                }

                UserCurrencyViewModel dupeCurrency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(c => c.Name.Equals(this.NameTextBox.Text));
                if (dupeCurrency != null && (this.currency == null || !this.currency.ID.Equals(dupeCurrency.ID)))
                {
                    await MessageBoxHelper.ShowMessageDialog("There already exists a currency or rank system with this name");
                    return;
                }

                UserInventoryViewModel dupeInventory = ChannelSession.Settings.Inventories.Values.FirstOrDefault(c => c.Name.Equals(this.NameTextBox.Text));
                if (dupeInventory != null)
                {
                    await MessageBoxHelper.ShowMessageDialog("There already exists an inventory with this name");
                    return;
                }

                string siName = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.NameTextBox.Text);

                if (siName.Equals("time") || siName.Equals("hours") || siName.Equals("mins") || siName.Equals("sparks") || siName.Equals("embers"))
                {
                    await MessageBoxHelper.ShowMessageDialog("This name is reserved and can not be used");
                    return;
                }

                int maxAmount = int.MaxValue;
                if (!string.IsNullOrEmpty(this.MaxAmountTextBox.Text))
                {
                    if (!int.TryParse(this.MaxAmountTextBox.Text, out maxAmount) || maxAmount <= 0)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The max amount must be greater than 0 or can be left empty for no max amount");
                        return;
                    }
                }

                if (string.IsNullOrEmpty(this.OnlineAmountRateTextBox.Text) || !int.TryParse(this.OnlineAmountRateTextBox.Text, out int onlineAmount) || onlineAmount < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The online amount must be 0 or greater");
                    return;
                }

                if (string.IsNullOrEmpty(this.OnlineTimeRateTextBox.Text) || !int.TryParse(this.OnlineTimeRateTextBox.Text, out int onlineTime) || onlineTime < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The online minutes must be 0 or greater");
                    return;
                }

                if (string.IsNullOrEmpty(this.OfflineAmountRateTextBox.Text) || !int.TryParse(this.OfflineAmountRateTextBox.Text, out int offlineAmount) || offlineAmount < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The offline amount must be 0 or greater");
                    return;
                }

                if (string.IsNullOrEmpty(this.OfflineTimeRateTextBox.Text) || !int.TryParse(this.OfflineTimeRateTextBox.Text, out int offlineTime) || offlineTime < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The offline minutes must be 0 or greater");
                    return;
                }

                if (onlineAmount > 0 && onlineTime == 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The online time can not be 0 if the online amount is greater than 0");
                    return;
                }

                if (offlineAmount > 0 && offlineTime == 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The offline time can not be 0 if the offline amount is greater than 0");
                    return;
                }

                int subscriberBonus = 0;
                if (string.IsNullOrEmpty(this.SubscriberBonusTextBox.Text) || !int.TryParse(this.SubscriberBonusTextBox.Text, out subscriberBonus) || subscriberBonus < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The Subscriber bonus must be 0 or greater");
                    return;
                }

                int modBonus = 0;
                if (string.IsNullOrEmpty(this.ModeratorBonusTextBox.Text) || !int.TryParse(this.ModeratorBonusTextBox.Text, out modBonus) || modBonus < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The Moderator bonus must be 0 or greater");
                    return;
                }

                int onFollowBonus = 0;
                if (string.IsNullOrEmpty(this.OnFollowBonusTextBox.Text) || !int.TryParse(this.OnFollowBonusTextBox.Text, out onFollowBonus) || onFollowBonus < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The On Follow bonus must be 0 or greater");
                    return;
                }

                int onHostBonus = 0;
                if (string.IsNullOrEmpty(this.OnHostBonusTextBox.Text) || !int.TryParse(this.OnHostBonusTextBox.Text, out onHostBonus) || onHostBonus < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The On Host bonus must be 0 or greater");
                    return;
                }

                int onSubscribeBonus = 0;
                if (string.IsNullOrEmpty(this.OnSubscribeBonusTextBox.Text) || !int.TryParse(this.OnSubscribeBonusTextBox.Text, out onSubscribeBonus) || onSubscribeBonus < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The On Subscribe bonus must be 0 or greater");
                    return;
                }

                if (this.IsRankToggleButton.IsChecked.GetValueOrDefault())
                {
                    if (this.ranks.Count() < 1)
                    {
                        await MessageBoxHelper.ShowMessageDialog("At least one rank must be created");
                        return;
                    }
                }

                int minActivityRate = 0;
                if (string.IsNullOrEmpty(this.MinimumActivityRateTextBox.Text) || !int.TryParse(this.MinimumActivityRateTextBox.Text, out minActivityRate) || minActivityRate < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The Minimum Activity Rate must be 0 or greater");
                    return;
                }

                bool isNew = false;
                if (this.currency == null)
                {
                    isNew         = true;
                    this.currency = new UserCurrencyViewModel();
                    ChannelSession.Settings.Currencies[this.currency.ID] = this.currency;
                }

                CurrencyAcquireRateTypeEnum acquireRate = CurrencyAcquireRateTypeEnum.Custom;
                if (this.OnlineRateComboBox.SelectedIndex >= 0)
                {
                    acquireRate = EnumHelper.GetEnumValueFromString <CurrencyAcquireRateTypeEnum>((string)this.OnlineRateComboBox.SelectedItem);
                }

                this.currency.IsTrackingSparks = false;
                this.currency.IsTrackingEmbers = false;
                if (acquireRate == CurrencyAcquireRateTypeEnum.Sparks)
                {
                    this.currency.IsTrackingSparks = true;
                }
                else if (acquireRate == CurrencyAcquireRateTypeEnum.Embers)
                {
                    this.currency.IsTrackingEmbers = true;
                }

                this.currency.Name      = this.NameTextBox.Text;
                this.currency.MaxAmount = maxAmount;

                this.currency.AcquireAmount          = onlineAmount;
                this.currency.AcquireInterval        = onlineTime;
                this.currency.OfflineAcquireAmount   = offlineAmount;
                this.currency.OfflineAcquireInterval = offlineTime;

                this.currency.SubscriberBonus  = subscriberBonus;
                this.currency.ModeratorBonus   = modBonus;
                this.currency.OnFollowBonus    = onFollowBonus;
                this.currency.OnHostBonus      = onHostBonus;
                this.currency.OnSubscribeBonus = onSubscribeBonus;

                this.currency.MinimumActiveRate = minActivityRate;
                this.currency.ResetInterval     = EnumHelper.GetEnumValueFromString <CurrencyResetRateEnum>((string)this.AutomaticResetComboBox.SelectedItem);

                this.currency.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.currency.Name);

                if (this.IsRankToggleButton.IsChecked.GetValueOrDefault())
                {
                    this.currency.Ranks = ranks.ToList();
                    this.currency.RankChangedCommand = this.rankChangedCommand;
                }
                else
                {
                    this.currency.Ranks = new List <UserRankViewModel>();
                    this.currency.RankChangedCommand = null;
                }

                foreach (var otherCurrencies in ChannelSession.Settings.Currencies)
                {
                    if (otherCurrencies.Value.IsRank == this.currency.IsRank)
                    {
                        // Turn off primary for all other currencies/ranks of the same kind
                        otherCurrencies.Value.IsPrimary = false;
                    }
                }
                this.currency.IsPrimary = this.IsPrimaryToggleButton.IsChecked.GetValueOrDefault();

                await ChannelSession.SaveSettings();

                if (isNew)
                {
                    List <NewCurrencyRankCommand> commandsToAdd = new List <NewCurrencyRankCommand>();

                    ChatCommand statusCommand = new ChatCommand("User " + this.currency.Name, this.currency.SpecialIdentifier, new RequirementViewModel(MixerRoleEnum.User, 5));
                    string statusChatText     = string.Empty;
                    if (this.currency.IsRank)
                    {
                        statusChatText = string.Format("@$username is a ${0} with ${1} {2}!", this.currency.UserRankNameSpecialIdentifier, this.currency.UserAmountSpecialIdentifier, this.currency.Name);
                    }
                    else
                    {
                        statusChatText = string.Format("@$username has ${0} {1}!", this.currency.UserAmountSpecialIdentifier, this.currency.Name);
                    }
                    statusCommand.Actions.Add(new ChatAction(statusChatText));
                    commandsToAdd.Add(new NewCurrencyRankCommand(string.Format("!{0} - {1}", statusCommand.Commands.First(), "Shows User's Amount"), statusCommand));

                    if (!this.currency.IsTrackingSparks && !this.currency.IsTrackingEmbers)
                    {
                        ChatCommand addCommand = new ChatCommand("Add " + this.currency.Name, "add" + this.currency.SpecialIdentifier, new RequirementViewModel(MixerRoleEnum.Mod, 5));
                        addCommand.Actions.Add(new CurrencyAction(this.currency, CurrencyActionTypeEnum.AddToSpecificUser, "$arg2text", username: "******"));
                        addCommand.Actions.Add(new ChatAction(string.Format("@$targetusername received $arg2text {0}!", this.currency.Name)));
                        commandsToAdd.Add(new NewCurrencyRankCommand(string.Format("!{0} - {1}", addCommand.Commands.First(), "Adds Amount To Specified User"), addCommand));

                        ChatCommand addAllCommand = new ChatCommand("Add All " + this.currency.Name, "addall" + this.currency.SpecialIdentifier, new RequirementViewModel(MixerRoleEnum.Mod, 5));
                        addAllCommand.Actions.Add(new CurrencyAction(this.currency, CurrencyActionTypeEnum.AddToAllChatUsers, "$arg1text"));
                        addAllCommand.Actions.Add(new ChatAction(string.Format("Everyone got $arg1text {0}!", this.currency.Name)));
                        commandsToAdd.Add(new NewCurrencyRankCommand(string.Format("!{0} - {1}", addAllCommand.Commands.First(), "Adds Amount To All Chat Users"), addAllCommand));

                        if (!this.currency.IsRank)
                        {
                            ChatCommand giveCommand = new ChatCommand("Give " + this.currency.Name, "give" + this.currency.SpecialIdentifier, new RequirementViewModel(MixerRoleEnum.User, 5));
                            giveCommand.Actions.Add(new CurrencyAction(this.currency, CurrencyActionTypeEnum.AddToSpecificUser, "$arg2text", username: "******", deductFromUser: true));
                            giveCommand.Actions.Add(new ChatAction(string.Format("@$username gave @$targetusername $arg2text {0}!", this.currency.Name)));
                            commandsToAdd.Add(new NewCurrencyRankCommand(string.Format("!{0} - {1}", giveCommand.Commands.First(), "Gives Amount To Specified User"), giveCommand));
                        }
                    }

                    NewCurrencyRankCommandsDialogControl dControl = new NewCurrencyRankCommandsDialogControl(this.currency, commandsToAdd);
                    string result = await MessageBoxHelper.ShowCustomDialog(dControl);
                    if (!string.IsNullOrEmpty(result) && result.Equals("True"))
                    {
                        foreach (NewCurrencyRankCommand command in dControl.commands)
                        {
                            if (command.AddCommand)
                            {
                                ChannelSession.Settings.ChatCommands.Add(command.Command);
                            }
                        }
                    }
                }

                this.Close();
            });
        }
예제 #7
0
        private async void SaveButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            await this.RunAsyncOperation(async() =>
            {
                if (string.IsNullOrEmpty(this.NameTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("An inventory name must be specified");
                    return;
                }

                UserInventoryViewModel dupeInventory = ChannelSession.Settings.Inventories.Values.FirstOrDefault(c => c.Name.Equals(this.NameTextBox.Text));
                if (dupeInventory != null && (this.inventory == null || !this.inventory.ID.Equals(dupeInventory.ID)))
                {
                    await MessageBoxHelper.ShowMessageDialog("There already exists an inventory with this name");
                    return;
                }

                UserCurrencyViewModel dupeCurrency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(c => c.Name.Equals(this.NameTextBox.Text));
                if (dupeCurrency != null)
                {
                    await MessageBoxHelper.ShowMessageDialog("There already exists a currency or rank system with this name");
                    return;
                }

                if (string.IsNullOrEmpty(this.DefaultMaxAmountTextBox.Text) || !int.TryParse(this.DefaultMaxAmountTextBox.Text, out int maxAmount) || maxAmount <= 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("The default max amount must be greater than 0");
                    return;
                }

                if (this.items.Count == 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("At least 1 item must be added");
                    return;
                }

                if (this.ShopEnableDisableToggleButton.IsChecked.GetValueOrDefault())
                {
                    if (string.IsNullOrEmpty(this.ShopCommandTextBox.Text))
                    {
                        await MessageBoxHelper.ShowMessageDialog("A command name must be specified for the shop");
                        return;
                    }

                    if (this.ShopCurrencyComboBox.SelectedIndex < 0)
                    {
                        await MessageBoxHelper.ShowMessageDialog("A currency must be specified for the shop");
                        return;
                    }
                }

                if (this.inventory == null)
                {
                    this.inventory = new UserInventoryViewModel();
                    ChannelSession.Settings.Inventories[this.inventory.ID] = this.inventory;
                }

                this.inventory.Name              = this.NameTextBox.Text;
                this.inventory.DefaultMaxAmount  = maxAmount;
                this.inventory.ResetInterval     = EnumHelper.GetEnumValueFromString <CurrencyResetRateEnum>((string)this.AutomaticResetComboBox.SelectedItem);
                this.inventory.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.inventory.Name);
                this.inventory.Items             = new Dictionary <string, UserInventoryItemViewModel>(this.items.ToDictionary(i => i.Name, i => i));
                this.inventory.ShopEnabled       = this.ShopEnableDisableToggleButton.IsChecked.GetValueOrDefault();
                this.inventory.ShopCommand       = this.ShopCommandTextBox.Text;
                if (this.ShopCurrencyComboBox.SelectedIndex >= 0)
                {
                    UserCurrencyViewModel currency = (UserCurrencyViewModel)this.ShopCurrencyComboBox.SelectedItem;
                    if (currency != null)
                    {
                        this.inventory.ShopCurrencyID = currency.ID;
                    }
                }
                this.inventory.ItemsBoughtCommand = (CustomCommand)this.ShopItemsBoughtCommandButtonsControl.DataContext;
                this.inventory.ItemsSoldCommand   = (CustomCommand)this.ShopItemsSoldCommandButtonsControl.DataContext;

                await ChannelSession.SaveSettings();

                this.Close();
            });
        }
        public Task ImportSettings()
        {
            CurrencyModel rank = new CurrencyModel()
            {
                Name = "Rank",
                SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("rank"),
                AcquireInterval   = 60,
                AcquireAmount     = 1,
                IsPrimary         = true
            };

            foreach (StreamlabsChatBotRankModel slrank in this.Ranks)
            {
                rank.Ranks.Add(new RankModel(slrank.Name, slrank.Requirement));
            }

            CurrencyModel currency = new CurrencyModel()
            {
                Name = "Points",
                SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                AcquireInterval   = 1,
                AcquireAmount     = 1,
                IsPrimary         = true
            };

            ChannelSession.Settings.Currency[rank.ID]     = rank;
            ChannelSession.Settings.Currency[currency.ID] = currency;

            this.AddCurrencyRankCommands(rank);
            this.AddCurrencyRankCommands(currency);

            //foreach (StreamlabsChatBotViewerModel viewer in this.Viewers)
            //{
            //    try
            //    {
            //        UserModel user = await ChannelSession.TwitchUserConnection.GetNewAPIUserByLogin(viewer.Name);
            //        if (user != null)
            //        {
            //            UserDataModel userData = new UserDataModel(user);
            //            ChannelSession.Settings.AddUserData(userData);
            //            rank.SetAmount(userData, viewer.Hours);
            //            currency.SetAmount(userData, viewer.Points);
            //        }
            //    }
            //    catch (Exception) { }
            //}

            foreach (StreamlabsChatBotCommandModel command in this.Commands)
            {
                command.ProcessData(currency, rank);
                ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
            }

            foreach (StreamlabsChatBotTimerModel timer in this.Timers)
            {
                StreamlabsChatBotCommandModel command = new StreamlabsChatBotCommandModel()
                {
                    Command = timer.Name, Response = timer.Response, Enabled = timer.Enabled
                };
                command.ProcessData(currency, rank);
                ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));

                timer.Actions = command.Actions;

                ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
            }

            foreach (string quote in this.Quotes)
            {
                ChannelSession.Settings.Quotes.Add(new UserQuoteViewModel(quote, DateTimeOffset.MinValue));
            }

            if (ChannelSession.Settings.Quotes.Count > 0)
            {
                ChannelSession.Settings.QuotesEnabled = true;
            }

            return(Task.FromResult(0));
        }
예제 #9
0
        private async Task FinalizeNewUser()
        {
            if (this.scorpBotData != null)
            {
                // Import Ranks
                int    rankEnabled   = this.scorpBotData.GetIntSettingsValue("currency", "enabled");
                string rankName      = this.scorpBotData.GetSettingsValue("currency", "name", "Rank");
                int    rankInterval  = this.scorpBotData.GetIntSettingsValue("currency", "onlinepayinterval");
                int    rankAmount    = this.scorpBotData.GetIntSettingsValue("currency", "activeuserbonus");
                int    rankMaxAmount = this.scorpBotData.GetIntSettingsValue("currency", "maxlimit");
                if (rankMaxAmount <= 0)
                {
                    rankMaxAmount = int.MaxValue;
                }
                int    rankOnFollowBonus    = this.scorpBotData.GetIntSettingsValue("currency", "onfollowbonus");
                int    rankOnSubBonus       = this.scorpBotData.GetIntSettingsValue("currency", "onsubbonus");
                int    rankSubBonus         = this.scorpBotData.GetIntSettingsValue("currency", "subbonus");
                string rankCommand          = this.scorpBotData.GetSettingsValue("currency", "command", "");
                string rankCommandResponse  = this.scorpBotData.GetSettingsValue("currency", "response", "");
                string rankUpCommand        = this.scorpBotData.GetSettingsValue("currency", "Currency1RankUpMsg", "");
                int    rankAccumulationType = this.scorpBotData.GetIntSettingsValue("currency", "ranksrectype");

                UserCurrencyViewModel rankCurrency       = null;
                UserCurrencyViewModel rankPointsCurrency = null;
                if (!string.IsNullOrEmpty(rankName))
                {
                    if (rankAccumulationType == 1)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName.Equals("Points") ? "Hours" : rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName.Equals("Points") ? "Hours" : rankName),
                            AcquireInterval   = 60,
                            AcquireAmount     = 1,
                            MaxAmount         = rankMaxAmount,
                        };

                        if (rankInterval >= 0 && rankAmount >= 0)
                        {
                            rankPointsCurrency = new UserCurrencyViewModel()
                            {
                                Name = "Points",
                                SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                                AcquireInterval   = rankInterval,
                                AcquireAmount     = rankAmount,
                                MaxAmount         = rankMaxAmount,
                                OnFollowBonus     = rankOnFollowBonus,
                                OnSubscribeBonus  = rankOnSubBonus,
                                SubscriberBonus   = rankSubBonus,
                                ModeratorBonus    = rankSubBonus
                            };

                            ChannelSession.Settings.Currencies[rankPointsCurrency.ID] = rankPointsCurrency;
                        }
                    }
                    else if (rankInterval >= 0 && rankAmount >= 0)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName),
                            AcquireInterval   = rankInterval,
                            AcquireAmount     = rankAmount,
                            MaxAmount         = rankMaxAmount,
                            OnFollowBonus     = rankOnFollowBonus,
                            OnSubscribeBonus  = rankOnSubBonus,
                            SubscriberBonus   = rankSubBonus,
                            ModeratorBonus    = rankSubBonus
                        };
                    }
                }

                // Import Currency
                int    currencyEnabled   = this.scorpBotData.GetIntSettingsValue("currency2", "enabled");
                string currencyName      = this.scorpBotData.GetSettingsValue("currency2", "name", "Currency");
                int    currencyInterval  = this.scorpBotData.GetIntSettingsValue("currency2", "onlinepayinterval");
                int    currencyAmount    = this.scorpBotData.GetIntSettingsValue("currency2", "activeuserbonus");
                int    currencyMaxAmount = this.scorpBotData.GetIntSettingsValue("currency2", "maxlimit");
                if (currencyMaxAmount <= 0)
                {
                    currencyMaxAmount = int.MaxValue;
                }
                int    currencyOnFollowBonus   = this.scorpBotData.GetIntSettingsValue("currency2", "onfollowbonus");
                int    currencyOnSubBonus      = this.scorpBotData.GetIntSettingsValue("currency2", "onsubbonus");
                int    currencySubBonus        = this.scorpBotData.GetIntSettingsValue("currency2", "subbonus");
                string currencyCommand         = this.scorpBotData.GetSettingsValue("currency2", "command", "");
                string currencyCommandResponse = this.scorpBotData.GetSettingsValue("currency2", "response", "");

                UserCurrencyViewModel currency = null;
                if (!string.IsNullOrEmpty(currencyName) && currencyInterval >= 0 && currencyAmount >= 0)
                {
                    currency = new UserCurrencyViewModel()
                    {
                        Name          = currencyName, SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currencyName), AcquireInterval = currencyInterval,
                        AcquireAmount = currencyAmount, MaxAmount = currencyMaxAmount, OnFollowBonus = currencyOnFollowBonus, OnSubscribeBonus = currencyOnSubBonus,
                    };
                    ChannelSession.Settings.Currencies[currency.ID] = currency;

                    if (!string.IsNullOrEmpty(currencyCommand) && !string.IsNullOrEmpty(currencyCommandResponse))
                    {
                        currencyCommandResponse = currencyCommandResponse.Replace("$points2", "$" + currency.UserAmountSpecialIdentifier);
                        currencyCommandResponse = currencyCommandResponse.Replace("$currencyname2", currency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(currencyCommand, currencyCommandResponse));
                    }
                }

                foreach (ScorpBotViewer viewer in this.scorpBotData.Viewers)
                {
                    ChannelSession.Settings.UserData[viewer.ID] = new UserDataViewModel(viewer);

                    if (rankPointsCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankPointsCurrency, (int)viewer.RankPoints);
                    }

                    if (rankCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankCurrency, (rankPointsCurrency != null) ? (int)viewer.Hours : (int)viewer.RankPoints);
                    }

                    if (currency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(currency, (int)viewer.Currency);
                    }
                }

                if (rankCurrency != null)
                {
                    ChannelSession.Settings.Currencies[rankCurrency.ID] = rankCurrency;

                    foreach (ScorpBotRank rank in this.scorpBotData.Ranks)
                    {
                        rankCurrency.Ranks.Add(new UserRankViewModel(rank.Name, rank.Amount));
                    }

                    if (!string.IsNullOrEmpty(rankCommand) && !string.IsNullOrEmpty(rankCommandResponse))
                    {
                        rankCommandResponse = rankCommandResponse.Replace(" / Raids: $raids", "");
                        rankCommandResponse = rankCommandResponse.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$currencyname", rankCurrency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(rankCommand, rankCommandResponse));
                    }

                    if (!string.IsNullOrEmpty(rankUpCommand))
                    {
                        rankUpCommand = rankUpCommand.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$currencyname", rankCurrency.Name);

                        ScorpBotCommand scorpCommand = new ScorpBotCommand("rankup", rankUpCommand);
                        ChatCommand     chatCommand  = new ChatCommand(scorpCommand);

                        rankCurrency.RankChangedCommand = new CustomCommand("User Rank Changed");
                        rankCurrency.RankChangedCommand.Actions.AddRange(chatCommand.Actions);
                    }
                }

                foreach (ScorpBotCommand command in this.scorpBotData.Commands)
                {
                    command.ProcessData(currency, rankCurrency);
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
                }

                foreach (ScorpBotTimer timer in this.scorpBotData.Timers)
                {
                    ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
                }

                foreach (string quote in this.scorpBotData.Quotes)
                {
                    ChannelSession.Settings.UserQuotes.Add(new UserQuoteViewModel(quote));
                }

                if (ChannelSession.Settings.UserQuotes.Count > 0)
                {
                    ChannelSession.Settings.QuotesEnabled = true;
                }

                if (this.scorpBotData.GetBoolSettingsValue("settings", "filtwordsen"))
                {
                    foreach (string filteredWord in this.scorpBotData.FilteredWords)
                    {
                        ChannelSession.Settings.FilteredWords.Add(filteredWord);
                    }
                    ChannelSession.Settings.ModerationFilteredWordsExcempt = this.scorpBotData.GetUserRoleSettingsValue("settings", "FilteredWordsPerm");
                }

                if (this.scorpBotData.GetBoolSettingsValue("settings", "chatcapschecknowarnregs"))
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.User;
                }
                else if (this.scorpBotData.GetBoolSettingsValue("settings", "chatcapschecknowarnsubs"))
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.Subscriber;
                }
                else if (this.scorpBotData.GetBoolSettingsValue("settings", "chatcapschecknowarnmods"))
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.Mod;
                }
                else
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.Streamer;
                }

                ChannelSession.Settings.ModerationCapsBlockIsPercentage = !this.scorpBotData.GetBoolSettingsValue("settings", "chatcapsfiltertype");
                if (ChannelSession.Settings.ModerationCapsBlockIsPercentage)
                {
                    ChannelSession.Settings.ModerationCapsBlockCount = this.scorpBotData.GetIntSettingsValue("settings", "chatperccaps");
                }
                else
                {
                    ChannelSession.Settings.ModerationCapsBlockCount = this.scorpBotData.GetIntSettingsValue("settings", "chatmincaps");
                }

                ChannelSession.Settings.ModerationBlockLinks        = this.scorpBotData.GetBoolSettingsValue("settings", "chatlinkalertsdel");
                ChannelSession.Settings.ModerationBlockLinksExcempt = this.scorpBotData.GetUserRoleSettingsValue("settings", "chatlinkalertsdelperm");
            }

            if (this.streamlabsChatBotData != null)
            {
                UserCurrencyViewModel rank = new UserCurrencyViewModel()
                {
                    Name = "Rank",
                    SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("rank"),
                    AcquireInterval   = 60,
                    AcquireAmount     = 1
                };

                foreach (StreamlabsChatBotRank slrank in this.streamlabsChatBotData.Ranks)
                {
                    rank.Ranks.Add(new UserRankViewModel(slrank.Name, slrank.Requirement));
                }

                UserCurrencyViewModel currency = new UserCurrencyViewModel()
                {
                    Name = "Points",
                    SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                    AcquireInterval   = 1,
                    AcquireAmount     = 1
                };

                ChannelSession.Settings.Currencies[rank.ID]     = rank;
                ChannelSession.Settings.Currencies[currency.ID] = currency;

                this.AddCurrencyRankCommands(rank);
                this.AddCurrencyRankCommands(currency);

                foreach (StreamlabsChatBotViewer viewer in this.streamlabsChatBotData.Viewers)
                {
                    UserModel user = await ChannelSession.Connection.GetUser(viewer.Name);

                    if (user != null)
                    {
                        viewer.ID = user.id;
                        ChannelSession.Settings.UserData[viewer.ID] = new UserDataViewModel(viewer);
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rank, viewer.Hours);
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(currency, viewer.Points);
                    }
                }

                foreach (StreamlabsChatBotCommand command in this.streamlabsChatBotData.Commands)
                {
                    command.ProcessData(currency, rank);
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
                }

                foreach (StreamlabsChatBotTimer timer in this.streamlabsChatBotData.Timers)
                {
                    StreamlabsChatBotCommand command = new StreamlabsChatBotCommand()
                    {
                        Command = timer.Name, Response = timer.Response, Enabled = timer.Enabled
                    };
                    command.ProcessData(currency, rank);
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));

                    timer.Actions = command.Actions;

                    ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
                }

                foreach (string quote in this.streamlabsChatBotData.Quotes)
                {
                    ChannelSession.Settings.UserQuotes.Add(new UserQuoteViewModel(quote));
                }

                if (ChannelSession.Settings.UserQuotes.Count > 0)
                {
                    ChannelSession.Settings.QuotesEnabled = true;
                }
            }

            if (this.soundwaveData != null && this.soundwaveProfiles != null && this.soundwaveProfiles.Count(p => p.AddProfile) > 0)
            {
                if (this.soundwaveData.StaticCooldown)
                {
                    ChannelSession.Settings.CooldownGroups[SoundwaveInteractiveCooldownGroupName] = this.soundwaveData.StaticCooldownAmount / 1000;
                }

                InteractiveGameListingModel soundwaveGame = this.interactiveGames.FirstOrDefault(g => g.name.Equals(SoundwaveInteractiveGameName));
                if (soundwaveGame != null)
                {
                    InteractiveGameVersionModel version = soundwaveGame.versions.FirstOrDefault();
                    if (version != null)
                    {
                        InteractiveGameVersionModel soundwaveGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(version);

                        if (soundwaveGameVersion != null)
                        {
                            InteractiveSceneModel soundwaveGameScene = soundwaveGameVersion.controls.scenes.FirstOrDefault();
                            if (soundwaveGameScene != null)
                            {
                                foreach (string profile in this.soundwaveProfiles.Where(p => p.AddProfile).Select(p => p.Name))
                                {
                                    // Add code logic to create Interactive Game on Mixer that is a copy of the Soundwave Interactive game, but with buttons filed in with name and not disabled
                                    InteractiveSceneModel       profileScene = InteractiveGameHelper.CreateDefaultScene();
                                    InteractiveGameListingModel profileGame  = await ChannelSession.Connection.CreateInteractiveGame(ChannelSession.Channel, ChannelSession.User, profile, profileScene);

                                    InteractiveGameVersionModel gameVersion = profileGame.versions.FirstOrDefault();
                                    if (gameVersion != null)
                                    {
                                        InteractiveGameVersionModel profileGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(gameVersion);

                                        if (profileGameVersion != null)
                                        {
                                            profileScene = profileGameVersion.controls.scenes.First();

                                            for (int i = 0; i < this.soundwaveData.Profiles[profile].Count(); i++)
                                            {
                                                SoundwaveButton soundwaveButton = this.soundwaveData.Profiles[profile][i];
                                                InteractiveButtonControlModel soundwaveControl = (InteractiveButtonControlModel)soundwaveGameScene.allControls.FirstOrDefault(c => c.controlID.Equals(i.ToString()));

                                                InteractiveButtonControlModel button = InteractiveGameHelper.CreateButton(soundwaveButton.name, soundwaveButton.name, soundwaveButton.sparks);
                                                button.position = soundwaveControl.position;

                                                RequirementViewModel requirements = new RequirementViewModel();
                                                requirements.Cooldown.Amount = soundwaveButton.cooldown;
                                                if (this.soundwaveData.StaticCooldown)
                                                {
                                                    requirements.Cooldown.Type      = CooldownTypeEnum.Group;
                                                    requirements.Cooldown.GroupName = SoundwaveInteractiveCooldownGroupName;
                                                }
                                                InteractiveButtonCommand command = new InteractiveButtonCommand(profileGame, profileScene, button, InteractiveButtonCommandTriggerType.MouseDown, requirements);

                                                SoundAction action = new SoundAction(soundwaveButton.path, soundwaveButton.volume);
                                                command.Actions.Add(action);

                                                ChannelSession.Settings.InteractiveCommands.Add(command);
                                                profileScene.buttons.Add(button);
                                            }

                                            await ChannelSession.Connection.UpdateInteractiveGameVersion(profileGameVersion);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            await ChannelSession.SaveSettings();
        }
예제 #10
0
        private static async Task Version4Upgrade(int version, string filePath)
        {
            if (version < 4)
            {
                string data = File.ReadAllText(filePath);
                data = data.Replace("MixItUp.Base.Actions.RankAction", "MixItUp.Base.Actions.CurrencyAction");
                data = data.Replace("\"Type\": 13\n", "\"Type\": 1\n");
                File.WriteAllText(filePath, data);

                LegacyDesktopChannelSettings legacySettings = await SerializerHelper.DeserializeFromFile <LegacyDesktopChannelSettings>(filePath);

                legacySettings.InitializeDB = false;

                List <LegacyUserDataViewModel> legacyUsers = new List <LegacyUserDataViewModel>();
                if (legacySettings.IsStreamer)
                {
                    string dbPath = ((DesktopSettingsService)ChannelSession.Services.Settings).GetDatabaseFilePath(legacySettings);
                    SQLiteDatabaseWrapper databaseWrapper = new SQLiteDatabaseWrapper(dbPath);
                    await databaseWrapper.RunReadCommand("SELECT * FROM Users", (SQLiteDataReader dataReader) =>
                    {
                        LegacyUserDataViewModel userData = new LegacyUserDataViewModel(dataReader);
                        legacyUsers.Add(userData);
                    });

                    File.Copy(DesktopSettingsService.SettingsTemplateDatabaseFileName, dbPath, overwrite: true);
                }

                await ChannelSession.Services.Settings.Initialize(legacySettings);

                DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath);

                settings.InitializeDB = false;
                await ChannelSession.Services.Settings.Initialize(settings);

                UserCurrencyViewModel currency = null;
                UserCurrencyViewModel rank     = null;
                if (settings.IsStreamer)
                {
                    if (!string.IsNullOrEmpty(legacySettings.CurrencyAcquisition.Name))
                    {
                        currency = legacySettings.CurrencyAcquisition;
                        currency.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currency.Name);
                        settings.Currencies.Add(legacySettings.CurrencyAcquisition.ID, legacySettings.CurrencyAcquisition);
                    }

                    if (!string.IsNullOrEmpty(legacySettings.RankAcquisition.Name))
                    {
                        rank = legacySettings.RankAcquisition;
                        rank.SpecialIdentifier  = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rank.Name);
                        rank.Ranks              = legacySettings.Ranks;
                        rank.RankChangedCommand = legacySettings.RankChangedCommand;
                        settings.Currencies.Add(legacySettings.RankAcquisition.ID, legacySettings.RankAcquisition);
                    }

                    foreach (LegacyUserDataViewModel user in legacyUsers)
                    {
                        settings.UserData[user.ID] = user;
                        if (rank != null)
                        {
                            settings.UserData[user.ID].SetCurrencyAmount(rank, user.RankPoints);
                        }
                        if (currency != null)
                        {
                            settings.UserData[user.ID].SetCurrencyAmount(currency, user.CurrencyAmount);
                        }
                    }

                    if (currency != null)
                    {
                        if (legacySettings.GiveawayCurrencyCost > 0)
                        {
                            settings.GiveawayCurrencyRequirement = new UserCurrencyRequirementViewModel(currency, legacySettings.GiveawayCurrencyCost);
                        }
                        if (legacySettings.GameQueueCurrencyCost > 0)
                        {
                            settings.GameQueueCurrencyRequirement = new UserCurrencyRequirementViewModel(currency, legacySettings.GameQueueCurrencyCost);
                        }
                    }

                    if (rank != null)
                    {
                        if (legacySettings.GiveawayUserRank != null && rank.Ranks.Any(r => r.Name.Equals(legacySettings.GiveawayUserRank)))
                        {
                            settings.GiveawayRankRequirement = new UserCurrencyRequirementViewModel(rank, rank.Ranks.FirstOrDefault(r => r.Name.Equals(legacySettings.GiveawayUserRank)));
                        }
                        if (legacySettings.GameQueueMinimumRank != null)
                        {
                            settings.GameQueueRankRequirement = new UserCurrencyRequirementViewModel(rank, legacySettings.GameQueueMinimumRank);
                        }
                    }
                }

                List <CommandBase> commands = new List <CommandBase>();
                commands.AddRange(settings.ChatCommands);
                commands.AddRange(settings.InteractiveCommands);
                commands.AddRange(settings.EventCommands);
                commands.AddRange(settings.TimerCommands);

                foreach (CommandBase command in commands)
                {
                    foreach (ActionBase action in command.Actions)
                    {
                        if (action is ChatAction)
                        {
                            ChatAction nAction = (ChatAction)action;
                            nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ChatText, currency, rank);
                        }
                        else if (action is CurrencyAction)
                        {
                            CurrencyAction nAction = (CurrencyAction)action;
                            nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ChatText, currency, rank);
                        }
                        else if (action is OBSStudioAction)
                        {
                            OBSStudioAction nAction = (OBSStudioAction)action;
                            nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SourceText, currency, rank);
                        }
                        else if (action is OverlayAction)
                        {
                            OverlayAction nAction = (OverlayAction)action;
                            nAction.ImagePath = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ImagePath, currency, rank);
                            nAction.Text      = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.Text, currency, rank);
                        }
                        else if (action is TextToSpeechAction)
                        {
                            TextToSpeechAction nAction = (TextToSpeechAction)action;
                            nAction.SpeechText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SpeechText, currency, rank);
                        }
                        else if (action is XSplitAction)
                        {
                            XSplitAction nAction = (XSplitAction)action;
                            nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SourceText, currency, rank);
                        }
                    }
                }

                if (settings.IsStreamer)
                {
                    foreach (ChatCommand command in settings.ChatCommands)
                    {
#pragma warning disable CS0612 // Type or member is obsolete
                        if (command.CurrencyCost > 0)
                        {
                            command.CurrencyRequirement = new UserCurrencyRequirementViewModel(currency, command.CurrencyCost);
                        }
#pragma warning restore CS0612 // Type or member is obsolete
                    }
                }

                await ChannelSession.Services.Settings.Save(settings);
            }
        }
        public async Task <bool> Validate()
        {
            if (string.IsNullOrEmpty(this.Name))
            {
                await DialogHelper.ShowMessage(string.Format(Resources.CurrencyRankNameRequired, this.CurrencyRankIdentifierString));

                return(false);
            }

            if (this.Name.Any(c => char.IsDigit(c)))
            {
                await DialogHelper.ShowMessage(Resources.CurrencyRankNameNoDigits);

                return(false);
            }

            CurrencyModel dupeCurrency = ChannelSession.Settings.Currency.Values.FirstOrDefault(c => c.Name.Equals(this.Name));

            if (dupeCurrency != null && (this.Currency == null || !this.Currency.ID.Equals(dupeCurrency.ID)))
            {
                await DialogHelper.ShowMessage(Resources.CurrencyRankNameDuplicate);

                return(false);
            }

            InventoryModel dupeInventory = ChannelSession.Settings.Inventory.Values.FirstOrDefault(c => c.Name.Equals(this.Name));

            if (dupeInventory != null)
            {
                await DialogHelper.ShowMessage(Resources.InventoryNameDuplicate);

                return(false);
            }

            string siName = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.Name);

            if (siName.Equals("time") || siName.Equals("hours") || siName.Equals("mins") || siName.Equals("sparks") || siName.Equals("embers") || siName.Equals("fanprogression"))
            {
                await DialogHelper.ShowMessage(Resources.CurrencyRankInventoryNameProtected + " time, hours, mins, sparks, embers, fanprogression");

                return(false);
            }

            if (string.IsNullOrEmpty(siName))
            {
                await DialogHelper.ShowMessage(Resources.CurrencyRankInventoryNameNotEmpty);

                return(false);
            }

            if (this.MaxAmount < 0)
            {
                await DialogHelper.ShowMessage(Resources.MaxAmountMustBeZeroOrMore);

                return(false);
            }

            if (this.OnlineRateAmount < 0 || this.OnlineRateInterval < 0)
            {
                await DialogHelper.ShowMessage(Resources.OnlineRateMustBeZeroOrMore);

                return(false);
            }

            if (this.OnlineRateAmount > 0 && this.OnlineRateInterval == 0)
            {
                await DialogHelper.ShowMessage(Resources.OnlineRateVsInterval1);

                return(false);
            }

            if (this.OfflineRateAmount < 0 || this.OfflineRateInterval < 0)
            {
                await DialogHelper.ShowMessage(Resources.OnlineRateVsInterval2);

                return(false);
            }

            if (this.OfflineRateAmount > 0 && this.OfflineRateInterval == 0)
            {
                await DialogHelper.ShowMessage(Resources.OfflineRateVsInterval);

                return(false);
            }

            if (this.RegularBonus < 0)
            {
                await DialogHelper.ShowMessage(Resources.RegularBonusZeroOrMore);

                return(false);
            }

            if (this.SubscriberBonus < 0)
            {
                await DialogHelper.ShowMessage(Resources.SubscriberBonusZeroOrMore);

                return(false);
            }

            if (this.ModeratorBonus < 0)
            {
                await DialogHelper.ShowMessage(Resources.ModeratorBonusZeroOrMore);

                return(false);
            }

            if (this.OnFollowBonus < 0)
            {
                await DialogHelper.ShowMessage(Resources.OnFollowBonusZeroOrMore);

                return(false);
            }

            if (this.OnHostBonus < 0)
            {
                await DialogHelper.ShowMessage(Resources.OnHostBonusZeroOrMore);

                return(false);
            }

            if (this.OnSubscribeBonus < 0)
            {
                await DialogHelper.ShowMessage(Resources.OnSubscribeBonusZeroOrMore);

                return(false);
            }

            if (this.IsRank)
            {
                if (this.Ranks.Count() < 1)
                {
                    await DialogHelper.ShowMessage(Resources.OneRankRequired);

                    return(false);
                }
            }

            if (this.MinimumActiveRate < 0)
            {
                await DialogHelper.ShowMessage(Resources.MinimumActivityRateZeroOrMore);

                return(false);
            }

            return(true);
        }
예제 #12
0
        public async Task <bool> Validate()
        {
            if (string.IsNullOrEmpty(this.Name))
            {
                await DialogHelper.ShowMessage(string.Format("A {0} name must be specified", this.CurrencyRankIdentifierString));

                return(false);
            }

            if (this.Name.Any(c => char.IsDigit(c)))
            {
                await DialogHelper.ShowMessage("The name can not contain any number digits in it");

                return(false);
            }

            CurrencyModel dupeCurrency = ChannelSession.Settings.Currency.Values.FirstOrDefault(c => c.Name.Equals(this.Name));

            if (dupeCurrency != null && (this.Currency == null || !this.Currency.ID.Equals(dupeCurrency.ID)))
            {
                await DialogHelper.ShowMessage("There already exists a currency or rank system with this name");

                return(false);
            }

            InventoryModel dupeInventory = ChannelSession.Settings.Inventory.Values.FirstOrDefault(c => c.Name.Equals(this.Name));

            if (dupeInventory != null)
            {
                await DialogHelper.ShowMessage("There already exists an inventory with this name");

                return(false);
            }

            string siName = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.Name);

            if (siName.Equals("time") || siName.Equals("hours") || siName.Equals("mins") || siName.Equals("sparks") || siName.Equals("embers") || siName.Equals("fanprogression"))
            {
                await DialogHelper.ShowMessage("The following names are reserved and can not be used: time, hours, mins, sparks, embers, fanprogression");

                return(false);
            }

            if (string.IsNullOrEmpty(siName))
            {
                await DialogHelper.ShowMessage("The name must have at least 1 letter in it");

                return(false);
            }

            if (this.MaxAmount < 0)
            {
                await DialogHelper.ShowMessage("The max amount must be greater than 0 or can be left as 0 for no max amount");

                return(false);
            }

            if (this.OnlineRateAmount < 0 || this.OnlineRateInterval < 0)
            {
                await DialogHelper.ShowMessage("The online amount & minutes must be 0 or greater");

                return(false);
            }

            if (this.OnlineRateAmount > 0 && this.OnlineRateInterval == 0)
            {
                await DialogHelper.ShowMessage("The online minutes can not be 0 if the online amount is greater than 0");

                return(false);
            }

            if (this.OfflineRateAmount < 0 || this.OfflineRateInterval < 0)
            {
                await DialogHelper.ShowMessage("The offline amount & minutes must be 0 or greater");

                return(false);
            }

            if (this.OfflineRateAmount > 0 && this.OfflineRateInterval == 0)
            {
                await DialogHelper.ShowMessage("The offline minutes can not be 0 if the offline amount is greater than 0");

                return(false);
            }

            if (this.RegularBonus < 0)
            {
                await DialogHelper.ShowMessage("The Regular bonus must be 0 or greater");

                return(false);
            }

            if (this.SubscriberBonus < 0)
            {
                await DialogHelper.ShowMessage("The Subscriber bonus must be 0 or greater");

                return(false);
            }

            if (this.ModeratorBonus < 0)
            {
                await DialogHelper.ShowMessage("The Moderator bonus must be 0 or greater");

                return(false);
            }

            if (this.OnFollowBonus < 0)
            {
                await DialogHelper.ShowMessage("The On Follow bonus must be 0 or greater");

                return(false);
            }

            if (this.OnHostBonus < 0)
            {
                await DialogHelper.ShowMessage("The On Host bonus must be 0 or greater");

                return(false);
            }

            if (this.OnSubscribeBonus < 0)
            {
                await DialogHelper.ShowMessage("The On Subscribe bonus must be 0 or greater");

                return(false);
            }

            if (this.IsRank)
            {
                if (this.Ranks.Count() < 1)
                {
                    await DialogHelper.ShowMessage("At least one rank must be created");

                    return(false);
                }
            }

            if (this.MinimumActiveRate < 0)
            {
                await DialogHelper.ShowMessage("The Minimum Activity Rate must be 0 or greater");

                return(false);
            }

            return(true);
        }
        private async Task FinalizeNewUser()
        {
            if (this.scorpBotData != null)
            {
                // Import Ranks
                int    rankEnabled   = int.Parse(this.scorpBotData.GetSettingsValue("currency", "enabled", "0"));
                string rankName      = this.scorpBotData.GetSettingsValue("currency", "name", "Rank");
                int    rankInterval  = int.Parse(this.scorpBotData.GetSettingsValue("currency", "onlinepayinterval", "0"));
                int    rankAmount    = int.Parse(this.scorpBotData.GetSettingsValue("currency", "activeuserbonus", "0"));
                int    rankMaxAmount = int.Parse(this.scorpBotData.GetSettingsValue("currency", "maxlimit", "-1"));
                if (rankMaxAmount <= 0)
                {
                    rankMaxAmount = int.MaxValue;
                }
                int    rankOnFollowBonus    = int.Parse(this.scorpBotData.GetSettingsValue("currency", "onfollowbonus", "0"));
                int    rankOnSubBonus       = int.Parse(this.scorpBotData.GetSettingsValue("currency", "onsubbonus", "0"));
                int    rankSubBonus         = int.Parse(this.scorpBotData.GetSettingsValue("currency", "subbonus", "0"));
                string rankCommand          = this.scorpBotData.GetSettingsValue("currency", "command", "");
                string rankCommandResponse  = this.scorpBotData.GetSettingsValue("currency", "response", "");
                string rankUpCommand        = this.scorpBotData.GetSettingsValue("currency", "Currency1RankUpMsg", "");
                int    rankAccumulationType = int.Parse(this.scorpBotData.GetSettingsValue("currency", "ranksrectype", "0"));

                UserCurrencyViewModel rankCurrency       = null;
                UserCurrencyViewModel rankPointsCurrency = null;
                if (rankEnabled == 1 && !string.IsNullOrEmpty(rankName))
                {
                    if (rankAccumulationType == 1)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName.Equals("Points") ? "Hours" : rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName.Equals("Points") ? "Hours" : rankName),
                            AcquireInterval   = 60,
                            AcquireAmount     = 1,
                            MaxAmount         = rankMaxAmount,
                        };

                        if (rankInterval >= 0 && rankAmount >= 0)
                        {
                            rankPointsCurrency = new UserCurrencyViewModel()
                            {
                                Name = "Points",
                                SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                                AcquireInterval   = rankInterval,
                                AcquireAmount     = rankAmount,
                                MaxAmount         = rankMaxAmount,
                                OnFollowBonus     = rankOnFollowBonus,
                                OnSubscribeBonus  = rankOnSubBonus,
                                SubscriberBonus   = rankSubBonus
                            };

                            ChannelSession.Settings.Currencies[rankPointsCurrency.ID] = rankPointsCurrency;
                        }
                    }
                    else if (rankInterval >= 0 && rankAmount >= 0)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName),
                            AcquireInterval   = rankInterval,
                            AcquireAmount     = rankAmount,
                            MaxAmount         = rankMaxAmount,
                            OnFollowBonus     = rankOnFollowBonus,
                            OnSubscribeBonus  = rankOnSubBonus,
                            SubscriberBonus   = rankSubBonus
                        };
                    }
                }

                // Import Currency
                int    currencyEnabled   = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "enabled", "0"));
                string currencyName      = this.scorpBotData.GetSettingsValue("currency2", "name", "Currency");
                int    currencyInterval  = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "onlinepayinterval", "0"));
                int    currencyAmount    = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "activeuserbonus", "0"));
                int    currencyMaxAmount = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "maxlimit", "-1"));
                if (currencyMaxAmount <= 0)
                {
                    currencyMaxAmount = int.MaxValue;
                }
                int    currencyOnFollowBonus   = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "onfollowbonus", "0"));
                int    currencyOnSubBonus      = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "onsubbonus", "0"));
                int    currencySubBonus        = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "subbonus", "0"));
                string currencyCommand         = this.scorpBotData.GetSettingsValue("currency2", "command", "");
                string currencyCommandResponse = this.scorpBotData.GetSettingsValue("currency2", "response", "");

                UserCurrencyViewModel currency = null;
                if (currencyEnabled == 1 && !string.IsNullOrEmpty(currencyName) && currencyInterval >= 0 && currencyAmount >= 0)
                {
                    currency = new UserCurrencyViewModel()
                    {
                        Name            = currencyName, SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currencyName), AcquireInterval = currencyInterval,
                        AcquireAmount   = currencyAmount, MaxAmount = currencyMaxAmount, OnFollowBonus = currencyOnFollowBonus, OnSubscribeBonus = currencyOnSubBonus,
                        SubscriberBonus = currencySubBonus
                    };
                    ChannelSession.Settings.Currencies[currency.ID] = currency;

                    if (!string.IsNullOrEmpty(currencyCommand) && !string.IsNullOrEmpty(currencyCommandResponse))
                    {
                        currencyCommandResponse = currencyCommandResponse.Replace("$points2", "$" + currency.UserAmountSpecialIdentifier);
                        currencyCommandResponse = currencyCommandResponse.Replace("$currencyname2", currency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(currencyCommand, currencyCommandResponse));
                    }
                }

                foreach (ScorpBotViewer viewer in this.scorpBotData.Viewers)
                {
                    ChannelSession.Settings.UserData[viewer.ID] = new UserDataViewModel(viewer);

                    if (rankPointsCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankPointsCurrency, (int)viewer.RankPoints);
                    }

                    if (rankCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankCurrency, (rankPointsCurrency != null) ? (int)viewer.Hours : (int)viewer.RankPoints);
                    }

                    if (currency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(currency, (int)viewer.Currency);
                    }
                }

                if (rankCurrency != null)
                {
                    ChannelSession.Settings.Currencies[rankCurrency.ID] = rankCurrency;

                    foreach (ScorpBotRank rank in this.scorpBotData.Ranks)
                    {
                        rankCurrency.Ranks.Add(new UserRankViewModel(rank.Name, rank.Amount));
                    }

                    if (!string.IsNullOrEmpty(rankCommand) && !string.IsNullOrEmpty(rankCommandResponse))
                    {
                        rankCommandResponse = rankCommandResponse.Replace(" / Raids: $raids", "");
                        rankCommandResponse = rankCommandResponse.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$currencyname", rankCurrency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(rankCommand, rankCommandResponse));
                    }

                    if (!string.IsNullOrEmpty(rankUpCommand))
                    {
                        rankUpCommand = rankUpCommand.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$currencyname", rankCurrency.Name);

                        ScorpBotCommand scorpCommand = new ScorpBotCommand("rankup", rankUpCommand);
                        ChatCommand     chatCommand  = new ChatCommand(scorpCommand);

                        rankCurrency.RankChangedCommand = new CustomCommand("User Rank Changed");
                        rankCurrency.RankChangedCommand.Actions.AddRange(chatCommand.Actions);
                    }
                }

                foreach (ScorpBotCommand command in this.scorpBotData.Commands)
                {
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
                }

                foreach (ScorpBotTimer timer in this.scorpBotData.Timers)
                {
                    ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
                }

                foreach (string quote in this.scorpBotData.Quotes)
                {
                    ChannelSession.Settings.UserQuotes.Add(new UserQuoteViewModel(quote));
                }

                if (ChannelSession.Settings.UserQuotes.Count > 0)
                {
                    ChannelSession.Settings.QuotesEnabled = true;
                }

                foreach (string bannedWord in this.scorpBotData.BannedWords)
                {
                    ChannelSession.Settings.BannedWords.Add(bannedWord);
                }
            }

            if (this.soundwaveData != null && this.soundwaveProfiles != null && this.soundwaveProfiles.Count(p => p.AddProfile) > 0)
            {
                if (this.soundwaveData.StaticCooldown)
                {
                    ChannelSession.Settings.InteractiveCooldownGroups.Add(SoundwaveInteractiveCooldownGroupName, this.soundwaveData.StaticCooldownAmount / 1000);
                }

                InteractiveGameListingModel soundwaveGame = this.interactiveGames.FirstOrDefault(g => g.name.Equals(SoundwaveInteractiveGameName));
                if (soundwaveGame != null)
                {
                    InteractiveGameVersionModel soundwaveGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(soundwaveGame.versions.First());

                    InteractiveSceneModel soundwaveGameScene = soundwaveGameVersion.controls.scenes.First();

                    foreach (string profile in this.soundwaveProfiles.Where(p => p.AddProfile).Select(p => p.Name))
                    {
                        // Add code logic to create Interactive Game on Mixer that is a copy of the Soundwave Interactive game, but with buttons filed in with name and not disabled
                        InteractiveSceneModel       profileScene = InteractiveGameHelper.CreateDefaultScene();
                        InteractiveGameListingModel profileGame  = await ChannelSession.Connection.CreateInteractiveGame(ChannelSession.Channel, ChannelSession.User, profile, profileScene);

                        InteractiveGameVersionModel gameVersion = profileGame.versions.FirstOrDefault();
                        if (gameVersion != null)
                        {
                            InteractiveGameVersionModel profileGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(gameVersion);

                            if (profileGameVersion != null)
                            {
                                profileScene = profileGameVersion.controls.scenes.First();

                                for (int i = 0; i < this.soundwaveData.Profiles[profile].Count(); i++)
                                {
                                    SoundwaveButton soundwaveButton = this.soundwaveData.Profiles[profile][i];
                                    InteractiveButtonControlModel soundwaveControl = (InteractiveButtonControlModel)soundwaveGameScene.allControls.FirstOrDefault(c => c.controlID.Equals(i.ToString()));

                                    InteractiveButtonControlModel button = InteractiveGameHelper.CreateButton(soundwaveButton.name, soundwaveButton.name, soundwaveButton.sparks);
                                    button.position = soundwaveControl.position;

                                    InteractiveCommand command = new InteractiveCommand(profileGame, profileScene, button, InteractiveButtonCommandTriggerType.MouseDown);
                                    command.IndividualCooldown = soundwaveButton.cooldown;
                                    if (this.soundwaveData.StaticCooldown)
                                    {
                                        command.CooldownGroup = SoundwaveInteractiveCooldownGroupName;
                                    }

                                    SoundAction action = new SoundAction(soundwaveButton.path, soundwaveButton.volume);
                                    command.Actions.Add(action);

                                    ChannelSession.Settings.InteractiveCommands.Add(command);
                                    profileScene.buttons.Add(button);
                                }

                                await ChannelSession.Connection.UpdateInteractiveGameVersion(profileGameVersion);
                            }
                        }
                    }
                }
            }

            await ChannelSession.SaveSettings();
        }
예제 #14
0
        public void ImportSettings()
        {
            // Import Ranks
            int    rankEnabled   = this.GetIntSettingsValue("currency", "enabled");
            string rankName      = this.GetSettingsValue("currency", "name", "Rank");
            int    rankInterval  = this.GetIntSettingsValue("currency", "onlinepayinterval");
            int    rankAmount    = this.GetIntSettingsValue("currency", "activeuserbonus");
            int    rankMaxAmount = this.GetIntSettingsValue("currency", "maxlimit");

            if (rankMaxAmount <= 0)
            {
                rankMaxAmount = int.MaxValue;
            }
            int    rankOnFollowBonus    = this.GetIntSettingsValue("currency", "onfollowbonus");
            int    rankOnSubBonus       = this.GetIntSettingsValue("currency", "onsubbonus");
            int    rankSubBonus         = this.GetIntSettingsValue("currency", "subbonus");
            string rankCommand          = this.GetSettingsValue("currency", "command", "");
            string rankCommandResponse  = this.GetSettingsValue("currency", "response", "");
            string rankUpCommand        = this.GetSettingsValue("currency", "Currency1RankUpMsg", "");
            int    rankAccumulationType = this.GetIntSettingsValue("currency", "ranksrectype");

            CurrencyModel rankCurrency       = null;
            CurrencyModel rankPointsCurrency = null;

            if (!string.IsNullOrEmpty(rankName))
            {
                if (rankAccumulationType == 1)
                {
                    rankCurrency = new CurrencyModel()
                    {
                        Name = rankName.Equals("Points") ? "Hours" : rankName,
                        SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName.Equals("Points") ? "Hours" : rankName),
                        AcquireInterval   = 60,
                        AcquireAmount     = 1,
                        MaxAmount         = rankMaxAmount,
                    };

                    if (rankInterval >= 0 && rankAmount >= 0)
                    {
                        rankPointsCurrency = new CurrencyModel()
                        {
                            Name = "Points",
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                            AcquireInterval   = rankInterval,
                            AcquireAmount     = rankAmount,
                            MaxAmount         = rankMaxAmount,
                            OnFollowBonus     = rankOnFollowBonus,
                            OnSubscribeBonus  = rankOnSubBonus,
                            SubscriberBonus   = rankSubBonus,
                            ModeratorBonus    = rankSubBonus,
                            IsPrimary         = true
                        };

                        ChannelSession.Settings.Currency[rankPointsCurrency.ID] = rankPointsCurrency;
                    }
                }
                else if (rankInterval >= 0 && rankAmount >= 0)
                {
                    rankCurrency = new CurrencyModel()
                    {
                        Name = rankName,
                        SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName),
                        AcquireInterval   = rankInterval,
                        AcquireAmount     = rankAmount,
                        MaxAmount         = rankMaxAmount,
                        OnFollowBonus     = rankOnFollowBonus,
                        OnSubscribeBonus  = rankOnSubBonus,
                        SubscriberBonus   = rankSubBonus,
                        ModeratorBonus    = rankSubBonus,
                        IsPrimary         = true
                    };
                }
            }

            // Import Currency
            int    currencyEnabled   = this.GetIntSettingsValue("currency2", "enabled");
            string currencyName      = this.GetSettingsValue("currency2", "name", "Currency");
            int    currencyInterval  = this.GetIntSettingsValue("currency2", "onlinepayinterval");
            int    currencyAmount    = this.GetIntSettingsValue("currency2", "activeuserbonus");
            int    currencyMaxAmount = this.GetIntSettingsValue("currency2", "maxlimit");

            if (currencyMaxAmount <= 0)
            {
                currencyMaxAmount = int.MaxValue;
            }
            int    currencyOnFollowBonus   = this.GetIntSettingsValue("currency2", "onfollowbonus");
            int    currencyOnSubBonus      = this.GetIntSettingsValue("currency2", "onsubbonus");
            int    currencySubBonus        = this.GetIntSettingsValue("currency2", "subbonus");
            string currencyCommand         = this.GetSettingsValue("currency2", "command", "");
            string currencyCommandResponse = this.GetSettingsValue("currency2", "response", "");

            CurrencyModel currency = null;

            if (!string.IsNullOrEmpty(currencyName) && currencyInterval >= 0 && currencyAmount >= 0)
            {
                currency = new CurrencyModel()
                {
                    Name = currencyName,
                    SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currencyName),
                    AcquireInterval   = currencyInterval,
                    AcquireAmount     = currencyAmount,
                    MaxAmount         = currencyMaxAmount,
                    OnFollowBonus     = currencyOnFollowBonus,
                    OnSubscribeBonus  = currencyOnSubBonus,
                    IsPrimary         = true
                };
                ChannelSession.Settings.Currency[currency.ID] = currency;

                if (!string.IsNullOrEmpty(currencyCommand) && !string.IsNullOrEmpty(currencyCommandResponse))
                {
                    currencyCommandResponse = currencyCommandResponse.Replace("$points2", "$" + currency.UserAmountSpecialIdentifier);
                    currencyCommandResponse = currencyCommandResponse.Replace("$currencyname2", currency.Name);
                    this.Commands.Add(new ScorpBotCommandModel(currencyCommand, currencyCommandResponse));
                }
            }

            if (rankCurrency != null)
            {
                ChannelSession.Settings.Currency[rankCurrency.ID] = rankCurrency;

                foreach (ScorpBotRankModel rank in this.Ranks)
                {
                    rankCurrency.Ranks.Add(new RankModel(rank.Name, rank.Amount));
                }

                if (!string.IsNullOrEmpty(rankCommand) && !string.IsNullOrEmpty(rankCommandResponse))
                {
                    rankCommandResponse = rankCommandResponse.Replace(" / Raids: $raids", "");
                    rankCommandResponse = rankCommandResponse.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                    rankCommandResponse = rankCommandResponse.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                    rankCommandResponse = rankCommandResponse.Replace("$currencyname", rankCurrency.Name);
                    this.Commands.Add(new ScorpBotCommandModel(rankCommand, rankCommandResponse));
                }

                if (!string.IsNullOrEmpty(rankUpCommand))
                {
                    rankUpCommand = rankUpCommand.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                    rankUpCommand = rankUpCommand.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                    rankUpCommand = rankUpCommand.Replace("$currencyname", rankCurrency.Name);

                    ScorpBotCommandModel scorpCommand = new ScorpBotCommandModel("rankup", rankUpCommand);
                    ChatCommand          chatCommand  = new ChatCommand(scorpCommand);

                    rankCurrency.RankChangedCommand = new CustomCommand("User Rank Changed");
                    rankCurrency.RankChangedCommand.Actions.AddRange(chatCommand.Actions);
                }
            }

            foreach (ScorpBotCommandModel command in this.Commands)
            {
                command.ProcessData(currency, rankCurrency);
                ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
            }

            foreach (ScorpBotTimerModel timer in this.Timers)
            {
                ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
            }

            foreach (string quote in this.Quotes)
            {
                ChannelSession.Settings.Quotes.Add(new UserQuoteViewModel(quote, DateTimeOffset.MinValue));
            }

            if (ChannelSession.Settings.Quotes.Count > 0)
            {
                ChannelSession.Settings.QuotesEnabled = true;
            }

            if (this.GetBoolSettingsValue("settings", "filtwordsen"))
            {
                foreach (string filteredWord in this.FilteredWords)
                {
                    ChannelSession.Settings.FilteredWords.Add(filteredWord);
                }
                ChannelSession.Settings.ModerationFilteredWordsExcempt = this.GetUserRoleSettingsValue("settings", "FilteredWordsPerm");
            }

            if (this.GetBoolSettingsValue("settings", "chatcapschecknowarnregs"))
            {
                ChannelSession.Settings.ModerationChatTextExcempt = UserRoleEnum.User;
            }
            else if (this.GetBoolSettingsValue("settings", "chatcapschecknowarnsubs"))
            {
                ChannelSession.Settings.ModerationChatTextExcempt = UserRoleEnum.Subscriber;
            }
            else if (this.GetBoolSettingsValue("settings", "chatcapschecknowarnmods"))
            {
                ChannelSession.Settings.ModerationChatTextExcempt = UserRoleEnum.Mod;
            }
            else
            {
                ChannelSession.Settings.ModerationChatTextExcempt = UserRoleEnum.Streamer;
            }

            ChannelSession.Settings.ModerationCapsBlockIsPercentage = !this.GetBoolSettingsValue("settings", "chatcapsfiltertype");
            if (ChannelSession.Settings.ModerationCapsBlockIsPercentage)
            {
                ChannelSession.Settings.ModerationCapsBlockCount = this.GetIntSettingsValue("settings", "chatperccaps");
            }
            else
            {
                ChannelSession.Settings.ModerationCapsBlockCount = this.GetIntSettingsValue("settings", "chatmincaps");
            }

            ChannelSession.Settings.ModerationBlockLinks        = this.GetBoolSettingsValue("settings", "chatlinkalertsdel");
            ChannelSession.Settings.ModerationBlockLinksExcempt = this.GetUserRoleSettingsValue("settings", "chatlinkalertsdelperm");

            foreach (ScorpBotViewerModel viewer in this.Viewers)
            {
                UserDataModel userData = new UserDataModel(viewer);
                ChannelSession.Settings.AddUserData(userData);

                UserViewModel user = new UserViewModel(userData);
                if (rankPointsCurrency != null)
                {
                    rankPointsCurrency.SetAmount(userData, (int)viewer.RankPoints);
                }

                if (rankCurrency != null)
                {
                    rankCurrency.SetAmount(userData, (rankPointsCurrency != null) ? (int)viewer.Hours : (int)viewer.RankPoints);
                }

                if (currency != null)
                {
                    currency.SetAmount(userData, (int)viewer.Currency);
                }
            }
        }