internal bool Contains(ModCommand comd)
        {
            ModCommand[] all = GetAllModCommands();
            foreach (ModCommand c in all)
            {
                if (c.Trigger == comd.Trigger)
                {
                    return true;
                }

            }
            return false;
        }
        internal void AddToHead(ModCommand comd)
        {
            if (!Contains(comd))
            {
                ModCommands.AddFirst(comd);
                if (!comingFromFile)
                {
                    WriteToFile();
                }


            }
            comingFromFile = false;


        }
        internal ModCommand[] GetAllModCommandsFromFile()
        {
            string all = TwitchChatBot.me.modCmdsFromFile.ReadAllText();
            if (all == "") return null;
            string[] splitUp = all.Split(new string[] { "NEW_LINE" }, StringSplitOptions.None);
            ModCommand[] ret = new ModCommand[splitUp.Length];
            for (int i = 0; i < ret.Length; i++)
            {
                string modify = splitUp[i];
                if (modify == "") return ret;
                modify = modify.Substring(1);
                int whereTrigger = modify.IndexOf(",");
                string trigger = modify.Substring(0, whereTrigger);
                modify = modify.Substring(whereTrigger + 1);
                string todo = modify;
                ret[i] = new ModCommand(trigger, todo);

            }
            return ret;


        }
 internal void AddToTail(ModCommand comd)
 {
     ModCommands.AddLast(comd);
 }
 internal ModCommand RemoveModCommand(ModCommand ModCommand)
 {
     ModCommands.Remove(ModCommand);
     WriteToFile();
     return ModCommand;
 }
        private void AddModCommand(string trigger, string todo)
        {
            for (int i = 0; i < TwitchChatBot.me.modCmdList.GetAllTriggers().Length; i++)
            {
                if (trigger == TwitchChatBot.me.modCmdList.GetAllTriggers()[i])
                {
                    return; //makes sure that you cant add a command that does 2 things
                }
            }

            ModCommand command = new ModCommand(trigger, todo);
            TwitchChatBot.me.modCmdList.AddToHead(command);
        }
Пример #7
0
        private void modCmdB_Click(object sender, EventArgs e)
        {
            if (trigBox.Text == "")
            {
                return;
            }
            if (trigBox.Text.Substring(0, 1) != "!")
            {
                trigBox.Text = "!" + trigBox.Text;
            }
            string trigger = trigBox.Text;
            string todo = doBox.Text;
            for (int i = 0; i < TwitchChatBot.me.modCmdList.GetAllTriggers().Length; i++)
            {
                if (trigger == TwitchChatBot.me.modCmdList.GetAllTriggers()[i])
                {
                    return; //makes sure that you cant add a command that does 2 things
                }
            }

            ModCommand command = new ModCommand(trigger, todo);
            TwitchChatBot.me.modCmdList.AddToHead(command);
            trigBox.Text = "";
            doBox.Text = "";
        }