Пример #1
0
        static void Main(string[] args)
        {
            string settingsPath = Path.Combine(Environment.CurrentDirectory, Path.Combine("config", "Settings.xml"));

            Bot myBot = new Bot();
            myBot.loadSettings(settingsPath);
            User myUser = new User("consoleUser", myBot);
            myBot.isAcceptingUserInput = false;
            myBot.loadAIMLFromFiles();
            myBot.isAcceptingUserInput = true;
            while (true)
            {
                Console.Write("You: ");
                string input = Console.ReadLine();
                if (input.ToLower() == "quit")
                {
                    break;
                }
                else
                {
                    Request r = new Request(input, myUser, myBot);
                    Result res = myBot.Chat(r);
                    Console.WriteLine("Bot: " + res.Output);
                }
            }
        }
Пример #2
0
        public void testEvaluateTimeOut()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.GlobalSettings.addSetting("timeout", "10");
            this.mockNode    = new AIMLbot.Utils.Node();
            this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);

            string path     = "Test 1 <that> that <topic> topic";
            string template = "<srai>TEST</srai>";

            this.mockNode = new AIMLbot.Utils.Node();
            this.mockNode.addCategory(path, template, "filename");

            string pathAlt     = "Alt Test <that> that <topic> topic";
            string templateAlt = "<srai>TEST ALT</srai>";

            this.mockNode.addCategory(pathAlt, templateAlt, "filename");
            this.mockQuery = new AIMLbot.Utils.SubQuery(path);

            System.Threading.Thread.Sleep(20);

            string result = this.mockNode.evaluate("Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder());

            Assert.AreEqual(string.Empty, result);
            Assert.AreEqual(true, this.mockRequest.hasTimedOut);
        }
