Beispiel #1
0
        public static Dictionary <string, string> GetCustomTestSpecialIdentifiers(string name)
        {
            Dictionary <string, string> specialIdentifiers = CommandModelBase.GetGeneralTestSpecialIdentifiers();

            if (name.Equals(MixItUp.Base.Resources.InventoryItemsBoughtCommandName) || name.Equals(MixItUp.Base.Resources.InventoryItemsSoldCommandName))
            {
                specialIdentifiers["itemtotal"]    = "5";
                specialIdentifiers["itemname"]     = "Chocolate Bars";
                specialIdentifiers["itemcost"]     = "500";
                specialIdentifiers["currencyname"] = "CURRENCY_NAME";
            }
            else if (name.Contains(MixItUp.Base.Resources.ModerationStrikeCommandName))
            {
                specialIdentifiers[ModerationService.ModerationReasonSpecialIdentifier] = "Bad Stuff";
            }
            else if (name.Equals(MixItUp.Base.Resources.RedemptionStoreManualRedeemNeededCommandName) || name.Equals(MixItUp.Base.Resources.RedemptionStoreDefaultRedemptionCommandName))
            {
                specialIdentifiers[RedemptionStoreProductModel.ProductNameSpecialIdentifier] = "Test Product";
            }
            else if (name.Equals(MixItUp.Base.Resources.GameQueueUserJoinedCommandName) || name.Equals(MixItUp.Base.Resources.GameQueueUserSelectedCommandName))
            {
                specialIdentifiers["queueposition"] = "1";
            }
            return(specialIdentifiers);
        }
        public override async Task CustomRun(CommandParametersModel parameters)
        {
            if (parameters.Arguments.Count() == 1)
            {
                string commandTrigger = parameters.Arguments.ElementAt(0).ToLower();

                CommandModelBase command = ChannelSession.Services.Command.AllEnabledChatAccessibleCommands.FirstOrDefault(c => c.Triggers.Contains(commandTrigger, StringComparer.InvariantCultureIgnoreCase));
                if (command == null)
                {
                    await ChannelSession.Services.Chat.SendMessage("ERROR: Could not find any command with that trigger");

                    return;
                }

                command.IsEnabled = false;

                if (ChannelSession.Services.Chat != null)
                {
                    await ChannelSession.Services.Chat.SendMessage("Disabled Command: !" + commandTrigger);

                    ChannelSession.Services.Chat.RebuildCommandTriggers();
                }
            }
            else
            {
                await ChannelSession.Services.Chat.SendMessage("Usage: !disablecommand <COMMAND TRIGGER, NO !>");
            }
        }
        public override async Task CustomRun(CommandParametersModel parameters)
        {
            if (parameters.Arguments.Count() >= 2)
            {
                string commandTrigger = parameters.Arguments.ElementAt(0).ToLower();

                CommandModelBase command = ChannelSession.Services.Command.AllEnabledChatAccessibleCommands.FirstOrDefault(c => c.Triggers.Contains(commandTrigger, StringComparer.InvariantCultureIgnoreCase));
                if (command == null)
                {
                    await ChannelSession.Services.Chat.SendMessage("ERROR: Could not find any command with that trigger");

                    return;
                }

                if (!int.TryParse(parameters.Arguments.ElementAt(1), out int cooldown) || cooldown < 0)
                {
                    await ChannelSession.Services.Chat.SendMessage("ERROR: Cooldown must be 0 or greater");

                    return;
                }

                if (command.Requirements.Cooldown != null)
                {
                    command.Requirements.Cooldown.IndividualAmount = cooldown;
                }

                if (parameters.Arguments.Count() > 2)
                {
                    StringBuilder commandTextBuilder = new StringBuilder();
                    foreach (string arg in parameters.Arguments.Skip(2))
                    {
                        commandTextBuilder.Append(arg + " ");
                    }

                    string commandText = commandTextBuilder.ToString();
                    commandText = commandText.Trim(new char[] { ' ', '\'', '\"' });

                    command.Actions.Clear();
                    command.Actions.Add(new ChatActionModel(commandText));
                }

                if (ChannelSession.Services.Chat != null)
                {
                    await ChannelSession.Services.Chat.SendMessage("Updated Command: !" + commandTrigger);

                    ChannelSession.Services.Chat.RebuildCommandTriggers();
                }
                ChannelSession.Settings.SetCommand(command);
            }
            else
            {
                await ChannelSession.Services.Chat.SendMessage("Usage: !updatecommand <COMMAND TRIGGER, NO !> <COOLDOWN> [OPTIONAL FULL COMMAND MESSAGE TEXT]");
            }
        }
 protected override async Task PerformInternal(CommandParametersModel parameters)
 {
     if (this.RunOneRandomly)
     {
         await CommandModelBase.RunActions(new List <ActionModelBase>() { this.Actions.Random() }, parameters);
     }
     else
     {
         await CommandModelBase.RunActions(this.Actions, parameters);
     }
 }
