Exemplo n.º 1
0
        public async Task MessageReceivedAsync(
            IDialogContext context,
            IAwaitable <IMessageActivity> argument)
        {
            var message        = await argument;
            var linksExtractor = new LinksExtractor(message.Text);
            int linksCount     = linksExtractor.GetDetectedLinksCount();

            if (linksCount > 1)
            {
                await context.PostAsync(
                    "Wow, let's do one link at a time, i'm not so intelligent yet.");
            }
            else if (linksCount == 1)
            {
                await context.Forward(
                    new ProcessLinkDialog(),
                    ResumeAfterLinkProcessed,
                    message);
            }
            else
            {
                context.Wait(MessageReceivedAsync);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine(DISCLAIMER);

            string username   = ReadInput("PluralSight Username");
            string password   = ReadInput("Pluralsight Password", hideInput: true);
            string courseName = ReadInput("Course name");

            Course course = null;

            try
            {
                course = new LinksExtractor().GetLinks(username, password, courseName);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            Downloader  downloader = new Downloader();
            ProgressBar bar        = null;

            //Display a progress bar when download starts
            downloader.DownloadBegin += (sender, e) => {
                bar = new ProgressBar(100, e.Message);
            };

            //Update the bar as download progresses
            downloader.DownloadProgressChanged += (sender, e) => {
                bar.SetProgress(e.Percentage);
            };

            downloader.DownloadCourse(course, Environment.CurrentDirectory);
        }
Exemplo n.º 3
0
        public void TestCount(string input, int expectedResult)
        {
            var extractor    = new LinksExtractor(input);
            int actualResult = extractor.GetDetectedLinksCount();

            Assert.Equal(expectedResult, actualResult);
        }
Exemplo n.º 4
0
        public async Task MessageReceivedAsync(
            IDialogContext context,
            IAwaitable <IMessageActivity> argument)
        {
            await context.SayAsync("ok, processing that doc");

            IMessageActivity messageActivity = await argument;
            string           message         = messageActivity.Text;
            var           extractor          = new LinksExtractor(message);
            List <string> links = extractor.ExtractLinks();
            await context.SayAsync($"ok, got {links.Count} links");

            link = links.First();
            if (links.Count > 1)
            {
                throw new InvalidOperationException(
                          "Cannot process several links at the moment.");
            }
            PromptDialog.Number(context,
                                ResumeAfterRateIsSet,
                                "How do you rate this article? (1-10)",
                                "Please retry",
                                3,
                                null,
                                1,
                                10);
        }
Exemplo n.º 5
0
        public void TestExtraction(string text, string expectedResult)
        {
            var           extractor    = new LinksExtractor(text);
            List <string> actualResult = extractor.ExtractLinks();
            bool          contains     = actualResult.Contains(expectedResult);

            Assert.True(contains);
        }