Exemple #1
0
 public void SetUserData(FccBotUserData data)
 {
     _botData.SetProperty(nameof(FccBotUserData), data);
     _sc.BotState.SetPrivateConversationData
     (
         _activity.ChannelId,
         _activity.Conversation.Id,
         _activity.From.Id,
         _botData
     );
 }
Exemple #2
0
        public string RespondOnAnyTextWithText(FccBotUserData data, Activity activity)
        {
            try
            {
                string reply = null;

                if (String.IsNullOrWhiteSpace(activity.Text))
                {
                    return(Response.YOU_SAID_NOTHING_PLEASE_SPEAK_UP);
                }

                if (activity.Text.Split(' ').Any(x => x.ToLowerInvariant() == FccBotCommands.HELP))
                {
                    return(Response.SHOW_HELP);
                }

                if (activity.Text.Split(' ').Any(x => x.ToLowerInvariant() == FccBotCommands.COMMANDS))
                {
                    return(Response.SHOW_COMMANDS);
                }

                if (activity.Text.Split(' ').Any(x => x.ToLowerInvariant() == FccBotCommands.HI))
                {
                    return(Response.HI_BACK);
                }

                if (activity.Text.Split(' ').Any(x => x.ToLowerInvariant() == FccBotCommands.HELLO))
                {
                    return(Response.HELLO_BACK);
                }

                if (reply == null && data.AskedForUserName == false)
                {
                    reply = Response.HELLO_MSG_AND_ASK_FOR_NAME;

                    // Set BotUserData
                    data.AskedForUserName = true;
                }
                else
                {
                    if (reply == null && data.UserName == null) // Name was never provided
                    {
                        // If we have asked for a username but it has not been set
                        // the current response is the user name
                        reply = String.Format(Response.HEY_THERE_USER_SPEAK_UP, activity.Text);

                        // Set BotUserData
                        data.UserName = activity.Text;
                    }
                    else // Name was provided
                    {
                        reply = String.Format(Response.REPEAT_AND_ASK_FOR_SELFIE, data.UserName, activity.Text);
                    }
                }

                return(reply);
            }
            catch (Exception ex)
            {
                return(String.Format(Response.WHOOPS_STH_WENT_WRONG_HERES_THE_ERROR, ex.Message));
            }
        }