Exemplo n.º 1
0
 protected BaseCommandHandler(
     IBotTelegramClient botTelegramClient,
     IEnumerable <string> supportedCommands)
 {
     BotClient          = botTelegramClient;
     _supportedCommands = supportedCommands;
 }
Exemplo n.º 2
0
 public TorrentDocumentHandler(
     ILogger <TorrentDocumentHandler> logger,
     IBotTelegramClient botClient,
     IConfigProvider configProvider)
 {
     _logger         = logger;
     _botClient      = botClient;
     _configProvider = configProvider;
 }
Exemplo n.º 3
0
 public TorrentStopCommandHandler(
     IBotTelegramClient botTelegramClient,
     TransmissionService transmissionService,
     ILogger <TorrentListCommandHandler> logger)
     : base(botTelegramClient, _supportedCommands)
 {
     _transmissionService = transmissionService;
     _logger = logger;
 }
Exemplo n.º 4
0
 public WifiCommandHandler(
     IBotTelegramClient botTelegramClient)
     : base(botTelegramClient, _supportedCommands)
 {
     _optionHandlers = new Dictionary <string, OptionHandlerDelegate>()
     {
         { "s", StateOptionHandler },
         { "state", StateOptionHandler },
         { "off", OffOptionHandler },
         { "on", OnOptionHandler }
     };
 }
 public TorrentCommandHandler(
     IBotTelegramClient botTelegramClient,
     TorrentListCommandHandler torrentListCommandHandler,
     ILogger <TorrentCommandHandler> logger)
     : base(botTelegramClient, _supportedCommands)
 {
     _torrentListCommandHandler = torrentListCommandHandler;
     _logger         = logger;
     _optionHandlers = new Dictionary <string, OptionHandlerDelegate>()
     {
         { "l", TorrentListOptionHandler },
         { "list", TorrentListOptionHandler },
     };
 }
Exemplo n.º 6
0
        public BotService(
            ILogger <BotService> logger,
            IEnumerable <IBotCommandHandler> botCommandHandlers,
            IEnumerable <IBotDocumentHandler> botDocumentHandlers,
            IBotTelegramClientControl botClientControl,
            IBotTelegramClient botClient,
            IConfigProvider configProvider,
            CommandLineProvider commandLineProvider)
        {
            _logger                 = logger;
            _botClientControl       = botClientControl;
            _botClient              = botClient;
            _commandLineProvider    = commandLineProvider;
            _config                 = configProvider.CurrentConfig;
            configProvider.Changed += OnConfigChanged;
            _botDocumentHandlers    = botDocumentHandlers.ToArray();

            foreach (var botCommand in botCommandHandlers)
            {
                foreach (var command in botCommand.SupportedCommands)
                {
                    if (string.IsNullOrWhiteSpace(command))
                    {
                        continue;
                    }

                    var commandText = command;
                    if (!IsCommand(commandText))
                    {
                        commandText = CommandPrefix + commandText;
                    }

                    _botCommandHandlers.Add(commandText.ToLower(), botCommand);
                }
            }

            _botClientControl.OnMessageReceived += BotOnMessageReceived;
        }
 public HiCommandHandler(IBotTelegramClient botTelegramClient)
     : base(botTelegramClient, _supportedCommands)
 {
 }