Exemple #1
1
 public Alice(Player player_)
 {
     player = player_;
     myBot = new AIMLbot.Bot();
     myUser = new User(player.Name, myBot);//y wont u set my name
     Initialize();
 }
    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();
    }
Exemple #3
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);
                }
            }
        }
Exemple #4
0
        //methods
        public bool initialize_iBOT()
        {
            //initialize bot
            bot = new Bot();
            bot.loadSettings(); //TODO: change settings.xml in config

            //user settings
            user = new User("DefaultUser", this.bot);

            //Log writer event setting
            bot.WrittenToLog += new Bot.LogMessageDelegate(bot_Log);

            //Initialize the bot's Mind
            try
            {
                AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.bot);
                this.bot.isAcceptingUserInput = false;
                loader.loadAIML(AIMLSourcePath);
                this.bot.isAcceptingUserInput = true;
            }
            catch (Exception ex)
            {
                ExceptionMsgs += DateTime.Now.ToString() + ">> " + ex.Message + Environment.NewLine;
                return false;
            }
            //the bot is ready to serve!
            initialized = true;
            return true;
        }
Exemple #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());
     }
 }
Exemple #6
0
 public TalkToAvatar(RadegastInstance inst, AIMLBot bot)
     : base(inst)
 {
     ContextType = typeof (Avatar);
     Label = "Talk to";
     aimlBot = bot;
 }
Exemple #7
0
 public void testSplittersSetUpFromBadData()
 {
     string pathToSettings = Path.Combine(Environment.CurrentDirectory, Path.Combine("configAlt", "SettingsAltBad.xml"));
     this.mockBot = new AIMLbot.Bot();
     this.mockBot.loadSettings(pathToSettings);
     Assert.AreEqual(4, this.mockBot.Splitters.Count);
 }
Exemple #8
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);

            }
        }
Exemple #9
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;
 }
Exemple #10
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="rawInput">The raw input from the user</param>
 /// <param name="user">The user who made the request</param>
 /// <param name="bot">The bot to which this is a request</param>
 public Request(string rawInput, User user, Bot bot)
 {
     this.rawInput = rawInput;
     this.user = user;
     this.bot = bot;
     this.StartedOn = DateTime.Now;
 }
Exemple #11
0
 public void testLoadAIMLWithValidAIMLfiles()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
     this.mockLoader.loadAIML();
     Assert.AreEqual(AIMLTagHandlers.sizeTagTests.Size, this.mockBot.Size);
 }
Exemple #12
0
 public void testLoadAIMLWithEmptyPath()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     this.mockBot.GlobalSettings.addSetting("aimldirectory", "aimlEmpty");
     this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
     this.mockLoader.loadAIML();
 }
Exemple #13
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);
        }
Exemple #14
0
 public Form1()
 {
     InitializeComponent();
     _myBot = new Bot();
     _myBot.loadSettings();
     _myUser = new User("consoleUser", _myBot);
     _synth = new SpeechSynthesizer();
 }
Exemple #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);
 }
Exemple #16
0
 public void testLoadAIMLFileWithValidXMLButMissingPattern()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     this.mockBot.GlobalSettings.addSetting("aimldirectory", "badaiml");
     this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
     this.mockLoader.loadAIMLFile(Path.Combine(this.mockBot.PathToAIML, "missingPattern.aiml"));
 }
Exemple #17
0
 public void testLoadAIMLFileWithBadXML()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     this.mockBot.GlobalSettings.addSetting("aimldirectory", "badaiml");
     this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
     this.mockLoader.loadAIMLFile(Path.Combine(this.mockBot.PathToAIML,"badlyFormed.aiml"));
 }
Exemple #18
0
 public void setupMockObjects()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     this.mockBot.loadAIMLFromFiles();
     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);
 }
Exemple #19
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> *");
 }
Exemple #20
0
        //private int cnt = 0;
        public METAbrain(METAboltInstance instance, AIMLbot.Bot myBot)
        {
            this.instance = instance;
            //client = this.instance.Client;
            netcom = this.instance.Netcom;
            this.myBot = myBot;

            answer = new mBrain();
        }
