public record Databases( IUserRepo UserRepo, IBadgeRepo BadgeRepo, IBank <User> PokeyenBank, IBank <User> TokensBank, ICommandLogger CommandLogger, IMessagequeueRepo MessagequeueRepo, IMessagelogRepo MessagelogRepo );
public record Databases( IUserRepo UserRepo, IPollRepo PollRepo, IBadgeRepo BadgeRepo, IBank <User> PokeyenBank, IBank <User> TokensBank, ICommandLogger CommandLogger, IMessagequeueRepo MessagequeueRepo, IMessagelogRepo MessagelogRepo, ILinkedAccountRepo LinkedAccountRepo, ISubscriptionLogRepo SubscriptionLogRepo, IModLogRepo ModLogRepo, IResponseCommandRepo ResponseCommandRepo );
public ModeBase(ILoggerFactory loggerFactory, BaseConfig baseConfig, StopToken stopToken) { PokedexData pokedexData = PokedexData.Load(); Setups.Databases repos = Setups.SetUpRepositories(baseConfig); ArgsParser argsParser = Setups.SetUpArgsParser(repos.UserRepo, pokedexData); var chats = new Dictionary <string, IChat>(); var chatFactory = new ChatFactory(loggerFactory, SystemClock.Instance, repos.UserRepo); foreach (ConnectionConfig connectorConfig in baseConfig.Chat.Connections) { IChat chat = chatFactory.Create(connectorConfig); if (chats.ContainsKey(chat.Name)) { throw new ArgumentException($"chat name '{chat.Name}' was used multiple times. It must be unique."); } chats[chat.Name] = chat; } _chats = chats.ToImmutableDictionary(); foreach (IChat chat in _chats.Values) { chat.IncomingMessage += MessageReceived; } _commandResponders = _chats.Values.ToImmutableDictionary( c => c.Name, c => (ICommandResponder) new CommandResponder(c)); _commandProcessors = _chats.Values.ToImmutableDictionary( c => c.Name, c => Setups.SetUpCommandProcessor(loggerFactory, argsParser, repos, stopToken, baseConfig.Chat, c, c, pokedexData.KnownSpecies)); _messagequeueRepo = repos.MessagequeueRepo; _messagelogRepo = repos.MessagelogRepo; _forwardUnprocessedMessages = baseConfig.Chat.ForwardUnprocessedMessages; _clock = SystemClock.Instance; }
public ModeBase( ILoggerFactory loggerFactory, Setups.Databases repos, BaseConfig baseConfig, StopToken stopToken, OverlayConnection overlayConnection, ProcessMessage?processMessage = null) { IClock clock = SystemClock.Instance; _logger = loggerFactory.CreateLogger <ModeBase>(); PokedexData pokedexData = PokedexData.Load(); ArgsParser argsParser = Setups.SetUpArgsParser(repos.UserRepo, pokedexData); _processMessage = processMessage ?? (_ => Task.FromResult(false)); var chats = new Dictionary <string, IChat>(); var chatFactory = new ChatFactory(loggerFactory, clock, repos.UserRepo, repos.TokensBank, repos.SubscriptionLogRepo, repos.LinkedAccountRepo, overlayConnection); foreach (ConnectionConfig connectorConfig in baseConfig.Chat.Connections) { IChat chat = chatFactory.Create(connectorConfig); if (chats.ContainsKey(chat.Name)) { throw new ArgumentException($"chat name '{chat.Name}' was used multiple times. It must be unique."); } chats[chat.Name] = chat; } _chats = chats.ToImmutableDictionary(); foreach (IChat chat in _chats.Values) { chat.IncomingMessage += MessageReceived; } _commandResponders = _chats.Values.ToImmutableDictionary( c => c.Name, c => (ICommandResponder) new CommandResponder(c)); _commandProcessors = _chats.Values.ToImmutableDictionary( c => c.Name, c => Setups.SetUpCommandProcessor(loggerFactory, argsParser, repos, stopToken, c, c, pokedexData.KnownSpecies)); _messagequeueRepo = repos.MessagequeueRepo; _messagelogRepo = repos.MessagelogRepo; _forwardUnprocessedMessages = baseConfig.Chat.ForwardUnprocessedMessages; _clock = SystemClock.Instance; ILogger <Moderator> moderatorLogger = loggerFactory.CreateLogger <Moderator>(); IImmutableList <IModerationRule> availableRules = ImmutableList.Create <IModerationRule>( new BannedUrlsRule(), new SpambotRule(), new EmoteRule(), new CopypastaRule(clock), new UnicodeCharacterCategoryRule() ); foreach (string unknown in baseConfig.DisabledModbotRules.Except(availableRules.Select(rule => rule.Id))) { moderatorLogger.LogWarning("unknown modbot rule '{UnknownRule}' marked as disabled", unknown); } IImmutableList <IModerationRule> rules = availableRules .Where(rule => !baseConfig.DisabledModbotRules.Contains(rule.Id)) .ToImmutableList(); _moderators = _chats.Values.ToImmutableDictionary( c => c.Name, c => (IModerator) new Moderator(moderatorLogger, c, rules, repos.ModLogRepo, clock)); }