Created
October 30, 2016 15:59
-
-
Save dgkanatsios/20c99f7768f0200bcdeaf83d71fe9312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class FullnameInputDialog : IDialog<string> | |
{ | |
public async Task StartAsync(IDialogContext context) | |
{ | |
var msg = context.MakeMessage(); | |
var attachments = new List<Attachment>(); | |
msg.AttachmentLayout = AttachmentLayoutTypes.List; | |
var actions = new List<CardAction>() | |
{ | |
Utilities.CreateCardAction(StringMessages.YesButton,StringMessages.YesButton) | |
}; | |
attachments.Add(Utilities.CreateHeroCardAttachment($"{StringMessages.EnterUserName.Replace("$UserName$", msg.Recipient.Name)}", null, $"{StringMessages.EnterCustomUserName}", null, actions)); | |
msg.Attachments = attachments; | |
await context.PostAsync(msg); | |
context.Wait(UsernameSelected); | |
} | |
public virtual async Task UsernameSelected(IDialogContext context, IAwaitable<IMessageActivity> argument) | |
{ | |
var message = await argument; | |
if (message.Text == StringMessages.YesButton) | |
{ | |
context.Done(context.MakeMessage().Recipient.Name); | |
} | |
else | |
{ | |
if (!string.IsNullOrEmpty(message.Text) && message.Text.Trim().Length >= 5 && message.Text.Trim().Length <= 30) | |
{ | |
context.Done(message.Text); | |
} | |
else | |
{ | |
await context.PostAsync(StringMessages.EnterUserNameQuestion); | |
context.Wait(UsernameSelected); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment