Example #1
0
        public string boilDown(string sentence)
        {
            int    max     = -1;
            string maxFile = "";
            string path    = "SynBotDir";

            foreach (string fileName in System.IO.Directory.EnumerateFiles(path)) //maybe don't hard code
            {
                Console.WriteLine(fileName + "file");
                SimlBot Chatbot = new SimlBot();
                Chatbot.PackageManager.LoadFromString(File.ReadAllText(fileName));
                var    result    = Chatbot.Chat(sentence);
                string outString = result.BotMessage;
                if (!outString.Contains(";"))
                {
                    continue;
                }
                string[] output     = result.BotMessage.Split(';');
                var      lastString = output[output.Length - 2];
                var      response   = lastString.Split(':');
                int      test       = Convert.ToInt32(response[0]);
                maxFile = max < test ? response[1] : maxFile;
                max     = max < test ? test : max;
            }
            //return new Tuple<string,bool>(maxFile, true);
            return(maxFile);
        }
Example #2
0
        //InitializeComponent();

        public void getMsg(string msg)
        {
            var result = Chatbot.Chat(msg);

            Msg = string.Format("User: {0}\nBot: {1}\n{2}", msg, result.BotMessage, result);
            msg = string.Empty;
        }
        private void SendButton_OnClick(object sender, RoutedEventArgs e)
        {
            var result = Chatbot.Chat(InputBox.Text);

            OutputBox.Text = string.Format("User: {0}\nBot: {1}\n{2}", InputBox.Text, result.BotMessage, OutputBox.Text);
            InputBox.Text  = string.Empty;
        }
Example #4
0
        private void pxj()
        {
            if (File.Exists(datestver.Properties.Settings.Default.stk + ".txt"))
            {
                string[] pkn = File.ReadAllLines(datestver.Properties.Settings.Default.stk + ".txt");
                foreach (string ft in pkn)
                {
                    var chatResulte = lk.Chat(ft);

                    Console.WriteLine(chatResulte.BotMessage);
                }
            }
            else
            {
                File.WriteAllText(datestver.Properties.Settings.Default.stk + ".txt", "my name is yan" + Environment.NewLine);
            }
        }
Example #5
0
        private void GenerateAndPublishBotResponse(IUserResponse message)
        {
            ChatResult result;

            if (currentUser == null)
            {
                result = bot.Chat(message.Text);
            }
            else
            {
                result = bot.Chat(new ChatRequest(message.Text, currentUser));
            }


            IBotResult botResponse = new ICAN.SIC.Plugin.SIMLHub.DataTypes.BotResult(result, message);

            hub.Publish <IBotResult>(botResponse);
        }
Example #6
0
        private void GetBotReponse(IUserResponse message)
        {
            ChatResult result;

            if (currentUser == null)
            {
                result = bot.Chat(message.Text);
            }
            else
            {
                result = bot.Chat(new ChatRequest(message.Text, currentUser));
            }

            Console.WriteLine("PrintMessage: " + result.BotMessage);

            IBotResult botResponse = new BotResult(result, message);

            hub.Publish <IBotResult>(botResponse);
        }
Example #7
0
        public BotResponse GetBotResponse(string input)
        {
            var normalizedInput = _inputNormalizer.Normalize(input);
            var chatResult      = _simlBot.Chat(normalizedInput);

            return(new BotResponse
            {
                ResponseText = chatResult.BotMessage
            });
        }
