Exemple #1
0
 public static async Task <bool> PlayVoiceReply(MessageModel e, VoiceReplyRule rule, bool alwaysMatch = false, bool overrideReadInQueue = false)
 {
     if (alwaysMatch || rule.Matches(e))
     {
         if ((VoiceReplyRule.ReplyMode)rule.ReplyingMode != VoiceReplyRule.ReplyMode.VoiceGeneration)
         {
             // play specific file:
             try
             {
                 if (Vars.CurrentConf.InstantVoiceReply || overrideReadInQueue)
                 {
                     Play(rule.ReplyContent, false, true);
                 }
                 else
                 {
                     // add the file to queue
                     fileList.Add(new TTSEntry(rule.ReplyContent, true));
                 }
             }
             catch (Exception ex)
             {
                 Bridge.ALog($"无法读出语音答复: {ex.Message}");
             }
         }
         else
         {
             // play by voice generation (and by default)
             // caution: different types of voice reply have different variables available
             await UnifiedPlay(
                 Main.ProcessVoiceReply(e, rule),
                 true,
                 Vars.CurrentConf.InstantVoiceReply || overrideReadInQueue
                 );
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public static string ProcessVoiceReply(MessageModel e, VoiceReplyRule rule)
        {
            // there's no need to check if the types match, we've already checked for it
            switch ((VoiceReplyRule.MatchSource)rule.MatchingSource)
            {
            case VoiceReplyRule.MatchSource.DanmakuContent:
                // available: $USER (including $$ and $!), $DM
                return(ProcessDanmaku(e, rule.ReplyContent));

            case VoiceReplyRule.MatchSource.DanmakuUser:
                // available: $USER (including $$ and $!), $DM
                return(ProcessDanmaku(e, rule.ReplyContent));

            case VoiceReplyRule.MatchSource.GiftName:
                // available: $USER (including $$ and $!), $GIFT and $COUNT
                return(ProcessGift(e, rule.ReplyContent));

            case VoiceReplyRule.MatchSource.GiftUser:
                // available: $USER (including $$ and $!), $GIFT and $COUNT
                return(ProcessGift(e, rule.ReplyContent));

            default: return(rule.ReplyContent);
            }
        }