Пример #1
0
        public async Task GiftRoute(object sender, ReceivedDanmakuArgs e)
        {
            // check user eligibility
            if (!Conf.CheckUserEligibility(e))
            {
                return;
            }
            // check gift eligibility
            if (!Conf.CheckGiftEligibility(e))
            {
                return;
            }
            Bridge.ALog("规则检查通过,准备朗读");
            if (Vars.CurrentConf.VoiceReplyFirst)
            {
                var hitAnyRule = await TTSPlayer.PlayVoiceReply(e.Danmaku);

                if (!hitAnyRule || !Vars.CurrentConf.IgnoreIfHitVoiceReply)
                {
                    await TTSPlayer.UnifiedPlay(ProcessGift(e));
                }
            }
            else
            {
                var hitAnyRule = Vars.CurrentConf.VoiceReplyRules.Any(x => x.Matches(e.Danmaku));
                if (!hitAnyRule || !Vars.CurrentConf.IgnoreIfHitVoiceReply)
                {
                    await TTSPlayer.UnifiedPlay(ProcessGift(e));
                }
                await TTSPlayer.PlayVoiceReply(e.Danmaku);
            }
        }
Пример #2
0
        public async Task InteractRoute(object sender, ReceivedMessageArgs e)
        {
            // check user eligibility
            if (!Conf.CheckUserEligibility(e))
            {
                return;
            }
            Bridge.ALog("规则检查通过,正在朗读用户交互事件");

            string result;

            switch (e.Message.MsgType)
            {
            case MsgTypeEnum.UserEnter:
                result = ProcessInteract(e.Message, Vars.CurrentConf.OnInteractEnter);
                break;

            case MsgTypeEnum.LiveShare:
                result = ProcessInteract(e.Message, Vars.CurrentConf.OnInteractShare);
                break;

            default: return;
            }

            await TTSPlayer.UnifiedPlay(result);
        }
Пример #3
0
 public async void OnDisconnected(object sender, DisconnectEvtArgs e)
 {
     if (!IsNAudioReady)
     {
         return;
     }
     if (!IsEnabled)
     {
         return;
     }
     if (!Vars.CurrentConf.AllowConnectEvents)
     {
         return;
     }
     else if (Vars.CurrentConf.ClearQueueAfterDisconnect)
     {
         TTSPlayer.fileList.Clear();
     }
     if (e == null)
     {
         await TTSPlayer.UnifiedPlay(
             Vars.CurrentConf.OnDisconnected.Replace(
                 "$ERROR", ""
                 ), true
             );
     }
     else
     {
         await TTSPlayer.UnifiedPlay(
             Vars.CurrentConf.OnDisconnected.Replace(
                 "$ERROR", e.Error.Message
                 )
             );
     }
 }
Пример #4
0
 public static async Task WelcomeRoute(object sender, ReceivedDanmakuArgs e)
 {
     // check user eligibility
     if (!Conf.CheckUserEligibility(e))
     {
         return;
     }
     Bridge.ALog("规则检查通过,准备朗读");
     await TTSPlayer.UnifiedPlay(Vars.CurrentConf.OnWelcome
                                 .Replace("$USER", e.Danmaku.UserName)
                                 , true
                                 );
 }
Пример #5
0
 public static async Task GuardBuyRoute(object sender, ReceivedDanmakuArgs e)
 {
     // check user eligibility
     if (!Conf.CheckUserEligibility(e))
     {
         return;
     }
     Bridge.ALog("规则检查通过,准备朗读");
     await TTSPlayer.UnifiedPlay(Vars.CurrentConf.OnGuardBuy
                                 .Replace("$COUNT", e.Danmaku.GiftCount.ToString())
                                 .Replace("$USER", e.Danmaku.UserName)
                                 , true
                                 );
 }
Пример #6
0
 public async void OnConnected(object sender, ConnectedEvtArgs e)
 {
     if (!IsNAudioReady)
     {
         return;
     }
     if (!IsEnabled)
     {
         return;
     }
     if (!Vars.CurrentConf.AllowConnectEvents)
     {
         return;
     }
     await TTSPlayer.UnifiedPlay(
         Vars.CurrentConf.OnConnected.Replace(
             "$ROOM", e.roomid.ToString()
             ), true
         );
 }
Пример #7
0
 public async Task SuperChatRoute(object sender, ReceivedDanmakuArgs e)
 {
     // check user eligibility
     if (!Conf.CheckUserEligibility(e))
     {
         return;
     }
     // check content eligibility
     if (!Conf.CheckKeywordEligibility(e))
     {
         return;
     }
     // check length rule
     if (!Conf.CheckDanmakuLength(e))
     {
         return;
     }
     Bridge.ALog("规则检查通过,准备朗读");
     await TTSPlayer.UnifiedPlay(ProcessSuperChat(e), Vars.CurrentConf.SuperChatIgnoreRandomDitch);
 }
