Esempio n. 1
0
 public AliceResponse(
     AliceRequest request,
     SessionState sessionState = default,
     UserState userState       = default
     ) : base(request, sessionState, userState)
 {
 }
Esempio n. 2
0
        public AliceResponse Generate(AliceRequest request, UserState newUserState = null, SessionState newSessionState = null)
        {
            var(text, tts) = GetTextTtsPair(request.HasScreen());
            var response = new AliceResponse(request, newSessionState, newUserState)
            {
                Response =
                {
                    Text    = text,
                    Tts     = tts,
                    Buttons = Buttons?.Select(b =>
                    {
                        var bData = b.Split("!");
                        return(bData.Length == 1 ? new Button(b) : new Button(bData[0])
                        {
                            Url   = bData[1],Hide= false
                        });
                    }).ToList()
                }
            };

            if (Images != null && Images.Length > 0)
            {
                var description = text
                                  .Replace("\\n", " ")
                                  .Replace("  ", " ")
                                  .SafeSubstring(256);

                if (Images.Length == 1)
                {
                    var imgData = Images[0].Split("!");
                    response.Response.Card = imgData.Length > 1
                        ? new SingleCard(imgData[0], new Button(imgData[1]))
                    {
                        Description = description
                    }
                        : new SingleCard(imgData[0])
                    {
                        Description = description
                    };
                }
                else
                {
                    response.Response.Card = new GalleryCard(Images.Select(i =>
                    {
                        var iData = i.Split("!");
                        return(iData.Length > 1
                            ? new GalleryItem(iData[0], iData[1])
                            : new GalleryItem(i));
                    }));
                }
            }

            return(response);
        }
Esempio n. 3
0
 public AliceResponse(AliceRequest request)
 {
     Session = request.Session;
     Version = request.Version;
 }
Esempio n. 4
0
 public AliceResponce(AliceRequest request)
 {
     Session = request.Session;
 }