Example #1
0
        /// <summary>
        /// ログとマッチングする
        /// </summary>
        /// <param name="telops">Telops</param>
        /// <param name="logLines">ログ行</param>
        public static void Match(
            IReadOnlyList <OnePointTelop> telops,
            IReadOnlyList <string> logLines)
        {
            foreach (var log in logLines)
            {
                telops.AsParallel().ForAll(telop =>
                {
                    var matched = false;

                    var regex       = telop.Regex;
                    var regexToHide = telop.RegexToHide;

                    // 開始条件を確認する
                    if (ConditionUtility.CheckConditionsForTelop(telop))
                    {
                        // 通常マッチ
                        if (regex == null)
                        {
                            var keyword = telop.KeywordReplaced;
                            if (!string.IsNullOrWhiteSpace(keyword))
                            {
                                if (log.ToUpper().Contains(
                                        keyword.ToUpper()))
                                {
                                    var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                                    if (!telop.AddMessageEnabled)
                                    {
                                        telop.MessageReplaced = messageReplaced;
                                    }
                                    else
                                    {
                                        telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                                 messageReplaced :
                                                                 Environment.NewLine + messageReplaced;
                                    }

                                    telop.MatchDateTime = DateTime.Now;
                                    telop.Delayed       = false;
                                    telop.MatchedLog    = log;
                                    telop.ForceHide     = false;

                                    SoundController.Default.Play(telop.MatchSound);
                                    SoundController.Default.Play(telop.MatchTextToSpeak);

                                    matched = true;
                                }
                            }
                        }

                        // 正規表現マッチ
                        else
                        {
                            var match = regex.Match(log);
                            if (match.Success)
                            {
                                var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                                if (!telop.AddMessageEnabled)
                                {
                                    telop.MessageReplaced = match.Result(messageReplaced);
                                }
                                else
                                {
                                    telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                             match.Result(messageReplaced) :
                                                             Environment.NewLine + match.Result(messageReplaced);
                                }

                                telop.MatchDateTime = DateTime.Now;
                                telop.Delayed       = false;
                                telop.MatchedLog    = log;
                                telop.ForceHide     = false;

                                SoundController.Default.Play(telop.MatchSound);
                                if (!string.IsNullOrWhiteSpace(telop.MatchTextToSpeak))
                                {
                                    var tts = match.Result(telop.MatchTextToSpeak);
                                    SoundController.Default.Play(tts);
                                }

                                matched = true;
                            }
                        }
                    }

                    if (matched)
                    {
                        // ディレイサウンドをスタートさせる
                        telop.StartDelayedSoundTimer();

                        SpellTimerCore.Default.UpdateNormalSpellTimerForTelop(telop, telop.ForceHide);
                        SpellTimerCore.Default.NotifyNormalSpellTimerForTelop(telop.Title);

                        return;
                    }

                    // 通常マッチ(強制非表示)
                    if (regexToHide == null)
                    {
                        var keyword = telop.KeywordToHideReplaced;
                        if (!string.IsNullOrWhiteSpace(keyword))
                        {
                            if (log.ToUpper().Contains(
                                    keyword.ToUpper()))
                            {
                                telop.ForceHide = true;
                                matched         = true;
                            }
                        }
                    }

                    // 正規表現マッチ(強制非表示)
                    else
                    {
                        if (regexToHide.IsMatch(log))
                        {
                            telop.ForceHide = true;
                            matched         = true;
                        }
                    }

                    if (matched)
                    {
                        SpellTimerCore.Default.UpdateNormalSpellTimerForTelop(telop, telop.ForceHide);
                        SpellTimerCore.Default.NotifyNormalSpellTimerForTelop(telop.Title);
                    }
                });   // end loop telops
            }
        }
