Skip to content

Instantly share code, notes, and snippets.

@BashkaMen
Created March 21, 2022 09:02
Show Gist options
  • Save BashkaMen/b0c1f26b14cbf1677bc357956c276e4d to your computer and use it in GitHub Desktop.
Save BashkaMen/b0c1f26b14cbf1677bc357956c276e4d to your computer and use it in GitHub Desktop.
public record GetFirstNameState() : IChatState
{
public ChatView View() => ChatView.Multiple(
ChatView.WithText("Enter first name"),
ChatView.WithTextHandler(OnText)
);
private async ValueTask<IChatState> OnText(TextMessage msg)
{
return new GetLastName(msg.Text);
}
}
public record GetLastName(string FirstName) : IChatState
{
public ChatView View() => ChatView.Multiple(
ChatView.WithText("Enter last name"),
ChatView.WithTextHandler(async msg => new PickGender(FirstName, msg.Text))
);
}
public record PickGender(string FirstName, string LastName) : IChatState
{
public ChatView View() =>
ChatView.WithReply(
"Pick your gender",
new()
{
{ "Man", async () => new ShowName(FirstName, LastName, "Man")},
{ "Woman", async () => new ShowName(FirstName, LastName, "Woman")},
}
);
}
public record ShowName(string FirstName, string LastName, string Gender) : IChatState
{
public ChatView View() => ChatView.WithText($"{FirstName} {LastName} {Gender}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment