public void TtsValidationIgnoreTags() { var model = new AliceResponseModel(); string tts1024Symbols = "XH9vWSTYNdADOjPYVKoKcjZS0PaTYqXpkHqFUry3fY0q2bm1FzvyPhW6IC8ca11Cpdv0H57XhLI5qsGcHWyBOEi93P325MYNIGHYliYYa4zDc1qCX1eouDAvkDBpxgH6SHhSJzGfJuQ1K60lYTTqmQtchBeDYf0dcCxP6DbCXvPXKrXICGCUliXivtUfYlGUXxW6sdodFUElMhKGfdU9ypMbkyoZ3fXFj26LgMUAFXA7CMNffVSs6d45GOgnDFX5o2BiCvmA65p3tMjKiU0rV068kJOR9567ckQzBz5zNm6HWnz2pvgE9WW3VouEmVEiWY4VVlHLokRCcE2SV63KTttwg3vPJMS9AHfgyaoC7SLQuKFbkx0PQD6P9HKaPXVc8VKMKWLHgqYER24vfk858M3bDmaUNMb4V1aPMX0DQbhtsE2km508KeI0GX21Ha1Z0eCAOXMZrRySAccPNUmm4QGP3ObmuMSYXxHXGDlWUqywuaw67XIYEdZN81UkPlfCG09Oa0a08I6Uu77ajAqzONEk8gQYeqpVPLcxqdbwjXEpiK7xjksOUPYhSZgaHQUbZ05NCGUYJUTimA4TVJOTfz9H5xB6TYxCFn1pjr5R98oXhtwtiRM7KzrHppOAC1dPUotms24i5YlMTmuzMabls4V9FFR58hMTWfmdaqroirExgYwoDZ2r8rNpVR47ITLPdhkhhfjO2hjps0J2Xbj6IyFBBvkAAKSoSkSbfvCcgzkpJ9eHvzCsSCHjE86Vmeh3eXzm20TOwr0bMJ9Dwczxoap01MJevOkWQ4OmQXcCnHVjUAP6BsgHmN2yZLVCqg9FUn9fJIGfN9jVJBdz1qivBpqKsS2Yv2mN4p7GVkkwcgMDnGVxislnR3vCwhf0YNkQ24kAJOvhGVAHhcMKBCF8LmOlvWN04pDvSiZwWUrS4cnHxwJrm6qtkvFxyw4N1zd74wmXH1VuIf6YEPMoo5mo2WmaQdCOZwPqmfXIHLyLFl1LRjOGthwS0wqXO0aoFhHr"; model.Tts = tts1024Symbols; model.Tts += AliceHelper.GetSpeakerTag("test"); }
private static string PrepareText(string text) { if (!string.IsNullOrEmpty(text)) { text = text.Replace("+", string.Empty); text = AliceHelper.GetStringWithoutTags(text); } return(text); }
public void TrimString() { var cardItem = new AliceGalleryCardItem { Title = AliceHelper.PrepareGalleryCardItemTitle(_tooLongString) }; Assert.True(cardItem.Title.Length < AliceGalleryCardItem.MaxTitleLength); Assert.EndsWith(AliceHelper.DefaultReducedStringEnding, cardItem.Title, StringComparison.OrdinalIgnoreCase); TestOutputHelper.WriteLine(cardItem.Title); }
public void MandatoryEnding() { var fireEmoji = char.ConvertFromUtf32(0x1F525); var cardItem = new AliceGalleryCardItem { Title = AliceHelper.PrepareGalleryCardItemTitle("IamShort", fireEmoji, AliceHelper.DefaultReducedStringEnding) }; Assert.True(cardItem.Title.Length < AliceGalleryCardItem.MaxTitleLength); Assert.EndsWith(fireEmoji, cardItem.Title, StringComparison.OrdinalIgnoreCase); TestOutputHelper.WriteLine(cardItem.Title); }
public override IAliceResponseBase Reply(SportsRequest sportsRequest) { SportKind sportKind = GetSportKind(sportsRequest); int pageIndex = GetPageIndex(sportsRequest); var newsResponse = GetNews(pageIndex, sportKind); int maxPageIndex = (int)Math.Ceiling(newsResponse.Total / (float)NewsPerPage) - 1; var buttons = new List <AliceButtonModel>(); if (pageIndex > 0) { buttons.Add(new SportsButtonModel("назад")); } if (pageIndex >= 0 && pageIndex < maxPageIndex) { buttons.Add(new SportsButtonModel("вперед")); } buttons.AddRange(Buttons); var news = newsResponse.Items; if (news.Any()) { var titles = news.Select(x => x.Title); string headerTts = GetSportKindText(HeaderTts, sportKind); string text = $"{headerTts}\n\n{string.Join("\n\n", titles)}"; string tts = $"{headerTts}{AliceHelper.SilenceString500}{string.Join(AliceHelper.SilenceString500, titles)}{AliceHelper.SilenceString1000}{Sports_Resources.Tips_Help}"; var response = new SportsGalleryResponse(sportsRequest, text, tts, buttons); response.Response.Card = new AliceGalleryCardModel { Items = new List <AliceGalleryCardItem>(), Header = new AliceGalleryCardHeaderModel(GetSportKindText(HeaderText, sportKind)) }; foreach (var newsArticle in news) { response.Response.Card.Items.Add(new AliceGalleryCardItem() { Title = AliceHelper .PrepareGalleryCardItemTitle(newsArticle.Title, GetTitleEnding(newsArticle), AliceHelper.DefaultReducedStringEnding), Button = new AliceImageCardButtonModel() { Url = newsArticle.Url } }); } response.Response.Buttons.AddRange(new List <AliceButtonModel>() { new AliceButtonModel("футбол"), new AliceButtonModel("хоккей"), new AliceButtonModel("баскетбол"), new AliceButtonModel("все") }); response.SessionState.PageIndex = pageIndex; response.SessionState.SportKind = sportKind; response.SessionState.CurrentScene = SceneType; return(response); } else { var response = new SportsResponse(sportsRequest, NoNewsText, buttons); response.SessionState.CurrentScene = SceneType; return(response); } }
public T TryGetUser <T>() { return(AliceHelper.JsonElementToObject <T>(User)); }
public T TryGetSession <T>() { return(AliceHelper.JsonElementToObject <T>(Session)); }