Example #2
0
        /// <summary>
        /// ログ1行1テロップに対して判定する
        /// </summary>
        /// <param name="telop">テロップ</param>
        /// <param name="log">ログ</param>
        public void MatchCore(
            Ticker telop,
            string log)
        {
            var matched = false;

            var regex       = telop.Regex;
            var regexToHide = telop.RegexToHide;

            // マッチング計測開始
            telop.StartMatching();

            // 開始条件を確認する
            if (ConditionUtility.CheckConditionsForTelop(telop))
            {
                // 通常マッチ
                if (regex == null)
                {
                    var keyword = telop.KeywordReplaced;
                    if (!string.IsNullOrWhiteSpace(keyword))
                    {
                        if (log.Contains(keyword, StringComparison.OrdinalIgnoreCase))
                        {
                            var messageReplaced = ConditionUtility.GetReplacedMessage(telop);

                            // PC名を置換する
                            messageReplaced = XIVPluginHelper.Instance.ReplacePartyMemberName(
                                messageReplaced,
                                Settings.Default.PCNameInitialOnDisplayStyle);

                            if (!telop.AddMessageEnabled)
                            {
                                telop.MessageReplaced = messageReplaced;
                            }
                            else
                            {
                                telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                         messageReplaced :
                                                         Environment.NewLine + messageReplaced;
                            }

                            telop.ForceHide     = false;
                            telop.Delayed       = false;
                            telop.MatchedLog    = log;
                            telop.MatchDateTime = DateTime.Now;

                            // マッチング計測終了
                            telop.EndMatching();

                            telop.Play(telop.MatchSound, telop.MatchAdvancedConfig);
                            telop.Play(telop.MatchTextToSpeak, telop.MatchAdvancedConfig);

                            matched = true;
                        }
                    }
                }

                // 正規表現マッチ
                else
                {
                    var match = regex.Match(log);
                    if (match.Success)
                    {
                        var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                        messageReplaced = match.Result(messageReplaced);

                        // PC名を置換する
                        messageReplaced = XIVPluginHelper.Instance.ReplacePartyMemberName(
                            messageReplaced,
                            Settings.Default.PCNameInitialOnDisplayStyle);

                        if (!telop.AddMessageEnabled)
                        {
                            telop.MessageReplaced = messageReplaced;
                        }
                        else
                        {
                            telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                     messageReplaced :
                                                     Environment.NewLine + messageReplaced;
                        }

                        telop.ForceHide     = false;
                        telop.Delayed       = false;
                        telop.MatchedLog    = log;
                        telop.MatchDateTime = DateTime.Now;

                        // マッチング計測終了
                        telop.EndMatching();

                        telop.Play(telop.MatchSound, telop.MatchAdvancedConfig);
                        if (!string.IsNullOrWhiteSpace(telop.MatchTextToSpeak))
                        {
                            var tts = match.Result(telop.MatchTextToSpeak);
                            telop.Play(tts, telop.MatchAdvancedConfig);
                        }

                        matched = true;
                    }
                }
            }

            if (matched)
            {
                // ディレイサウンドをスタートさせる
                telop.StartDelayedSoundTimer();

                SpellsController.Instance.UpdateNormalSpellTimerForTelop(telop, telop.ForceHide);
                SpellsController.Instance.NotifyNormalSpellTimerForTelop(telop.Title);

                return;
            }

            // 通常マッチ(強制非表示)
            if (regexToHide == null)
            {
                var keyword = telop.KeywordToHideReplaced;
                if (!string.IsNullOrWhiteSpace(keyword))
                {
                    if (log.Contains(keyword, StringComparison.OrdinalIgnoreCase))
                    {
                        telop.ForceHide = true;
                        matched         = true;
                    }
                }
            }

            // 正規表現マッチ(強制非表示)
            else
            {
                if (regexToHide.IsMatch(log))
                {
                    telop.ForceHide = true;
                    matched         = true;
                }
            }

            if (matched)
            {
                SpellsController.Instance.UpdateNormalSpellTimerForTelop(telop, telop.ForceHide);
                SpellsController.Instance.NotifyNormalSpellTimerForTelop(telop.Title);
            }
        }
