Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- /*
- * SmartBOT in C#
- * Author : Donny
- * Version : 1.0
- * Email : ilubmonsters@gmail.com
- *
- * Description :
- * I was learning C#, so decided to port my old Python script.
- * Have fun!
- *
- *
- */
- class bot {
- public void botSays (string txt)
- {
- Console.WriteLine("-> "+txt+"");
- }
- public string AS ()
- {
- //artificial stupidity
- Random rand = new Random();
- string[] bot = {"Yea", "Hello there", "LOL", "xD", "Do you have a life?"};
- return bot[rand.Next(0, bot.Length)];
- }
- public void process (string input)
- {
- Dictionary<string, string> answers = new Dictionary<string, string> () {
- {"who made you", "Donny<3"}, {"are you a human", "Yes, I'm"},
- {"are you a bot", "No! :x"}
- };
- string[] greetings = {"hello", "hi", "hey"};
- string[] cuss = {"shit", "bitch"};
- string kind = "none";
- if (answers.ContainsKey (input)) {
- botSays (answers [input]);
- } else {
- string[] divide = input.Split (' ');
- foreach (string g in greetings) {
- foreach (string s in divide) {
- if (g == s) {
- kind = "greet";
- }
- }
- }
- foreach (string c in cuss) {
- foreach (string s in divide) {
- if (c == s) {
- kind = "cuss";
- }
- }
- }
- if (kind == "greet") {
- botSays ("Hello!");
- } else if (kind == "cuss") {
- botSays ("Please don't use bad words.. :X");
- } else {
- botSays (AS ());
- }
- }
- }
- public void user ()
- {
- Console.Write (":: ");
- string user = Console.ReadLine ();
- user = user.ToLower();
- if (user == "exit") {
- botSays ("Bye");
- System.Environment.Exit (0);
- } else {
- process(user);
- }
- }
- }
- class main {
- public static void Main ()
- {
- bot ObjB = new bot ();
- Console.WriteLine ("Hello, Welcome to SmartBOT!");
- while (true) {
- ObjB.user();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement