コード例 #1
0
ファイル: DadCommand.cs プロジェクト: pulcher/TalkingHead
        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;
        }
コード例 #2
0
ファイル: TwitchBot.cs プロジェクト: pulcher/TalkingHead
        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();
        }
コード例 #3
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;
 }
コード例 #4
0
        public AskCommand(TwitchClient client, ISayingResponse sayingResponse, string mood, ILogger logger)
        {
            if (string.IsNullOrEmpty(mood))
            {
                mood = Moods.Snarky;
            }

            this.client         = client;
            this.logger         = logger;
            this.sayingResponse = sayingResponse;
            this.mood           = mood;
        }
コード例 #5
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();
        }
コード例 #6
0
 public SayCommand(TwitchClient client, ISayingResponse sayingResponse, ILogger <Worker> logger)
 {
     this.client         = client;
     this.logger         = logger;
     this.sayingResponse = sayingResponse;
 }
コード例 #7
0
 public InspirationalCommand(TwitchClient client, ISayingResponse sayingResponse, ILogger <Worker> logger)
 {
     this.client         = client;
     this.sayingResponse = sayingResponse;
     this.logger         = logger;
 }