コード例 #1
0
        private async Task SearchLivescore(IDialogContext context, FootballQuery searchQuery)
        {
            var Livescore = this.GetLivescore(searchQuery);

            var heroCard = new ThumbnailCard
            {
                Title    = "BotFramework Thumbnail Card",
                Subtitle = "Your bots — wherever your users are talking",
                Text     = "Build and connect intelligent bots to interact with your users naturally wherever they are, from text/sms to Skype, Slack, Office 365 mail and other popular services.",
                Images   = new List <CardImage> {
                    new CardImage("https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg")
                },
                Buttons = new List <CardAction> {
                    new CardAction(ActionTypes.OpenUrl, "Get Started", value: "https://docs.microsoft.com/bot-framework")
                }
            };

            //  return heroCard.ToAttachment();

            Attachment attachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content     = heroCard
            };

            var reply = context.MakeMessage();

            reply.Attachments.Add(attachment);

            await context.PostAsync(reply);
        }
コード例 #2
0
        private IEnumerable <League> GetMatches(FootballQuery searchQuery)
        {
            var matches = new List <League>();

            // Filling the hotels results manually just for demo purposes
            for (int i = 1; i <= 2; i++)
            {
                if (i == 1)
                {
                    League match = new League()
                    {
                        Name  = $"Match No. {i}",
                        Team1 = searchQuery.Team1,
                        Team2 = searchQuery.Team2,
                        // Rating = random.Next(1, 5),
                        // NumberOfReviews = random.Next(0, 5000),
                        // PriceStarting = random.Next(80, 450),
                        Image      = $"https://www.games4reloaded.com/wp-content/uploads/2018/07/prediction-800x445.jpg",
                        MoreImages = new List <string>()
                        {
                            "https://nesncom.files.wordpress.com/2018/07/samuel-umtiti.jpg?w=640",
                            "https://media.fox4news.com/media.fox4news.com/photo/2018/07/09/France%20vs%20Belgium_1531173430360.jpg_5771874_ver1.0_640_360.jpg",
                            "https://images.indianexpress.com/2018/07/fifa-ap-m.jpg",
                            "https://cdn.images.dailystar.co.uk/dynamic/1/photos/437000/France-vs-Belgium-World-Cup-Russia-semi-final-girls-1389437.jpg"
                        }
                    };

                    matches.Add(match);
                }
                else
                {
                    League match = new League()
                    {
                        Name  = $"Match No. {i}",
                        Team2 = searchQuery.Team2,
                        Team1 = searchQuery.Team1,
                        // Rating = random.Next(1, 5),
                        // NumberOfReviews = random.Next(0, 5000),
                        // PriceStarting = random.Next(80, 450),
                        Image      = $"http://sportfunlive.com/wp-content/uploads/2018/07/croatia-vs-england.jpg",
                        MoreImages = new List <string>()
                        {
                            "https://pickssoccer.com/wp-content/uploads/2018/07/England-vs-Croatia-min.jpg",
                            "https://media.fox4news.com/media.fox4news.com/photo/2018/07/09/France%20vs%20Belgium_1531173430360.jpg_5771874_ver1.0_640_360.jpg",
                            "https://i2-prod.mirror.co.uk/incoming/article12879927.ece/ALTERNATES/s482b/FBL-WC-2018-MATCH30-ENG-PAN.jpg",
                            "https://static.standard.co.uk/s3fs-public/thumbnails/image/2018/07/10/10/2018-07-07T161833Z-1348922517-RC1BAB4773E0-RTRMADP-3-SOCCER-WORLDCUP-SWE-ENG-FANS.JPG?w968h681"
                        }
                    };

                    matches.Add(match);
                }
            }

            //matches.Sort((h1, h2) => h1.PriceStarting.CompareTo(h2.PriceStarting));

            return(matches);
        }
コード例 #3
0
        private IEnumerable <Livescore> GetLivescore(FootballQuery searchQuery)
        {
            var livescore = new List <Livescore>();

            for (int i = 1; i <= 2; i++)
            {
                if (i == 1)
                {
                    Livescore match = new Livescore()
                    {
                        Name   = $"Match No. {i}",
                        Team1  = searchQuery.Team1,
                        Team2  = searchQuery.Team2,
                        lscore = "https://apifootball.com/api/?action=get_events&from=2016-10-30&to=2016-11-01&league_id=62&APIkey=ac41d66e732ff9ef06a1e697e79a039bbb971bf7f093014e9b200c0003bdbd63",
                        // Rating = random.Next(1, 5),
                        // NumberOfReviews = random.Next(0, 5000),
                        // PriceStarting = random.Next(80, 450),
                        Image      = $"https://www.games4reloaded.com/wp-content/uploads/2018/07/prediction-800x445.jpg",
                        MoreImages = new List <string>()
                        {
                            "https://nesncom.files.wordpress.com/2018/07/samuel-umtiti.jpg?w=640",
                            "https://media.fox4news.com/media.fox4news.com/photo/2018/07/09/France%20vs%20Belgium_1531173430360.jpg_5771874_ver1.0_640_360.jpg",
                            "https://images.indianexpress.com/2018/07/fifa-ap-m.jpg",
                            "https://cdn.images.dailystar.co.uk/dynamic/1/photos/437000/France-vs-Belgium-World-Cup-Russia-semi-final-girls-1389437.jpg"
                        }
                    };
                    livescore.Add(match);
                }
                else
                {
                    Livescore match = new Livescore()
                    {
                        Name   = $"Match No. {i}",
                        Team1  = searchQuery.Team1,
                        Team2  = searchQuery.Team2,
                        lscore = "https://apifootball.com/api/?action=get_events&from=2016-10-30&to=2016-11-01&league_id=62&APIkey=ac41d66e732ff9ef06a1e697e79a039bbb971bf7f093014e9b200c0003bdbd63",
                        // Rating = random.Next(1, 5),
                        // NumberOfReviews = random.Next(0, 5000),
                        // PriceStarting = random.Next(80, 450),
                        Image      = $"https://www.games4reloaded.com/wp-content/uploads/2018/07/prediction-800x445.jpg",
                        MoreImages = new List <string>()
                        {
                            "https://nesncom.files.wordpress.com/2018/07/samuel-umtiti.jpg?w=640",
                            "https://media.fox4news.com/media.fox4news.com/photo/2018/07/09/France%20vs%20Belgium_1531173430360.jpg_5771874_ver1.0_640_360.jpg",
                            "https://images.indianexpress.com/2018/07/fifa-ap-m.jpg",
                            "https://cdn.images.dailystar.co.uk/dynamic/1/photos/437000/France-vs-Belgium-World-Cup-Russia-semi-final-girls-1389437.jpg"
                        }
                    };
                    livescore.Add(match);
                }
            }
            return(livescore);
        }
