Пример #1
0
        protected override void GenerateUseCommands(List <ulong> perms)
        {
            // Generate base use commands from ContentModule
            base.GenerateUseCommands(perms);

            // Add verbose listing command
            List <ulong> allListPerms = new List <ulong>(_adminIds);

            allListPerms.AddRange(perms);
            Rule vlistRule = RuleGenerator.HasRoleByIds(allListPerms) & RuleGenerator.PrefixatedCommand(_prefix, "vlist");

            _useCommands.Add(new BotCommand($"{StringID}-vlistcmd", vlistRule, VerboseListCommand));
        }
Пример #2
0
        /// <summary>
        /// Generates content addition commands from specified list of allowed role IDs.
        /// </summary>
        /// <param name="perms">List of Roles IDs which are allowed to use Add commands.</param>
        protected virtual void GenerateAddCommands(List <ulong> perms)
        {
            List <ulong> allPerms = new List <ulong>(_adminIds);

            allPerms.AddRange(perms);
            Rule addRule = RuleGenerator.HasRoleByIds(allPerms) & RuleGenerator.PrefixatedCommand(_prefix, "add");

            IBotCommand addCmd = new BotCommand($"{StringID}-addcmd", addRule, AddCommand);

            _addCommands = new List <IBotCommand> {
                addCmd
            };
        }
Пример #3
0
        /// <summary>
        /// Generates content deletion commands from specified list of allowed role IDs.
        /// </summary>
        /// <param name="perms">List of Roles IDs which are allowed to use Delete commands.</param>
        protected virtual void GenerateDelCommands(List <ulong> perms)
        {
            List <ulong> allPerms = new List <ulong>(_adminIds);

            allPerms.AddRange(perms);
            Rule delRule = RuleGenerator.HasRoleByIds(allPerms) & RuleGenerator.PrefixatedCommand(_prefix, "del");

            IBotCommand delCmd = new BotCommand($"{StringID}-delcmd", delRule, DeleteCommand);

            _delCommands = new List <IBotCommand> {
                delCmd
            };
        }
Пример #4
0
        /// <summary>
        /// Generates module configuration commands from specified list of allowed role IDs.
        /// </summary>
        /// <param name="perms">List of Roles IDs which are allowed to use Config commands.</param>
        protected virtual void GenerateCfgCommands(List <ulong> perms)
        {
            List <ulong> allPerms = new List <ulong>(_adminIds);

            allPerms.AddRange(perms);
            Rule cmdRule = RuleGenerator.HasRoleByIds(allPerms) & RuleGenerator.PrefixatedCommand(_prefix, "cfg");

            IBotCommand configCmd = new BotCommand($"{StringID}-configcmd", cmdRule, ConfigCommand);

            _cfgCommands = new List <IBotCommand> {
                configCmd
            };
        }
Пример #5
0
        /// <summary>
        /// Generates content usage commands from specified list of allowed role IDs.
        /// </summary>
        /// <param name="perms">List of Roles IDs which are allowed to use Use commands.</param>
        protected virtual void GenerateUseCommands(List <ulong> perms)
        {
            List <IBotCommand> useCommands = new List <IBotCommand>();

            var stringKeys = RPKeyListGenerator(_moduleConfig.Root, String.Empty, true);

            List <ulong> allUsePerms = new List <ulong>(_adminIds);

            allUsePerms.AddRange(perms);
            Rule useRule;

            foreach (var strKey in stringKeys)
            {
                useRule = RuleGenerator.HasRoleByIds(allUsePerms) &
                          RuleGenerator.PrefixatedCommand(_prefix, strKey) &
                          !RuleGenerator.UserByID(_clientId); // prevent bot triggering on itself

                useCommands.Add(new BotCommand($"{StringID}-{strKey}-usecmd", useRule, UseCommandGenerator(strKey)));
            }

            useRule = RuleGenerator.HasRoleByIds(allUsePerms) &
                      RuleGenerator.TextIdentity(_prefix) &
                      !RuleGenerator.UserByID(_clientId);

            // to support empty prefix commands e.g. c! or i!
            useCommands.Add(new BotCommand($"{StringID}-usecmd", useRule, UseCommandGenerator(String.Empty)));

            List <ulong> allHelpPerms = new List <ulong>(_adminIds);

            allHelpPerms.AddRange(perms);
            Rule helpRule = RuleGenerator.HasRoleByIds(allHelpPerms) & RuleGenerator.PrefixatedCommand(_prefix, "help");

            useCommands.Add(new BotCommand($"{StringID}-helpcmd", helpRule, HelpCommand));

            List <ulong> allListPerms = new List <ulong>(_adminIds);

            allListPerms.AddRange(perms);
            Rule listRule = RuleGenerator.HasRoleByIds(allListPerms) & RuleGenerator.PrefixatedCommand(_prefix, "list");

            useCommands.Add(new BotCommand($"{StringID}-listcmd", listRule, ListCommand));

            List <ulong> allSearchPerms = new List <ulong>(_adminIds);

            allSearchPerms.AddRange(perms);
            Rule searchRule = RuleGenerator.HasRoleByIds(allSearchPerms) & RuleGenerator.PrefixatedCommand(_prefix, "search");

            useCommands.Add(new BotCommand($"{StringID}-searchcmd", searchRule, SearchCommand));

            _useCommands = useCommands;
        }