Exemple #1
0
        static void Main(string[] args)
        {
            IBot    bot    = new TextBot();
            IParser parser = new TextParser();

            bot.Attach(parser).ContinueWith((x) =>
            {
                Console.WriteLine("记忆单元载入完成");
                while (true)
                {
                    Console.Write("你:");
                    var input = Console.ReadLine();
                    if (input == "exit")
                    {
                        break;
                    }
                    Console.WriteLine("机器人:" + bot.GetResponse(input));
                }
            });
            Console.WriteLine("正在载入记忆单元");
            while (true)
            {
                System.Threading.Thread.Sleep(TimeSpan.FromDays(1));
            }
        }
        private async Task <bool> CreatePost()
        {
            try
            {
                StateBot     stateBot = new StateBot();
                TextBot      textBot  = new TextBot();
                ImageBot     imageBot = new ImageBot();
                InstagramBot instaBot = new InstagramBot();

                Post post = checkBoxCache.Checked ? await stateBot.Load() : new Post();

                post.Keyword         = textBoxNameActor.Text;
                post.MaxNumberImages = (int)numberPhotos.Value;

                await textBot.FetchTvCreditsFromTMDB(post);

                await textBot.FetchBiographyFromWikipedia(post);

                await textBot.SanitizeContent(post);

                await stateBot.Save(post);

                await imageBot.FetchImagesFromGoogle(post);

                await imageBot.DownloadImages(post);

                await imageBot.ScaleImages(post);

                await stateBot.Save(post);

                await instaBot.LoginAsync();

                if (post.Images.Count <= 1)
                {
                    await instaBot.UploadPhotoAsync(post);
                }
                else
                {
                    await instaBot.UploadPhotosAlbumAsync(post);
                }

                await imageBot.DeleteFileImages(post);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Falha ao postar as fotos, por favor tente novamente.", "Erro", MessageBoxButtons.OK);

                return(false);
            }
        }
Exemple #3
0
        private static void Main(string[] args)
        {
            var content  = new Content();
            var progress = new Progress <string>();

            content.NumberOfSentences = 9;

            progress.ProgressChanged += (sender, progressMessage) => UserInputManager.ReportProgress(progressMessage);

#if DEBUG
            content.SearchTerm         = "Bacon";
            content.WikipediaPageTitle = "Bacon";
            content.Prefix             = "Who is";
#else
            content.SearchTerm         = UserInputManager.AskAndReturnSearchTerm();
            content.WikipediaPageTitle = UserInputManager.AskAndReturnWikipediaPageTitleAsync(content.SearchTerm, content.NumberOfSentences).Result;
            content.Prefix             = UserInputManager.AskAndReturnPrefix();
#endif
            content = TextBot.RunAsync(content, progress).Result;

            ReadKey();
        }