Esempio n. 1
0
        public async void Test1()
        {
            var quoteApi = new QuoteApi("https://test-api.iasadmin.com/Quote_API");
            var qu       = await quoteApi.ApiQuoteGetUSStateGetWithHttpInfoAsync("33611");

            Assert.Equal("FL", qu.Content.ToString());
        }
Esempio n. 2
0
        public async void Test2()
        {
            var quoteApi = new QuoteApi("https://test-api.iasadmin.com/Quote_API");
            var qu       = await quoteApi.ApiQuoteGetIssueAgeGetWithHttpInfoAsync(DateTime.Now,
                                                                                  Convert.ToDateTime("11/23/1968"));

            Assert.Equal("52", qu.Content.ToString());
        }
Esempio n. 3
0
        public async Task GetRandomQuote()
        {
            var quoteApi   = new QuoteApi();
            var quoteOfDay = await quoteApi.GetQuoteOfDay();

            Quote.QuoteString = "\"" + quoteOfDay.QuoteString + "\"";
            //_drawInfo.QouteOfDay =
            //   "\"You know what it’s like to wake up in the middle of the night with a vivid dream? And you know that if you don’t have a pencil and pad by the bed, it will be completely gone by the next morning. Sometimes it’s important to wake up and stop dreaming. When a really great dream shows up, grab it.\"";
            Quote.Author = "- " + quoteOfDay.Author;
        }
Esempio n. 4
0
 public async Task Quote(QuoteType type = QuoteType.Random, [Multiword] string text = "")
 {
     if (type == QuoteType.Default)
     {
         var quote = new QuoteApi().Quote();
         if (quote != null)
         {
             await Context.EmbedAsync(new EmbedBuilder()
                                      .WithDescription(quote.QuoteText)
                                      .WithFooter(quote.QuoteAuthor.Length > 0 ? $"by {quote.QuoteAuthor}" : "")
                                      ).ConfigureAwait(false);
         }
         else
         {
             await Context.ApplyResultReaction(CommandResult.Failed).ConfigureAwait(false);
         }
     }
     else if (type == QuoteType.Trump)
     {
         var quote = new TrumpQuoteApi().Quote(text?.Length > 0 ? text : null);
         if (!string.IsNullOrEmpty(quote))
         {
             await Context.EmbedAsync(new EmbedBuilder()
                                      .WithDescription(quote)
                                      .WithFooter(new EmbedFooterBuilder()
             {
                 Text = @"by Donald Trump"
             })
                                      ).ConfigureAwait(false);
         }
         else
         {
             await Context.ApplyResultReaction(CommandResult.Failed).ConfigureAwait(false);
         }
     }
 }
Esempio n. 5
0
 public void Init()
 {
     instance = new QuoteApi();
 }
Esempio n. 6
0
 public void Init()
 {
     instance = new QuoteApi();
 }
Esempio n. 7
0
        internal async Task <string> AnswerQuestionAsync(string userQuestion)
        {
            AIConfiguration config  = new AIConfiguration("dialogflow.com", SupportedLanguage.Russian);
            var             apiAi   = new ApiAi(config);
            List <string>   answers = new List <string>();

            userQuestion = userQuestion.ToLowerInvariant();

            if (userQuestion == "/start" || userQuestion == "начать")
            {
                try
                {
                    await GetStartMessageAsync(answers);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            if (userQuestion.Contains("сколько времени"))
            {
                var    time       = DateTime.Now.ToString("HH:mm");
                string timeString = $"Точное время: {time}";
                if (!answers.Contains(timeString))
                {
                    answers.Add(timeString);
                }
            }

            if (userQuestion.Contains("какой сегодня день"))
            {
                var    date       = DateTime.Now.ToString("dd.MM.yyyy");
                string dateString = $"Сегодня: {date}";
                if (!answers.Contains(dateString))
                {
                    answers.Add(dateString);
                }
            }

            if (userQuestion.StartsWith("какая погода в городе"))
            {
                var words      = userQuestion.Split(' ');
                var city       = words[words.Length - 1];
                var weatherApi = new WeatherApi();
                var forecast   = await weatherApi.GetWeatherInCityAsync(city);

                if (!answers.Contains(forecast))
                {
                    answers.Add(forecast);
                }
            }

            if (userQuestion == "цитата")
            {
                var    quoteApi = new QuoteApi();
                string quote    = await quoteApi.GetQuote();

                if (!answers.Contains(quote))
                {
                    answers.Add(quote);
                }
            }


            if (answers.Count == 0)
            {
                var    response = apiAi.TextRequest(userQuestion);
                string answer   = response.Result.Fulfillment.Speech;
                if (String.IsNullOrEmpty(answer))
                {
                    answer = "Прости, я тебя не понимаю";
                }

                answers.Add(answer);
            }

            return(String.Join(", ", answers));
        }