Exemple #1
0
        public async Task <bool> Greet(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            usingIntentRouter.Success = true;
            return(true);
        }
Exemple #2
0
        public async Task <bool> HandleNone(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            usingIntentRouter.Success = false;
            return(true);
        }
Exemple #3
0
        public async Task <bool> HandleShowUser(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            var entity = result.Entities.Where(e => e.Key == "username").Select(e => e.Value).FirstOrDefault();

            if (entity == null)
            {
                usingIntentRouter.Success = false;
                return(false);
            }

            var username = entity.First().Value;


            var user = await DataProvider.Instance.GetUserByName(username);

            if (user != null)
            {
                usingIntentRouter.TextResponse = result.OriginalQuery.Replace(username, user.Name);
                var adventure = await DataProvider.Instance.GetLatestAdventureByUser(user);

                ((Frame)Window.Current.Content).Navigate(typeof(AdventurePage), adventure.Id.ToString());
            }
            else
            {
            }

            usingIntentRouter.Success = true;
            return(true);
        }
Exemple #4
0
        public async Task <bool> HandleShowMap(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            var entity = result.Entities.Where(e => e.Key.StartsWith("builtin.geography")).Select(e => e.Value).FirstOrDefault();

            if (entity == null)
            {
                usingIntentRouter.Success = false;
                return(false);
            }

            var location = entity.First().Value;
            var type     = entity.First().Name.Split('.').Last();

            if (MainPage.Instance != null)
            {
                MainPage.Instance.MoveMap(location, type);
            }
            else
            {
                ((Frame)Window.Current.Content).Navigate(typeof(MainPage), $"showmap:{location}:{type}");
            }

            usingIntentRouter.Success = true;
            return(true);
        }
Exemple #5
0
        public async Task <bool> DoMath(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            usingIntentRouter.SpeechRespose = "I like math too";
            usingIntentRouter.Success       = true;
            return(true);
        }
Exemple #6
0
        public async Task <bool> HandleThanks(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            usingIntentRouter.SpeechRespose = "your welcome";
            usingIntentRouter.Success       = true;
            return(true);
        }
Exemple #7
0
        public async Task <bool> HandleWhoIsClosest(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            var adventures = await DataProvider.Instance.GetFriendsAdventures();

            var myLocation = await Maps.GetCurrentLocationAsync();

            if (myLocation == null)
            {
                usingIntentRouter.TextResponse = usingIntentRouter.SpeechRespose = "Could not find your location";
                return(true);
            }

            double    minDistance = double.PositiveInfinity;
            Adventure adv         = null;

            foreach (var adventure in adventures)
            {
                var distance = Maps.GetDistanceBetweenPoints(myLocation.Position, adventure.Location);
                if (distance < minDistance)
                {
                    minDistance = distance;
                    adv         = adventure;
                }
            }

            if (adv != null)
            {
                usingIntentRouter.TextResponse = usingIntentRouter.SpeechRespose = $"Closest adventure is {adv.Name} by {adv.User.Name}";
                if (MainPage.Instance != null)
                {
                    MainPage.Instance.MoveMap(adv);
                }
            }
            else
            {
                usingIntentRouter.TextResponse = usingIntentRouter.SpeechRespose = $"Couldn't find the closest adventure";
            }

            usingIntentRouter.Success = true;
            return(true);
        }