mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 07:05:36 +01:00
Fix sending telegram notification
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -1,3 +1,4 @@
|
|||||||
|
use reqwest::Url;
|
||||||
use serenity::all::ActivityData;
|
use serenity::all::ActivityData;
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
use serenity::model::channel::Message;
|
use serenity::model::channel::Message;
|
||||||
@@ -7,14 +8,17 @@ pub mod config;
|
|||||||
|
|
||||||
|
|
||||||
async fn send_to_telegram(msg: &str) {
|
async fn send_to_telegram(msg: &str) {
|
||||||
let url = format!(
|
let base_url = format!("https://api.telegram.org/bot{}/sendMessage", config::CONFIG.telegram_bot_token);
|
||||||
"https://api.telegram.org/bot{}/sendMessage?chat_id={}&text={}",
|
|
||||||
config::CONFIG.telegram_bot_token,
|
|
||||||
config::CONFIG.telgram_channel_id,
|
|
||||||
msg
|
|
||||||
);
|
|
||||||
|
|
||||||
reqwest::get(&url).await.expect("Error sending message to Telegram");
|
let url = Url::parse_with_params(
|
||||||
|
base_url.as_ref(),
|
||||||
|
&[
|
||||||
|
("chat_id", &config::CONFIG.telgram_channel_id.to_string().as_ref()),
|
||||||
|
("text", &msg)
|
||||||
|
]
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
|
reqwest::get(url).await.expect("Error sending message to Telegram");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user