Esempio n. 1
0
 public AssetsHelper(ICultureHelper _cultureHelper)
 {
     cultureHelper = _cultureHelper;
     Styles = new ItemRegistrar(cultureHelper);
     Styles.Format = ItemRegistrarFromatters.StyleFormat;
     Scripts = new ItemRegistrar(cultureHelper);
     Scripts.Format = ItemRegistrarFromatters.ScriptFormat;
 }
Esempio n. 2
0
 public DashboardController(IUserService userService, IPictureService pictureService, IUserContext userContext, IAuthenticationService authenticationService, IRoleService roleService, IPermissionService permissionService, ICultureHelper cultureHelper, IFeedbackService feedbackService, IEventService eventService, ICommentService commentService, IAuditService auditService, ISystemLogService systemLogService, IReplyService replyService, ISMSService smsService)
 {
     this._userService           = userService;
     this._pictureService        = pictureService;
     this._userContext           = userContext;
     this._authenticationService = authenticationService;
     this._roleService           = roleService;
     this._permissionService     = permissionService;
     this._cultureHelper         = cultureHelper;
     this._feedbackService       = feedbackService;
     this._eventService          = eventService;
     this._commentService        = commentService;
     this._auditService          = auditService;
     this._systemLogService      = systemLogService;
     this._replyService          = replyService;
     this._smsService            = smsService;
 }
Esempio n. 3
0
        public async Task RunBot(IServiceProvider provider, IConfiguration configuration, ICultureHelper cultureHelper, string discordToken = null)
        {
            IsRunning     = true;
            CultureHelper = cultureHelper;
            Client        = new DiscordSocketClient(new DiscordSocketConfig
            {
                LogLevel = Discord.LogSeverity.Info
            });

            Commands = new CommandService(new CommandServiceConfig()
            {
                CaseSensitiveCommands = false,
                LogLevel       = Discord.LogSeverity.Info,
                DefaultRunMode = RunMode.Async
            });

            Services = provider;

            // Read cultures from appsettings

            // Add this assembly for command fetching
            await Commands.AddModuleAsync <GiveAway>(Services);

            await Commands.AddModuleAsync <FunActions>(Services);

            await Commands.AddModuleAsync <HelpModule>(Services);

            // Add eventhandlers
            Client.MessageReceived -= Client_MessageReceived;
            Client.MessageReceived += Client_MessageReceived;
            Client.Log             += Client_Log;

            AppSettings appSettings = configuration.GetSection("AppSettings").Get <AppSettings>();

            discordToken = discordToken ?? appSettings.DiscordToken;

            // Login and start
            await Client.LoginAsync(Discord.TokenType.Bot, discordToken);

            await Client.SetGameAsync("giveaway | %help");

            await Client.StartAsync();
        }
Esempio n. 4
0
 public Localizable(ICultureHelper cultureHelper)
 {
     CultureHelper = cultureHelper;
 }
Esempio n. 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDiscordClient discordClient, ICultureHelper cultureHelper)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("DiscordFunAndGiveawayBot is alive!");

                if (!discordClient.IsRunning)
                {
                    // You can add the token as an environment variable - e.g. as a Config Var in Heroku
                    string discordToken = Environment.GetEnvironmentVariable("DiscordToken");
                    await discordClient.RunBot(app.ApplicationServices, Configuration, cultureHelper, discordToken);
                }
            });
        }
Esempio n. 6
0
 public ItemRegistrar(ICultureHelper _cultureHelper)
 {
     _items = new List<Item>();
     cultureHelper = _cultureHelper;
 }