Пример #1
0
        public void RunCore()
        {
            Logging.Log.Instance.DiscordLibraryLevel.Level = System.Diagnostics.SourceLevels.Warning;
            Console.Write("Discord Authentication Token > ");
            string DiscordAuthorizationToken = Console.ReadLine();
            string ImgurAuthenticationSecret = "Q", OAuthAccessToken = "Q", OAuthRefreshToken = "Q";

            Console.Write("Imgur Authentication ID > ");
            string ImgurAuthenticationID = Console.ReadLine();

            Console.Write("Imgur Authentication Secret > ");
            ImgurAuthenticationSecret = Console.ReadLine();
            Console.Write("Imgur OAuth Access Token > ");
            OAuthAccessToken = Console.ReadLine();

            /*
             * Console.Write("Imgur OAuth Refresh Token > ");
             * OAuthRefreshToken=Console.ReadLine();
             */
            SingleThreadReadWriteLock ShutdownLock = new SingleThreadReadWriteLock();

            Discord.DiscordInterfacerMain         _Discord;
            Imgur.ImgurInterfacer                 _Imgur;
            Application.CacheingTaglistRepository RepositoryTaglists;
            Program Core = new Program(
                new ProcessLatestCommentsActivity(
                    _Imgur = new Imgur.ImgurInterfacerMain(
                        new DataAccess.SettingsRepositoryMain(@"DataAccess\Settings1.xml"),
                        ImgurAuthenticationID, ImgurAuthenticationSecret,
                        "wereleven", 77530931,
                        OAuthAccessToken, OAuthRefreshToken, "bearer",
                        DateTimeOffset.UtcNow + TimeSpan.FromDays(11),
                        TimeSpan.FromSeconds(11), 0.1F, 140, "#",
                        ShutdownLock
                        ),
                    new DataAccess.SettingsRepositoryMain(@"DataAccess\Settings1.xml"),
                    RepositoryTaglists = new CacheingTaglistRepository(new DataAccess.TaglistRepositoryMain(@"DataAccess\Taglists.xml")),
                    new ProcessCommentActivity(
                        new Imgur.ImgurCommandParser("@Tagaroo2", _Imgur),
                        new ProcessTagCommandActivity(
                            _Imgur,
                            _Discord = new Discord.DiscordInterfacerMain(
                                DiscordAuthorizationToken,
                                388542416225042435UL, 388542416225042439UL,
                                388542416225042439UL, "/",
                                2000
                                ),
                            RepositoryTaglists
                            )
                        )
                    ),
                _Imgur,
                _Discord,
                new DataAccess.TaglistRepositoryMain(@"DataAccess\Taglists.xml"),
                new DataAccess.SettingsRepositoryMain(@"DataAccess\Settings1.xml"),
                ShutdownLock
                );

            Core.Run();
        }
Пример #2
0
        public void RunDebugDiscord()
        {
            Console.Write("Authentication Token > ");
            string DiscordAuthorizationToken = Console.ReadLine();

            Discord.DiscordInterfacer          Discord = new Discord.DiscordInterfacerMain(DiscordAuthorizationToken, 388542416225042435UL, 388542416225042439UL, 388542416225042439UL, "/", 3000);
            SingleThreadSynchronizationContext RunOn   = new SingleThreadSynchronizationContext(new NullSynchronizationContext());

            Discord.Initialize(new ServiceCollection().AddSingleton <Discord.DiscordInterfacer>(Discord).AddSingleton <Imgur.ImgurInterfacer>(new TestImgurInterfacer()), RunOn);
            //Logging.Log.Instance.AddTraceListener(new Logging.DiscordTraceListener("DiscordListener",Discord,new System.Diagnostics.TextWriterTraceListener(Console.Out)));
            Logging.Log.Instance.DiscordLevel.Level        = System.Diagnostics.SourceLevels.Verbose;
            Logging.Log.Instance.DiscordLibraryLevel.Level = System.Diagnostics.SourceLevels.Warning;
            System.Threading.SynchronizationContext.SetSynchronizationContext(RunOn);
            RunOn.RunOnCurrentThread(async() => {
                await Discord.Connect();

                /*
                 * await Task.Delay(1000);
                 * await Discord.PostGalleryItemDetails(388542416225042439UL,new GalleryItem(
                 * "Q","Gallery Link","https://imgur.com/gallery/YYL69",null,null,false,DateTimeOffset.UtcNow,string.Empty,null,null
                 * ));
                 * await Discord.PostGalleryItemDetails(388542416225042439UL,new GalleryItem(
                 * "Q","Album Link","https://imgur.com/a/YYL69",null,null,false,DateTimeOffset.UtcNow,string.Empty,null,null
                 * ));
                 * await Discord.PostGalleryItemDetails(388542416225042439UL,new GalleryItem(
                 * "Q","Image Link","https://imgur.com/2rzgptw",null,null,false,DateTimeOffset.UtcNow,string.Empty,null,null
                 * ));
                 * await Discord.PostGalleryItemDetails(388542416225042439UL,new GalleryItem(
                 * "Q","Resource Link","https://i.imgur.com/2rzgptw.jpg",null,null,false,DateTimeOffset.UtcNow,string.Empty,null,null
                 * ));
                 */
                /*
                 * try{
                 * await Discord.SendMessage(388542416225042439UL,string.Concat(Enumerable.Repeat(
                 * "2001-character-message-MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM-",
                 * 20
                 * ))+"M",false);
                 * }catch(Discord.DiscordException Error){
                 * }
                 */
                await Task.Run(() => {
                    Console.ReadKey(true);
                });
                await Discord.Shutdown();
                RunOn.Finish();
            });
        }