Esempio n. 1
0
        /// <summary>
        /// Returns the pre-defined get started response.
        /// </summary>
        public static Activity GetStartedResponse(Activity message, string defaultResponse)
        {
            if (!string.IsNullOrEmpty(defaultResponse))
            {
                BotService.SendATextResponse(message, defaultResponse);
            }

            string   userGreeting        = GetUsernameValue(message.From.Name);
            Activity replyToConversation = message.CreateReply(userGreeting + "To get started, simple type something like the following:\n\n * Show me the top 5 recipes\n\n * Show me a recipe with chicken and basil\n\n * Show me a recipe for risotto\n\n * Show me todays special.\n\n Recipy Bot is always online so feel free to send me a message anytime.");

            return(replyToConversation);
        }
Esempio n. 2
0
        public static Activity GetTopNRecipes(Activity message, int n, string defaultResponse)
        {
            if (!string.IsNullOrEmpty(defaultResponse))
            {
                BotService.SendATextResponse(message, defaultResponse);
            }

            RecipePuppyDataModel webResponse   = WebApiConnectorService.GenericGetRequest <RecipePuppyDataModel>(BotConstants.BotApiSettings.RecipePuppyWebApiUrl);
            IEnumerable <int>    randomNumbers = MiscService.GiveXFromYNumbers(n, webResponse.results.Count());

            return(GenerateRecipeMessage(message, webResponse, randomNumbers, defaultResponse));
        }
Esempio n. 3
0
        public static Activity GetRecipeWith(Activity message, string[] ingredients, string defaultResponse)
        {
            if (!string.IsNullOrEmpty(defaultResponse))
            {
                BotService.SendATextResponse(message, defaultResponse);
            }

            string listOfIngredients           = string.Join(",", ingredients.Select(item => item).ToArray());
            RecipePuppyDataModel webResponse   = WebApiConnectorService.GenericGetRequest <RecipePuppyDataModel>(BotConstants.BotApiSettings.RecipePuppyWebApiUrlWithIngredients + "" + listOfIngredients);
            IEnumerable <int>    randomNumbers = MiscService.GiveXFromYNumbers(BotConstants.OtherConstants.MaxOptionsGives, webResponse.results.Count());

            return(GenerateRecipeMessage(message, webResponse, randomNumbers, defaultResponse));
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the pre-defined feedback response.
        /// </summary>
        public static Activity FeedbackResponse(Activity message, string defaultResponse)
        {
            if (!string.IsNullOrEmpty(defaultResponse))
            {
                BotService.SendATextResponse(message, defaultResponse);
            }

            string response = "We would love to hear your feedback. Please visit [our contact page](https://recipybot.azurewebsites.net/contact) to send us your feedback.";

            BotService.SendATextResponse(message, response);
            Activity replyToConversation = message.CreateReply("If you spot any issues that you would like to raise, please visit [this page](https://github.com/ClydeDz/RecipyBot/issues/new).");

            return(replyToConversation);
        }
Esempio n. 5
0
        /// <summary>
        /// Returns the pre-defined about us response.
        /// </summary>
        public static Activity AboutResponse(Activity message, string defaultResponse)
        {
            if (!string.IsNullOrEmpty(defaultResponse))
            {
                BotService.SendATextResponse(message, defaultResponse);
            }

            string response = "The Recipy Bot is your virtual assistant that helps you in your mundane task of deciding what to cook. Just ask The Recipy Bot what you would like a recipe for or get ideas for recipes that include the ingredients you have on you.";

            BotService.SendATextResponse(message, response);
            Activity replyToConversation = message.CreateReply("This is developed by [Clyde D'Souza](https://clydedsouza.net).\n\nRecipes provided by [Recipe Puppy](http://www.recipepuppy.com/).");

            return(replyToConversation);
        }
Esempio n. 6
0
        public static Activity GetRecipeGif(Activity message, string defaultResponse)
        {
            try
            {
                if (!string.IsNullOrEmpty(defaultResponse))
                {
                    BotService.SendATextResponse(message, defaultResponse);
                }

                GifRecipesDataModel webResponse   = WebApiConnectorService.GenericGetRequest <GifRecipesDataModel>(BotConstants.BotApiSettings.GifRecipes);
                IEnumerable <int>   randomNumbers = MiscService.GiveXFromYNumbers(1, webResponse.data.children.Where(p => p.data.domain == BotConstants.OtherConstants.GifImgurKeyword).Count());

                Activity replyToConversation = message.CreateReply("Here's your GIF recipe");
                replyToConversation.Attachments      = new List <Attachment>();
                replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
                //replyToConversation.Text = "kjfjefkwek";

                foreach (var value in randomNumbers)
                {
                    var thisData = webResponse.data.children.Where(k => k.data.domain == BotConstants.OtherConstants.GifImgurKeyword).ElementAt(value);

                    BotService.SendATextResponse(message, MiscService.MakeGif(thisData.data.url));

                    replyToConversation.Attachments.Add(
                        new AnimationCard
                    {
                        Title     = thisData.data.title,
                        Subtitle  = "by @" + thisData.data.author + ". Perfect for " + thisData.data.link_flair_text.ToString().ToLower().Trim(),
                        Autostart = true,
                        Shareable = true,
                        Image     = new ThumbnailUrl
                        {
                            Url = thisData.data.thumbnail
                        },
                        Media = new List <MediaUrl>
                        {
                            new MediaUrl()
                            {
                                Url = MiscService.MakeGif(thisData.data.url), Profile = "image/gif"
                            }
                        },
                        Buttons = new List <CardAction>
                        {
                            new CardAction()
                            {
                                Title = "Learn More",
                                Type  = ActionTypes.OpenUrl,
                                Value = "https://peach.blender.org/"
                            }
                        }
                    }.ToAttachment()
                        );
                }

                return(replyToConversation);
            }
            catch (NullReferenceException nex)
            {
                System.Diagnostics.Trace.TraceError("GIF Recipes " + nex.Message);
                return(message.CreateReply("Apologies, we couldn't find any GIF recipes at this moment."));
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.TraceError("GIF Recipes " + e.Message);
                return(message.CreateReply("Apologies, we couldn't find any GIF recipes at this moment."));
            }
        }