/// <summary> /// 主函数 /// </summary> /// <param name="args">args</param> public static void Main(string[] args) { ////ForwardingService try { object config = ConfigurationManager.GetSection("forwarderService"); var serviceConfig = config as ForwarderServiceConfig; if (serviceConfig == null) { logger.Info("Invaild configuration, service start abnormal."); return; } var service = new ForwarderService(); service.Init(serviceConfig); service.Start(); } catch (Exception e) { logger.Info("Service start abnormal.", e); } try { WarningService service = new WarningService("WarningService.xml", AppDomain.CurrentDomain.BaseDirectory); new ServiceRunner(service).Run("WarningService"); } catch (Exception ex) { logger.FatalFormat("ERROR DESCRIBE: {0} \n\r", ex.Message); } Console.ReadLine(); }
/// <summary> /// Initializes a new instance of the <see cref="WarningSetCommands"/> class. /// </summary> /// <param name="warnings">The moderation service.</param> /// <param name="feedback">The feedback service.</param> public WarningSetCommands ( WarningService warnings, UserFeedbackService feedback ) { _warnings = warnings; _feedback = feedback; }
/// <summary> /// Initializes a new instance of the <see cref="WarningSetCommands"/> class. /// </summary> /// <param name="warnings">The moderation service.</param> /// <param name="feedback">The feedback service.</param> public WarningSetCommands ( [NotNull] WarningService warnings, [NotNull] UserFeedbackService feedback ) { _warnings = warnings; _feedback = feedback; }
/// <summary> /// Initializes a new instance of the <see cref="WarningSetCommands"/> class. /// </summary> /// <param name="warnings">The moderation service.</param> /// <param name="context">The command context.</param> /// <param name="feedback">The feedback service.</param> public WarningSetCommands ( WarningService warnings, ICommandContext context, FeedbackService feedback ) { _warnings = warnings; _context = context; _feedback = feedback; }
/// <summary> /// Initializes a new instance of the <see cref="ExpirationBehaviour"/> class. /// </summary> /// <param name="client">The Discord client.</param> /// <param name="warnings">The warning service.</param> /// <param name="bans">The ban service.</param> public ExpirationBehaviour ( [NotNull] DiscordSocketClient client, [NotNull] WarningService warnings, [NotNull] BanService bans ) : base(client) { _warnings = warnings; _bans = bans; }
/// <inheritdoc /> protected override void ConfigureServices(IServiceProvider serviceProvider) { var coreDatabase = serviceProvider.GetRequiredService <CoreDatabaseContext>(); coreDatabase.Database.Create(); var warningDatabase = serviceProvider.GetRequiredService <ModerationDatabaseContext>(); warningDatabase.Database.Create(); this.Database = warningDatabase; this.Warnings = serviceProvider.GetRequiredService <WarningService>(); }
/// <inheritdoc /> protected override void ConfigureServices(IServiceProvider serviceProvider) { var coreDatabase = serviceProvider.GetRequiredService <CoreDatabaseContext>(); var coreCreateScript = coreDatabase.Database.GenerateCreateScript(); var moderationDatabase = serviceProvider.GetRequiredService <ModerationDatabaseContext>(); var moderationCreateScript = moderationDatabase.Database.GenerateCreateScript(); moderationDatabase.Database.ExecuteSqlRaw(coreCreateScript); moderationDatabase.Database.ExecuteSqlRaw(moderationCreateScript); this.Database = moderationDatabase; this.Warnings = serviceProvider.GetRequiredService <WarningService>(); }
/// <summary> /// Initializes a new instance of the <see cref="WarningCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="warnings">The warning service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public WarningCommands ( [NotNull] ModerationService moderation, [NotNull] WarningService warnings, [NotNull] UserFeedbackService feedback, [NotNull] InteractivityService interactivity, [NotNull] ChannelLoggingService logging ) { _moderation = moderation; _warnings = warnings; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
/// <summary> /// Initializes a new instance of the <see cref="WarningCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="warnings">The warning service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public WarningCommands ( ModerationService moderation, WarningService warnings, UserFeedbackService feedback, InteractivityService interactivity, ChannelLoggingService logging ) { _moderation = moderation; _warnings = warnings; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
/// <summary> /// Initializes a new instance of the <see cref="WarningCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="warnings">The warning service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="logging">The logging service.</param> /// <param name="userAPI">The user API.</param> /// <param name="context">The command context.</param> public WarningCommands ( ModerationService moderation, WarningService warnings, FeedbackService feedback, ChannelLoggingService logging, IDiscordRestUserAPI userAPI, ICommandContext context ) { _moderation = moderation; _warnings = warnings; _feedback = feedback; _logging = logging; _userAPI = userAPI; _context = context; }
private async Task <OperationResult> RescindWarningIfExpiredAsync ( ChannelLoggingService loggingService, WarningService warnings, SocketGuild guild, UserWarning warning, CancellationToken ct ) { if (ct.IsCancellationRequested) { return(OperationResult.FromError("Operation was cancelled.")); } if (!(warning.ExpiresOn <= DateTime.UtcNow)) { // No rescinding is needed, so we'll just bail out return(OperationResult.FromSuccess()); } var rescinder = guild.GetUser(this.Client.CurrentUser.Id); var notifyResult = await loggingService.NotifyUserWarningRemovedAsync(warning, rescinder); if (!notifyResult.IsSuccess) { return(OperationResult.FromError(notifyResult)); } var deleteResult = await warnings.DeleteWarningAsync(warning, ct); if (!deleteResult.IsSuccess) { return(OperationResult.FromError(deleteResult)); } return(OperationResult.FromSuccess()); }