Advertisement
Protocol_

SmartBOT

Dec 22nd, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. /*
  5.  * SmartBOT in C#
  6.  * Author : Donny
  7.  * Version : 1.0
  8.  * Email : ilubmonsters@gmail.com
  9.  *
  10.  * Description :
  11.  * I was learning C#, so decided to port my old Python script.
  12.  * Have fun!
  13.  *
  14.  *
  15.  */
  16.  
  17. class bot {
  18.     public void botSays (string txt)
  19.     {
  20.         Console.WriteLine("-> "+txt+"");
  21.     }
  22.  
  23.     public string AS ()
  24.     {
  25.         //artificial stupidity
  26.         Random rand = new Random();
  27.         string[] bot = {"Yea", "Hello there", "LOL", "xD", "Do you have a life?"};
  28.         return bot[rand.Next(0, bot.Length)];
  29.  
  30.     }
  31.  
  32.     public void process (string input)
  33.     {
  34.         Dictionary<string, string> answers = new Dictionary<string, string> () {
  35.             {"who made you", "Donny<3"}, {"are you a human", "Yes, I'm"},
  36.             {"are you a bot", "No! :x"}
  37.         };
  38.         string[] greetings = {"hello", "hi", "hey"};
  39.         string[] cuss = {"shit", "bitch"};
  40.  
  41.         string kind = "none";
  42.  
  43.         if (answers.ContainsKey (input)) {
  44.             botSays (answers [input]);
  45.         } else {
  46.             string[] divide = input.Split (' ');
  47.             foreach (string g in greetings) {
  48.                 foreach (string s in divide) {
  49.                     if (g == s) {
  50.                         kind = "greet";
  51.                     }
  52.                 }
  53.             }
  54.             foreach (string c in cuss) {
  55.                 foreach (string s in divide) {
  56.                     if (c == s) {
  57.                         kind = "cuss";
  58.                     }
  59.                 }
  60.             }
  61.  
  62.             if (kind == "greet") {
  63.                 botSays ("Hello!");
  64.             } else if (kind == "cuss") {
  65.                 botSays ("Please don't use bad words.. :X");
  66.             } else {
  67.                 botSays (AS ());
  68.             }
  69.  
  70.         }
  71.     }
  72.  
  73.     public void user ()
  74.     {
  75.         Console.Write (":: ");
  76.         string user = Console.ReadLine ();
  77.         user = user.ToLower();
  78.         if (user == "exit") {
  79.             botSays ("Bye");
  80.             System.Environment.Exit (0);
  81.         } else {
  82.             process(user);
  83.         }
  84.     }
  85.  
  86. }
  87.  
  88. class main {
  89.     public static void Main ()
  90.     {
  91.         bot ObjB = new bot ();
  92.         Console.WriteLine ("Hello, Welcome to SmartBOT!");
  93.         while (true) {
  94.             ObjB.user();
  95.         }
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement