Exemplo n.º 1
0
        /*
         * private bool IsMod(string talker, string[] Talker_List)
         * {
         *  for(int i = 0; i < Talker_List.Length; i++)
         *  {
         *      if (Talker_List[i].Replace(" ", "") == talker)
         *          return true;
         *  }
         *  return false;
         * }
         *
         * private void SE12_Thread()
         * {
         *  while (true)
         *  {
         *      try
         *      {
         *          Thread.Sleep(3600000);
         *      }
         *      catch (Exception)
         *      {
         *
         *          Thread.Sleep(1500);
         *          if(IsMod())
         *          SE_Force_Enable = true;
         *          Thread.Sleep(12000);
         *          SE_Force_Enable = false;
         *      }
         *  }
         * }
         *
         * private void SE30_Thread()
         * {
         *  while (true)
         *  {
         *      try
         *      {
         *          Thread.Sleep(3600000);
         *      }
         *      catch (Exception)
         *      {
         *          SE_Force_Enable = true;
         *          Thread.Sleep(30000);
         *          SE_Force_Enable = false;
         *      }
         *  }
         * }
         */
        private void SE_pro(string msg)
        {
            int _index;

            if (msg == "")
            {
                return;
            }

            for (int i = 0; i < SEList.Count; i++)
            {
                _index = msg.IndexOf(SEList[i].GetWord());
                if (_index != -1)
                {
                    string _SubStringLeft  = msg.Remove(_index).Replace("\n", "");
                    string _SubStringRight = msg.Remove(0, (_index + SEList[i].GetWord().Length)).Replace("\n", "");

                    SE_pro(_SubStringLeft);
                    TTS_queue.Enqueue(SEList[i].GetWord());
                    SE_pro(_SubStringRight);

                    return;
                }
            }

            TTS_queue.Enqueue(msg);
        }
Exemplo n.º 2
0
        private void Msg_Reader()
        {
            string msg;
            string talker = null;

            while (true)
            {
                try
                {
                    Thread.Sleep(3600000);
                }
                catch (ThreadInterruptedException)
                {
                    while (msg_queue.Count != 0)
                    {
                        msg    = msg_queue.Dequeue().ToString();
                        talker = Who_Talk(msg);
                        talker = talker.ToLower();

                        msg = Room_Content_Proccess(msg);   //回傳的msg已經處理成僅剩留言訊息,不包含talker

                        if (CommandSpeech)                  //如果以指令來說話之功能 啟用
                        {
                            msg = Speech_Msg_By_command(msg);
                        }
                        msg = Speech_Content_Proccess(msg); //處理多餘的符號

                        Msg_Command_Proc(talker, msg);

                        if (!msg.StartsWith("!") && !msg.StartsWith("/")) //如果不是指令
                        {
                            if (Except_Index(talker) == -1)               //如果不是Bot
                            {
                                int index = Nick_Name_Index(talker);      //判別該留言之人是否具有暱稱
                                if (index >= 0)                           //假如有暱稱
                                {
                                    string _NickName;
                                    _NickName = TransToNick(index);
                                    TTS_queue.Enqueue(_NickName);
                                    TTS_queue.Enqueue("說");
                                }

                                msg = Education_String_Replace(msg);
                                msg = Msg_WordsNumLimit(msg);
                                //====此時的msg已是替換過教育文字並被限制字數後的訊息====
                                msg = msg.Replace("\n", "");
                                if (!SE_pause)
                                {
                                    SE_pro(msg);    //使用recursive之方式
                                }
                                else
                                {
                                    TTS_queue.Enqueue(msg);
                                }
                                TTS_T.Interrupt();


                                //====自動回應====

                                Msg_ReAct(talker, msg);

                                if (msg.Contains("やっほー"))  //檢查棒讀醬反應
                                {
                                    if (talker != current_channel.ToLower())
                                    {
                                        Push_A_message_to_Room(current_channel + " : Ver 1.3.1 やっほー\n");
                                        irc.sendchatMessage("Ver 1.3.1 やっほー");
                                    }
                                }

                                //================
                            }
                        } //End_ else if(!msg.StartsWith("!"))
                    }     //End_ while(msg_queue.Count != 0)
                }         //End_ catch
            }
        }
Exemplo n.º 3
0
        private void SpeechQueue_Puller()
        {
            while (true)
            {
                try
                {
                    Thread.Sleep(3600000);
                }
                catch (ThreadInterruptedException)
                {
                    while (TTS_queue.Count != 0)
                    {
                        string msg   = TTS_queue.Dequeue().ToString();
                        int    index = SE_index(msg);
                        if (!Disturb_State)
                        {
                            if ((!SE_pause) && index != -1)
                            {
                                double _dTime;
                                double _reTime;
                                int    _iTime;

                                if (TTS_queue.Count <= 8)
                                {
                                    if (player != null)
                                    {
                                        player.Stop();
                                        player.Dispose();
                                        player = null;
                                        volumeStream.Dispose();
                                        volumeStream = null;
                                        MainOutputStream.Dispose();
                                        MainOutputStream = null;
                                    }

                                    _reTime = PlaySE(index);
                                    if (_reTime != 0)
                                    {
                                        _dTime = _reTime * 1000;
                                        _iTime = (int)(_dTime - 10);
                                        if (!SE_Cancel_Func)
                                        {
                                            if (_iTime <= 10)
                                            {
                                                _iTime = 10;
                                            }
                                            Thread.Sleep(_iTime);
                                        }
                                        else
                                        {
                                            Thread.Sleep(10);
                                        }
                                    }
                                }
                                else
                                {
                                    SpeechTheText(msg);
                                }
                            }
                            else
                            {
                                SpeechTheText(msg);
                            }
                        }// End of if (!Disturb_State)
                    }
                }
            }
        }