Beispiel #1
0
 private void PraseCommand(AssistantBot assistant, Command command, RecognitionResult result)
 {
     foreach (CustomCommand cmd in _customCommands)
     {
         if (command.MatchById(cmd.id))
         {
             foreach (string line in cmd.instructionLines)
             {
                 if (line.StartsWith("-s"))
                 {
                     assistant.Speak(line.Substring(3, line.Length - 4));
                 }
                 if (line.StartsWith("-o"))
                 {
                     try
                     {
                         System.Diagnostics.Process.Start(line.Substring(3, line.Length - 4));
                     }
                     catch (Exception ex)
                     {
                         assistant.Speak("I couldn't find what you wannted to open. Be sure you provided a link, or a valid path in the custom command " + cmd.name);
                     }
                 }
                 if (line.StartsWith("-w"))
                 {
                     Thread.Sleep(Convert.ToInt32(line.Substring(3, line.Length - 4)));
                 }
             }
             return;
         }
     }
 }
        internal void Prase(RecognitionResult result)
        {
            Command cmd;

            _isParsing = true;
            foreach (Service srv in _services)
            {
                cmd = srv.GetCommandByTag(result.Semantics.Value.ToString());
                if (cmd != null)
                {
                    cmd.Execute(_assistant, result);
                    _isParsing = false;
                    _assistant.formControl.MinimizeWindow();
                    return;
                }
            }
            _isParsing = false;
            _assistant.Speak("Sorry, I did not understand.");
            _assistant.formControl.MinimizeWindow();
        }
Beispiel #3
0
        private void CloneButton_Click(object sender, EventArgs e)
        {
            if (_repositoryPath == null)
            {
                _assistant.Speak("Please provide me with a path to the repository directory.");
                return;
            }

            if (gitName.Text == "")
            {
                _assistant.Speak("Sorry. You have to give me a name for your repository.");
                return;
            }
            if (gitPath.Text.StartsWith(@"https://bitbucket.org") && gitPath.Text != "")
            {
                try
                {
                    Repository.Clone(gitPath.Text, _repositoryPath);
                    string[]      repositories = File.ReadAllLines(_repositoriesFile);
                    List <string> repos        = repositories.ToList();
                    repos.Add(gitName.Text + "|" + Path.Combine(_repositoryPath, ".git"));
                    File.WriteAllLines(_repositoriesFile, repos);
                    _assistant.Speak("Repository cloned!");
                }
                catch (Exception ex)
                {
                    _assistant.Speak("Error ocoured:" + ex.Message);
                }
            }
            else
            {
                if (!_repositoryPath.EndsWith(".git"))
                {
                    _assistant.Speak("Pleas specifiy a path to a git repository.");
                    return;
                }
                string[]      repositories = File.ReadAllLines(_repositoriesFile);
                List <string> repos        = repositories.ToList();
                repos.Add(gitName.Text + "|" + _repositoryPath);
                File.WriteAllLines(_repositoriesFile, repos);
                _assistant.Speak("Repository registered!");
            }
        }