Example #8
0
        public static string GetResponse(string msg, string user, string languageFile)
        {
            var simlBot = new SimlBot();

            simlBot.PackageManager.LoadFromString(File.ReadAllText(languageFile));
            var result = simlBot.Chat(msg);

            // save it to database
            //db.InsertChat(msg, result.BotMessage, user);
            return(result.BotMessage);
        }
        /*
         * Handles the "send" button click
         */
        private void SendButton_OnClick(object sender, RoutedEventArgs e)
        {
            usermsg = new Label();
            botmsg  = new Label();
            TextBlock txtBlockuser = new TextBlock();
            TextBlock txtBlockbot  = new TextBlock();

            txtBlockuser.TextWrapping = TextWrapping.Wrap;
            txtBlockbot.TextWrapping  = TextWrapping.Wrap;
            var    result = Chatbot.Chat(InputBox.Text);
            string outPut = result.BotMessage;

            txtBlockuser.Text             = " You: " + InputBox.Text;
            usermsg.Name                  = "usermsg"; //user input box
            usermsg.Target                = OutputBox;
            usermsg.Content               = txtBlockuser;
            usermsg.BorderThickness       = new Thickness(1);
            usermsg.Background            = (SolidColorBrush)(new BrushConverter().ConvertFrom(ColorUser));
            usermsg.HorizontalAlignment   = HorizontalAlignment.Center;
            usermsg.VerticalAlignment     = VerticalAlignment.Top;
            usermsg.Width                 = 200;
            usermsg.Margin                = new Thickness(0, 10, 0, 0);
            usermsg.RenderTransformOrigin = new Point(0.5, 0.5);
            usermsg.RenderTransform       = new SkewTransform(10, 0);
            usermsg.FontFamily            = new FontFamily("Candara");
            usermsg.FontSize              = fontSize;
            usermsg.Foreground            = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
            OutputBox.Items.Insert(0, usermsg);
            txtBlockbot.Text             = "  BOT: " + result.BotMessage;
            botmsg.Name                  = GoldBOT; //bot's response box
            botmsg.Target                = OutputBox;
            botmsg.Content               = txtBlockbot;
            botmsg.BorderThickness       = new Thickness(1);
            botmsg.Background            = (SolidColorBrush)(new BrushConverter().ConvertFrom(ColorBOT));
            botmsg.HorizontalAlignment   = HorizontalAlignment.Center;
            botmsg.VerticalAlignment     = VerticalAlignment.Top;
            botmsg.Width                 = 200;
            botmsg.Margin                = new Thickness(28, 0, 0, 0);
            botmsg.RenderTransformOrigin = new Point(0.5, 0.5);
            botmsg.RenderTransform       = new SkewTransform(-10, 0);
            botmsg.FontFamily            = new FontFamily("Candara");
            botmsg.FontSize              = fontSize;
            botmsg.Foreground            = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
            OutputBox.Items.Insert(0, botmsg);
            if (!unixCommands(outPut))//checks for specific responses by the bot to perform functions
            {
                txtBlockbot.Text = " BOT: \n" + Program.backendCommand(InputBox.Text);
                //Console.WriteLine(InputBox.Text+"::: yo");
            }
            InputBox.Text = string.Empty;
            //unixCommands(outPut);
        }
Example #10
0
        private void MakeMachineMessageUserFriendly(IMachineMessage message)
        {
            IUserFriendlyMachineMessage userFriendlyMessage;

            ChatResult result = null;

            if (message.Message != null)
            {
                if (currentUser == null)
                {
                    result = bot?.Chat(message.Message);
                }
                else
                {
                    result = bot?.Chat(new ChatRequest(message.Message, currentUser));
                }
            }

            if (result != null)
            {
                userFriendlyMessage = new UserFriendlyMachineMessage(result.BotMessage);
                hub.Publish <IUserFriendlyMachineMessage>(userFriendlyMessage);
            }
        }
Example #11
0
        public async void SendResponse()
        {
            var chatRequest = new ChatRequest(_message.Text, _user);
            var chatResult  = _siml.Chat(chatRequest);

            if (!chatResult.Success)
            {
                var noResponse = BotClass.BotResponse.SimsimiNullResult();
                await BotClient.SendTextAsync(_message, noResponse);

                return;
            }

            await BotClient.SendTextAsync(_message, chatResult.BotMessage);
        }
    string getResponse(string textReceived)
    {
        if (hasBotBeenCreated == false)
        {
            simlBot = new SimlBot();
            botUser = simlBot.CreateUser();
            var packageString = File.ReadAllText("SIMLPackage.simlpk");
            simlBot.PackageManager.LoadFromString(packageString);
        }
        var chatRequest = new ChatRequest(textReceived, botUser);    //These two can't access the objects created above
        var chatResult  = simlBot.Chat(chatRequest);

        if (chatResult.Success)
        {
            var botMessage = chatResult.BotMessage;
            return(botMessage);
        }
        else
        {
            return("I don't have a response for that");
        }
    }