Exemple #21
0
 public aimlForm()
 {
     InitializeComponent();
     this.toolStripMenuItemSpeech.Checked = true;
     this.richTextBoxInput.Focus();
     myBot = new Bot();
     myBot.loadSettings();
     myUser = new User("DefaultUser",this.myBot);
     myBot.WrittenToLog += new Bot.LogMessageDelegate(myBot_WrittenToLog);
 }
Exemple #22
0
        public ChatBot(string userId)
        {
            this.bot = new Bot();
            this.bot.loadSettings();

            this.user = new User(userId, this.bot);
            this.bot.isAcceptingUserInput = false;
            this.bot.loadAIMLFromFiles();
            this.bot.isAcceptingUserInput = true;
        }
Exemple #23
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);
 }
        public MainWindow()
        {
            bot = new Bot();
            user = new User("DefaultUser", bot);
            bot.loadSettings();
            AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(bot);
            bot.isAcceptingUserInput = false;
            loader.loadAIML(bot.PathToAIML);
            bot.isAcceptingUserInput = true;

            InitializeComponent();
        }
Exemple #25
0
        public HotShotBot()
        {
            //------I added this code just coz I love that Light Green Geeky Looking Console ;-)------
                    //Console.BackgroundColor = ConsoleColor.Blue;
                      Console.ForegroundColor = ConsoleColor.Green;
            //----------------------------------------------------------------------------------------

            AimlBot = new Bot();
            myUser = new User(UserId, AimlBot);
            Console.Title = "HotShotBot v1.0 - By Vivek Yadav (www.Shellvhack.com)";
            Initialize();
        }
Exemple #26
0
 public void testGeneratePathWorksWithGoodData()
 {
     this.mockBot = new Bot();
     this.mockBot.loadSettings();
     XmlDocument testDoc = new XmlDocument();
     testDoc.Load(Path.Combine(this.mockBot.PathToAIML,"testThat.aiml"));
     XmlNode testNode = testDoc.LastChild.FirstChild.FirstChild;
     this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
     string result = this.mockLoader.generatePath(testNode, "testing topic 123", false);
     string expected = "test 1 <that> testing that 123 <topic> testing topic 123";
     Assert.AreEqual(expected, result);
 }
Exemple #27
0
        public void testCustomTagPigLatin()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.AreEqual(true, fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);
            Result output = this.mockBot.Chat("Test pig latin", "1");

            Assert.AreEqual("(Allway ethay orldway isway away agestay!).", output.Output);
        }
Exemple #28
0
        public void testCustomTagAccessToWebService()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.AreEqual(true, fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);
            Result output = this.mockBot.Chat("what is my fortune", "1");

            Assert.Greater(output.RawOutput.Length, 0);
        }
Exemple #29
0
        public void TestCustomTagNotFoundInLoadedDll()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.AreEqual(true, fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);
            Result output = this.mockBot.Chat("test missing custom tag", "1");

            Assert.AreEqual("The inner text of the missing tag.", output.RawOutput);
        }
Exemple #30
0
        public void testCustomTagOverride()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.AreEqual(true, fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);
            Result output = this.mockBot.Chat("test custom tag override", "1");

            Assert.AreEqual("Override default tag implementation works correctly.", output.RawOutput);
        }
Exemple #31
0
        public void testCustomTagGoodData()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.AreEqual(true, fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);
            Result output = this.mockBot.Chat("test custom tag", "1");

            Assert.AreEqual("Test tag works! inner text is here.", output.RawOutput);
        }
