/// <summary>
 /// Set a new <paramref name="handler"/>
 /// </summary>
 /// <param name="handler">The value of <see cref="handler"/></param>
 public void SetHandler(ICustomCommandHandler handler)
 {
     if (this.handler != null)
     {
         throw new InvalidOperationException("SetHandler() already called!");
     }
     this.handler = handler ?? throw new ArgumentNullException(nameof(handler));
 }
示例#2
0
 /// <inheritdoc />
 public void RegisterCommandHandler(ICustomCommandHandler customCommandHandler)
 {
     if (this.customCommandHandler != null)
     {
         throw new InvalidOperationException("RegisterCommandHandler() already called!");
     }
     this.customCommandHandler = customCommandHandler ?? throw new ArgumentNullException(nameof(customCommandHandler));
 }
示例#3
0
 public CommandHandler(DiscordSocketClient discordSocketClient, CommandService commandService, IServiceProvider services, ICustomCommandHandler customCommandHandler, BotConfig botConfig)
 {
     _discordSocketClient  = discordSocketClient;
     _commandService       = commandService;
     _services             = services;
     _customCommandHandler = customCommandHandler;
     _botConfig            = botConfig;
 }
示例#4
0
        private CommandHandler BuildSut <TCommand, TResult>(ICustomCommandHandler <TCommand, TResult> instance)
        {
            var services = new ServiceCollection();

            services.AddSingleton <ICustomCommandHandler <TCommand, TResult> >(instance);

            return(new CommandHandler(services.BuildServiceProvider()));
        }
示例#5
0
        public JsonTrackingContext(IIOManager ioManager, ICustomCommandHandler customCommandHandler, Action onDispose, string commandsPath, string channelsPath)
        {
            this.ioManager            = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
            this.customCommandHandler = customCommandHandler ?? throw new ArgumentNullException(nameof(customCommandHandler));
            this.onDispose            = onDispose ?? throw new ArgumentNullException(nameof(onDispose));
            this.commandsPath         = commandsPath ?? throw new ArgumentNullException(nameof(commandsPath));
            this.channelsPath         = channelsPath ?? throw new ArgumentNullException(nameof(channelsPath));

            channelsSemaphore = new SemaphoreSlim(1);
        }
示例#6
0
 private void SetupRepositories()
 {
     _streamerDataRepository = new StreamerDataRepository(_botConfig.DatabaseLocation);
     _streamerDataRepository.Initialize();
     _settingsRepository   = new SettingsRepository(_botConfig.DatabaseLocation);
     _botConfig.Prefix     = _settingsRepository.InitializeAndGetPrefix();
     _commandsRepository   = new CommandsRepository(_botConfig.DatabaseLocation);
     _twitchClient         = new TwitchClient(_token, _streamerDataRepository);
     _customCommandHandler = new CustomCommandHandler(_commandsRepository);
 }
示例#7
0
 public CustomCommands(ICustomCommandHandler customCommandHandler)
 {
     _customCommandHandler = customCommandHandler;
 }