예제 #1
0
        public TwitchBot(TwitchClient client, ConnectionCredentials clientCredentials, string channelName,
                         IConfiguration config, ISayingResponse sayingResponse, IDadJokeService dadJokeService,
                         IEnumerable <ICommandMbhToTwitch> listOfCommands, ICommandMbhTwitchHelp helpCommand, ILogger <Worker> logger)
        {
            this.client = client;

            this.helpCommandReal = (ICommandMbhToTwitch)helpCommand;
            this.logger          = logger;
            this.sayingResponse  = sayingResponse;
            this.dadJokeService  = dadJokeService;

            var listOfNames = listOfCommands.Select(x => x.Name);

            this.logger.LogInformation($"-------------- List of Names :  {string.Join(',', listOfNames)}");
            dictOfCommands = listOfCommands
                             .ToDictionary(x => x.Name, x => x, StringComparer.OrdinalIgnoreCase);

            this.client.Initialize(clientCredentials, channelName);

            this.client.OnLog                 += Client_OnLog;
            this.client.OnJoinedChannel       += Client_OnJoinedChannel;
            this.client.OnMessageReceived     += Client_OnMessageReceived;
            this.client.OnWhisperReceived     += Client_OnWhisperReceived;
            this.client.OnNewSubscriber       += Client_OnNewSubscriber;
            this.client.OnReSubscriber        += Client_OnReSubscriber;
            this.client.OnConnected           += Client_OnConnected;
            this.client.OnChatCommandReceived += Client_OnChatCommandReceived;
            this.client.OnRaidNotification    += Client_OnRaidNotification;

            var clientResult = this.client.Connect();
        }
예제 #2
0
        private string alternateSite = "https://karljoke.herokuapp.com/jokes/random"; //= string.Empty;

        public DadCommand(TwitchClient client, ISayingResponse sayingResponse, IDadJokeService dadJokeService, ILogger <Worker> logger)
        {
            this.client         = client;
            this.sayingResponse = sayingResponse;
            this.dadJokeService = dadJokeService;
            this.logger         = logger;
        }
 public SheepQueueService(
     ISheepStorageService sheepStorage,
     IDadJokeService dadJokeService,
     ILogger <SheepQueueService> logger)
 {
     _sheepStorageService = sheepStorage;
     _dadJokeService      = dadJokeService;
     _logger = logger;
 }
예제 #4
0
 public MbhCommand(TwitchClient client, IConfiguration config, ISayingResponse sayingResponse,
                   IDadJokeService dadJokeService, ILogger <Worker> logger)
 {
     this.client         = client;
     this.config         = config;
     this.sayingResponse = sayingResponse;
     this.dadJokeService = dadJokeService;
     this.logger         = logger;
 }
예제 #5
0
 public ChatBotService(
     IHubContext <ChatHub> chatHub,
     IDadJokeService dataJokeService,
     ICommandSignal commandSignal,
     ILogger <ChatBotService> logger)
 {
     _chatHub         = chatHub;
     _dataJokeService = dataJokeService;
     _commandSignal   = commandSignal;
     _logger          = logger;
 }
예제 #6
0
        public Worker(IServiceProvider service, IConfiguration config, ILogger <Worker> logger)
        {
            this.logger  = logger;
            this.service = service;
            this.config  = config;

            var defaultLogLevel = config["Logging:LogLevel:Default"];

            logger.LogInformation($"defaultLogLevel = {defaultLogLevel}");

            var userName    = config["TwitchBotConfiguration:UserName"];
            var accessToken = config["TwitchBotConfiguration:AccessToken"];

            using var scope = service.CreateScope();

            twitchClient =
                service.GetRequiredService <TwitchClient>();

            connectionCredentials =
                service.GetRequiredService <ConnectionCredentials>();

            scopedSayingResponse =
                scope.ServiceProvider
                .GetRequiredService <ISayingResponse>();
            scopedDadJokeService =
                scope.ServiceProvider
                .GetRequiredService <IDadJokeService>();

            var listOfCommands = scope.ServiceProvider.GetServices <ICommandMbhToTwitch>();
            var helpCommand    = scope.ServiceProvider.GetService <ICommandMbhTwitchHelp>();

            var twitchBot = new TwitchBot(twitchClient, connectionCredentials, "haroldpulcher",
                                          config, scopedSayingResponse, scopedDadJokeService,
                                          listOfCommands, helpCommand, logger);

            SetupGPIO();
        }
예제 #7
0
 public DadJokeController(IDadJokeService dadJokeService)
 {
     _dadJokeService = dadJokeService;
 }
예제 #8
0
 public MessageService(ITelegramBotService telegramBotService, IDadJokeService dadJokeService)
 {
     _telegramBotService = telegramBotService;
     _dadJokeService     = dadJokeService;
 }