Moved handler.func.is_none check to the top
This commit is contained in:
parent
916b20e33c
commit
667f8b64fb
@ -21,6 +21,11 @@ where
|
|||||||
) -> BoxFuture<'a, crate::Result<Option<Message>>>,
|
) -> BoxFuture<'a, crate::Result<Option<Message>>>,
|
||||||
{
|
{
|
||||||
let mut handler = next.lock().await;
|
let mut handler = next.lock().await;
|
||||||
|
if handler.func.is_none() {
|
||||||
|
let _ = dialogue.exit().await;
|
||||||
|
return Err(HandlerUsed.into());
|
||||||
|
}
|
||||||
|
|
||||||
delete_optional(&bot, handler.previous.as_ref()).await;
|
delete_optional(&bot, handler.previous.as_ref()).await;
|
||||||
|
|
||||||
let text = match msg.text() {
|
let text = match msg.text() {
|
||||||
@ -40,11 +45,6 @@ where
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if handler.func.is_none() {
|
|
||||||
let _ = dialogue.exit().await;
|
|
||||||
return Err(HandlerUsed.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(failure_message) = check(&bot, &msg, &db, text).await? {
|
if let Some(failure_message) = check(&bot, &msg, &db, text).await? {
|
||||||
handler.previous = Some(failure_message);
|
handler.previous = Some(failure_message);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -28,7 +28,13 @@ pub async fn get_existing_name(
|
|||||||
next: PackagedHandler<String>,
|
next: PackagedHandler<String>,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||||
|
|
||||||
let mut handler = next.lock().await;
|
let mut handler = next.lock().await;
|
||||||
|
if handler.func.is_none() {
|
||||||
|
let _ = dialogue.exit().await;
|
||||||
|
return Err(HandlerUsed.into());
|
||||||
|
}
|
||||||
|
|
||||||
delete_optional(&bot, handler.previous.as_ref()).await;
|
delete_optional(&bot, handler.previous.as_ref()).await;
|
||||||
|
|
||||||
let text = match msg.text() {
|
let text = match msg.text() {
|
||||||
@ -54,11 +60,6 @@ pub async fn get_existing_name(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if handler.func.is_none() {
|
|
||||||
let _ = dialogue.exit().await;
|
|
||||||
return Err(HandlerUsed.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(failure_message) = check_name(&bot, &msg, &db, text, user_id).await? {
|
if let Some(failure_message) = check_name(&bot, &msg, &db, text, user_id).await? {
|
||||||
handler.previous = Some(failure_message);
|
handler.previous = Some(failure_message);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -114,7 +114,13 @@ pub async fn get_user(
|
|||||||
next: PackagedHandler<User>,
|
next: PackagedHandler<User>,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||||
|
|
||||||
let mut handler = next.lock().await;
|
let mut handler = next.lock().await;
|
||||||
|
if handler.func.is_none() {
|
||||||
|
let _ = dialogue.exit().await;
|
||||||
|
return Err(HandlerUsed.into());
|
||||||
|
}
|
||||||
|
|
||||||
delete_optional(&bot, handler.previous.as_ref()).await;
|
delete_optional(&bot, handler.previous.as_ref()).await;
|
||||||
|
|
||||||
if let Some("/cancel") = msg.text().map(str::trim) {
|
if let Some("/cancel") = msg.text().map(str::trim) {
|
||||||
@ -125,11 +131,6 @@ pub async fn get_user(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if handler.func.is_none() {
|
|
||||||
let _ = dialogue.exit().await;
|
|
||||||
return Err(HandlerUsed.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
let document = match msg.document() {
|
let document = match msg.document() {
|
||||||
Some(document) => document,
|
Some(document) => document,
|
||||||
None => {
|
None => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user