<commit_before>﻿using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Bot.Connector;
using IntermediatorBotSample.Dialogs;
using Microsoft.Bot.Builder.Dialogs;
using Underscore.Bot.MessageRouting;
using Underscore.Bot.Utils;
using Underscore.Bot.Models;
using System.Globalization;
using IntermediatorBot.Strings;

namespace IntermediatorBotSample.Controllers
{
    [BotAuthentication]
    public class MessagesController : ApiController
    {
        public const string CommandInitiateEngagement = "human";

        public MessagesController()
        {
            // Note: This class is constructed every time there is a new activity (Post called).
        }

        /// <summary>
        /// Handles the received message.
        /// </summary>
        public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
        {
            if (activity.Locale != null)
            {
                ConversationText.Culture = new CultureInfo(activity.Locale);
            }

            if (activity.Type == ActivityTypes.Message)
            {
                MessageRouterManager messageRouterManager = WebApiConfig.MessageRouterManager;
                IMessageRouterResultHandler messageRouterResultHandler = WebApiConfig.MessageRouterResultHandler;

                messageRouterManager.MakeSurePartiesAreTracked(activity);

                // First check for commands (both from back channel and the ones directly typed)
                MessageRouterResult messageRouterResult = WebApiConfig.BackChannelMessageHandler.HandleBackChannelMessage(activity);

                if (messageRouterResult.Type != MessageRouterResultType.EngagementAdded
                    || await WebApiConfig.CommandMessageHandler.HandleCommandAsync(activity) == false)
                {
                    // No command detected

                    // Let the message router manager instance handle the activity
                    messageRouterResult = await messageRouterManager.HandleActivityAsync(activity, false);

                    if (messageRouterResult.Type == MessageRouterResultType.NoActionTaken)
                    {
                        // No action was taken by the message router manager. This means that the user
                        // is not engaged in a 1:1 conversation with a human (e.g. customer service
                        // agent) yet.<commit_msg>Hot fix!<commit_after>﻿using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Bot.Connector;
using IntermediatorBotSample.Dialogs;
using Microsoft.Bot.Builder.Dialogs;
using Underscore.Bot.MessageRouting;
using Underscore.Bot.Utils;
using Underscore.Bot.Models;
using System.Globalization;
using IntermediatorBot.Strings;

namespace IntermediatorBotSample.Controllers
{
    [BotAuthentication]
    public class MessagesController : ApiController
    {
        public const string CommandInitiateEngagement = "human";

        public MessagesController()
        {
            // Note: This class is constructed every time there is a new activity (Post called).
        }

        /// <summary>
        /// Handles the received message.
        /// </summary>
        public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
        {
            if (activity.Locale != null)
            {
                ConversationText.Culture = new CultureInfo(activity.Locale);
            }

            if (activity.Type == ActivityTypes.Message)
            {
                MessageRouterManager messageRouterManager = WebApiConfig.MessageRouterManager;
                IMessageRouterResultHandler messageRouterResultHandler = WebApiConfig.MessageRouterResultHandler;

                messageRouterManager.MakeSurePartiesAreTracked(activity);

                // First check for commands (both from back channel and the ones directly typed)
                MessageRouterResult messageRouterResult = WebApiConfig.BackChannelMessageHandler.HandleBackChannelMessage(activity);

                if (messageRouterResult.Type != MessageRouterResultType.EngagementAdded
                    && await WebApiConfig.CommandMessageHandler.HandleCommandAsync(activity) == false)
                {
                    // No command detected

                    // Let the message router manager instance handle the activity
                    messageRouterResult = await messageRouterManager.HandleActivityAsync(activity, false);

                    if (messageRouterResult.Type == MessageRouterResultType.NoActionTaken)
                    {
                        // No action was taken by the message router manager. This means that the user
                        // is not engaged in a 1:1 conversation with a human (e.g. customer service
                        // agent) yet.
{'fraction_non_alphanumeric': 0.06745950379331556, 'fraction_numerical': 0.0008201763379126512, 'mean_word_length': 2.313858695652174, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4936391', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1071, 'n_words': 298}