SHARE
TWEET

Everybody Edits - How to make "help x" command

capasha Oct 1st, 2016 (edited) 132 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. namespace EECommands
  7. {
  8.     class Program
  9.     {
  10.         //Store the command and the description
  11.         static Dictionary<string, string> cmdhelp = new Dictionary<string, string>();
  12.         static void Main(string[] args)
  13.         {
  14.             //Add help information
  15.             cmdhelp.Add("kick", ".kick <username> [reason]\nWill kick the user out of the room");
  16.             cmdhelp.Add("ban", ".ban <username> [time] [reason]\nWill ban the user permanent or timebased");
  17.  
  18.             //The words from the message
  19.             string line = "!help ban";
  20.  
  21.             //If . , - _ ! & % ? is the first character
  22.             if (Regex.IsMatch(line.Substring(0, 1), @"\.|,|-|_|!|\&|%|\?"))
  23.             {
  24.                 //Split the line to words
  25.                 var words = line.Substring(1, line.Length - 1).Split(' ').ToLower();
  26.                 if (words[0] == "help"))
  27.                 {
  28.                     //If there is 2 words
  29.                     if (words.Length == 2)
  30.                     {
  31.                         //Look if the word/command exist with information how to use it.
  32.                         if (cmdhelp.ContainsKey(words[1]))
  33.                         {
  34.                             Console.WriteLine(cmdhelp[words[1]]);
  35.                         }
  36.                         //No word/command exist with information how to use it.
  37.                         else
  38.                         {
  39.                             Console.WriteLine("The command: " + words[1] + " doesn't exist");
  40.                         }
  41.                     }
  42.                 }
  43.  
  44.             }
  45.             Console.ReadKey();
  46.         }
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top