Пример #8
0
        public override async void Start()
        {
            Log("插件启动中");
            var loadWindow = new Windows.LoadingWindowLight();

            try
            {
                loadWindow.IsOpen            = true;
                loadWindow.ProgressBar.Value = 30; Conf.Delay(10);
                ALog("正在检查配置");
                await Conf.InitiateAsync();

                loadWindow.ProgressBar.Value = 60; Conf.Delay(10);
                ALog("配置初始化成功");
                ALog("正在启用播放器");
                TTSPlayer.Init();
                loadWindow.ProgressBar.Value = 80; Conf.Delay(10);
                if (Vars.CurrentConf.AutoUpdate)
                {
                    ALog("正在启动更新检查");
                    Thread updateChecker = new Thread(() => UpdateThread());
                    updateChecker.Start();
                }
                loadWindow.ProgressBar.Value = 100; Conf.Delay(10);
                loadWindow.IsOpen            = false;
                Log("启动成功");
                IsEnabled = true;
                if ((Vars.ManagementWindow != null) && !Vars.ManagementWindow.WindowDisposed)
                {
                    Vars.ManagementWindow.Dispatcher.Invoke(() => { Vars.ManagementWindow.CheckBox_IsPluginActive.IsChecked = true; });
                }
                base.Start();
            }
            catch (Exception ex)
            {
                loadWindow.IsOpen = false;
                Log($"启动过程中出错: {ex}");
                Windows.AsyncDialog.Open("启动失败,更多信息请查看日志(首页)。\n请在反馈错误时附加日志信息。\n\n如您在后期继续使用时遇到问题,请尝试重新启动弹幕姬。", "Re: TTSCat", MessageBoxIcon.Error);
                Log("启动失败");
            }
        }
Пример #9
0
        public async Task InteractRoute(object sender, ReceivedDanmakuArgs e)
        {
            // check user eligibility
            if (!Conf.CheckUserEligibility(e))
            {
                return;
            }
            Bridge.ALog("规则检查通过,正在朗读用户交互事件");

            string result;

            switch (e.Danmaku.InteractType)
            {
            case InteractTypeEnum.Enter:
                result = ProcessInteract(e.Danmaku, Vars.CurrentConf.OnInteractEnter);
                break;

            case InteractTypeEnum.Follow:
                result = ProcessInteract(e.Danmaku, Vars.CurrentConf.OnInteractFollow);
                break;

            case InteractTypeEnum.MutualFollow:
                result = ProcessInteract(e.Danmaku, Vars.CurrentConf.OnInteractMutualFollow);
                break;

            case InteractTypeEnum.Share:
                result = ProcessInteract(e.Danmaku, Vars.CurrentConf.OnInteractShare);
                break;

            case InteractTypeEnum.SpecialFollow:
                result = ProcessInteract(e.Danmaku, Vars.CurrentConf.OnInteractSpecialFollow);
                break;

            default: return;
            }

            await TTSPlayer.UnifiedPlay(result);
        }
Пример #10
0
        public async Task CommentRoute(object sender, ReceivedMessageArgs e)
        {
            // check user eligibility
            if (!Conf.CheckUserEligibility(e))
            {
                return;
            }
            // check content eligibility
            if (!Conf.CheckKeywordEligibility(e))
            {
                return;
            }
            // check length rule
            if (!Conf.CheckDanmakuLength(e))
            {
                return;
            }
            Bridge.ALog("规则检查通过,准备朗读");
            if (Vars.CurrentConf.VoiceReplyFirst)
            {
                var hitAnyRule = await TTSPlayer.PlayVoiceReply(e.Message);

                if (!hitAnyRule || !Vars.CurrentConf.IgnoreIfHitVoiceReply)
                {
                    await TTSPlayer.UnifiedPlay(ProcessDanmaku(e));
                }
            }
            else
            {
                var hitAnyRule = Vars.CurrentConf.VoiceReplyRules.Any(x => x.Matches(e.Message));
                if (!hitAnyRule || !Vars.CurrentConf.IgnoreIfHitVoiceReply)
                {
                    await TTSPlayer.UnifiedPlay(ProcessDanmaku(e));
                }
                await TTSPlayer.PlayVoiceReply(e.Message);
            }
        }
Пример #11
0
 public async Task LiveStartRoute(object sender, ReceivedMessageArgs e)
 {
     await TTSPlayer.UnifiedPlay(Vars.CurrentConf.OnLiveStart, true);
 }
Пример #12
0
 public async Task WarningRoute(object sender, ReceivedDanmakuArgs e)
 {
     await TTSPlayer.UnifiedPlay(Vars.CurrentConf.OnWarning, true);
 }