waitForPattern method
Wait for pattern from the user.
Possibly returns null
if the listener has been cancelled before
it completes. Otherwise, returns a Context object with the incoming update.
Implementation
Future<Context?> waitForPattern({
required ID chatId,
required Pattern pattern,
Duration? timeout,
bool clearUnfulfilled = true,
}) async {
return await waitFor(
chatId: chatId,
timeout: timeout,
clearUnfulfilled: clearUnfulfilled,
filter: (up) {
if (pattern is String) {
return up.msg?.text?.contains(pattern) == true;
} else if (pattern is RegExp) {
return pattern.hasMatch(up.msg?.text ?? "");
} else {
return false;
}
},
);
}