<commit_before>﻿using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System.Text.RegularExpressions;
using cynosure.Model;
using Microsoft.Bot.Builder.Scorables;
using Microsoft.ApplicationInsights;
using System.Reflection;
using System.Collections.Generic;

namespace cynosure.Dialogs
{
    [Serializable]
    public class RootDispatchDialog : DispatchDialog
    {

        Standup _standup;

        [MethodBind]
        [ScorableGroup(0)]
        private async Task ActivityHandler(IDialogContext context, IActivity activity)
        { 
            try
            {
                switch (activity.Type)
                {
                    case ActivityTypes.Message:
                        this.ContinueWithNextGroup();
                        break;
                    case ActivityTypes.ConversationUpdate:
                    case ActivityTypes.ContactRelationUpdate:
                    case ActivityTypes.Typing:
                    case ActivityTypes.DeleteUserData:
                    case ActivityTypes.Ping:
                    default:
                        break;
                }
            }
            catch (Microsoft.Bot.Builder.Internals.Fibers.InvalidNeedException ex)
            {
                var telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                Activity reply = ((Activity)activity).CreateReply("Sorry, I'm having some difficulties here. I have to reboot myself. Let's start over");
                await connector.Conversations.ReplyToActivityAsync(reply);
                StateClient stateClient = activity.GetStateClient();
                await stateClient.BotState.DeleteStateForUserAsync(activity.ChannelId, activity.From.Id);
            }
        }

        private async Task standupUpdatedAsync(IDialogContext context, IAwaitable<Standup> result)
        {
            var standup = await result;
            context.UserData.SetValue(@"standup", standup);
        }

        private async Task profileUpdated(IDialogContext context, IAwaitable<UserProfile> result)
        {
            var profile = await result;
            context.UserData.SetValue(@"profile", profile);
        }

