use telegram-bot-api in debug builds (controlled by presense of env variable)

This commit is contained in:
mykola2312 2024-09-13 07:25:20 +03:00
parent 02758f6789
commit 0bf6c1b63e

View file

@ -27,11 +27,11 @@ use super::start::{cmd_start, handle_my_chat_member};
pub async fn bot_main(db: DbPool) -> anyhow::Result<()> { pub async fn bot_main(db: DbPool) -> anyhow::Result<()> {
event!(Level::INFO, "start"); event!(Level::INFO, "start");
let bot = if cfg!(debug_assertions) { let bot = if let Ok(api_url) = std::env::var("BOT_API_URL") {
Bot::new(unwrap_env("BOT_TOKEN")) Bot::new(unwrap_env("BOT_TOKEN"))
.set_api_url(Url::from_str(&api_url).unwrap())
} else { } else {
// we use telegram bot api server only in production Bot::new(unwrap_env("BOT_TOKEN"))
Bot::new(unwrap_env("BOT_TOKEN")).set_api_url(Url::from_str(&unwrap_env("BOT_API_URL"))?)
}; };
let listener = Polling::builder(bot.clone()) let listener = Polling::builder(bot.clone())