Skip to content

Commit

Permalink
Proper error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tapnisu committed Apr 5, 2024
1 parent 061a6d6 commit 0115ccc
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,24 @@ impl EventHandler for Handler {
return;
}

self.sender_bot
.send_message(
self.output_chat_id.to_owned(),
format_message(&ctx, &msg, self.hide_usernames).await.unwrap(),
)
.parse_mode(ParseMode::MarkdownV2)
.await
.unwrap();
if let Err(err) = send_message(self, &ctx, &msg).await {
println!("{}", err);
}
}
}

async fn send_message(
handler: &Handler,
ctx: &Context,
msg: &Message,
) -> anyhow::Result<teloxide::prelude::Message> {
let message = format_message(ctx, msg, handler.hide_usernames).await?;

let result = handler
.sender_bot
.send_message(handler.output_chat_id.to_owned(), message)
.parse_mode(ParseMode::MarkdownV2)
.await?;

Ok(result)
}

0 comments on commit 0115ccc

Please sign in to comment.