import { ConversationForm } from "https://deno.land/x/grammy_conversations@v1.1.0/mod.ts";
Form building utilities that are exposed on conversation.form
.
All methods of this class behave similarly. They all follow these steps:
- Wait for an update.
- Validate the contained data.
- Skip the update if validation fails.
- Extract the data if the validation succeeds, and return the data.
Moreover, you are able to pass a handler to each method that will be called if the user sends an update that fails validation.
Constructors
This class is constructed internally by the plugin.
Type Parameters
Methods
Waits until the user sends a number, and returns this number. If the user
sends something that cannot be parsed to a number using parseInt
, these
updates will be skipped. You may specify the otherwise
handler that is
called in such cases. Among other things, this allows you to tell the
user that they need to send some text. You can also pass a radix that
will be passed to parseInt
.
Waits until the user sends a number, and returns this number. If the user
sends something that cannot be parsed to a number using parseFloat
,
these updates will be skipped. You may specify the otherwise
handler
that is called in such cases. Among other things, this allows you to tell
the user that they need to send some text.
Waits until the user sends one of the given strings, and returns the
selected string. This is escpecially useful if you previously sent a
custom keyboard, and you expect the user to press one of the keyboard
buttons. If the user does something else, these updates will be skipped.
You may specify the otherwise
handler that is called in such cases.
Among other things, this allows you to tell the user that they need to
select one of the given options.
Waits until the user sends some text, and returns this text. If the user
does something else, these updates will be skipped. You may specify the
otherwise
handler that is called in such cases. Among other things,
this allows you to tell the user that they need to send some text.
Waits until the user sends a URL, and returns this URL. If the user sends
something that cannot be parsed to a URL by the global URL
constructor,
these updates will be skipped. You may specify the otherwise
handler
that is called in such cases. Among other things, this allows you to tell
the user that they did not send a valid URL.
Note that the URL constructor requires