Beispiel #1
0
 private void LoadDefaultCommands()
 {
     _commandsList = new List <IBotCommand>()
     {
         new BotCommand("pingcmd",
                        RuleGenerator.PrefixatedCommand(_prefix, "ping"),
                        PingCommand),
         new BotCommand("ctrlcmd",
                        RuleGenerator.PrefixatedCommand(_prefix, "ctrl") &
                        RuleGenerator.UserByID(_superUserID),
                        CtrlCommand),
         new BotCommand("rollcmd",
                        RuleGenerator.PrefixatedCommand(_prefix, "roll"),
                        RollCommand),
         new BotCommand("yesnocmd",
                        RuleGenerator.PrefixatedCommand(_prefix, "yesno"),
                        BinaryChoiceCommand),
         new BotCommand("magic8ballcmd",
                        RuleGenerator.PrefixatedCommand(_prefix, "8ball"),
                        Magic8BallCommand),
         new BotCommand("emojistatscmd",
                        RuleGenerator.PrefixatedCommand(_prefix, "emojistats") &
                        RuleGenerator.RoleByID(455287765995618304u), // VV
                        EmojiStatsCmd)
     };
 }
Beispiel #2
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;
        }