Example #13
0
        private void Bot_MessageReceived(object sender, MessageEventArgs e)
        {
            Console.WriteLine("{0} said: {1}", e.User.Name, e.Message.Text);

            //Console.WriteLine("Server: " + e.Server);
            //Console.WriteLine("Channel id: " + e.Channel.Id);
            //e.Server.Users

            if (e.Message.IsAuthor)
            {
                return;
            }

            ChatResult result;
            String     chatText = "";
            String     userText = e.Message.Text;

            isPrivate = false;

            ulong chid = e.Message.Channel.Id;

            Console.WriteLine(chid);

            if (e.Message.Channel.IsPrivate)
            {
                //Console.WriteLine("Private Message: ", userText);
                result   = chatBot.Chat(e.Message.Text);
                chatText = result.ToString();
                e.Channel.SendMessage(chatText);
                isPrivate = true;
            }
            else
            {
                if (userText.ToLower().StartsWith("@bob"))
                {
                    System.Threading.Thread.Sleep(500);

                    waiting = false;
                    int    found   = userText.IndexOf(' ');
                    string newText = userText.Substring(found + 1);

                    result = chatBot.Chat(newText);

                    chatText = result.ToString();
                    string output = chatText.Replace("noob Serene player", e.User.Name);
                    e.Channel.SendMessage(output);

                    // Throw out a random message from Bob
                    startTime = DateTime.Now.Millisecond;
                    Random random       = new Random();
                    int    randomNumber = random.Next(5, 21);
                    //endTime = startTime + (randomNumber * 60000);
                    endTime = startTime + 30000;
                    waiting = true;

                    //Console.WriteLine("{0} said: {1}", e.User.Name, newText);
                }
            }

            using (StreamWriter w = File.AppendText(botFilename))
            {
                String currentUsername = e.User.Name;

                if (isPrivate)
                {
                    currentUsername = e.User.Name + " (PM)";
                }

                if (!chatText.Equals(""))
                {
                    Log(currentUsername + ": " + userText, w);
                    Log("Bob: " + chatText, w);
                }
            }
        }
        private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string speech = e.Result.Text.ToLower();

            //Keyword to enable listening mode
            if (e.Result.Text == "ella")
            {
                ISListenModeEnabled = true; //resume listening
                sSynth.Speak("I am listening");
                enableMic.Visibility = System.Windows.Visibility.Visible;
            }

            //Check if AI is in listening mode
            if (ISListenModeEnabled == true)
            {
                //Start Google Search
                if (speech == "search google")
                {
                    ISeventStarted = speech;
                    sSynth.SpeakAsync("what do you want to search google for?");
                    speech = string.Empty;
                }
                else if (speech != string.Empty && ISeventStarted == "search google")
                {
                    Process.Start("http://google.com/search?q=" + speech);
                    ISeventStarted = string.Empty;
                }
                //End Google Search

                //Start setup
                if (speech == "setup")
                {
                    ISeventStarted = speech;
                    sSynth.SpeakAsync("what is your name?");
                    speech = string.Empty;
                }
                else if (speech != string.Empty && ISeventStarted == "setup")
                {
                    assignNames(speech);
                    myName = speech;
                    sSynth.SpeakAsync("hi there " + speech);
                    ISeventStarted = string.Empty;
                }
                //End setup

                //test
                var result     = simlBot.Chat(speech);
                var botMessage = result.BotMessage;

                if (result.Success)
                {
                    sSynth.SpeakAsync(botMessage);
                }

                //Start of commands
                switch (e.Result.Text)
                {
                case "exit application":
                    sSynth.Speak("terminating " + aiName + ", goodbye " + myName);
                    System.Windows.Application.Current.Shutdown();
                    break;

                // case "how are you":
                //   sSynth.Speak("great. how are you?");
                //  break;

                case "test":
                    sSynth.Speak("testing initializing");
                    pBuilder.ClearContent();
                    pBuilder.AppendText(answer.Text);
                    sSynth.Speak(pBuilder);
                    break;

                case "what is your name":
                    if (string.IsNullOrEmpty(aiName))
                    {
                        sSynth.Speak("My name has not been setup. To name me, command me to setup");
                    }
                    else
                    {
                        sSynth.Speak("my name is " + aiName);
                    }
                    break;

                case "read memory":
                    sSynth.Speak("reading memory. initializing memory sequence");
                    sSynth.Speak(word);
                    break;

                case "ella sleep":
                    enableMic.Visibility = System.Windows.Visibility.Hidden;
                    sSynth.Speak("going to sleep");
                    ISListenModeEnabled = false;


                    break;

                case "who are you":
                case "what are you":
                    if (string.IsNullOrEmpty(myName))
                    {
                        sSynth.Speak("i am a personal artificial intelligence assistant");
                    }
                    else
                    {
                        sSynth.Speak("i am " + myName + "'s personal artificial intelligence assistant");
                    }
                    break;

                case "voice reset":
                    sSynth.Speak("voice reset initialized");
                    sSynth.SelectVoice("Microsoft Zira Desktop");
                    sSynth.Speak("voice reset complete");
                    break;


                case "setup reset":
                    sSynth.Speak("setup reset initialized");
                    myName = null;
                    deleteAllSavedStates();
                    if (string.IsNullOrEmpty(myName))
                    {
                        sSynth.Speak("setup reset complete");
                    }
                    else
                    {
                        sSynth.Speak("setup reset failed");
                    }
                    break;

                case "open facebook":
                    sSynth.Speak("Opening Facebook");
                    proc = System.Diagnostics.Process.Start("https://www.facebook.com/");
                    break;

                case "open youtube":
                    sSynth.Speak("Opening youtube");
                    proc = System.Diagnostics.Process.Start("https://www.youtube.com/");
                    break;


                default:
                    answer.Text = answer.Text + " " + e.Result.Text.ToString();
                    break;
                }
                //End of commands
            }
            //End of listening mode check
        }