20 lines
467 B
Rust
20 lines
467 B
Rust
use reqwest::Client;
|
|
|
|
pub async fn send_to_telegram(bot_token: &str, chat_id: &str, message: &str) -> Result<(), Box<dyn std::error::Error>> {
|
|
let url = format!("https://api.telegram.org/bot{}/sendMessage", bot_token);
|
|
|
|
let params = [
|
|
("chat_id", chat_id),
|
|
("text", message),
|
|
("parse_mode", "Markdown")
|
|
];
|
|
|
|
|
|
let client = Client::new();
|
|
client.post(&url)
|
|
.form(¶ms)
|
|
.send()
|
|
.await?;
|
|
|
|
Ok(())
|
|
} |