Exemple #32
0
        public void testCustomTagAccessToRssFeedWithArguments()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.AreEqual(true, fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);
            Result output = this.mockBot.Chat("Test news tag with descriptions", "1");
            string result = output.RawOutput.Replace("[[BBC News]]", "");

            Assert.Greater(result.Length, 0);
        }
        /// <summary>
        /// Returns a User from cache or creates a new one, based upon their Gmail username, allowing the bot to track conversations per user.
        /// </summary>
        /// <param name="jid">unique string ID (gmail username)</param>
        /// <returns>User</returns>
        public static User GetUser(string jid, Bot bot)
        {
            // Maintain sticky sessions with specific users, allows bot to remember them.
            Hashtable myHash = Hashtable.Synchronized(_userSessions);
            User user = (User)myHash[jid];

            if (user == null)
            {
                user = new User(jid, bot);
                myHash[jid] = user;
            }

            return user;
        }
Exemple #34
0
        public void testCustomTagAccessToRSSFeed()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.True(fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);
            Result output = this.mockBot.Chat("Test news tag", "1");
            string result = output.RawOutput.Replace("[[BBC News]]", "");

            Assert.True(result.Length > 0);
        }
Exemple #35
0
        private Dictionary<string, User> _users; // The people chatting to this bot

        #endregion Fields

        #region Constructors

        public AimlChatProvider(string ownerFirstName)
        {
            System.Console.WriteLine("[AILMCharProvider] CHAT:STARTLISTENING, CHAT:STOPLISTENING, CHAT:RELOAD_NLP are acceptable commands from client chat channel.");
            _bot = new AimlBot();
            _bot.loadSettings();
            _bot.isAcceptingUserInput = false;
            _bot.loadAIMLFromFiles();

            _bot.isAcceptingUserInput = true;

            _users = new Dictionary<string, User>();
            _chatActive = false;
            _ownerFirstName = ownerFirstName;
        }
Exemple #36
0
 public void testLoadSettingsWithPath()
 {
     string pathToSettings = Path.Combine(Environment.CurrentDirectory,Path.Combine("configAlt","SettingsAlt.xml"));
     this.mockBot = new AIMLbot.Bot();
     this.mockBot.loadSettings(pathToSettings);
     Assert.AreEqual(true, this.mockBot.GlobalSettings.containsSettingCalled("aimldirectory"));
     Assert.AreEqual(true, this.mockBot.GlobalSettings.containsSettingCalled("feelings"));
     Assert.AreEqual("*****@*****.**", this.mockBot.AdminEmail);
     Assert.AreEqual(AIMLbot.Utils.Gender.Unknown, this.mockBot.Sex);
     Assert.AreEqual(true, this.mockBot.GenderSubstitutions.containsSettingCalled(" HE "));
     Assert.AreEqual(true, this.mockBot.Person2Substitutions.containsSettingCalled(" YOUR "));
     Assert.AreEqual(true, this.mockBot.PersonSubstitutions.containsSettingCalled(" MYSELF "));
     Assert.AreEqual(true, this.mockBot.DefaultPredicates.containsSettingCalled("we"));
 }
Exemple #37
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");
 }
Exemple #38
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");
 }
Exemple #39
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;
        }
Exemple #40
0
        public void testGeneratePathWorksAsUserInput()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            XmlDocument testDoc = new XmlDocument();

            testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testNoThat.aiml"));
            XmlNode testNode = testDoc.LastChild.FirstChild;

            this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
            string result   = this.mockLoader.generatePath("This * is _ a pattern", "This * is _ a that", "This * is _ a topic", true);
            string expected = "This is a pattern <that> This is a that <topic> This is a topic";

            Assert.AreEqual(expected, result);
        }