Пример #3
0
    void Start()

    {
        //  Debug.Log("aaaaa");
        LogSystem.InstallDefaultReactors();

        //  Create credential and instantiate service
        Credentials credentials = new Credentials("c20a3f60-9df3-4d5b-86e5-027ccde5c42c", "mnCUwtXFpNSl", "https://gateway.watsonplatform.net/conversation/api");

        _conversation             = new Conversation(credentials);
        _conversation.VersionDate = _conversationVersionDate;

        bot     = new AIMLbot.Bot();
        user    = new AIMLbot.User("User", bot);
        request = new AIMLbot.Request("", user, bot);
        result  = new AIMLbot.Result(user, bot, request);
        bot.loadSettings(Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
        // Load AIML files from AIML path defined in Settings.xml
        bot.loadAIMLFromFiles();
        if (bot != null)
        {
            bot.UseJavaScript = true;
        }


        //   TextToSpeechMark ttsm = gameObject.GetComponent<TextToSpeechMark>();
        //  AskQuestion();
    }
Пример #4
0
        public string GetResp(string msg, string user)
        {
            try
            {
                myUser = null;
                //GC.Collect();

                myUser = new AIMLbot.User(user, myBot);

                AIMLbot.Request myRequest = new AIMLbot.Request(msg, myUser, myBot);
                AIMLbot.Result  myResult  = myBot.Chat(myRequest);

                string reply = myResult.Output;

                if (reply.Length > 5)
                {
                    if (reply.Substring(0, 5).ToLower(CultureInfo.CurrentCulture) == "error")
                    {
                        return(string.Empty);
                    }

                    return(reply);
                }

                return(reply);
            }
            catch (Exception ex)
            {
                Logger.Log("There has been an error starting AI.", Helpers.LogLevel.Warning, ex);
                return(string.Empty);
            }
        }
Пример #5
0
 static void Main(string[] args)
 {
     AIMLbot.Bot chatBot;
     AIMLbot.User chatUser;
     string channel = args[0];
     string rnick = args[1];
     string rmsg = args[2];
     try
     {
     if (rmsg.StartsWith("!") == false)
     {
     string query = rmsg;
     ObsidianFunctions.Functions ObsidFunc = new ObsidianFunctions.Functions();
     chatBot = new AIMLbot.Bot();
     chatBot.loadSettings();
     chatUser = new AIMLbot.User(rnick, chatBot);
     chatBot.loadAIMLFromFiles();
     chatBot.isAcceptingUserInput = true;
     AIMLbot.Request r = new AIMLbot.Request(query, chatUser, chatBot);
     AIMLbot.Result res = chatBot.Chat(r);
     Console.WriteLine("PRIVMSG " + rnick + " :" + res.Output);
     }
     }
     catch (Exception ex)
     {
     Console.WriteLine("PRIVMSG " + rnick + " :" + ex.ToString());
     }
 }
Пример #6
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="user">The user for whom this is a result</param>
 /// <param name="bot">The bot providing the result</param>
 /// <param name="request">The request that originated this result</param>
 public Result(User user, Bot bot, Request request)
 {
     this.user = user;
     this.bot = bot;
     this.request = request;
     this.request.result = this;
 }
Пример #7
0
        static void Main(string[] args)
        {
            AIMLbot.Bot  chatBot;
            AIMLbot.User chatUser;
            string       channel = args[0];
            string       rnick   = args[1];
            string       rmsg    = args[2];

            try
            {
                if (rmsg.StartsWith("!") == false)
                {
                    string query = rmsg;
                    ObsidianFunctions.Functions ObsidFunc = new ObsidianFunctions.Functions();
                    chatBot = new AIMLbot.Bot();
                    chatBot.loadSettings();
                    chatUser = new AIMLbot.User(rnick, chatBot);
                    chatBot.loadAIMLFromFiles();
                    chatBot.isAcceptingUserInput = true;
                    AIMLbot.Request r   = new AIMLbot.Request(query, chatUser, chatBot);
                    AIMLbot.Result  res = chatBot.Chat(r);
                    Console.WriteLine("PRIVMSG " + rnick + " :" + res.Output);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("PRIVMSG " + rnick + " :" + ex.ToString());
            }
        }
Пример #8
0
        public void testEvaluateWithInternationalCharset()
        {
            string path     = "中 文 <that> * <topic> *";
            string template = "中文 (Chinese)";

            this.mockNode = new AIMLbot.Utils.Node();
            this.mockNode.addCategory(path, template, "filename");

            string path2     = "日 本 語 <that> * <topic> *";
            string template2 = "日 本 語 (Japanese)";

            this.mockNode.addCategory(path2, template2, "filename");

            string path3     = "Русский язык <that> * <topic> *";
            string template3 = "Русский язык (Russian)";

            this.mockNode.addCategory(path3, template3, "filename");

            this.mockRequest = new Request("中 文", new User("1", this.mockBot), this.mockBot);
            this.mockQuery   = new AIMLbot.Utils.SubQuery(path);
            Assert.AreEqual("中文 (Chinese)", this.mockNode.evaluate("中 文 <that> * <topic> *", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));

            this.mockRequest = new Request("日 本 語", new User("1", this.mockBot), this.mockBot);
            this.mockQuery   = new AIMLbot.Utils.SubQuery(path);
            Assert.AreEqual("日 本 語 (Japanese)", this.mockNode.evaluate("日 本 語 <that> * <topic> *", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));

            this.mockRequest = new Request("Русский язык", new User("1", this.mockBot), this.mockBot);
            this.mockQuery   = new AIMLbot.Utils.SubQuery(path);
            Assert.AreEqual("Русский язык (Russian)", this.mockNode.evaluate("Русский язык <that> * <topic> *", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));
        }
Пример #9
0
        public string Chat(string input)
        {
            var request = new Request(input, this.user, this.bot);
            var response = this.bot.Chat(request);

            return response.Output;
        }
Пример #10
0
 public void testResultHandlers()
 {
     this.mockUser = new User("1", this.mockBot);
     Assert.AreEqual("", this.mockUser.getResultSentence());
     Request mockRequest = new Request("Sentence 1. Sentence 2",this.mockUser,this.mockBot);
     Result mockResult = new Result(this.mockUser, this.mockBot, mockRequest);
     mockResult.InputSentences.Add("Result 1");
     mockResult.InputSentences.Add("Result 2");
     mockResult.OutputSentences.Add("Result 1");
     mockResult.OutputSentences.Add("Result 2");
     this.mockUser.addResult(mockResult);
     Result mockResult2 = new Result(this.mockUser, this.mockBot, mockRequest);
     mockResult2.InputSentences.Add("Result 3");
     mockResult2.InputSentences.Add("Result 4");
     mockResult2.OutputSentences.Add("Result 3");
     mockResult2.OutputSentences.Add("Result 4");
     this.mockUser.addResult(mockResult2);
     Assert.AreEqual("Result 3", this.mockUser.getResultSentence());
     Assert.AreEqual("Result 3", this.mockUser.getResultSentence(0));
     Assert.AreEqual("Result 1", this.mockUser.getResultSentence(1));
     Assert.AreEqual("Result 4", this.mockUser.getResultSentence(0, 1));
     Assert.AreEqual("Result 2", this.mockUser.getResultSentence(1, 1));
     Assert.AreEqual("", this.mockUser.getResultSentence(0, 2));
     Assert.AreEqual("", this.mockUser.getResultSentence(2, 0));            
     Assert.AreEqual("Result 3", this.mockUser.getThat());
     Assert.AreEqual("Result 3", this.mockUser.getThat(0));
     Assert.AreEqual("Result 1", this.mockUser.getThat(1));
     Assert.AreEqual("Result 4", this.mockUser.getThat(0, 1));
     Assert.AreEqual("Result 2", this.mockUser.getThat(1, 1));
     Assert.AreEqual("", this.mockUser.getThat(0, 2));
     Assert.AreEqual("", this.mockUser.getThat(2, 0));
 }
        /// <summary>
        /// Given an input string, return an output from the bot.
        /// </summary>
        /// <param name="input">string</param>
        /// <param name="user">User (so conversations can be tracked by the bot, per user)</param>
        /// <returns>string</returns>
        public String getOutput(String input, User user)
        {
            Request r = new Request(input, user, this);
            Result res = Chat(r);

            return (res.Output);
        }
Пример #12
0
 /// <summary>
 /// Creates an instance of the Result class.
 /// </summary>
 /// <param name="user">The user for whom this is a result</param>
 /// <param name="request">The request that originated this result</param>
 public Result(User user, Request request)
 {
     User = user;
     Request = request;
     Request.Result = this;
     _splitters = ChatBot.Splitters.ToArray();
 }
Пример #13
0
        public void testEvaluateWithMultipleWildcardsSwitched()
        {
            string path     = "Test * 1 _ <that> Test * 1 _ <topic> Test _ 1 *";
            string template = "<srai>TEST</srai>";

            this.mockNode = new AIMLbot.Utils.Node();
            this.mockNode.addCategory(path, template, "filename");

            string pathAlt     = "Alt Test <that> that <topic> topic";
            string templateAlt = "<srai>TEST ALT</srai>";

            this.mockNode.addCategory(pathAlt, templateAlt, "filename");

            this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);
            this.mockQuery   = new AIMLbot.Utils.SubQuery(path);

            Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test FIRST USER 1 SECOND USER <that> Test FIRST THAT 1 SECOND THAT <topic> Test FIRST TOPIC 1 SECOND TOPIC", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));
            Assert.AreEqual(2, this.mockQuery.InputStar.Count);
            Assert.AreEqual("SECOND USER", (string)this.mockQuery.InputStar[0]);
            Assert.AreEqual("FIRST USER", (string)this.mockQuery.InputStar[1]);
            Assert.AreEqual(2, this.mockQuery.ThatStar.Count);
            Assert.AreEqual("SECOND THAT", (string)this.mockQuery.ThatStar[0]);
            Assert.AreEqual("FIRST THAT", (string)this.mockQuery.ThatStar[1]);
            Assert.AreEqual(2, this.mockQuery.TopicStar.Count);
            Assert.AreEqual("SECOND TOPIC", (string)this.mockQuery.TopicStar[0]);
            Assert.AreEqual("FIRST TOPIC", (string)this.mockQuery.TopicStar[1]);
        }
Пример #14
0
        static void Main(string[] args)
        {
            _bot = InstantiateBot();
            _user = new User("chris", _bot);
            var input = string.Empty;
            Console.WriteLine("Say somthing to begin teaching me.");
            while (input.ToLower() != "q")
            {
                input = GetUserInput();
                if (input.StartsWith("/"))
                {
                    if (input.StartsWith("/bot"))
                        ProcessBotCommand(input);
                    if (input == "/save")
                    {
                        SaveBot();
                        continue;
                    }
                }

                var request = new Request(input, _user, _bot);
                var response = _bot.Chat(request);
                TellUser(response);

            }
        }
Пример #15
0
 public void setupMockObjects()
 {
     this.mockBot = new Bot();
     this.mockUser = new User("1", this.mockBot);
     this.mockRequest = new Request("This is a test", this.mockUser, this.mockBot);
     this.mockQuery = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *");
     this.mockResult = new Result(this.mockUser, this.mockBot, this.mockRequest);
 }
Пример #16
0
 public dateTagTests()
 {
     mockRequest    = new Request("This is a test", this.mockUser, this.mockBot);
     this.mockQuery = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *");
     this.mockQuery.InputStar.Insert(0, "first star");
     this.mockQuery.InputStar.Insert(0, "second star");
     mockResult = new Result(this.mockUser, this.mockBot, mockRequest);
 }
Пример #17
0
 /// <summary>
 /// This method takes an input string, then finds a response using the the AIMLbot library and returns it
 /// </summary>
 /// <param name="input">Input Text</param>
 /// <returns>Response</returns>
 public String getOutput(String input)
 {
     Request r = new Request(input, myUser, myBot);
      Debug.Print("Request jest taki"+ r.ToString()+"  "+ r.rawInput);
      Result res=myBot.Chat(r);
      Debug.Print("wynik" + res.ToString());
      return(res.Output);
 }
 public string getoutput(string Input)
 {
     SpeechLib.SpVoice synth = new SpeechLib.SpVoice();
     Request request = new Request(Input, user, bot);
     Result result = bot.Chat(request);
     synth.Speak(result.Output, (SpeechVoiceSpeakFlags.SVSFDefault));
     return(result.Output);
 }
Пример #19
0
        public void Test()
        {
            var bot = new Bot();

            var user = new User("me", bot);
            var request = new Request("test", user, bot);
            var result = bot.Chat(request);
        }
 public String getOutput(String rawInput)
 {
     SpeechSynthesizer SpeechSynth = new SpeechSynthesizer();
     Request request = new Request(rawInput, myUser, myBot);
     Result result = myBot.Chat(request);
     SpeechSynth.Speak(result.Output);
     return (result.Output);
 }
Пример #21
0
 public void setupMockObjects()
 {
     this.mockBot     = new Bot();
     this.mockUser    = new User("1", this.mockBot);
     this.mockRequest = new Request("This is a test", this.mockUser, this.mockBot);
     this.mockResult  = new Result(this.mockUser, this.mockBot, this.mockRequest);
     this.mockQuery   = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *");
 }
Пример #22
0
 public CommandResponse ProcessCommand(CommandRequest commandRequest)
 {
     var r = new Request(commandRequest.Command, _myUser, _myBot);
     var res = _myBot.Chat(r);
     var whatToDo = res.user.Predicates.grabSetting("whattodo");
     var ret = _myBot.Chat(new Request("DO", _myUser, _myBot));
     var processor = _commandProcessorFactory.GetCommandProcessor(commandRequest);
     return processor.ProcessCommand(commandRequest);
 }
Пример #23
0
 public void setupMockObjects()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     this.mockBot.GlobalSettings.addSetting("timeout", "9999999999");
     this.mockNode    = new AIMLbot.Utils.Node();
     this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);
     this.mockQuery   = new AIMLbot.Utils.SubQuery("Test 1 <that> * <topic> *");
 }
