Beispiel #1
0
        public object LunchRequest([FromBody] AliceRequest aliceRequest, [FromHeader] string Authorization = null)
        {
            if (Authorization != null)
            {
                new AliceLunchService().Execute("проверка токена авторизации");
                if (service.CheckAuthorization(Authorization, aliceRequest.Session.SessionId))
                {
                    new AliceLunchService().Execute("активация навыка");
                    var answer = service.ProcessLunchRequest(aliceRequest);
                    return(aliceRequest.Reply(answer));
                }

                else
                {
                    new AliceLunchService().Execute("ОШИБКА АВТОРИЗАЦИИ");
                    return(aliceRequest.Reply("Ошибка авторизации, попробуйте еще раз"));
                }
            }
            else if (aliceRequest.Meta.Interfaces.AccountLinking != null)
            {
                new AliceLunchService().Execute("запрос авторизации");
                return(aliceRequest.AuthReply());
            }
            else
            {
                new AliceLunchService().Execute("авторизация не поддерживается");
                return(aliceRequest.Reply("авторизация недоступна"));
            }
        }
Beispiel #2
0
        //api/Alice
        public AliceResponse CofeeRequest([FromBody] AliceRequest aliceRequest)
        {
            logger.Debug("Получен запрос от Алисы: " + JsonConvert.SerializeObject(aliceRequest));
            switch (aliceRequest.Session.SkillId)
            {
            case "CoffeskillID":
            {
                if (aliceRequest.Request.OriginalUtterance.Contains("Сделай кофе"))
                {
                }
                else if (aliceRequest.Request.OriginalUtterance.Contains("Долго еще?"))
                {
                }
                else
                {
                    return(aliceRequest.Reply("Непонятно, повторите", "Непон+ятно, повтор+ите"));
                }
            }

            default:
            {
                return(aliceRequest.Reply("Неизвестная команда", "Неизв+естная ком+анда", true));
                //break;
            }
            }
            //var response = aliceRequest.Reply(aliceRequest.Request.OriginalUtterance, true);
            //logger.Debug("Отправляю ответ: " + JsonConvert.SerializeObject(response));
            //return response;
        }
Beispiel #3
0
 public AliceResponse Proc(AliceRequest request, AnswerManagement answer, Random random, ConcurrentDictionary <string, SuperHeroDaySession> concurrentDictionary)
 {
     if (concurrentDictionary.TryRemove(request.Session.SessionId, out _))
     {
         return(request.Reply(answer.Text[random.Next(answer.Text.Length)], true));
     }
     else
     {
         return(request.Reply("Команда Пока! Не смог удалить user в session, но разпознал WordsActivators"));
     }
 }
        public AliceResponse Post([FromBody] AliceRequest value)
        {
            generator.SetData(value);
            var result = generator.Generate();

            return(value.Reply(result));
        }
        public static AliceResponse Reply(this AliceRequest req, ResponseCard card)
        {
            var response = req.Reply(card.Title);

            response.Response.Card = card;
            return(response);
        }
Beispiel #6
0
        public AliceResponse Process(AliceRequest request, LemurState state)
        {
            var image  = GetNext();
            var result = request.Reply(image);

            return(result);
        }
        public static AliceResponse Reply(this AliceRequest req, ResponseCard card, string text = "")
        {
            var response = req.Reply(text);

            response.Response.Card = card;
            return(response);
        }
Beispiel #8
0
        public AliceResponse Post([FromBody] AliceRequest aliceRequest)
        {
            aGen.SetData(aliceRequest);
            var answer = aGen.Generate();

            return(aliceRequest.Reply(answer));
        }
Beispiel #9
0
        public AliceResponse Process(AliceRequest request, LemurState state)
        {
            var response = request.Reply($"{GetBestQuote(request.Request.OriginalUtterance)} - - - - - - - - - \n{finishingQuestionsProcessor.GetNext()}");

            state.AskedFinishQuestion = true;
            return(response);
        }
        //api/Alice
        public AliceResponse CofeeRequest([FromBody] AliceRequest aliceRequest)
        {
            logger.Debug("Получен запрос от Алисы: " + JsonConvert.SerializeObject(aliceRequest));
            generator.SetData(aliceRequest);
            var answer = generator.Generate();

            return(aliceRequest.Reply(answer));
        }
Beispiel #11
0
        public AliceResponse Proc(AliceRequest request, FillingData fillingData, Random random)
        {
            var facts = fillingData.FillingFactsIsHoroscope(new DateTime(2020, 10, 1));

            if (request.HasScreen())
            {
                ResponseCard responsecard = new ResponseCardBigImage()
                {
                    Title = "День Супер Героя приветствует тебя!", ImageId = "1030494/ec38baf408786fd3d8ed"
                };
                return(request.Reply(responsecard));
            }
            else
            {
                return(request.Reply("День Супер Героя приветствует тебя! " + facts[random.Next(facts.Count)].Fact));
            }
        }