        [RegexPattern("start standup|standup|start|stand up")]
        [ScorableGroup(1)]
        public void StartStandup(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Start Standup");
            context.Call<Standup>(new DoneItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("edit done|done|edit completed|completed|edite complete|complete")]
        [ScorableGroup(1)]
        public void EditDone(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Edit Done");
            context.Call<Standup>(new DoneItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("^Add (?<item>.*) to done items.")]
        [ScorableGroup(1)]
        public void AddDone(IDialogContext context, IActivity activity, [Entity("item")] string itemText)
        {
            Standup standup;
            if (!context.UserData.TryGetValue(@"profile", out standup))
            {
                context.PostAsync("Not currently in a standup. Use \"start standup\" to get started.");
            }
            standup.Done.Add(itemText);
            context.PostAsync(standup.Summary());
        }

        [RegexPattern("edit committed|committed|edit commitments|commitments")]
        [ScorableGroup(1)]
        public void EditCommitments(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Edit Commitments");
            context.Call<Standup>(new CommittedItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("edit issues|issues|edit barriers|barriers|edit needs|needs|edit blockers|blockers")]
        [ScorableGroup(1)]
        public void EditIssues(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Edit Issues");
            context.Call<Standup>(new IssueItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("standup summary|summary|standup report|report")]
        [ScorableGroup(1)]
        public async Task StandupSummary(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();<commit_msg>Add command to add committed and blocker items.<commit_after>﻿using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System.Text.RegularExpressions;
using cynosure.Model;
using Microsoft.Bot.Builder.Scorables;
using Microsoft.ApplicationInsights;
using System.Reflection;
using System.Collections.Generic;

namespace cynosure.Dialogs
{
    [Serializable]
    public class RootDispatchDialog : DispatchDialog
    {

        Standup _standup;

        [MethodBind]
        [ScorableGroup(0)]
        private async Task ActivityHandler(IDialogContext context, IActivity activity)
        { 
            try
            {
                switch (activity.Type)
                {
                    case ActivityTypes.Message:
                        this.ContinueWithNextGroup();
                        break;
                    case ActivityTypes.ConversationUpdate:
                    case ActivityTypes.ContactRelationUpdate:
                    case ActivityTypes.Typing:
                    case ActivityTypes.DeleteUserData:
                    case ActivityTypes.Ping:
                    default:
                        break;
                }
            }
            catch (Microsoft.Bot.Builder.Internals.Fibers.InvalidNeedException ex)
            {
                var telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                Activity reply = ((Activity)activity).CreateReply("Sorry, I'm having some difficulties here. I have to reboot myself. Let's start over");
                await connector.Conversations.ReplyToActivityAsync(reply);
                StateClient stateClient = activity.GetStateClient();
                await stateClient.BotState.DeleteStateForUserAsync(activity.ChannelId, activity.From.Id);
            }
        }

        private async Task standupUpdatedAsync(IDialogContext context, IAwaitable<Standup> result)
        {
            var standup = await result;
            context.UserData.SetValue(@"standup", standup);
        }

        private async Task profileUpdated(IDialogContext context, IAwaitable<UserProfile> result)
        {
            var profile = await result;
            context.UserData.SetValue(@"profile", profile);
        }

        [RegexPattern("start standup|standup|start|stand up")]
        [ScorableGroup(1)]
        public void StartStandup(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Start Standup");
            context.Call<Standup>(new DoneItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("edit done|done|edit completed|completed|edite complete|complete")]
        [ScorableGroup(1)]
        public void EditDone(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Edit Done");
            context.Call<Standup>(new DoneItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("^Add (?<item>.*) to done items.")]
        [ScorableGroup(1)]
        public void AddDone(IDialogContext context, IActivity activity, [Entity("item")] string itemText)
        {
            Standup standup;
            if (!context.UserData.TryGetValue(@"profile", out standup))
            {
                context.PostAsync("Not currently in a standup. Use \"start standup\" to get started.");
            }
            standup.Done.Add(itemText);
            context.PostAsync(standup.Summary());
        }

        [RegexPattern("edit committed|committed|edit commitments|commitments")]
        [ScorableGroup(1)]
        public void EditCommitments(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Edit Commitments");
            context.Call<Standup>(new CommittedItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("^Add (?<item>.*) to committed items.")]
        [ScorableGroup(1)]
        public void AddCommitted(IDialogContext context, IActivity activity, [Entity("item")] string itemText)
        {
            Standup standup;
            if (!context.UserData.TryGetValue(@"profile", out standup))
            {
                context.PostAsync("Not currently in a standup. Use \"start standup\" to get started.");
            }
            standup.Committed.Add(itemText);
            context.PostAsync(standup.Summary());
        }

        [RegexPattern("edit issues|issues|edit barriers|barriers|edit needs|needs|edit blockers|blockers")]
        [ScorableGroup(1)]
        public void EditIssues(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
            telemetry.TrackEvent("Edit Issues");
            context.Call<Standup>(new IssueItemsDialog(), standupUpdatedAsync);
        }

        [RegexPattern("^Add (?<item>.*) to barriers.")]
        [ScorableGroup(1)]
        public void AddBarrier(IDialogContext context, IActivity activity, [Entity("item")] string itemText)
        {
            Standup standup;
            if (!context.UserData.TryGetValue(@"profile", out standup))
            {
                context.PostAsync("Not currently in a standup. Use \"start standup\" to get started.");
            }
            standup.Issues.Add(itemText);
            context.PostAsync(standup.Summary());
        }

        [RegexPattern("standup summary|summary|standup report|report")]
        [ScorableGroup(1)]
        public async Task StandupSummary(IDialogContext context, IActivity activity)
        {
            var telemetry = new TelemetryClient();
{'fraction_non_alphanumeric': 0.09186775603268098, 'fraction_numerical': 0.0015200456013680411, 'mean_word_length': 2.235095267363245, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '234935', 'n_tokens_mistral': 2624, 'n_tokens_neox': 2512, 'n_words': 569}