Пример #24
0
 public void setupMockObjects()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     this.mockBot.GlobalSettings.addSetting("timeout", "9999999999");
     this.mockNode = new AIMLbot.Utils.Node();
     this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);
     this.mockQuery = new AIMLbot.Utils.SubQuery("Test 1 <that> * <topic> *");
 }
Пример #25
0
        private void button1_Click(object sender, EventArgs e)
        {

            var r = new Request(txtInputText.Text, _myUser, _myBot);
            var res = _myBot.Chat(r);
            textBox1.Text = res.Output;
            if (checkBox1.Checked) 
                _synth.Speak(res.Output);
            
        }
Пример #26
0
 public void setupMockObjects()
 {
     this.mockBot     = new Bot();
     this.mockUser    = new User("1", this.mockBot);
     this.mockRequest = new Request("This is a test", this.mockUser, this.mockBot);
     this.mockQuery   = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *");
     this.mockQuery.InputStar.Insert(0, "first star");
     this.mockQuery.InputStar.Insert(0, "second star");
     //this.mockResult = new Result(this.mockUser, this.mockBot, this.mockRequest);
 }
Пример #27
0
 public void setupMockObjects()
 {
     this.mockBot = new Bot();
     this.mockUser = new User("1", this.mockBot);
     this.mockRequest = new Request("This is a test", this.mockUser, this.mockBot);
     this.mockQuery = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *");
     this.mockQuery.InputStar.Insert(0, "first star");
     this.mockQuery.InputStar.Insert(0, "second star");
     //this.mockResult = new Result(this.mockUser, this.mockBot, this.mockRequest);
 }
