internal bool Contains(OwnerCommand comd) { OwnerCommand[] all = GetAllOwnerCommands(); foreach (OwnerCommand c in all) { if (c.Trigger == comd.Trigger) { return true; } } return false; }
internal void AddToHead(OwnerCommand comd) { if (!Contains(comd)) { OwnerCommands.AddFirst(comd); if (!comingFromFile) { WriteToFile(); } } comingFromFile = false; }
internal OwnerCommand[] GetAllOwnerCommands() { if (!addedBase) { OwnerCommand.delToDo ownerCmdDel = () => { string x = "Owner Commands: "; for (int i = 0; i < OwnerCommands.ToArray<OwnerCommand>().Length; i++) { x += $"{OwnerCommands.ToArray<OwnerCommand>()[i].Trigger}, "; } x = x.Substring(0, x.Length - 2); x += "."; TwitchChatBot.me.Client.Whisper(x, new Owner(TwitchChatBot.me.ChannelIn.Name,1)); }; OwnerCommand oCmds = new OwnerCommand("!ownercommands", ownerCmdDel); OwnerCommands.AddFirst(oCmds); addedBase = true; } return OwnerCommands.ToArray<OwnerCommand>(); }
internal OwnerCommand[] GetAllOwnerCommandsFromFile() { string all = TwitchChatBot.me.ownerCmdsFromFile.ReadAllText(); if (all == "") return null; string[] splitUp = all.Split(new string[] { "NEW_LINE" }, StringSplitOptions.None); OwnerCommand[] ret = new OwnerCommand[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 OwnerCommand(trigger, todo); } return ret; }
internal void AddToTail(OwnerCommand comd) { OwnerCommands.AddLast(comd); }
internal OwnerCommand RemoveOwnerCommand(OwnerCommand OwnerCommand) { OwnerCommands.Remove(OwnerCommand); WriteToFile(); return OwnerCommand; }
private void AddOwnerCommand(string trigger, string todo) { for (int i = 0; i < TwitchChatBot.me.ownerCmdList.GetAllTriggers().Length; i++) { if (trigger == TwitchChatBot.me.ownerCmdList.GetAllTriggers()[i]) { return; //makes sure that you cant add a command that does 2 things } } OwnerCommand command = new OwnerCommand(trigger, todo); TwitchChatBot.me.ownerCmdList.AddToHead(command); }
private void ownerCmdB_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.ownerCmdList.GetAllTriggers().Length; i++) { if (trigger == TwitchChatBot.me.ownerCmdList.GetAllTriggers()[i]) { return; //makes sure that you cant add a command that does 2 things } } OwnerCommand command = new OwnerCommand(trigger, todo); TwitchChatBot.me.ownerCmdList.AddToHead(command); trigBox.Text = ""; doBox.Text = ""; }