Exemple #41
0
        public void testLoadSettingsWithPath()
        {
            string pathToSettings = Path.Combine(Environment.CurrentDirectory, Path.Combine("configAlt", "SettingsAlt.xml"));

            this.mockBot = new AIMLbot.Bot();
            this.mockBot.loadSettings(pathToSettings);
            Assert.AreEqual(true, this.mockBot.GlobalSettings.containsSettingCalled("aimldirectory"));
            Assert.AreEqual(true, this.mockBot.GlobalSettings.containsSettingCalled("feelings"));
            Assert.AreEqual("*****@*****.**", this.mockBot.AdminEmail);
            Assert.AreEqual(AIMLbot.Utils.Gender.Unknown, this.mockBot.Sex);
            Assert.AreEqual(true, this.mockBot.GenderSubstitutions.containsSettingCalled(" HE "));
            Assert.AreEqual(true, this.mockBot.Person2Substitutions.containsSettingCalled(" YOUR "));
            Assert.AreEqual(true, this.mockBot.PersonSubstitutions.containsSettingCalled(" MYSELF "));
            Assert.AreEqual(true, this.mockBot.DefaultPredicates.containsSettingCalled("we"));
        }
Exemple #42
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;
     }
 }
Exemple #43
0
        public void testGeneratePathWorksWithNoThatTag()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            XmlDocument testDoc = new XmlDocument();

            testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testNoThat.aiml"));
            XmlNode testNode = testDoc.LastChild.FirstChild;

            this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
            string result   = this.mockLoader.generatePath(testNode, "*", false);
            string expected = "test 1 <that> * <topic> *";

            Assert.AreEqual(expected, result);
        }
Exemple #44
0
        public void testGeneratePathWorksWithGoodDataWithWildcards()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            XmlDocument testDoc = new XmlDocument();

            testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testWildcards.aiml"));
            XmlNode testNode = testDoc.LastChild.FirstChild.FirstChild;

            this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot);
            string result   = this.mockLoader.generatePath(testNode, "testing _ 123 *", false);
            string expected = "test * 1 _ <that> testing * that _ 123 <topic> testing _ 123 *";

            Assert.AreEqual(expected, result);
        }
Exemple #45
0
 public void testLoadSettings()
 {
     this.mockBot = new AIMLbot.Bot();
     this.mockBot.loadSettings();
     Assert.AreEqual(true, this.mockBot.GlobalSettings.containsSettingCalled("aimldirectory"));
     Assert.AreEqual(true, this.mockBot.GlobalSettings.containsSettingCalled("feelings"));
     Assert.AreEqual("", this.mockBot.AdminEmail);
     Assert.AreEqual(true, this.mockBot.TrustAIML);
     Assert.AreEqual(256, this.mockBot.MaxThatSize);
     Assert.AreEqual(AIMLbot.Utils.Gender.Unknown, this.mockBot.Sex);
     Assert.AreEqual(true, this.mockBot.GenderSubstitutions.containsSettingCalled(" HE "));
     Assert.AreEqual(true, this.mockBot.Person2Substitutions.containsSettingCalled(" YOUR "));
     Assert.AreEqual(true, this.mockBot.PersonSubstitutions.containsSettingCalled(" MYSELF "));
     Assert.AreEqual(true, this.mockBot.DefaultPredicates.containsSettingCalled("we"));
 }
Exemple #46
0
        public void testSaveSerialization()
        {
            this.mockBot = new AIMLbot.Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            FileInfo fi = new FileInfo(this.binaryGraphmasterFileName);

            if (fi.Exists)
            {
                fi.Delete();
            }
            this.mockBot.saveToBinaryFile(this.binaryGraphmasterFileName);
            FileInfo fiCheck = new FileInfo(this.binaryGraphmasterFileName);

            Assert.AreEqual(true, fiCheck.Exists);
        }
Exemple #47
0
        public chat()
        {
            chat_time.AutoReset = false;
            chat_time.Elapsed  += stop_chat;
            chat_time.Enabled   = false;

            still_chatting = false;
            chatting_nick  = new List <string>();
            myBot          = new AIMLbot.Bot();
            myBot.loadSettings(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "chat" + Path.DirectorySeparatorChar + "Settings.xml");
            myUser = new User("chat_nick", myBot);

            AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(myBot);
            myBot.isAcceptingUserInput = false;
            loader.loadAIML(myBot.PathToAIML);
            myBot.isAcceptingUserInput = true;
        }