Пример #28
0
        public void testEvaluateWithEmptyNode()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockNode    = new AIMLbot.Utils.Node();
            this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);
            this.mockQuery   = new AIMLbot.Utils.SubQuery("Test 1 <that> that <topic> topic");

            Assert.AreEqual(string.Empty, this.mockNode.evaluate("Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));
        }
Пример #29
0
 public void testEvaluateWithNoWildCards()
 {
     string path = "Test 1 <that> that <topic> topic";
     string template = "<srai>TEST</srai>";
     this.mockNode = new AIMLbot.Utils.Node();
     this.mockNode.addCategory(path, template, "filename");
     this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);
     this.mockQuery = new AIMLbot.Utils.SubQuery(path);
     Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));
 }
Пример #30
0
        public void testEvaluateWithNoWildCards()
        {
            string path     = "Test 1 <that> that <topic> topic";
            string template = "<srai>TEST</srai>";

            this.mockNode = new AIMLbot.Utils.Node();
            this.mockNode.addCategory(path, template, "filename");
            this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);
            this.mockQuery   = new AIMLbot.Utils.SubQuery(path);
            Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test 1 <that> that <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));
        }
Пример #31
0
 public void setupMockObjects()
 {
     this.mockBot         = new Bot();
     this.mockUser        = new User("1", this.mockBot);
     this.mockRequest     = new Request("This is a test", this.mockUser, this.mockBot);
     this.mockQuery       = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *");
     this.mockResult      = new Result(this.mockUser, this.mockBot, this.mockRequest);
     this.possibleResults = new ArrayList();
     this.possibleResults.Add("random 1");
     this.possibleResults.Add("random 2");
     this.possibleResults.Add("random 3");
     this.possibleResults.Add("random 4");
     this.possibleResults.Add("random 5");
 }
Пример #32
0
        static void getOutput(String input)
        {
            Bot myBot = new Bot();
            User myUser = new User("consoleUser", myBot);

                 myBot.loadSettings();
             myBot.isAcceptingUserInput = false;
             myBot.loadAIMLFromFiles();
             myBot.isAcceptingUserInput = true;

             Request r = new Request(input, myUser, myBot);
             Result res = myBot.Chat(r);
             Console.WriteLine("Bot: " + res.Output);
        }
Пример #33
0
 public string Chat(string userInput)
 {
     if (bot.isAcceptingUserInput)
     {
         Request newRequest = new Request(userInput, user, bot);
         Result result = bot.Chat(newRequest);
         lastRequest = newRequest;
         lastResult = result;
         return result.Output;
     }
     else {
         return "I don't understand.";
     }
 }
Пример #34
0
 public void setupMockObjects()
 {
     this.mockBot = new Bot();
     this.mockUser = new User("1", this.mockBot);
     this.mockRequest = new Request("This is a test", this.mockUser, this.mockBot);
     this.mockQuery = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *");
     this.mockResult = new Result(this.mockUser, this.mockBot, this.mockRequest);
     this.possibleResults = new ArrayList();
     this.possibleResults.Add("random 1");
     this.possibleResults.Add("random 2");
     this.possibleResults.Add("random 3");
     this.possibleResults.Add("random 4");
     this.possibleResults.Add("random 5");
 }
