Ejemplo n.º 1
0
 public RoleRemover(IDiscordAccess?discordAccess,
                    IDynamicConfiguration?dynamicConfiguration)
 {
     _discordAccess           = discordAccess ?? throw new ArgumentNullException(nameof(discordAccess));
     _dynamicConfiguration    = dynamicConfiguration ?? throw new ArgumentNullException(nameof(dynamicConfiguration));
     _usersToFreeFromBasement = new List <DiscordUserId>();
 }
Ejemplo n.º 2
0
 public ConfigReminderModule(IConfigurationDatabaseAccess configurationDatabaseAccess,
                             IDynamicConfiguration dynamicConfiguration,
                             ILogger <ConfigReminderModule> logger)
 {
     _configurationDatabaseAccess = configurationDatabaseAccess;
     _dynamicConfiguration        = dynamicConfiguration;
     _logger = logger;
 }
Ejemplo n.º 3
0
 public BirthdayService(IBirthdayProvider birthdayProvider,
                        IDynamicConfiguration dynamicConfiguration,
                        IDiscordAccess discordAccess)
 {
     _birthdayProvider     = birthdayProvider;
     _dynamicConfiguration = dynamicConfiguration;
     _discordAccess        = discordAccess;
 }
Ejemplo n.º 4
0
 public UnitsSyncService(IDiscordAccess discordAccess,
                         IUnitsAccess unitsAccess,
                         IDynamicConfiguration dynamicConfiguration,
                         ILogger <UnitsSyncService> logger)
 {
     _discordAccess        = discordAccess ?? throw new ArgumentNullException(nameof(discordAccess));
     _unitsAccess          = unitsAccess ?? throw new ArgumentNullException(nameof(unitsAccess));
     _dynamicConfiguration = dynamicConfiguration ?? throw new ArgumentNullException(nameof(dynamicConfiguration));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Ejemplo n.º 5
0
 public ImageProvider(IGameRoleProvider gameRoleProvider,
                      IWebAccess webAccess,
                      IDiscordAccess discordAccess,
                      IDynamicConfiguration dynamicConfiguration)
 {
     _gameRoleProvider     = gameRoleProvider;
     _webAccess            = webAccess;
     _discordAccess        = discordAccess;
     _dynamicConfiguration = dynamicConfiguration;
 }
Ejemplo n.º 6
0
 public GameRoleProvider(IDatabaseAccess databaseAccess,
                         IDynamicConfiguration dynamicConfiguration,
                         ILogger <GameRoleProvider> logger)
 {
     _databaseAccess       = databaseAccess;
     _dynamicConfiguration = dynamicConfiguration;
     _logger = logger;
     _games  = new List <AvailableGame>();
     _gamesRolesCustomIds = Array.Empty <string>();
 }
Ejemplo n.º 7
0
 public DiscordUserEventHandler(IUserStore userStore,
                                IPrivacyProvider privacyProvider,
                                INonMemberRoleProvider nonMemberRoleProvider,
                                IGameRoleProvider gameRoleProvider,
                                IDatabaseAccess databaseAccess,
                                IDynamicConfiguration dynamicConfiguration)
 {
     _userStore             = userStore;
     _privacyProvider       = privacyProvider;
     _nonMemberRoleProvider = nonMemberRoleProvider;
     _gameRoleProvider      = gameRoleProvider;
     _databaseAccess        = databaseAccess;
     _dynamicConfiguration  = dynamicConfiguration;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// This overload is quite flexible because it takes in an IDynamicConfiguration which can represent
        /// an XML File or a database containing the commands. It also supports command chaining.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="raiseExceptionsOnConfigErrors"></param>

        public void CleanUp(IDynamicConfiguration configuration, bool raiseExceptionsOnConfigErrors)
        {
            var bulkCommandConfigurator   = new BulkCommandConfigurator();
            var bulkCommandInvocationInfo = bulkCommandConfigurator.ParseCommandStrings(configuration.GetCommandConfigurations());

            foreach (var invocationInfo in bulkCommandInvocationInfo.InvocationInfos)
            {
                CleanUp(invocationInfo.Key, invocationInfo.Value.ToDictionary(x => x.CommandName, x => x.Configuration));
            }

            if (raiseExceptionsOnConfigErrors && bulkCommandInvocationInfo.AdditionalInfo.Any())
            {
                throw new InvalidOperationException(bulkCommandInvocationInfo.AdditionalInfo.Aggregate(string.Empty, (x, y) => x + Environment.NewLine + y));
            }
        }
Ejemplo n.º 9
0
 public BotEngine(ILogger <BotEngine> logger,
                  IDynamicConfiguration dynamicConfiguration,
                  IDiscordAccess discordAccess,
                  IUnitsSignalRClient unitsSignalRClient,
                  IBotInformationProvider botInformationProvider,
                  IPrivacyProvider privacyProvider)
 {
     _logger = logger;
     _dynamicConfiguration             = dynamicConfiguration;
     _dynamicConfiguration.DataLoaded += DynamicConfiguration_DataLoaded;
     _discordAccess          = discordAccess;
     _unitsSignalRClient     = unitsSignalRClient;
     _botInformationProvider = botInformationProvider;
     _privacyProvider        = privacyProvider;
     _isFirstConnect         = true;
 }
Ejemplo n.º 10
0
    public StaticMessageProvider(IMessageProvider messageProvider,
                                 IGameRoleProvider gameRoleProvider,
                                 IBotInformationProvider botInformationProvider,
                                 ILogger <StaticMessageProvider> logger,
                                 IDynamicConfiguration dynamicConfiguration)
    {
        _channelSemaphores    = new Dictionary <DiscordChannelId, SemaphoreSlim>();
        _messageProvider      = messageProvider;
        _gameRoleProvider     = gameRoleProvider;
        _logger               = logger;
        _dynamicConfiguration = dynamicConfiguration;
#if DEBUG
        _provideStaticMessages = botInformationProvider.GetEnvironmentName() == Constants.RuntimeEnvironment.Production;
#else
        // Don't change this statement, or the bot might not behave the way it should in the production environment.
        _provideStaticMessages = botInformationProvider.GetEnvironmentName() == Constants.RuntimeEnvironment.Production;
#endif

        if (_provideStaticMessages)
        {
            _gameRoleProvider.GameChanged += GameRoleProvider_GameChanged;
        }
    }
Ejemplo n.º 11
0
 public static IDynamicConfigurationSource CreateDefaultDynamicConfigurationSource(int priority, string sourceId, IDynamicConfiguration dynamicConfiguration)
 {
     return((IDynamicConfigurationSource) new DefaultDynamicConfigurationSource(priority, sourceId, dynamicConfiguration));
 }
 public DefaultDynamicConfigurationSource(int priority, string sourceId, IDynamicConfiguration configuration)
     : base(priority, sourceId, (IConfiguration)configuration)
 {
 }
Ejemplo n.º 13
0
 public TimeInformationProvider(IDynamicConfiguration dynamicConfiguration,
                                ILogger <TimeInformationProvider> logger)
 {
     _dynamicConfiguration = dynamicConfiguration;
     _logger = logger;
 }
Ejemplo n.º 14
0
 public ReminderService(IDynamicConfiguration dynamicConfiguration,
                        IDiscordAccess discordAccess)
 {
     _dynamicConfiguration = dynamicConfiguration ?? throw new ArgumentNullException(nameof(dynamicConfiguration));
     _discordAccess        = discordAccess ?? throw new ArgumentNullException(nameof(discordAccess));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// This overload is quite flexible because it takes in an IDynamicConfiguration which can represent
        /// an XML File or a database containing the commands. It also supports command chaining.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="raiseExceptionsOnConfigErrors"></param>
        public void CleanUp(IDynamicConfiguration configuration, bool raiseExceptionsOnConfigErrors)
        {
            var bulkCommandConfigurator = new BulkCommandConfigurator();
            var bulkCommandInvocationInfo =  bulkCommandConfigurator.ParseCommandStrings(configuration.GetCommandConfigurations());

            foreach (var invocationInfo in bulkCommandInvocationInfo.InvocationInfos)
            {
                CleanUp(invocationInfo.Key, invocationInfo.Value.ToDictionary(x => x.CommandName, x => x.Configuration));
            }

            if (raiseExceptionsOnConfigErrors && bulkCommandInvocationInfo.AdditionalInfo.Any())
            {
                throw new InvalidOperationException(bulkCommandInvocationInfo.AdditionalInfo.Aggregate(string.Empty, (x,y) => x + Environment.NewLine + y));
            }
        }