Exemple #48
0
        public void testAttributesAreSetupAfterBadData()
        {
            string pathToSettings = Path.Combine(Environment.CurrentDirectory, Path.Combine("configAlt", "SettingsAltBad.xml"));

            this.mockBot = new AIMLbot.Bot();
            this.mockBot.loadSettings(pathToSettings);
            Assert.AreEqual(this.mockBot.AdminEmail, "");
            Assert.AreEqual(this.mockBot.IsLogging, false);
            System.Globalization.CultureInfo mockCIObj = new System.Globalization.CultureInfo("en-US");
            Assert.AreEqual(this.mockBot.Locale.EnglishName, mockCIObj.EnglishName);
            Assert.AreEqual(this.mockBot.PathToAIML, Path.Combine(Environment.CurrentDirectory, "aiml"));
            Assert.AreEqual(this.mockBot.PathToConfigFiles, Path.Combine(Environment.CurrentDirectory, "config"));
            Assert.AreEqual(this.mockBot.PathToLogs, Path.Combine(Environment.CurrentDirectory, "logs"));
            Assert.AreEqual(this.mockBot.Sex, AIMLbot.Utils.Gender.Unknown);
            Assert.AreEqual(this.mockBot.TimeOut, 2000);
            Assert.AreEqual(this.mockBot.TimeOutMessage, "ERROR: The request has timed out.");
            Assert.AreEqual(this.mockBot.WillCallHome, false);
        }
Exemple #49
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;
        }
    }
Exemple #50
0
 private bool LoadALICE()
 {
     try
     {
         Alice = new AIMLbot.Bot();
         Alice.isAcceptingUserInput = false;
         Alice.loadSettings();
         AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(Alice);
         Alice.isAcceptingUserInput = false;
         loader.loadAIML(Alice.PathToAIML);
         Alice.isAcceptingUserInput = true;
         return(true);
     }
     catch (Exception ex)
     {
         System.Console.WriteLine("Failed loading ALICE: " + ex.Message);
         return(false);
     }
 }
Exemple #51
0
        public void testAttributesAreOKWithGoodData()
        {
            string pathToSettings = Path.Combine(Environment.CurrentDirectory, Path.Combine("configAlt", "SettingsAlt.xml"));

            this.mockBot = new AIMLbot.Bot();
            this.mockBot.loadSettings(pathToSettings);
            Assert.AreEqual(this.mockBot.AdminEmail, "*****@*****.**");
            Assert.AreEqual(this.mockBot.IsLogging, true);
            System.Globalization.CultureInfo mockCIObj = new System.Globalization.CultureInfo("en-GB");
            Assert.AreEqual(this.mockBot.Locale.EnglishName, mockCIObj.EnglishName);
            Assert.AreEqual(this.mockBot.PathToAIML, Path.Combine(Environment.CurrentDirectory, "aiml"));
            Assert.AreEqual(this.mockBot.PathToConfigFiles, Path.Combine(Environment.CurrentDirectory, "configAlt"));
            Assert.AreEqual(this.mockBot.PathToLogs, Path.Combine(Environment.CurrentDirectory, "logs"));
            Assert.AreEqual(this.mockBot.Sex, AIMLbot.Utils.Gender.Unknown);
            Assert.AreEqual(this.mockBot.TimeOut, 2000);
            Assert.AreEqual(this.mockBot.TimeOutMessage, "OOPS: The request has timed out.");
            Assert.AreEqual(this.mockBot.WillCallHome, true);
            Assert.AreEqual(5, this.mockBot.Splitters.Count);
        }
Exemple #52
0
        public MainWindow()
        {
            InitializeComponent();

            asyncWorker         = new BackgroundWorker();
            asyncWorker.DoWork += launchWorkerAsync;

            bot = new AIMLbot.Bot();
            bot.loadSettings();
            bot.isAcceptingUserInput = false;
            bot.loadAIMLFromFiles();
            bot.isAcceptingUserInput = true;
            user = new User("Уважаемый", bot);

            user.Predicates.addSetting("favouriteanimal", "default");
            user.Predicates.addSetting("name", "default");

            Config.current = Config.LoadFromJson(Path.Combine("..", "..", "config.json"));
            generator      = new ImageProcessor();
            initNet();
            net.LoadFromJson(Path.Combine("..", "..", "bot.json"));
        }
