예제 #1
0
 private void VeuxTuExecuterSpotify(Wakeup wakeup)
 {
     Talk("You don't have spotify. Do you want to install it ? ");
     wakeup.EnAttenteDuneReponse  = true;
     wakeup.AffirmationPrecedente = "hey carl install spotify.";
     return;
 }
예제 #2
0
        //
        // Comprendre le string et faire une action
        //

        public void Executer(string demande, Wakeup wakeup)
        {
            string username = Environment.UserName;

            string[] demandecut = demande.Split(' ');
            if (Bibliotheque == "Ordre")
            {
                for (int i = 0; i <= demandecut.Length - 1; i++)
                {
                    if (demandecut[i].ToLower() == "spotify")
                    {
                        bool installSpotify = false;
                        //Verifie si on repond a la reponse d'installation
                        if (demandecut[i - 1] == "install")
                        {
                            Process.Start("https://www.spotify.com/ca-fr/download/windows/");
                            wakeup.EnAttenteDuneReponse = false;
                            break;
                        }

                        try
                        {
                            Process.Start("C:\\Users\\" + username + "\\AppData\\Roaming\\Spotify\\Spotify.exe");
                        }
                        catch (System.ComponentModel.Win32Exception)
                        {
                            installSpotify = true;
                        }
                        if (installSpotify)
                        {
                            Talk("You don't have spotify. Do you want to install it ? ");
                            wakeup.EnAttenteDuneReponse  = true;
                            wakeup.AffirmationPrecedente = "hey carl install spotify.";
                            installSpotify = false;
                            break;
                        }
                    }
                    if (demandecut[i].ToLower() == "google")
                    {
                        //Verifier l'ordre qu'on a donner pour demarrer google.
                        if (OrdreChoisi == "search")
                        {
                            if (demandecut[i + 1] == "")
                            {
                                Console.WriteLine("You have to specify what to search.");
                                Talk("You have to specify what to search. ");
                                break;
                            }
                            else
                            {
                                Process.Start("https://www.google.com/search?q=" + demandecut[i + 1]);
                            }
                        }
                        else
                        {
                            Process.Start("http://www.google.com");
                        }

                        break;
                    }
                    if (demandecut[i].ToLower() == "p**n")
                    {
                        Process.Start("http://www.pornhub.com");
                    }
                }
            }
            else if (Bibliotheque == "Question")
            {
                for (int i = 0; i <= demandecut.Length - 1; i++)
                {
                    if (demandecut[i].ToLower() == "temps")
                    {
                        Talk("This is what I found on the net");
                        Process.Start("https://www.theweathernetwork.com");
                    }
                    else if (demandecut[i].ToLower() == "who")
                    {
                        for (int i2 = 0; i2 < demandecut.Length - 1; i2++)
                        {
                            if (demandecut[i2].ToLower() == "are")
                            {
                                for (int i3 = 0; i3 < demandecut.Length; i3++)
                                {
                                    if (demandecut[i3].ToLower() == "you" || demandecut[i3].ToLower() == "you?")
                                    {
                                        Talk("I am Carl, an Artificial Intelligence designed by David Daoud and Félix Noiseux, two students studying in computer science at Saint-Hyacinthe.");
                                    }
                                }
                            }
                        }
                    }
                    else if (true)
                    {
                    }
                }
                Bibliotheque = "";
            }
        }