Пример #35
0
        public string Ask(string name, string question)
        {
            var sharpBot = new Bot();
            sharpBot.loadSettings(SettingsPath);
            var loader = new AIMLbot.Utils.AIMLLoader(sharpBot);
            loader.loadAIML(aimlPath);
            sharpBot.isAcceptingUserInput = false;
            sharpBot.isAcceptingUserInput = true;

            var patient = new User(name, sharpBot);
            var request = new Request(question, patient, sharpBot);
            var answer = sharpBot.Chat(request);
            return answer.Output;
        }
Пример #36
0
 /// <summary>
 /// Initialize our derived MonoBehaviour
 /// </summary>
 void Start()
 {
     CommText     = GameObject.Find("CommText").GetComponent <Text>();
     ResponseText = GameObject.Find("ResponseText").GetComponent <Text>();
     bot          = new AIMLbot.Bot();
     user         = new AIMLbot.User("User", bot);
     request      = new AIMLbot.Request("", user, bot);
     result       = new AIMLbot.Result(user, bot, request);
     bot.loadSettings(Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
     bot.loadAIMLFromFiles();
     if (bot != null)
     {
         bot.UseJavaScript = true;
     }
 }
Пример #37
0
        public String Respond(String input, User user)
        {
            var r = new Request(input, user, this);
            var res = Chat(r);

            // The AIMLBot will learn user names during a conversation
            // (e.g., you can say "My name is Bob" and thereafter the bot will
            // refer to you as Bob). But since this bot is in a chat room, it should
            // already know a person's name. The AIML settings have the default user
            // name set to "un-named user"; we'll check for that string and replace it
            // with the known chat room name. That way, the bot learning behavior is preserved
            // but the bot seems less dumb when sitting in a chat room

            String result = res.Output.Replace("un-named user", user.UserID);

            return (result);
        }
Пример #38
0
        public void testEvaluateWithStarWildCardThat()
        {
            string path     = "Test 1 <that> Test * 1 <topic> topic";
            string template = "<srai>TEST</srai>";

            this.mockNode = new AIMLbot.Utils.Node();
            this.mockNode.addCategory(path, template, "filename");

            string pathAlt     = "Alt Test <that> that <topic> topic";
            string templateAlt = "<srai>TEST ALT</srai>";

            this.mockNode.addCategory(pathAlt, templateAlt, "filename");
            this.mockRequest = new Request("Test 1", new User("1", this.mockBot), this.mockBot);
            this.mockQuery   = new AIMLbot.Utils.SubQuery(path);
            Assert.AreEqual("<srai>TEST</srai>", this.mockNode.evaluate("Test 1 <that> Test WILDCARD WORDS 1 <topic> topic", this.mockQuery, this.mockRequest, AIMLbot.Utils.MatchState.UserInput, new StringBuilder()));
            Assert.AreEqual("WILDCARD WORDS", (string)this.mockQuery.ThatStar[0]);
        }
Пример #39
0
 private void processInputFromUser()
 {
     if (this.myBot.isAcceptingUserInput)
     {
         string rawInput = this.inputTextBox.Text;
         this.inputTextBox.Text = string.Empty;
         this.outputRichTextBox.AppendText("You: " + rawInput + Environment.NewLine);
         Request myRequest = new Request(rawInput, this.myUser, this.myBot);
         Result myResult = this.myBot.Chat(myRequest);
         this.lastRequest = myRequest;
         this.lastResult = myResult;
         this.outputRichTextBox.AppendText("Bot: " + myResult.Output + Environment.NewLine + Environment.NewLine);
     }
     else
     {
         this.inputTextBox.Text = string.Empty;
         this.outputRichTextBox.AppendText("Bot not accepting user input." + Environment.NewLine);
     }
 }
Пример #40
0
    /// <summary>
    /// Initialize our derived MonoBehaviour
    /// </summary>
    void Start()
    {
        // Initialize Program # variables
// For Webplayer plattform and WebGl
#if (UNITY_WEBPLAYER || UNITY_WEBGL)
        ProgramSharpWebplayerCoroutine WebplayerCoroutine = this.gameObject.GetComponent <ProgramSharpWebplayerCoroutine>();
        if (WebplayerCoroutine != null)
        {
            bot = new AIMLbot.Bot(WebplayerCoroutine, Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
        }
        else
        {
            Debug.LogWarning("You need to attatch the Webplayer Component in Webplayer plattform mode.");
        }
// Other plattforms
#else
        // Only for Windows, Linux and Mac OSX
        bot = new AIMLbot.Bot();
#endif
        user    = new AIMLbot.User("User", bot);
        request = new AIMLbot.Request("", user, bot);
        result  = new AIMLbot.Result(user, bot, request);
// Only for Windows, Linux, Mac OSX Android and IOS
#if !(UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_ANDROID || UNITY_IOS)
        // Load Settings from Xml file in config directory. Plattform dependend Path issues may
        // occur.
        bot.loadSettings(Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
        // Load AIML files from AIML path defined in Settings.xml
        bot.loadAIMLFromFiles();
#endif
// Android and IOS release
#if (UNITY_ANDROID || UNITY_IOS)
        // Load Settings from Xml file in config directory within resources folder.
        bot.loadSettings("Chatbot/Program #/config/Settings");
        // Load AIML files from AIML path defined in Settings.xml
        bot.loadAIMLFromFiles();
#endif
        // Define to or not to use JavaScript (Jurassic) in AIML
        if (bot != null)
        {
            bot.UseJavaScript = true;
        }
    }
Пример #41
0
        public void testResultHandlers()
        {
            XmlNode testNode   = StaticHelpers.getNode("<input/>");
            Result  mockResult = new Result(this.mockUser, this.mockBot, this.mockRequest);

            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.input(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("", this.mockBotTagHandler.Transform());
            this.mockRequest = new Request("Sentence 1. Sentence 2", this.mockUser, this.mockBot);
            mockResult.InputSentences.Add("Result 1");
            mockResult.InputSentences.Add("Result 2");
            this.mockUser.addResult(mockResult);
            Result mockResult2 = new Result(this.mockUser, this.mockBot, this.mockRequest);

            mockResult2.InputSentences.Add("Result 3");
            mockResult2.InputSentences.Add("Result 4");
            this.mockUser.addResult(mockResult2);

            Assert.AreEqual("Result 3", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<input index=\"1\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.input(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 3", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<input index=\"2,1\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.input(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 1", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<input index=\"1,2\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.input(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 4", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<input index=\"2,2\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.input(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 2", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<input index=\"1,3\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.input(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<input index=\"3\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.input(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("", this.mockBotTagHandler.Transform());
        }
Пример #42
0
        public void testMultiCondition()
        {
            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test1", "match1");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 1 match 1 found.", this.mockResult.RawOutput);

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test1", "match2");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 1 match 2 found.", this.mockResult.RawOutput);
            this.mockUser.Predicates.addSetting("test1", "");

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test2", "match1");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 2 match 1 found.", this.mockResult.RawOutput);

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test2", "match2");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 2 match 2 found.", this.mockResult.RawOutput);
            this.mockUser.Predicates.addSetting("test2", "");


            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test3", "match test the star works");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("match * found.", this.mockResult.RawOutput);
            this.mockUser.Predicates.addSetting("test3", "");


            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test3", "match test the star won't match this");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("default match found.", this.mockResult.RawOutput);

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test", "match4");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("default match found.", this.mockResult.RawOutput);
        }
Пример #43
0
        public void testMultiCondition()
        {
            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test1", "match1");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 1 match 1 found.", this.mockResult.RawOutput);

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test1", "match2");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 1 match 2 found.", this.mockResult.RawOutput);
            this.mockUser.Predicates.addSetting("test1", "");

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test2", "match1");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 2 match 1 found.", this.mockResult.RawOutput);

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test2", "match2");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("test 2 match 2 found.", this.mockResult.RawOutput);
            this.mockUser.Predicates.addSetting("test2", "");


            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test3", "match test the star works");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("match * found.", this.mockResult.RawOutput);
            this.mockUser.Predicates.addSetting("test3", "");


            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test3", "match test the star won't match this");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("default match found.", this.mockResult.RawOutput);

            this.mockRequest = new Request("test multi condition", this.mockUser, this.mockBot);
            this.mockUser.Predicates.addSetting("test", "match4");
            this.mockResult = this.mockBot.Chat(this.mockRequest);
            Assert.AreEqual("default match found.", this.mockResult.RawOutput);
        }
