public SettingsRequirementViewModel(SettingsRequirementModel requirement)
 {
     this.ShowOnChatContextMenu = requirement.ShowOnChatContextMenu;
     if (ChannelSession.Settings.DeleteChatCommandsWhenRun)
     {
         this.DeleteChatMessageWhenRun = requirement.DontDeleteChatMessageWhenRun;
     }
     else
     {
         this.DeleteChatMessageWhenRun = requirement.DeleteChatMessageWhenRun;
     }
 }
Example #2
0
        private async Task RunChatCommand(ChatMessageViewModel message, CommandModelBase command, IEnumerable <string> arguments)
        {
            Logger.Log(LogLevel.Debug, string.Format("Command Found For Message - {0} - {1} - {2}", message.ID, message, command));
            await command.Perform(new CommandParametersModel(message.User, message.Platform, arguments));

            SettingsRequirementModel settings = command.Requirements.Settings;

            if (settings != null)
            {
                if (settings != null && settings.ShouldChatMessageBeDeletedWhenRun)
                {
                    await this.DeleteMessage(message);
                }
            }
        }
Example #3
0
        private async Task RunChatCommand(ChatMessageViewModel message, CommandModelBase command, IEnumerable <string> arguments)
        {
            Logger.Log(LogLevel.Debug, string.Format("Command Found For Message - {0} - {1} - {2}", message.ID, message, command));

            CommandParametersModel parameters = new CommandParametersModel(message);

            parameters.Arguments = new List <string>(arguments);   // Overwrite arguments to account for variable argument length for commands
            parameters.SpecialIdentifiers["message"] = message.PlainTextMessage;
            await ChannelSession.Services.Command.Queue(command, parameters);

            SettingsRequirementModel settings = command.Requirements.Settings;

            if (settings != null)
            {
                if (settings != null && settings.ShouldChatMessageBeDeletedWhenRun)
                {
                    await this.DeleteMessage(message);
                }
            }
        }
Example #4
0
        public void RebuildCommandTriggers()
        {
            try
            {
                this.triggersToCommands.Clear();
                this.longestTrigger = 0;
                this.wildcardCommands.Clear();
                this.chatMenuCommands.Clear();
                foreach (ChatCommandModel command in ChannelSession.AllEnabledChatAccessibleCommands)
                {
                    if (command.Wildcards)
                    {
                        this.wildcardCommands.Add(command);
                    }
                    else
                    {
                        foreach (string trigger in command.GetFullTriggers())
                        {
                            string t = trigger.ToLower();
                            this.triggersToCommands[t] = command;
                            this.longestTrigger        = Math.Max(this.longestTrigger, t.Length);
                        }
                    }

                    SettingsRequirementModel settings = command.Requirements.Settings;
                    if (settings != null && settings.ShowOnChatContextMenu)
                    {
                        this.chatMenuCommands.Add(command);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
            this.ChatCommandsReprocessed(this, new EventArgs());
        }