Пример #1
0
        public void Add(Command comd)
        {
            if (!TriggerMatch(comd.Trigger))
            {
                string designation = "";
                if (comd is OwnerCommand)
                {
                    designation = "owner";
                }
                else if (comd is ModCommand)
                {
                    designation = "mod";
                }
                else
                {
                    designation = "normal";
                }
                string total = designation + ":";
                total += comd.Trigger + ",.,";
                total += comd.CommandLine;
                total += "(SIGNED_END_12345)";

                WriteNewLine(total);
            }
            
        }
Пример #2
0
        public CommandsFile(string name) : base(name)
        {
            size = 0;
            MakeSureYouCanWrite();
            commands = new Command[100];
            string stuffInFile = File.ReadAllText(directory);
            char[] cutOff = "(SIGNED_END_12345)".ToCharArray();
            string[] stuffSplitUp = stuffInFile.Split(cutOff);
            
            foreach(string stuff in stuffSplitUp)
            {
                try
                {
                    string use = stuff;
                    string permission = use.Substring(0, use.IndexOf(":"));
                    use = use.Substring(use.IndexOf(":") + 1);
                    string trigger = use.Substring(0, use.IndexOf(",.,"));
                    use = use.Substring(0, use.IndexOf(",.,") + 1);
                    string todo = use.Substring(0, use.IndexOf("(SIGNED_END_12345)"));

                    if (permission == "owner")
                    {
                        commands[size] = new OwnerCommand(trigger, todo);
                    }
                    else if (permission == "mod")
                    {
                        commands[size] = new ModCommand(trigger, todo);
                    }
                    else
                    {
                        commands[size] = new Command(trigger, todo);
                    }
                    size++;
                }
                catch(ArgumentOutOfRangeException e)
                {
                    TwitchChatBot.UseBot.AddToLabel("Something caught in COMMANDSFILE, exiting.");
                    break;
                }
                
            }
            TwitchChatBotToList();
        }
Пример #3
0
 public CommandList(Command[] cmds)
 {
     _array = cmds;
     foreach (Command comd in _array)
     {
         commands.Add(comd);
     }
 }
Пример #4
0
 public void AddCommand(string trigger, string todo, User user)
 {
     Command cmd = new Command(trigger, todo);
     AddCommand(cmd, user);
     
     
 }
Пример #5
0
 public void AddCommand(Command cmd, User user)
 {
     if (user.Permission >= 1 && !AddCommandAlreadyMatches(cmd.Trigger))
     {
         commands.Add(cmd);
         CommandsFile file = new CommandsFile(TwitchChatBot.ChannelIn.Name.ToLower() + "_commands");
         file.Add(cmd);
         
         RemoveCommand("!list");
         _toString = ToString();
         commands.Add(new Command("!list", _toString + " and list."));
         UpdateArray();
     }
     
 }
Пример #6
0
 public int GetWhereMatches(Command cmd)
 {
     int i = 0;
     foreach(Command comd in _array)
     {
         
         if (comd.Name.Equals(cmd.Trigger))
         {
             return i;
         }
         i++;
     }
     throw new CommandNotFoundException("");
 }