Exemple #53
0
        public void testCustomTagsMultipleInstances()
        {
            this.mockBot = new Bot();
            this.mockBot.loadSettings();
            this.mockBot.loadAIMLFromFiles();
            AIMLbot.User           mockUser     = new User("1", this.mockBot);
            AIMLbot.Request        mockRequest  = new Request("Pig latin", mockUser, this.mockBot);
            AIMLbot.Result         mockResult   = new Result(mockUser, this.mockBot, mockRequest);
            AIMLbot.Utils.SubQuery mockSubquery = new AIMLbot.Utils.SubQuery("PIG LATIN <that> * <topic> *");
            FileInfo fi = new FileInfo(this.pathToCustomTagDll);

            Assert.AreEqual(true, fi.Exists);
            this.mockBot.loadCustomTagHandlers(this.pathToCustomTagDll);

            XmlNode pigLatin1 = AIMLbot.Utils.AIMLTagHandler.getNode("<piglatin>(All the world is a stage!)</piglatin>");
            XmlNode pigLatin2 = AIMLbot.Utils.AIMLTagHandler.getNode("<piglatin>(All the world is still a stage!)</piglatin>");

            AIMLbot.Utils.AIMLTagHandler taghandler1 = this.mockBot.getBespokeTags(mockUser, mockSubquery, mockRequest, mockResult, pigLatin1);
            AIMLbot.Utils.AIMLTagHandler taghandler2 = this.mockBot.getBespokeTags(mockUser, mockSubquery, mockRequest, mockResult, pigLatin2);

            Assert.AreEqual("(Allway ethay orldway isway away agestay!)", taghandler1.Transform());
            Assert.AreEqual("(Allway ethay orldway isway illstay away agestay!)", taghandler2.Transform());
        }
 /// <summary>
 /// Pass AIMLbot.Bot instance.
 /// </summary>
 /// <param name="tmpbot">AIMLbot.Bot instance.</param>
 public void Initialize(AIMLbot.Bot tmpbot, string tmppath, bool tmploadsettingsfromscene = false)
 {
     // Should settings be loaded from scene or file.
     loadsettingsfromscene = tmploadsettingsfromscene;
     // Retrieve AIMLbot.Bot instance.
     bot = tmpbot;
     // Throw warning if no bot passed
     if (bot == null)
     {
         Debug.LogWarning("Initialize(AIMLbot.Bot tmpbot) function, tmpbot==null.");
     }
     // Throw waring if no path passed
     if (tmppath == null)
     {
         Debug.LogWarning("Initialize function, tmppath==null. Take default path");
         pathtosettings = Application.dataPath + "/Chatbot/Program%20%23/config/Settings.xml";
     }
     else
     {
         pathtosettings = tmppath;
     }
     StartCoroutine(this.Load(pathtosettings));
 }
 public void setupMockBot()
 {
     this.mockBot = new AIMLbot.Bot();
     this.mockBot.loadSettings();
 }
Exemple #56
0
 public void testLoadSettingsWithEmptyArg()
 {
     // Other tests for loading settings are covered in the generic SettingsDictionaryTests.cs file
     this.mockBot = new AIMLbot.Bot();
     this.mockBot.loadSettings("");
 }
Exemple #57
0
 public RequestTests()
 {
     this.mockBot  = new Bot();
     this.mockUser = new User("1", this.mockBot);
 }
Exemple #58
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);
 }
Exemple #59
0
 public void testAdminEmailValidationApostrophe()
 {
     this.mockBot            = new AIMLbot.Bot();
     this.mockBot.AdminEmail = "o'*****@*****.**";
     Assert.AreEqual(this.mockBot.AdminEmail, "o'*****@*****.**");
 }
