Crates.io | telegram_notifyrs |
lib.rs | telegram_notifyrs |
version | 0.1.3 |
source | src |
created_at | 2020-10-21 17:56:25.623942 |
updated_at | 2020-12-24 17:03:44.009618 |
description | Easily send single telegram messages! |
homepage | |
repository | https://github.com/evan-chaney/telegram-notifyrs |
max_upload_size | |
id | 303914 |
size | 40,163 |
A simple way to send messages via Telegram in Rust. I found it difficult to find a Crate for sending messages via Telegram without initializing a whole bot listener so I decided to make one. Feel free to open issues/PRs!
Include the crate under dependencies in your Cargo.toml
[dependencies]
telegram_notifyrs = "0.1.3"
use telegram_notifyrs;
telegram_notifyrs::send_message("This is my message".to_string(), "this-is-my-api-token", 1234567890);
use std::env;
use telegram_notifyrs;
fn main() {
let token = env::var("TELEGRAM_BOT_TOKEN").expect("TELEGRAM_BOT_TOKEN not set");
let chat_id: i64 = env::var("TELEGRAM_CHAT_ID")
.expect("Missing TELEGRAM_CHAT_ID environment variable")
.parse()
.expect("Error parsing TELEGRAM_CHAT_ID as i64");
telegram_notifyrs::send_message("Test from library".to_string(), &token, chat_id);
}