⚡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 rust application to quickly send messages to Telegram bots, groups, and channels.
-
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 and testing it as a class
- Check out example.rs where there is a concrete example with tests
Sending CSV file
use ;
```
- Refer to tests.rs for more reference on how to send a CSV file
## Setting up your environment
1.
- Make sure that your Rust compiler is up to date (
rustygram
currently 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 a 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
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