Exemple #60
0
        public void StartPlugin(RadegastInstance inst)
        {
            Instance = inst;
            Instance.ClientChanged += new EventHandler <ClientChangedEventArgs>(Instance_ClientChanged);

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.enabled"))
            {
                Instance.GlobalSettings["plugin.alice.enabled"] = OSD.FromBoolean(Enabled);
            }
            else
            {
                Enabled = Instance.GlobalSettings["plugin.alice.enabled"].AsBoolean();
            }

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.disableOnStart"))
            {
                Instance.GlobalSettings["plugin.alice.disableOnStart"] = OSD.FromBoolean(DisableOnStart);
            }
            else
            {
                DisableOnStart = Instance.GlobalSettings["plugin.alice.disableOnStart"].AsBoolean();
            }
            if (DisableOnStart)
            {
                Enabled = false;
            }
            btn_DisableOnStart = new ToolStripMenuItem("Disable on start", null, (object sender, EventArgs e) =>
            {
                DisableOnStart = btn_DisableOnStart.Checked = !DisableOnStart;
                Instance.GlobalSettings["plugin.alice.disableOnStart"] = OSD.FromBoolean(DisableOnStart);
            });
            btn_DisableOnStart.Checked = DisableOnStart;

            EnabledButton = new ToolStripMenuItem("Enabled", null, (object sender, EventArgs e) =>
            {
                Enabled = SetEnabled(!Enabled);
                EnabledButton.Checked = MenuButton.Checked = Enabled;
                Instance.GlobalSettings["plugin.alice.enabled"] = OSD.FromBoolean(Enabled);
            });

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.respondWithoutName"))
            {
                Instance.GlobalSettings["plugin.alice.respondWithoutName"] = OSD.FromBoolean(respondWithoutName);
            }
            else
            {
                respondWithoutName = Instance.GlobalSettings["plugin.alice.respondWithoutName"].AsBoolean();
            }

            respondWithoutNameButton = new ToolStripMenuItem("Respond without name", null, (object sender, EventArgs e) =>
            {
                respondWithoutName = respondWithoutNameButton.Checked = !respondWithoutName;
                Instance.GlobalSettings["plugin.alice.respondWithoutName"] = OSD.FromBoolean(respondWithoutName);
            });

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.respondRange"))
            {
                Instance.GlobalSettings["plugin.alice.respondRange"] = respondRange;
            }
            else
            {
                respondRange = Instance.GlobalSettings["plugin.alice.respondRange"];
            }

            distance_5m = new ToolStripMenuItem("5m range", null, (object sender, EventArgs e) =>
            {
                distance_5m.Checked = !distance_5m.Checked;
                if (distance_5m.Checked)
                {
                    respondRange         = 5;
                    distance_10m.Checked = false;
                    distance_15m.Checked = false;
                    distance_20m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_10m.Checked && !distance_15m.Checked && !distance_20m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            distance_10m = new ToolStripMenuItem("10m range", null, (object sender, EventArgs e) =>
            {
                distance_10m.Checked = !distance_10m.Checked;
                if (distance_10m.Checked)
                {
                    respondRange         = 10;
                    distance_5m.Checked  = false;
                    distance_15m.Checked = false;
                    distance_20m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_5m.Checked && !distance_15m.Checked && !distance_20m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            distance_15m = new ToolStripMenuItem("15m range", null, (object sender, EventArgs e) =>
            {
                distance_15m.Checked = !distance_15m.Checked;
                if (distance_15m.Checked)
                {
                    respondRange         = 15;
                    distance_5m.Checked  = false;
                    distance_10m.Checked = false;
                    distance_20m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_5m.Checked && !distance_10m.Checked && !distance_20m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            distance_20m = new ToolStripMenuItem("20m range", null, (object sender, EventArgs e) =>
            {
                distance_20m.Checked = !distance_20m.Checked;
                if (distance_20m.Checked)
                {
                    respondRange         = 20;
                    distance_5m.Checked  = false;
                    distance_10m.Checked = false;
                    distance_15m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_5m.Checked && !distance_10m.Checked && !distance_15m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            if (!Instance.GlobalSettings.ContainsKey("plugin.alice.shout2shout"))
            {
                Instance.GlobalSettings["plugin.alice.shout2shout"] = OSD.FromBoolean(shout2shout);
            }
            else
            {
                shout2shout = Instance.GlobalSettings["plugin.alice.shout2shout"].AsBoolean();
            }

            btn_shout2shout = new ToolStripMenuItem("Shout response to Shout", null, (object sender, EventArgs e) =>
            {
                shout2shout = btn_shout2shout.Checked = !shout2shout;
                Instance.GlobalSettings["plugin.alice.shout2shout"] = OSD.FromBoolean(shout2shout);
            });

            if (!Instance.GlobalSettings.ContainsKey("plugin.alice.whisper2whisper"))
            {
                Instance.GlobalSettings["plugin.alice.whisper2whisper"] = OSD.FromBoolean(whisper2whisper);
            }
            else
            {
                whisper2whisper = Instance.GlobalSettings["plugin.alice.whisper2whisper"].AsBoolean();
            }

            btn_whisper2whisper = new ToolStripMenuItem("Whisper response to Whisper", null, (object sender, EventArgs e) =>
            {
                whisper2whisper = btn_whisper2whisper.Checked = !whisper2whisper;
                Instance.GlobalSettings["plugin.alice.whisper2whisper"] = OSD.FromBoolean(whisper2whisper);
            });

            MenuButton = new ToolStripMenuItem("ALICE chatbot", null, (object sender, EventArgs e) =>
            {
                Enabled = SetEnabled(!Enabled);
                EnabledButton.Checked = MenuButton.Checked = Enabled;
                Instance.GlobalSettings["plugin.alice.enabled"] = OSD.FromBoolean(Enabled);
            });

            btn_enableDelay = new ToolStripMenuItem("Enable random delay", null, (sender, e) =>
            {
                btn_enableDelay.Checked = !btn_enableDelay.Checked;
                Instance.GlobalSettings["plugin.alice.enable_delay"] = EnableRandomDelay = btn_enableDelay.Checked;
            });
            btn_enableDelay.Checked = EnableRandomDelay = Instance.GlobalSettings["plugin.alice.enable_delay"];

            Instance.MainForm.PluginsMenu.DropDownItems.Add(MenuButton);
            Instance.MainForm.PluginsMenu.Visible = true;
            MenuButton.DropDownItems.Add(EnabledButton);
            MenuButton.Checked = EnabledButton.Checked = Enabled;

            MenuButton.DropDownItems.Add(respondWithoutNameButton);
            MenuButton.DropDownItems.Add(distance_5m);
            MenuButton.DropDownItems.Add(distance_10m);
            MenuButton.DropDownItems.Add(distance_15m);
            MenuButton.DropDownItems.Add(distance_20m);
            MenuButton.DropDownItems.Add(btn_shout2shout);
            MenuButton.DropDownItems.Add(btn_whisper2whisper);

            respondWithoutNameButton.Checked = respondWithoutName;
            if (respondRange == 5.0)
            {
                distance_5m.Checked = true;
            }
            else if (respondRange == 10.0)
            {
                distance_10m.Checked = true;
            }
            else if (respondRange == 15.0)
            {
                distance_15m.Checked = true;
            }
            else if (respondRange == 20.0)
            {
                distance_20m.Checked = true;
            }
            btn_shout2shout.Checked     = shout2shout;
            btn_whisper2whisper.Checked = whisper2whisper;

            MenuButton.DropDownItems.Add(btn_enableDelay);
            MenuButton.DropDownItems.Add(btn_DisableOnStart);
            MenuButton.DropDownItems.Add("Reload AIML", null, (object sender, EventArgs e) =>
            {
                Alice = null;
                GC.Collect();
                LoadALICE();
            });

            SetEnabled(Enabled);

            // Events
            RegisterClientEvents(Client);
        }