⚡rustygram is a minimal and blazing fast telegram notification framework using Rust. Abstracts away the Telegram API complexity so your app doesn't have to worry about the underlying implementation.
Highlights
-
Easily integrate rustygram into your app to quickly send messages to Telegram bots, groups, and channels if you have the chat ID.
-
Send asynchronous notifications in a reliable way.
API overview
create_bot- create a bot instance consistsing of Telegram's bot token, and target chat_idsend_message- call Telegram bot's API sendMessage to send message asynchronously
Examples
Send in simple way
Send in MarkdownV2 or HTML style message
Send message in MarkdownV2
use ;
Send messsage in HTML
use ;
Setting up your environment
- Download Rust.
- Create a new bot using @Botfather to get a token in the format
189:blablabla. - Initialise the
BOT_TOKENenvironmental variable to your token:
# Unix-like
# Windows command line
# Windows PowerShell
- Make sure that your Rust compiler is up to date (
rustygramcurrently requires rustc at least version 1.68):
# If you're using stable
# If you're using nightly
- Run
cargo new my_bot, enter the directory and put these lines into yourCargo.toml:
[]
= "0.1"
= "0.4"
= "0.4"
= { = "1.8", = ["rt-multi-thread", "macros"] }
Tests
You can test by define the following two environment variables
TEST_BOT_TOKEN- telegram bot's tokenTEST_CHAT_ID- telegram bot's chat id
then execute
cargo test
some tests will send a single, or multiple messages to specified chat id on behalf
of such telegram bot. Please take a look at src/tests.rs.
Note
You can utilize this telegram bot @username_to_id_bot in order to get your
telegram channel's chat_id.
Contributing
See CONRIBUTING.md.
Acknowledgements
This project is heavily inspired by teloxide. However it is not a fork of teloxide, but a complete rewrite in order to make it more minimal and faster for the use case of sending notifications on telegram.
The simplistic design is inspired by rustelebot but with more modular and extensible design, also changing the underlying libraries used to be more modern.
License
MIT, Chia Yong Kang