Esempio n. 1
0
 static async Task ModeratorCommands(string userName, string message, IrcClient irc)
 {
     if (message.StartsWith("!hello"))
     {
         irc.SendPublicChatMessage("World!");
     }
     if (message.StartsWith("!addcom"))
     {
         var fmtstring       = message.Substring(8);
         var FirstSpaceIndex = fmtstring.IndexOf(' ');
         var FirstString     = fmtstring.Substring(0, FirstSpaceIndex);
         foreach (CustomCommands com in CommandsList)
         {
             if (FirstString == com.CommandName)
             {
                 irc.SendPublicChatMessage("That command already exists. Try again");
                 goto End; // Ends the if statement if the command already exists.
             }
         }
         var            SecondString = fmtstring.Substring(FirstSpaceIndex + 1);
         CustomCommands command      = new CustomCommands();
         command.CommandName     = FirstString;
         command.CommandResponse = SecondString;
         command.IsModCommand    = false;
         CommandsList.Add(command);
         CustomCommands.SaveCommands(CommandsList, CommandLocation);
         irc.SendPublicChatMessage("Command added!");
         End :;
     }
     if (message.StartsWith("!delcom"))
     {
         var fmtstring    = message.Substring(8);
         var foundCommand = false;
         foreach (CustomCommands command in CommandsList)
         {
             if (command.CommandName == fmtstring)
             {
                 foundCommand = true;
                 CommandsList.Remove(command);
                 CustomCommands.SaveCommands(CommandsList, CommandLocation);
                 irc.SendPublicChatMessage("Command Removed!");
                 break;
             }
         }
         if (!foundCommand)
         {
             irc.SendPublicChatMessage("No command with that name exists");
         }
     }
     if (message.StartsWith("!editcom"))
     {
         var fmtstring       = message.Substring(9);
         var FirstSpaceIndex = fmtstring.IndexOf(' ');
         var FirstString     = fmtstring.Substring(0, FirstSpaceIndex);
         var foundCommand    = false;
         foreach (CustomCommands com in CommandsList)
         {
             if (FirstString == com.CommandName)
             {
                 var SecondString = fmtstring.Substring(FirstSpaceIndex + 1);
                 com.CommandResponse = SecondString;
                 CustomCommands.SaveCommands(CommandsList, CommandLocation);
                 foundCommand = true;
                 irc.SendPublicChatMessage("Command Edited!");
                 break;
             }
         }
         if (!foundCommand)
         {
             irc.SendPublicChatMessage("No command with that name exists");
         }
     }
 }