Exemple #1
0
 public ChatCommand(ScorpBotCommand command)
     : this(command.Command, command.Command, command.Requirements)
 {
     this.Actions.AddRange(command.Actions);
     this.IncludeExclamationInCommands = command.ContainsExclamation;
     this.IsEnabled = command.Enabled;
 }
Exemple #2
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();
        }
        private async Task <ScorpBotData> GatherScorpBotData(string folderPath)
        {
            try
            {
                ScorpBotData scorpBotData = new ScorpBotData();

                string dataPath         = Path.Combine(folderPath, "Data");
                string settingsFilePath = Path.Combine(dataPath, "settings.ini");
                if (Directory.Exists(dataPath) && File.Exists(settingsFilePath))
                {
                    IEnumerable <string> lines = File.ReadAllLines(settingsFilePath);

                    string currentGroup = null;
                    foreach (var line in lines)
                    {
                        if (line.Contains("="))
                        {
                            string[] splits = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                            if (splits.Count() == 2)
                            {
                                scorpBotData.Settings[currentGroup].Add(splits[0], splits[1]);
                            }
                        }
                        else
                        {
                            currentGroup = line.Replace("[", "").Replace("]", "").ToLower();
                            scorpBotData.Settings.Add(currentGroup, new Dictionary <string, string>());
                        }
                    }

                    string databasePath = Path.Combine(dataPath, "Database");
                    if (Directory.Exists(databasePath))
                    {
                        SQLiteDatabaseWrapper databaseWrapper = new SQLiteDatabaseWrapper(databasePath);

                        databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "CommandsDB.sqlite");
                        await databaseWrapper.RunReadCommand("SELECT * FROM RegCommand",
                                                             (reader) =>
                        {
                            if (ScorpBotCommand.IsACommand(reader))
                            {
                                scorpBotData.Commands.Add(new ScorpBotCommand(reader));
                            }
                        });

                        databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "Timers2DB.sqlite");
                        await databaseWrapper.RunReadCommand("SELECT * FROM TimeCommand",
                                                             (reader) =>
                        {
                            scorpBotData.Timers.Add(new ScorpBotTimer(reader));
                        });

                        databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "FilteredWordsDB.sqlite");
                        await databaseWrapper.RunReadCommand("SELECT * FROM Word",
                                                             (reader) =>
                        {
                            scorpBotData.BannedWords.Add(((string)reader["word"]).ToLower());
                        });

                        databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "QuotesDB.sqlite");
                        await databaseWrapper.RunReadCommand("SELECT * FROM Quotes",
                                                             (reader) =>
                        {
                            scorpBotData.Quotes.Add((string)reader["quote_text"]);
                        });

                        databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "RankDB.sqlite");
                        await databaseWrapper.RunReadCommand("SELECT * FROM Rank",
                                                             (reader) =>
                        {
                            scorpBotData.Ranks.Add(new ScorpBotRank(reader));
                        });

                        databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "Viewers3DB.sqlite");
                        await databaseWrapper.RunReadCommand("SELECT * FROM Viewer",
                                                             (reader) =>
                        {
                            scorpBotData.Viewers.Add(new ScorpBotViewer(reader));
                        });
                    }
                }

                return(scorpBotData);
            }
            catch (Exception ex) { Logger.Log(ex); }
            return(null);
        }
        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();
        }
Exemple #5
0
 public ChatCommand(ScorpBotCommand command)
     : this(command.Command, command.Command, command.Permission, command.Cooldown, null)
 {
     this.Actions.Add(new ChatAction(command.Text));
     this.IsEnabled = command.Enabled;
 }