Beispiel #5
0
 public CommandInstanceModel(CommandModelBase command, CommandParametersModel parameters)
 {
     if (ChannelSession.Settings.Commands.ContainsKey(command.ID))
     {
         this.CommandID = command.ID;
     }
     else
     {
         this.command = command;
     }
     this.Parameters = parameters;
 }
Beispiel #6
0
        public override string ToString()
        {
            CommandModelBase command = this.Command;

            if (command != null)
            {
                return(command.Name);
            }
            else if (this.Actions.Count > 0)
            {
                return(MixItUp.Base.Resources.ActionList);
            }
            else
            {
                return(MixItUp.Base.Resources.Unknown);
            }
        }
Beispiel #7
0
        public HashSet <ActionTypeEnum> GetActionTypes()
        {
            CommandModelBase command = this.Command;

            if (command != null)
            {
                return(command.GetActionTypesInCommand());
            }
            else
            {
                HashSet <ActionTypeEnum> actionTypes = new HashSet <ActionTypeEnum>();
                foreach (ActionModelBase action in this.Actions)
                {
                    actionTypes.Add(action.Type);
                }
                return(actionTypes);
            }
        }
Beispiel #8
0
        public List <ActionModelBase> GetActions()
        {
            List <ActionModelBase> actions = new List <ActionModelBase>();

            CommandModelBase command = this.Command;

            if (command != null)
            {
                if (command is ActionGroupCommandModel && ((ActionGroupCommandModel)command).RunOneRandomly)
                {
                    actions.Add(command.Actions.Random());
                }
                else
                {
                    actions.AddRange(command.Actions);
                }
            }
            else
            {
                actions.AddRange(this.Actions);
            }

            return(actions);
        }
        public static Dictionary <string, string> GetEventTestSpecialIdentifiers(EventTypeEnum eventType)
        {
            Dictionary <string, string> specialIdentifiers = CommandModelBase.GetGeneralTestSpecialIdentifiers();

            switch (eventType)
            {
            case EventTypeEnum.TwitchChannelRaided:
                specialIdentifiers["hostviewercount"] = "123";
                specialIdentifiers["raidviewercount"] = "123";
                break;

            case EventTypeEnum.TwitchChannelSubscribed:
                specialIdentifiers["message"]         = "Test Message";
                specialIdentifiers["usersubplanname"] = "Plan Name";
                specialIdentifiers["usersubplan"]     = "Tier 1";
                break;

            case EventTypeEnum.TwitchChannelResubscribed:
                specialIdentifiers["message"]         = "Test Message";
                specialIdentifiers["usersubplanname"] = "Plan Name";
                specialIdentifiers["usersubplan"]     = "Tier 1";
                specialIdentifiers["usersubmonths"]   = "5";
                specialIdentifiers["usersubstreak"]   = "3";
                break;

            case EventTypeEnum.TwitchChannelSubscriptionGifted:
                specialIdentifiers["usersubplanname"]     = "Plan Name";
                specialIdentifiers["usersubplan"]         = "Tier 1";
                specialIdentifiers["usersubmonthsgifted"] = "3";
                specialIdentifiers["isanonymous"]         = "false";
                break;

            case EventTypeEnum.TwitchChannelMassSubscriptionsGifted:
                specialIdentifiers["subsgiftedamount"]         = "5";
                specialIdentifiers["subsgiftedlifetimeamount"] = "100";
                specialIdentifiers["usersubplan"] = "Tier 1";
                specialIdentifiers["isanonymous"] = "false";
                break;

            case EventTypeEnum.TwitchChannelBitsCheered:
                specialIdentifiers["bitsamount"] = "10";
                specialIdentifiers["Message"]    = "Test Message";
                break;

            case EventTypeEnum.TwitchChannelPointsRedeemed:
                specialIdentifiers["rewardname"] = "Test Reward";
                specialIdentifiers["rewardcost"] = "100";
                specialIdentifiers["message"]    = "Test Message";
                break;

            case EventTypeEnum.ChatUserTimeout:
                specialIdentifiers["timeoutlength"] = "5m";
                break;

            case EventTypeEnum.StreamlabsDonation:
            case EventTypeEnum.TiltifyDonation:
            case EventTypeEnum.ExtraLifeDonation:
            case EventTypeEnum.TipeeeStreamDonation:
            case EventTypeEnum.TreatStreamDonation:
            case EventTypeEnum.StreamJarDonation:
            case EventTypeEnum.JustGivingDonation:
            case EventTypeEnum.StreamElementsDonation:
                UserDonationModel donation = new UserDonationModel()
                {
                    Amount    = 12.34,
                    Message   = "Test donation message",
                    ImageLink = genericImage
                };

                switch (eventType)
                {
                case EventTypeEnum.StreamlabsDonation: donation.Source = UserDonationSourceEnum.Streamlabs; break;

                case EventTypeEnum.TiltifyDonation: donation.Source = UserDonationSourceEnum.Tiltify; break;

                case EventTypeEnum.ExtraLifeDonation: donation.Source = UserDonationSourceEnum.ExtraLife; break;

                case EventTypeEnum.TipeeeStreamDonation: donation.Source = UserDonationSourceEnum.TipeeeStream; break;

                case EventTypeEnum.TreatStreamDonation: donation.Source = UserDonationSourceEnum.TreatStream; break;

                case EventTypeEnum.StreamJarDonation: donation.Source = UserDonationSourceEnum.StreamJar; break;

                case EventTypeEnum.JustGivingDonation: donation.Source = UserDonationSourceEnum.JustGiving; break;

                case EventTypeEnum.StreamElementsDonation: donation.Source = UserDonationSourceEnum.StreamElements; break;
                }

                foreach (var kvp in donation.GetSpecialIdentifiers())
                {
                    specialIdentifiers[kvp.Key] = kvp.Value;
                }

                if (eventType == EventTypeEnum.TreatStreamDonation)
                {
                    specialIdentifiers["donationtype"] = "Pizza";
                }
                break;

            case EventTypeEnum.PatreonSubscribed:
                specialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierNameSpecialIdentifier]   = "Super Tier";
                specialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierAmountSpecialIdentifier] = "12.34";
                specialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierImageSpecialIdentifier]  = genericImage;
                break;

            case EventTypeEnum.StreamlootsCardRedeemed:
                specialIdentifiers["streamlootscardname"]  = "Test Card";
                specialIdentifiers["streamlootscardimage"] = "https://res.cloudinary.com/streamloots/image/upload/f_auto,c_scale,w_250,q_90/static/e19c7bf6-ca3e-49a8-807e-b2e9a1a47524/en_dl_character.png";
                specialIdentifiers["streamlootscardvideo"] = "https://cdn.streamloots.com/uploads/5c645b78666f31002f2979d1/3a6bf1dc-7d61-4f93-be0a-f5dc1d0d33b6.webm";
                specialIdentifiers["streamlootscardsound"] = "https://static.streamloots.com/b355d1ef-d931-4c16-a48f-8bed0076401b/alerts/default.mp3";
                specialIdentifiers["streamlootsmessage"]   = "Test Message";
                break;

            case EventTypeEnum.StreamlootsPackPurchased:
            case EventTypeEnum.StreamlootsPackGifted:
                specialIdentifiers["streamlootspurchasequantity"] = "1";
                break;
            }
            return(specialIdentifiers);
        }
Beispiel #10
0
 public CommandInstanceModel(CommandModelBase command) : this(command, new CommandParametersModel())
 {
 }