Example #1
0
        internal async Task <SkillResponse> HandleFavIntent()
        {
            SkillResponse response = null;

            // get favs
            _favList = await _powerTwitterService.GetFavouritesList();

            // detect every fav lang
            bool differentLang = false;

            foreach (FavModel fav in _favList)
            {
                fav.lang = await _translateService.DetectLanguage(fav.cr825_message);

                differentLang = fav.lang != _accessor.Lang || differentLang;
            }


            if (_accessor.IntentRequest.Intent.Name == IntentNames.Favorites) // firstTime
            {
                response = await _translateDialog.HandleTranslationPossibilityAsync();
            }
            else
            {
                if (_accessor.IntentRequest.Intent.Name == IntentNames.YesIntent)
                {
                    await ChangeLanguage();
                }
                var message = string.Join("<break time=\"2s\"/>", _favList.Select(fav => fav.ToSSML()));
                message = string.Format(_accessor.LocaleResources.GetValueOrDefault(key: LanguageKeys.Favorites), message);
                message = $"<speak>{message}</speak>";

                response = ResponseBuilder.Tell(new SsmlOutputSpeech()
                {
                    Ssml = message
                });
            }
            return(response);
        }