コード例 #4
0
        public async Task StartAsync(IDialogContext context)
        {
            var message = context.Activity as IMessageActivity;
            var query   = FootballQuery.Parse(message.Value);

            await context.PostAsync($"Ok. Searching for the LiveScore Between   {query.Team1} and {query.Team2} ");

            try
            {
                await SearchLivescore(context, query);
            }
            catch (FormCanceledException ex)
            {
                await context.PostAsync($"Oops! Something went wrong :( Technical Details: {ex.InnerException.Message}");
            }
        }
コード例 #5
0
        private async Task SearchMatches(IDialogContext context, FootballQuery searchQuery)
        {
            var Football = this.GetMatches(searchQuery);

            // Result count
            var title = $"I found in total {Football.Count()} matches for your teams:";
            var intro = new List <CardElement>()
            {
                new TextBlock()
                {
                    Text  = title,
                    Size  = TextSize.ExtraLarge,
                    Speak = $"<s>{title}</s>"
                }
            };

            // Hotels in rows of three
            var rows = Split(Football, 3)
                       .Select(group => new ColumnSet()
            {
                Columns = new List <Column>(group.Select(AsFootballItem))
            });

            var card = new AdaptiveCard()
            {
                Body = intro.Union(rows).ToList()
            };

            Attachment attachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content     = card
            };

            var reply = context.MakeMessage();

            reply.Attachments.Add(attachment);

            await context.PostAsync(reply);
        }
コード例 #6
0
ファイル: RootDialog.cs プロジェクト: parag8897/FootballBot
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            if (message.Value != null)
            {
                // Got an Action Submit
                dynamic value      = message.Value;
                string  submitType = value.Type.ToString();
                switch (submitType)
                {
                case "leagueSearch":
                    FootballQuery query1;
                    try
                    {
                        query1 = FootballQuery.Parse(value);

                        // Trigger validation using Data Annotations attributes from the FootballsQuery model
                        List <ValidationResult> results = new List <ValidationResult>();
                        bool valid = Validator.TryValidateObject(query1, new ValidationContext(query1, null, null), results, true);
                        if (!valid)
                        {
                            // Some field in the Football Query are not valid
                            var errors = string.Join("\n", results.Select(o => " - " + o.ErrorMessage));
                            await context.PostAsync("Please complete all the search parameters:\n" + errors);

                            return;
                        }
                    }
                    catch (InvalidCastException)
                    {
                        // Football Query could not be parsed
                        await context.PostAsync("Please complete all the search parameters");

                        return;
                    }

                    // Proceed with Footballs search
                    await context.Forward(new LeagueDialog(), this.ResumeAfterOptionDialog, message, CancellationToken.None);

                    return;

                case "leagueSelection":
                    await SendFootballSelectionAsync(context, (League)JsonConvert.DeserializeObject <League>(value.ToString()));

                    context.Wait(MessageReceivedAsync);

                    return;

                case "LivescoreSearch":
                    FootballQuery query2;
                    try
                    {
                        query2 = FootballQuery.Parse(value);

                        // Trigger validation using Data Annotations attributes from the FootballsQuery model
                        List <ValidationResult> results = new List <ValidationResult>();
                        bool valid = Validator.TryValidateObject(query2, new ValidationContext(query2, null, null), results, true);
                        if (!valid)
                        {
                            // Some field in the Football Query are not valid
                            var errors = string.Join("\n", results.Select(o => " - " + o.ErrorMessage));
                            await context.PostAsync("Please complete all the search parameters:\n" + errors);

                            return;
                        }
                    }
                    catch (InvalidCastException)
                    {
                        // Football Query could not be parsed
                        await context.PostAsync("Please complete all the search parameters");

                        return;
                    }

                    // Proceed with Livescore search
                    await context.Forward(new LivescoreDialog(), this.ResumeAfterOptionDialog, message, CancellationToken.None);

                    return;
                }
            }

            if (message.Text != null && (message.Text.ToLower().Contains("help") || message.Text.ToLower().Contains("support") || message.Text.ToLower().Contains("problem")))
            {
                await context.Forward(new SupportDialog(), this.ResumeAfterSupportDialog, message, CancellationToken.None);
            }
            else
            {
                await ShowOptionsAsync(context);
            }
        }