Пример #44
0
        public void testResultHandlers()
        {
            XmlNode testNode = StaticHelpers.getNode("<that/>");
            Result mockResult = new Result(this.mockUser, this.mockBot, this.mockRequest);
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.that(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("", this.mockBotTagHandler.Transform());
            this.mockRequest = new Request("Sentence 1. Sentence 2", this.mockUser, this.mockBot);
            mockResult.OutputSentences.Add("Result 1");
            mockResult.OutputSentences.Add("Result 2");
            this.mockUser.addResult(mockResult);
            Result mockResult2 = new Result(this.mockUser, this.mockBot, this.mockRequest);
            mockResult2.OutputSentences.Add("Result 3");
            mockResult2.OutputSentences.Add("Result 4");
            this.mockUser.addResult(mockResult2);

            Assert.AreEqual("Result 3", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<that index=\"1\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.that(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 3", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<that index=\"2,1\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.that(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 1", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<that index=\"1,2\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.that(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 4", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<that index=\"2,2\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.that(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("Result 2", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<that index=\"1,3\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.that(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("", this.mockBotTagHandler.Transform());

            testNode = StaticHelpers.getNode("<that index=\"3\"/>");
            this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.that(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, mockResult, testNode);
            Assert.AreEqual("", this.mockBotTagHandler.Transform());
        }
Пример #45
0
        public string Query(string querystring)
        {
            if (this.bot.isAcceptingUserInput)
            {
                Request myRequest = new Request(querystring, this.user, this.bot);
                Result myResult = this.bot.Chat(myRequest);
                this.lastRequest = myRequest;
                this.lastResult = myResult;

                //log the request made
                System.IO.File.AppendAllText(AIMLSourcePath + "\\Executor_Info", DateTime.Now.ToString() + ">>  " + querystring + Environment.NewLine + "            >> " + myResult.Output);

                return myResult.Output;

            }
            else
            {
                return "Bot not expecting Input!";
                //todo add exception here
            }
        }
Пример #46
0
        public string ParseQuery(string query)
        {
            string res;
            try
            {
                //query = MorfParse(query);

                Request chatRequest = new Request(query, ChatUser, ChatBot);
                Result chatRes = ChatBot.Chat(chatRequest);
                res = chatRes.Output;

                if (res.StartsWith("DO_WORK|"))
                {   // 1. Odpytanie bazy danych na podstawie znanych informacji
                    // 2. Ponowne zapytanie systemu konwersacyjnego - rekurencja
                    res = ParseQuery(queryDatabase(res));
                }

            }catch(Exception ex)
            {
                res = "Wystąpił błąd podczas przetwarzania zapytania: " + ex.Message;
            }
            return res;
        }
Пример #47
0
 static void Main(string[] args)
 {
     Bot myBot = new Bot();
     myBot.loadSettings();
     User myUser = new User("consoleUser", myBot);
     myBot.isAcceptingUserInput = false;
     myBot.loadAIMLFromFiles();
     myBot.isAcceptingUserInput = true;
     while (true)
     {
         Console.Write("You: ");
         string input = Console.ReadLine();
         if (input.ToLower() == "quit")
         {
             break;
         }
         else
         {
             Request r = new Request(input, myUser, myBot);
             Result res = myBot.Chat(r);
             Console.WriteLine("Bot: " + res.Output);
         }
     }
 }
Пример #48
0
 public ResultTests()
 {
     this.mockBot  = new Bot();
     this.mockUser = new User("1", this.mockBot);
     mockRequest   = new Request("This is a test", this.mockUser, this.mockBot);
 }
Пример #49
0
 public void testSetAndCondition()
 {
     this.mockRequest = new Request("TEST SET AND CONDITION", this.mockUser, this.mockBot);
     this.mockResult  = this.mockBot.Chat(this.mockRequest);
     Assert.AreEqual("End value: 1.", this.mockResult.RawOutput);
 }
Пример #50
0
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            // Every event coming from a different thread (almost all of them, most certanly those
            // from libomv) needs to be executed on the GUI thread. This code can be basically
            // copy-pasted on the begining of each libomv event handler that results in update
            // of any GUI element
            //
            // In this case the IM we sent back as a reply is also displayed in the corresponding IM tab
            if (Instance.MainForm.InvokeRequired)
            {
                Instance.MainForm.BeginInvoke(
                    new MethodInvoker(
                        delegate()
                        {
                            Self_IM(sender, e);
                        }
                        ));
                return;
            }

            // We need to filter out all sorts of things that come in as a instante message
            if (e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc
                && !Instance.Groups.ContainsKey(e.IM.IMSessionID)  // Message is not group IM (sessionID == groupID)
                && e.IM.BinaryBucket.Length < 2                    // Session is not ad-hoc friends conference
                && e.IM.FromAgentName != "Second Life"             // Not a system message
                && Alice.isAcceptingUserInput                    // Alice bot loaded successfully
                && Enabled                                       // Alice bot is enabled
                )
            {
                ThreadPool.QueueUserWorkItem(sync =>
                {
                    lock (syncChat)
                    {
                        Alice.GlobalSettings.updateSetting("location", "region " + Client.Network.CurrentSim.Name);
                        AIMLbot.User user;
                        if (AliceUsers.ContainsKey(e.IM.FromAgentName))
                        {
                            user = (AIMLbot.User)AliceUsers[e.IM.FromAgentName];
                        }
                        else
                        {
                            user = new User(e.IM.FromAgentName, Alice);
                            user.Predicates.removeSetting("name");
                            user.Predicates.addSetting("name", FirstName(e.IM.FromAgentName));
                            AliceUsers[e.IM.FromAgentName] = user;
                        }
                        AIMLbot.Request req = new Request(e.IM.Message, user, Alice);
                        AIMLbot.Result res = Alice.Chat(req);
                        string msg = res.Output;
                        if (msg.Length > 1000)
                        {
                            msg = msg.Substring(0, 1000);
                        }
                        if (EnableRandomDelay) System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(3));
                        Instance.Netcom.SendIMStartTyping(e.IM.FromAgentID, e.IM.IMSessionID);
                        if (EnableRandomDelay)
                        {
                            System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(5));
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(1000);
                        }
                        Instance.Netcom.SendIMStopTyping(e.IM.FromAgentID, e.IM.IMSessionID);
                        if (Instance.MainForm.InvokeRequired)
                        {
                            Instance.MainForm.BeginInvoke(new MethodInvoker(() => Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID)));
                        }
                        else
                        {
                            Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID);
                        }
                    }
                });
            }
        }