Example #3
0
        /// <summary>
        /// ログとマッチングする
        /// </summary>
        /// <param name="telops">Telops</param>
        /// <param name="logLines">ログ行</param>
        public static void Match(
            IReadOnlyList <OnePointTelop> telops,
            IReadOnlyList <string> logLines)
        {
            foreach (var log in logLines)
            {
                telops.AsParallel().ForAll(telop =>
                {
                    var matched = false;

                    var regex       = telop.Regex;
                    var regexToHide = telop.RegexToHide;

                    // 開始条件を確認する
                    if (ConditionUtility.CheckConditionsForTelop(telop))
                    {
                        // 通常マッチ
                        if (regex == null)
                        {
                            var keyword = telop.KeywordReplaced;
                            if (!string.IsNullOrWhiteSpace(keyword))
                            {
                                if (log.ToUpper().Contains(
                                        keyword.ToUpper()))
                                {
                                    var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                                    if (!telop.AddMessageEnabled)
                                    {
                                        telop.MessageReplaced = messageReplaced;
                                    }
                                    else
                                    {
                                        telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                                 messageReplaced :
                                                                 Environment.NewLine + messageReplaced;
                                    }

                                    telop.MatchDateTime = DateTime.Now;
                                    telop.Delayed       = false;
                                    telop.MatchedLog    = log;
                                    telop.ForceHide     = false;

                                    SoundController.Default.Play(telop.MatchSound);
                                    SoundController.Default.Play(telop.MatchTextToSpeak);

                                    matched = true;
                                }
                            }
                        }

                        // 正規表現マッチ
                        else
                        {
                            var match = regex.Match(log);
                            if (match.Success)
                            {
                                var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                                if (!telop.AddMessageEnabled)
                                {
                                    telop.MessageReplaced = match.Result(messageReplaced);
                                }
                                else
                                {
                                    telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                             match.Result(messageReplaced) :
                                                             Environment.NewLine + match.Result(messageReplaced);
                                }

                                telop.MatchDateTime = DateTime.Now;
                                telop.Delayed       = false;
                                telop.MatchedLog    = log;
                                telop.ForceHide     = false;

                                SoundController.Default.Play(telop.MatchSound);
                                if (!string.IsNullOrWhiteSpace(telop.MatchTextToSpeak))
                                {
                                    var tts = match.Result(telop.MatchTextToSpeak);
                                    SoundController.Default.Play(tts);
                                }

                                matched = true;
                            }
                        }
                    }

                    if (matched)
                    {
                        SpellTimerCore.Default.updateNormalSpellTimerForTelop(telop, telop.ForceHide);
                        SpellTimerCore.Default.notifyNormalSpellTimerForTelop(telop.Title);
                        return;
                    }

                    // 通常マッチ(強制非表示)
                    if (regexToHide == null)
                    {
                        var keyword = telop.KeywordToHideReplaced;
                        if (!string.IsNullOrWhiteSpace(keyword))
                        {
                            if (log.ToUpper().Contains(
                                    keyword.ToUpper()))
                            {
                                telop.ForceHide = true;
                                matched         = true;
                            }
                        }
                    }

                    // 正規表現マッチ(強制非表示)
                    else
                    {
                        if (regexToHide.IsMatch(log))
                        {
                            telop.ForceHide = true;
                            matched         = true;
                        }
                    }

                    if (matched)
                    {
                        SpellTimerCore.Default.updateNormalSpellTimerForTelop(telop, telop.ForceHide);
                        SpellTimerCore.Default.notifyNormalSpellTimerForTelop(telop.Title);
                    }
                });   // end loop telops
            }

            // スペルの更新とサウンド処理を行う
            foreach (var telop in telops)
            {
                var regex = telop.Regex;

                // ディレイ時間が経過した?
                if (!telop.Delayed &&
                    telop.MatchDateTime > DateTime.MinValue &&
                    telop.Delay > 0)
                {
                    var delayed = telop.MatchDateTime.AddSeconds(telop.Delay);
                    if (DateTime.Now >= delayed)
                    {
                        telop.Delayed = true;
                        SoundController.Default.Play(telop.DelaySound);
                        var tts = regex != null && !string.IsNullOrWhiteSpace(telop.DelayTextToSpeak) ?
                                  regex.Replace(telop.MatchedLog, telop.DelayTextToSpeak) :
                                  telop.DelayTextToSpeak;
                        SoundController.Default.Play(tts);
                    }
                }
            }
#if false
            Parallel.ForEach(telops, (telop) =>
            {
            }); // end loop telops
#endif
        }