Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDatabaseDeveloperPageExceptionFilter();
            services.AddControllers();

            string connectionString = PsqlConnectionStringParser.GetEFConnectionString(Configuration["DATABASE_URL"]);

            services
            .AddDbContext <HonzaBotnerDbContext>(options =>
                                                 options.UseNpgsql(connectionString, b => b.MigrationsAssembly("HonzaBotner"))
                                                 )

            // Swagger
            .AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "HonzaBotner", Version = "v1"
                }); })

            // Botner
            .AddBotnerServicesOptions(Configuration)
            .AddHttpClient()
            .AddBotnerServices()

            // Discord
            .AddDiscordOptions(Configuration)
            .AddCommandOptions(Configuration)
            .AddDiscordBot(config =>
            {
                //config.RegisterCommands<AuthorizeCommands>();
                config.RegisterCommands <BotCommands>();
                config.RegisterCommands <ChannelCommands>();
                config.RegisterCommands <EmoteCommands>();
                config.RegisterCommands <FunCommands>();
                config.RegisterCommands <MemberCommands>();
                config.RegisterCommands <MessageCommands>();
                config.RegisterCommands <PollCommands>();
                config.RegisterCommands <TestCommands>();
                config.RegisterCommands <VoiceCommands>();
                config.RegisterCommands <WarningCommands>();
            }, reactions =>
            {
                reactions
                .AddEventHandler <BoosterHandler>()
                .AddEventHandler <EmojiCounterHandler>()
                .AddEventHandler <HornyJailHandler>()
                .AddEventHandler <NewChannelHandler>()
                .AddEventHandler <PinHandler>()
                .AddEventHandler <RoleBindingsHandler>(EventHandlerPriority.High)
                .AddEventHandler <StaffVerificationEventHandler>(EventHandlerPriority.Urgent)
                .AddEventHandler <VerificationEventHandler>(EventHandlerPriority.Urgent)
                .AddEventHandler <VoiceHandler>()
                ;
            }
                           )

            // Managers
            .AddTransient <IVoiceManager, VoiceManager>()
            ;
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDatabaseDeveloperPageExceptionFilter();
            services.AddControllers();

            string connectionString = PsqlConnectionStringParser.GetEFConnectionString(Configuration["DATABASE_URL"]);

            services.AddDbContext <HonzaBotnerDbContext>(options =>
                                                         options.UseNpgsql(connectionString, b => b.MigrationsAssembly("HonzaBotner")));

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "HonzaBotner", Version = "v1"
                });
            });

            services.AddBotnerServicesOptions(Configuration)
            .AddHttpClient()
            .AddBotnerServices();

            services.AddDiscordOptions(Configuration)
            .AddCommandOptions(Configuration)
            .AddDiscordBot(config =>
            {
                //config.RegisterCommands<AuthorizeCommands>();
                config.RegisterCommands <ChannelCommands>();
                config.RegisterCommands <EmoteCommands>();
                config.RegisterCommands <MemberCommands>();
                config.RegisterCommands <MessageCommands>();
                config.RegisterCommands <VoiceCommands>();
                config.RegisterCommands <PollCommands>();
                // config.AddCommand<HiCommand>(HiCommand.ChatCommand);
                // config.AddCommand<AuthorizeCommand>(AuthorizeCommand.ChatCommand);
                // config.AddCommand<CountCommand>(CountCommand.ChatCommand);
                // config.AddCommand<Activity>(Activity.ChatCommand);
                // config.AddCommand<HugCommand>(HugCommand.ChatCommand);
                // // Messages
                // config.AddCommand<SendMessage>(SendMessage.ChatCommand);
                // config.AddCommand<EditMessage>(EditMessage.ChatCommand);
                // config.AddCommand<SendImage>(SendImage.ChatCommand);
                // config.AddCommand<EditImage>(EditImage.ChatCommand);
                // // Polls
                // config.AddCommand<PollCommand>(PollCommand.ChatCommand);
            }, reactions =>
            {
                reactions.AddReaction <VerificationReactionHandler>()
                .AddReaction <StaffVerificationReactionHandler>()
                .AddReaction <EmojiCounterHandler>()
                .AddReaction <PinHandler>();
            });

            services.AddSingleton <IVoiceManager, VoiceManager>();
        }