Пример #51
0
 public void testRecursiveBlockCondition()
 {
     this.mockRequest = new Request("test block recursive call", this.mockUser, this.mockBot);
     this.mockResult  = this.mockBot.Chat(this.mockRequest);
     Assert.AreEqual("Test passed.", this.mockResult.RawOutput);
 }
Пример #52
0
        async void do_work(object sender, DoWorkEventArgs e)
        {
            var worker = sender as BackgroundWorker;
            var key    = e.Argument as String;

            try
            {
                var bot = new Telegram.Bot.TelegramBotClient(key);
                await bot.SetWebhookAsync("");

                AIMLbot.Bot lazy = new AIMLbot.Bot();


                lazy.loadSettings();
                lazy.loadAIMLFromFiles();
                lazy.isAcceptingUserInput = false;
                AIMLbot.User us = new AIMLbot.User("Username", lazy);
                lazy.isAcceptingUserInput = true;


                bot.OnCallbackQuery += async(object sc, Telegram.Bot.Args.CallbackQueryEventArgs ev) =>
                {
                    Telegram.Bot.Types.FileToSend s;
                    var message = ev.CallbackQuery.Message;
                    if (ev.CallbackQuery.Data == "callback1")
                    {
                        s = new Telegram.Bot.Types.FileToSend("https://i.pinimg.com/originals/f7/e9/80/f7e980c9700c8395535b835e66f02a59.jpg");
                    }
                    else if (ev.CallbackQuery.Data == "callback2")
                    {
                        s = new Telegram.Bot.Types.FileToSend("https://static.independent.co.uk/s3fs-public/thumbnails/image/2012/02/29/22/pg-28-sloth-cooke.jpg");
                    }
                    await bot.SendPhotoAsync(message.Chat.Id, s, "Sure! But... not today :)");

                    await bot.AnswerCallbackQueryAsync(ev.CallbackQuery.Id);
                };

                bot.OnUpdate += async(object su, Telegram.Bot.Args.UpdateEventArgs evu) =>
                {
                    if (evu.Update.CallbackQuery != null || evu.Update.InlineQuery != null)
                    {
                        return;
                    }
                    var update  = evu.Update;
                    var message = update.Message;
                    if (message == null)
                    {
                        return;
                    }
                    if (message.Type == Telegram.Bot.Types.Enums.MessageType.TextMessage)
                    {
                        if (message.Text[0] == '/')
                        {
                            if (message.Text == "/test")
                            {
                                await bot.SendTextMessageAsync(message.Chat.Id, "Yeah...",
                                                               replyToMessageId : message.MessageId);
                            }

                            if (message.Text == "/sleep")
                            {
                                var s = new Telegram.Bot.Types.FileToSend("https://beano-uploads-production.imgix.net/store/f4046f22dffe92e3f2167accb6942f788159d0f979f970dcda59f1d0e529?auto=compress&w=752&h=423&fit=min");
                                await bot.SendPhotoAsync(message.Chat.Id,
                                                         s, "Yeeeeeeeeeah, sleeeeeeeeep!");
                            }

                            if (message.Text == "/song")
                            {
                                var s = new Telegram.Bot.Types.FileToSend("http://store.naitimp3.ru/download/0/cGR1a0tRTWJwZW8wMlI2aitkT1UzVkxNdXE2dUNiRTAvcGRkeGphMTVFVTdQcGFURWlFOFQyUGZFTXJ6UVo4cWxVSUNza2NOQUpoZkJOU2ozYTJhWUpLSVdiUTRTanQrVmZnN1hQV1U5Tkk9/eels_i_need_some_sleep_(NaitiMP3.ru).mp3");
                                await bot.SendAudioAsync(message.Chat.Id, s, "", 4, "Eels", "I need some sleep...");
                            }

                            if (message.Text == "/work")
                            {
                                var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(
                                    new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardButton[][]
                                {
                                    // First row
                                    new [] {
                                        // First column
                                        new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardCallbackButton("Work", "callback1"),

                                        // Second column
                                        new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardCallbackButton("Work harder", "callback2")
                                    },
                                }
                                    );

                                await bot.SendTextMessageAsync(message.Chat.Id, "Hmmmm... What should I do?..!", Telegram.Bot.Types.Enums.ParseMode.Default, false, false, 0, keyboard);
                            }
                        }
                        else if ((message.Text[0] >= 'а' && message.Text[0] <= 'я') || (message.Text[0] >= 'А' && message.Text[0] <= 'Я'))
                        {
                            await bot.SendTextMessageAsync(message.Chat.Id, "I'm too lazy to learn russian, sorry...",
                                                           replyToMessageId : message.MessageId);
                        }
                        else
                        {
                            AIMLbot.Request r   = new AIMLbot.Request(message.Text, us, lazy);
                            AIMLbot.Result  res = lazy.Chat(r);

                            await bot.SendTextMessageAsync(message.Chat.Id, res.Output,
                                                           replyToMessageId : message.MessageId);
                        }
                    }
                };

                bot.StartReceiving();
            }
            catch (Telegram.Bot.Exceptions.ApiRequestException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #53
0
 public void testRequestConstructor()
 {
     mockRequest = new Request("This is a test", this.mockUser, this.mockBot);
     Assert.Equal("This is a test", mockRequest.rawInput);
 }
Пример #54
0
 public void setupMockObjects()
 {
     this.mockBot     = new Bot();
     this.mockUser    = new User("1", this.mockBot);
     this.mockRequest = new Request("This is a test", this.mockUser, this.mockBot);
 }