Beispiel #12
0
    public AliceResponse WebHook([FromBody] AliceRequest req)
    {
        var str = req.Request.Command.Split(' ');

        var m = new MorpherClient();

        str = str.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => m.Russian.Parse(x).Plural.Nominative).ToArray();

        var s = str.FirstOrDefault(x => replies.ContainsKey(x));

        if (s != null)
        {
            return(req.Reply(replies[s]));
        }

        return(req.Reply("я не знаю такой цвет"));
    }
Beispiel #13
0
        public AliceResponse Process(AliceRequest request, LemurState state)
        {
            var response = request.Reply("Может послушаешь музыку?");

            response.Response.Buttons = new[]
            {
                GetNext()
            };
            state.AskedFinishQuestion = true;
            return(response);
        }
Beispiel #14
0
        public AliceResponse Proc(AliceRequest request, ConcurrentDictionary <string, SuperHeroDaySession> concurrentDictionary, FillingData fillingData, Random random)
        {
            SuperHeroDaySession heroAndDialog = concurrentDictionary[request.Session.SessionId];

            switch (heroAndDialog.Context)
            {
            case EnumDialogueContext.History:
                var history = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x.History).FirstOrDefault();
                return(request.Reply($"{history}"));

            case EnumDialogueContext.Facts:
                Facts facts = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(y => y.Facts[random.Next(1, y.Facts.Count)]).FirstOrDefault();
                if (request.HasScreen())
                {
                    return(request.Reply($"{facts.Fact}"));
                    // todo: add buttom "ещё"
                }
                else
                {
                    return(request.Reply($"{facts.Fact}"));
                }

            case EnumDialogueContext.DebutComicBook:
                if (request.HasScreen())
                {
                    var          superHero    = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x).FirstOrDefault();
                    ResponseCard responseCard = new ResponseCardItemsList()
                    {
                        Header = new ResponseItemsListHeader {
                            Text = superHero.HeroicName
                        },
                        Items = new ResponseItemsListImage[] { new ResponseItemsListImage {
                                                                   Title = $"Дебютировал {superHero.DebutDate.ToLongDateString()}", Descriptin = superHero.DebutComicBook + superHero.DebutComicBookNumber
                                                               } },
                        // todo: format date
                        Footer = new ResponseCardFooter {
                            Text = "Оценить навык", Button = new ResponseCardButton {
                                Text = "Оценить навык"
                            }
                        }
                    };
                    return(request.Reply(responseCard));
                }
                else
                {
                    var comicBook = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(y => new { y.DebutComicBook, y.DebutComicBookNumber, y.DebutDate }).FirstOrDefault();
                    return(request.Reply($"{comicBook.DebutComicBook}{comicBook.DebutComicBookNumber} {comicBook.DebutDate.Month} {comicBook.DebutDate.Year}"));
                }

            case EnumDialogueContext.Universe:
                if (request.HasScreen())
                {
                    var          superHero    = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x).FirstOrDefault();
                    ResponseCard responseCard = new ResponseCardItemsList()
                    {
                        Header = new ResponseItemsListHeader {
                            Text = superHero.HeroicName
                        },
                        Items = new ResponseItemsListImage[] { new ResponseItemsListImage {
                                                                   Title = superHero.Universe, Descriptin = "Вселенная"
                                                               } },
                        Footer = new ResponseCardFooter {
                            Text = "Оценить навык", Button = new ResponseCardButton {
                                Text = "Оценить навык"
                            }
                        }
                    };
                    return(request.Reply(responseCard));
                }
                else
                {
                    var universe = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x.Universe).FirstOrDefault();
                    return(request.Reply($"{universe}"));
                }

            case EnumDialogueContext.Nickname:
                if (request.HasScreen())
                {
                    var          superHero    = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x).FirstOrDefault();
                    ResponseCard responseCard = new ResponseCardItemsList()
                    {
                        Header = new ResponseItemsListHeader {
                            Text = superHero.RealName
                        },
                        Items = new ResponseItemsListImage[] { new ResponseItemsListImage {
                                                                   Title = superHero.HeroicName, Descriptin = "Супергеройское имя"
                                                               } },
                        Footer = new ResponseCardFooter {
                            Text = "Оценить навык", Button = new ResponseCardButton {
                                Text = "Оценить навык"
                            }
                        }
                    };
                    return(request.Reply(responseCard));
                }
                else
                {
                    var nickname = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x.HeroicName).FirstOrDefault();
                    return(request.Reply($"{nickname}"));
                }

            case EnumDialogueContext.RealName:
                if (request.HasScreen())
                {
                    var          superHero    = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x).FirstOrDefault();
                    ResponseCard responseCard = new ResponseCardItemsList()
                    {
                        Header = new ResponseItemsListHeader {
                            Text = superHero.HeroicName
                        },
                        Items = new ResponseItemsListImage[] { new ResponseItemsListImage {
                                                                   Title = superHero.RealName, Descriptin = "Настоящее имя"
                                                               } },
                        Footer = new ResponseCardFooter {
                            Text = "Оценить навык", Button = new ResponseCardButton {
                                Text = "Оценить навык"
                            }
                        }
                    };
                    return(request.Reply(responseCard));
                }
                else
                {
                    var realName = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x.RealName).FirstOrDefault();
                    return(request.Reply($"{realName}"));
                }

            case EnumDialogueContext.Horoscop:
                //if (request.HasScreen()) {
                //    Facts horoscop = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(y => y.Facts.Where(z => z.IsHoroscope == true).ElementAt(random.Next(0, y.Facts.Count()))).FirstOrDefault();
                //    ResponseCard responseCard = new ResponseCardItemsList()
                //    {
                //        Header = new ResponseItemsListHeader { Text = "Гороскоп" },
                //        Items = new ResponseItemsListImage[] { new ResponseItemsListImage { Title = DateTime.Now.ToLongDateString(), Descriptin = horoscop.Fact } },
                //        Footer = new ResponseCardFooter { Text = "Оценить навык", Button = new ResponseCardButton { Text = "Оценить навык" } }
                //    };
                //    return request.Reply(responseCard);
                //} else {
                Facts horoscop = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(y => y.Facts.Where(z => z.IsHoroscope == true).ElementAt(random.Next(0, y.Facts.Count()))).FirstOrDefault();
                return(request.Reply($"{horoscop.Fact}"));

            //}
            case EnumDialogueContext.All:
                if (request.HasScreen())
                {
                    var          defaultSuperHero = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x).FirstOrDefault();
                    ResponseCard responseCard     = new ResponseCardItemsList()
                    {
                        Header = new ResponseItemsListHeader {
                            Text = defaultSuperHero.HeroicName
                        },
                        Items = new ResponseItemsListImage[] { new ResponseItemsListImage {
                                                                   ImageId = defaultSuperHero.ImageSuperHero, Title = defaultSuperHero.Universe, Descriptin = defaultSuperHero.RealName
                                                               },
                                                               new ResponseItemsListImage {
                                                                   Title = defaultSuperHero.DebutDate.ToLongDateString(), Descriptin = defaultSuperHero.DebutComicBook + defaultSuperHero.DebutComicBookNumber
                                                               } },
                        Footer = new ResponseCardFooter {
                            Text = "Оценить навык", Button = new ResponseCardButton {
                                Text = "Оценить навык"
                            }
                        }
                    };
                    return(request.Reply(responseCard));
                    // todo: format date && add buttons
                }
                else
                {
                    var defaultSuperHero = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x).FirstOrDefault();
                    return(request.Reply($"{defaultSuperHero.HeroicName} из вселенной {defaultSuperHero.Universe} дебютировал {defaultSuperHero.DebutDate.ToLongDateString()} в {defaultSuperHero.DebutComicBook}{defaultSuperHero.DebutComicBookNumber}"));
                }

            default:
                if (request.HasScreen())
                {
                    var          defaultSuperHero = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x).FirstOrDefault();
                    ResponseCard responseCard     = new ResponseCardItemsList()
                    {
                        Header = new ResponseItemsListHeader {
                            Text = defaultSuperHero.HeroicName
                        },
                        Items = new ResponseItemsListImage[] { new ResponseItemsListImage {
                                                                   ImageId = defaultSuperHero.ImageSuperHero, Title = defaultSuperHero.Universe, Descriptin = defaultSuperHero.RealName
                                                               },
                                                               new ResponseItemsListImage {
                                                                   Title = defaultSuperHero.DebutDate.ToLongDateString(), Descriptin = defaultSuperHero.DebutComicBook + defaultSuperHero.DebutComicBookNumber
                                                               } },
                        Footer = new ResponseCardFooter {
                            Text = "Оценить навык", Button = new ResponseCardButton {
                                Text = "Оценить навык"
                            }
                        }
                    };
                    return(request.Reply(responseCard));
                    // todo: format date && add buttons
                }
                else
                {
                    var defaultHistory = fillingData.FillingHero().Where(x => x.Id == heroAndDialog.Hero).Select(x => x.History).FirstOrDefault();
                    return(request.Reply(defaultHistory));
                }
            }
        }
Beispiel #15
0
        public AliceResponse Proc(AliceRequest request, ConcurrentDictionary <string, SuperHeroDaySession> concurrentDictionary)
        {
            SuperHeroDaySession temp = concurrentDictionary[request.Session.SessionId];

            return(request.Reply("Уточни супергероя"));
        }
Beispiel #16
0
 public AliceResponse Process(AliceRequest request, LemurState state)
 {
     return(request.Reply("Привет, я лемур узбого+ин, расскажи мне что с тобой случилось, и я постараюсь поддержать тебя."));
 }
Beispiel #17
0
 public AliceResponse WebHook([FromBody] AliceRequest req)
 {
     return(req.Reply("Привет"));
 }
Beispiel #18
0
 public AliceResponse Process(AliceRequest request, LemurState state)
 {
     return(request.Reply("Я рада, что смогла помочь.", true));
 }
Beispiel #19
0
 public AliceResponse WebHook([FromBody] AliceRequest req) => req.Reply("Привет");
        public AliceResponse Post([FromBody] AliceRequest request)
        {
            var lunchService = new LunchServise();

            request.Reply(lunchService.ProcessLunchRequest(request));
        }