Exemple #1
0
        public async Task <Message> RunAsync()
        {
            // Translate to bot message
            var botMessage = BotMessage.Populate <Message, BotMessage>(this.message);

            // First run through pipeline
            var pipelineTaskIndex = 0;

            for (; pipelineTaskIndex < this.pipeline.Count; pipelineTaskIndex++)
            {
                botMessage = await this.pipeline[pipelineTaskIndex].HandleMessage(botMessage);

                // Break the pipeline execution if message was handled
                if (botMessage.IsHandled)
                {
                    break;
                }
            }

            // Reverse run through pipeline
            for (; pipelineTaskIndex >= 0; pipelineTaskIndex--)
            {
                botMessage = await this.pipeline[pipelineTaskIndex].ResultMessage(botMessage);
            }

            var responseMessage = botMessage.CreateReplyMessage(botMessage.Response, "en");

            responseMessage.BotConversationData          = botMessage.BotConversationData;
            responseMessage.BotPerUserInConversationData = botMessage.BotPerUserInConversationData;
            responseMessage.BotUserData = botMessage.BotUserData;

            return(responseMessage);
        }
Exemple #2
0
 public virtual async Task <BotMessage> ResultMessage(BotMessage message)
 {
     return(message);
 }
Exemple #3
0
 public virtual async Task <BotMessage> HandleMessage(BotMessage message)
 {
     return(message);
 }
Exemple #4
0
 /// <summary>
 /// Translates the message to bot message.
 /// </summary>
 /// <param name="message">The message to translate.</param>
 /// <returns>Returns new instance of <see cref="BotMessage"/> with properties populated from common serializable properties with specified message.</returns>
 public static BotMessage AsBotMessage(this Message message)
 {
     return(BotMessage.Populate <Message, BotMessage>(message));
 }