示例#1
0
 public TempUnverifyService(IOptions <Configuration> config, BotLoggingService logger, DiscordSocketClient client)
 {
     Data   = new List <TempUnverifyItem>();
     Config = config.Value;
     Logger = logger;
     Client = client;
 }
示例#2
0
        public BackgroundTaskScheduler(BackgroundTaskQueue queue, IServiceProvider provider, BotLoggingService botLoggingService)
        {
            Queue             = queue;
            Provider          = provider;
            BotLoggingService = botLoggingService;

            LastSchedulesAt = new Dictionary <Type, DateTime>();
        }
示例#3
0
 protected LoggerMethodBase(DiscordSocketClient client, Configuration config, IMessageCache messageCache, HttpClient httpClient,
                            BotLoggingService loggingService)
 {
     Client         = client;
     Config         = config;
     MessageCache   = messageCache;
     HttpClient     = httpClient;
     LoggingService = loggingService;
 }
示例#4
0
        public ChannelStats(IOptions <Configuration> config, BotLoggingService loggingService)
        {
            Changes   = new HashSet <ulong>();
            WebTokens = new List <ChannelboardWebToken>();
            Counters  = new Dictionary <ulong, ChannelStat>();

            LoggingService = loggingService;
            Config         = config.Value;
        }
示例#5
0
        public Logger(DiscordSocketClient client, IOptions <Configuration> config, IMessageCache messageCache, BotLoggingService loggingService)
        {
            Client         = client;
            Config         = config.Value;
            MessageCache   = messageCache;
            LoggingService = loggingService;

            Counters = new Dictionary <string, uint>();

            HttpClient = new HttpClient();
        }
示例#6
0
        public InitService(IServiceProvider provider, BotLoggingService botLoggingService)
        {
            BotLoggingService = botLoggingService;

            var initiableName = typeof(IInitiable).Name;

            Initiables = Assembly.GetExecutingAssembly().GetTypes()
                         .Where(t => t.GetInterface(initiableName) != null)
                         .Select(t => (IInitiable)provider.GetService(t))
                         .Where(o => o != null)
                         .ToList();
        }
示例#7
0
        public EmoteStats(IOptions <Configuration> config, BotLoggingService loggingService)
        {
            Config = config.Value;

            Counter = new Dictionary <string, EmoteStat>();
            Changes = new HashSet <string>();

            LoggingService = loggingService;

            var syncPeriod = GrillBotService.DatabaseSyncPeriod;

            DbSyncTimer = new Timer(SyncTimerCallback, null, syncPeriod, syncPeriod);
        }
示例#8
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var scheduleable = typeof(IBackgroundTaskScheduleable);

            var serviceTypes = Assembly.GetExecutingAssembly()
                               .GetTypes()
                               .Where(o => o.GetInterface(scheduleable.FullName) != null)
                               .ToList();

            if (serviceTypes.Count == 0)
            {
                return;
            }

            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    using var scope = Provider.CreateScope();

                    foreach (var type in serviceTypes)
                    {
                        if (scope.ServiceProvider.GetService(type) is not IBackgroundTaskScheduleable service)
                        {
                            continue;
                        }

                        if (service.CanScheduleTask(GetLastSchedule(type)))
                        {
                            foreach (var task in service.GetBackgroundTasks())
                            {
                                Queue.Add(task);
                            }

                            LastSchedulesAt[type] = DateTime.Now;
                        }
                    }
                }
                catch (Exception ex)
                {
                    var message = new LogMessage(LogSeverity.Error, nameof(BackgroundTaskScheduler), "Scheduling tasks failed.", ex);
                    await BotLoggingService.OnLogAsync(message);
                }
                finally
                {
                    await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
                }
            }
        }
示例#9
0
 public UnverifyService(UnverifyChecker checker, UnverifyProfileGenerator profileGenerator, UnverifyLogger logger,
                        UnverifyMessageGenerator messageGenerator, UnverifyTimeParser timeParser, BotState botState, DiscordSocketClient discord,
                        BotLoggingService loggingService, ILogger <UnverifyService> appLogger, IGrillBotRepository grillBotRepository,
                        BackgroundTaskQueue queue)
 {
     Checker = checker;
     UnverifyProfileGenerator = profileGenerator;
     UnverifyLogger           = logger;
     MessageGenerator         = messageGenerator;
     TimeParser         = timeParser;
     BotState           = botState;
     DiscordClient      = discord;
     Logger             = loggingService;
     AppLogger          = appLogger;
     GrillBotRepository = grillBotRepository;
     Queue = queue;
 }
示例#10
0
 public MessageDeleted(DiscordSocketClient client, Configuration config, IMessageCache messageCache, HttpClient httpClient,
                       BotLoggingService loggingService) : base(client, config, messageCache, httpClient, loggingService)
 {
 }
示例#11
0
 public MessageCache(DiscordSocketClient client, BotLoggingService loggingService)
 {
     Data           = new Dictionary <ulong, IMessage>();
     Client         = client;
     LoggingService = loggingService;
 }
示例#12
0
 public AutoReplyService(IOptions <Configuration> configuration, BotLoggingService botLogging)
 {
     Data       = new List <AutoReplyItem>();
     BotLogging = botLogging;
     Config     = configuration.Value;
 }
示例#13
0
 public LogMiddleware(RequestDelegate next, BotLoggingService loggingService)
 {
     Next           = next;
     LoggingService = loggingService;
 }