Ejemplo n.º 1
0
        public TwitchIrcClient(IOptions <TwitchIrcConfig> twitchConfigOptions)
        {
            try
            {
                _twitchIrcConfig = twitchConfigOptions.Value;

                _tcpClient     = new TcpClient(_twitchIrcConfig.Server, _twitchIrcConfig.Port);
                _networkStream = _tcpClient.GetStream();
                _inputStream   = new StreamReader(_networkStream);
                _outputStream  = new StreamWriter(_networkStream)
                {
                    NewLine = "\r\n", AutoFlush = true
                };;

                // Try to join the room
                _outputStream.WriteLine("PASS " + _twitchIrcConfig.OAuthToken);
                _outputStream.WriteLine("NICK " + _twitchIrcConfig.UserName);
                _outputStream.WriteLine("USER " + _twitchIrcConfig.UserName + " 8 * :" + _twitchIrcConfig.UserName);
                _outputStream.WriteLine("JOIN #" + _twitchIrcConfig.Channel);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 public ProcessUserDataService(IMessageParser messageParser,
                               IOptions <TwitchIrcConfig> twitchConfigOptions,
                               ITwitchIrcClient twitchIrcClient,
                               ITwitchApiUserClient twitchApiUserClient,
                               ITwitchApiFollowerClient twitchApiFollowerClient)
 {
     _twitchApiFollowerClient = twitchApiFollowerClient;
     _twitchApiUserClient     = twitchApiUserClient;
     _twitchIrcClient         = twitchIrcClient;
     _twitchIrcConfig         = twitchConfigOptions.Value;
     _messageParser           = messageParser;
 }
Ejemplo n.º 3
0
        private bool Init()
        {
            //TwitchIrcのコンフィグをファイルから読み込む
            TwitchIrcConfigReader ticr            = new TwitchIrcConfigReader();
            TwitchIrcConfig       twitchIrcConfig = ticr.ReadJsonFromFile(TWITCH_IRC_CONFIG_FILE);

            if (twitchIrcConfig == null)
            {
                Console.WriteLine("ファイル読み込みに失敗しました。");
                return(false);
            }

            //指定したブロードキャストに接続
            _irc = new IrcClient(
                twitchIrcConfig.NetworkConfig.Server.ToString(),
                (int)twitchIrcConfig.NetworkConfig.Port,
                twitchIrcConfig.BotConfig.BotName.ToString(),
                twitchIrcConfig.BotConfig.Oauth.ToString(),
                twitchIrcConfig.BotConfig.BroadcasterName.ToString()
                );

            //チャット内容分割用のクラスを作成
            _twitchIrcSliceMessage = new TwitchIrcSliceMessage(twitchIrcConfig.ActionTriggers);

            //ログイン維持用のタスクを作成し開始
            _ping = new TwitchIrcPingSender(_irc);
            _ping.Start();

            //棒読みちゃん接続設定をファイルから読み込む
            BouyomichanConfigReader brc = new BouyomichanConfigReader();
            BouyomichanConfig       bouyomichanConfig = brc.ReadJsonFromFile(BOUYOMICHAN_CONFIG_FILE);

            //読み込みに失敗した
            if (bouyomichanConfig == null)
            {
                Console.WriteLine("ファイル読み込みに失敗しました。");
                return(false);
            }
            //棒読みちゃんに接続する設定をセット
            _bouyomichanWriter = new BouyomichanSender(
                bouyomichanConfig.Host,
                (int)bouyomichanConfig.Port,
                (int)bouyomichanConfig.ByteCode,
                (int)bouyomichanConfig.Voice,
                (int)bouyomichanConfig.Volume,
                (int)bouyomichanConfig.Speed,
                (int)bouyomichanConfig.Tone
                );

            //**************** ここからBotの設定 *******************

            //ボイスロイド読み上げbotの初期化をファイルから行う
            _twitchBotConvertToVoiceroidTalk = TwitchBotConvertToVoiceroidTalk.Create(_irc, VOICEROID_TALK_CONFIG_FILE);
            //設定の読み込みに失敗したら失敗
            if (_twitchBotConvertToVoiceroidTalk == null)
            {
                Console.WriteLine("ファイル読み込みに失敗しました。");
                return(false);
            }

            //******************************************************

            //成功
            return(true);
        }