Skip to content

Commit

Permalink
fix: panic when failed to parse Cmd
Browse files Browse the repository at this point in the history
close #8
  • Loading branch information
itsusinn committed Aug 6, 2021
1 parent f09966a commit 1557964
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/despatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ pub async fn cmd_or_msg_repl_with_listener<'a,N,Cmd, CH, MH, FutC, FutM, ErrC, E
let cx = Arc::new(cx);
async move {
if let Some(text_content) = cx.clone().update.text() {
if text_content.starts_with("/") {
let cmd = Cmd::parse(&*text_content, clone_bot_name).unwrap();
cmd_handler(cx.to_owned(), cmd).await.log_on_error().await
} else {
msg_handler(cx.to_owned(), String::from(text_content)).await.log_on_error().await
let parse = Cmd::parse(&*text_content, clone_bot_name);
match parse{
Ok(cmd) => cmd_handler(cx.to_owned(), cmd).await.log_on_error().await,
Err(_) => msg_handler(cx.to_owned(), String::from(text_content)).await.log_on_error().await
}
};
}
Expand Down

0 comments on commit 1557964

Please sign in to comment.