コード例 #1
0
 void ProcessCommonResponse(string message, out BotResponse response)
 {
     response      = new BotResponse();
     response.From = message;
     response.Text = string.Format("{0}", BotTextHelper.GetCommonText(message));
     response.Rank = ResponseRank.Normal;
     object[] parameter = new object[] { response };
     response.RtfText = RtfDocumentHelper.GetRtfText(parameter);
 }
コード例 #2
0
 void ProcessDefaultResponse(string messageText, out BotResponse response)
 {
     response      = new BotResponse();
     response.From = messageText;
     response.Text = string.Format("{0}", BotTextHelper.GetRandomText());
     response.Rank = ResponseRank.Low;
     object[] parameter = new object[] { response };
     response.RtfText = RtfDocumentHelper.GetRtfText(parameter);
 }
コード例 #3
0
 void ProcessChatResponse(string messageText, out BotResponse response)
 {
     try
     {
         ChatResult data = SimlBot.Instance.Chat(messageText);
         if (data.Success && !string.IsNullOrEmpty(data.BotMessage))
         {
             response      = new BotResponse();
             response.From = messageText;
             response.Text = string.Format("{0}", data.BotMessage);
             response.Rank = ResponseRank.Normal;
             object[] parameter = new object[] { response, data.Data.Current };
             response.RtfText = RtfDocumentHelper.GetRtfText(parameter);
             return;
         }
     }
     catch (Exception) { }
     response = null;
 }
コード例 #4
0
 void ProcessSynSetResultResponse(string messageText, out BotResponse response)
 {
     try
     {
         WordNetPlugin wnPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WordNetPlugin>();
         wnPlugin.QueryName = messageText;
         var synSetResult = wnPlugin.GenerateSynSetResult();
         if (synSetResult != null)
         {
             response      = new BotResponse();
             response.From = messageText;
             response.Text = string.Format("{0}", synSetResult.CommonSynSet);
             response.Rank = ResponseRank.Normal;
             object[] parameter = new object[] { synSetResult, wnPlugin.GenerateSuggestionResult(), wnPlugin.GenerateThesResult() };
             response.RtfText = RtfDocumentHelper.GetRtfText(parameter);
             return;
         }
     }
     catch (Exception) { }
     response = null;
 }
コード例 #5
0
        BotResponse GenerateResponse(Syn.VA.Interaction.Message message, ChatResult eventResult)
        {
            int count = 1;

            int[]       formation = { 1, 2, 3, 4 };
            BotResponse response  = null;

            if (message.Type == Syn.VA.Interaction.MessageType.EventMessage)
            {
                response      = new BotResponse();
                response.From = string.Empty;
                response.Hint = string.Empty;
                response.Rank = ResponseRank.Normal;
                response.Text = eventResult.BotMessage;
                object[] parameter = new object[] { response };
                response.RtfText = RtfDocumentHelper.GetRtfText(parameter);
                return(response);
            }

            while (response == null || string.IsNullOrEmpty(response.Text))
            {
                int option = (formation.Length >= count) && (count >= 1) ? formation[count - 1] : 100;
                switch (option)
                {
                case 1: ProcessCommonResponse(message.Text, out response); break;

                case 2: ProcessQuotationResultResponse(message.Text, out response); break;

                case 3: ProcessChatResponse(message.Text, out response); break;

                case 4: ProcessSynSetResultResponse(message.Text, out response); break;

                default: ProcessDefaultResponse(message.Text, out response); break;
                }
                count++;
            }
            return(response);
        }
コード例 #6
0
 void ProcessQuotationResultResponse(string message, out BotResponse response)
 {
     try
     {
         KJBiblePlugin kjPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <KJBiblePlugin>();
         kjPlugin.QueryName      = message;
         kjPlugin.QueryTestament = BibleNet.KJV.TestamentType.Old | BibleNet.KJV.TestamentType.New;
         kjPlugin.IsQueryLimited = false;
         var quotationResult = kjPlugin.GetQuotationResult();
         if (quotationResult != null)
         {
             response      = new BotResponse();
             response.From = message;
             response.Text = string.Format("{0}", quotationResult.CommonQuotation);
             response.Rank = ResponseRank.Normal;
             object[] parameter = new object[] { quotationResult };
             response.RtfText = RtfDocumentHelper.GetRtfText(parameter);
             return;
         }
     }
     catch (Exception) { }
     response = null;
 }