Rustace (@RustaceBot) is a fully functional Telegram bot that demonstrates every feature of the tgbotrs library — a fully-featured, auto-generated Rust Telegram Bot API library.
This bot covers:
- ✅ All 165 API methods from Telegram Bot API 9.4
- ✅ All 285 types — strongly typed
- ✅ All 15 update types (message, callback, inline, polls, reactions, boosts, etc.)
- ✅ Long-polling mode (
Poller) - ✅ Webhook mode (
WebhookServer) - ✅ Interactive menus, inline keyboards, reply keyboards
- ✅ Media sending demos (photo, animation, audio, video, voice, document, sticker)
- ✅ Inline query handling with results
- ✅ Dice animations (🎲🎯🎳🏀⚽🎰)
git clone https://github.com/ankit-chaubey/RustaceBot.git
cd RustaceBotcp .env.example .envEdit .env and set your BOT_TOKEN:
BOT_TOKEN=1234567890:AAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BOT_MODE=polling # or webhookcargo run --releaseAll configuration is done via the .env file. See .env.example for all available options.
BOT_TOKEN=your_token_here
BOT_MODE=polling
POLLING_TIMEOUT=30
POLLING_LIMIT=100BOT_TOKEN=your_token_here
BOT_MODE=webhook
WEBHOOK_URL=https://your-domain.com
WEBHOOK_PORT=8080
WEBHOOK_PATH=/webhook
WEBHOOK_SECRET=your_random_secret_here
WEBHOOK_MAX_CONNECTIONS=40
WEBHOOK_DROP_PENDING=falseNote: For webhook mode, your server needs a valid HTTPS certificate accessible from the internet. Telegram supports ports 80, 88, 443, 8443.
| Command | Description |
|---|---|
/start |
Welcome message & main menu |
/help |
Full command reference |
/about |
About Rustace & tgbotrs |
/menu |
Show main interactive menu |
/dice |
Roll a dice 🎲 |
/darts |
Throw darts 🎯 |
/bowling |
Play bowling 🎳 |
/basketball |
Shoot hoops 🏀 |
/football |
Kick the ball ⚽ |
/slots |
Slot machine 🎰 |
/fact |
Random Rust fact 💡 |
/joke |
Programmer joke 😂 |
/magic8 |
Magic 8-ball 🔮 |
/coinflip |
Flip a coin 🪙 |
/photo |
Demo send_photo() |
/animation |
Demo send_animation() |
/location |
Demo send_location() |
/venue |
Demo send_venue() |
/contact |
Demo send_contact() |
/poll |
Create a poll 📊 |
/textstyles |
HTML formatting demo |
/botinfo |
Bot info (get_me) |
/webhookinfo |
Webhook status |
/membercount |
Chat member count |
/admins |
List administrators |
/invitelink |
Generate invite link |
/mycommands |
Show registered commands |
/myprofile |
Your profile photos |
/library |
Full library method overview |
/stats |
Bot statistics |
/setcommands |
Register bot commands |
/deletecommands |
Delete bot commands |
/deletewebhook |
Remove webhook |
send_message— with HTML parse mode, reply markupsend_photo— photo with captionsend_animation— GIF/MP4 animationsend_audio— audio filessend_video— video filessend_video_note— circular videosend_voice— voice messagessend_document— any filesend_sticker— sticker messagessend_location— map locationsend_venue— venue with addresssend_contact— contact cardsend_dice— animated dice (🎲🎯🎳🏀⚽🎰)send_poll— interactive pollssend_media_group— photo/video albums
edit_message_text— edit sent messagesedit_message_reply_markup— update keyboardsedit_message_caption— update media captionsedit_message_live_location— live location updatesstop_message_live_location— stop live sharing
get_chat— fetch chat infoget_chat_administrators— list adminsget_chat_member_count— member countget_chat_member— member infoban_chat_member/unban_chat_memberrestrict_chat_member/promote_chat_memberpin_chat_message/unpin_chat_messageexport_chat_invite_link— invite linkcreate_chat_invite_link— custom invite linkleave_chat— bot leaves chat
get_me— bot self infoget_webhook_info— webhook statusset_webhook/delete_webhookget_updates— manual pollingget_file— file info & download URL
set_my_commands/get_my_commands/delete_my_commandsset_my_name/get_my_nameset_my_description/get_my_descriptionset_my_short_description/get_my_short_description
answer_inline_query— with articles, text, URL buttonsanswer_callback_query— toast, alert, URL callbacks
get_my_star_balance— bot's star balanceget_star_transactions— transaction historysend_invoice/create_invoice_linkanswer_shipping_queryanswer_pre_checkout_query
get_sticker_set,create_new_sticker_set,add_sticker_to_setset_sticker_emoji_list,set_sticker_keywordsreplace_sticker_in_set,delete_sticker_set- ...and more
get_business_connectionset_business_account_name,set_business_account_bioread_business_message,delete_business_messages- ...and more
send_game,set_game_score,get_game_high_scores
post_story,edit_story,delete_story,repost_story
RustaceBot/
├── src/
│ ├── main.rs # Entry point, bot init, polling/webhook
│ ├── config.rs # .env configuration loader
│ ├── dispatcher.rs # Update dispatcher (all 15 update types)
│ └── handlers/
│ ├── mod.rs # Handler module exports
│ ├── commands.rs # /command handlers & menu keyboards
│ ├── callbacks.rs # Inline keyboard callback handler
│ └── inline.rs # Inline query handler
├── .env.example # Environment configuration template
├── .gitignore
├── Cargo.toml
└── README.md
[dependencies]
tgbotrs = { version = "0.1.4", features = ["webhook"] }
tokio = { version = "1", features = ["full"] }
dotenv = "0.15"
log = "0.4"
env_logger = "0.11"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
rand = "0.8"
anyhow = "1"# Debug build
cargo build
# Release build (recommended for production)
cargo build --release
# Run directly
cargo run
# Run with specific log level
RUST_LOG=debug cargo runserver {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location /webhook {
proxy_pass http://127.0.0.1:8080/webhook;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}.env for webhook:
BOT_MODE=webhook
WEBHOOK_URL=https://your-domain.com
WEBHOOK_PORT=8080
WEBHOOK_PATH=/webhook
WEBHOOK_SECRET=your_random_secrettgbotrs is a fully-featured, auto-generated Telegram Bot API library for Rust.
[dependencies]
tgbotrs = { version = "0.1.4", features = ["webhook"] }
tokio = { version = "1", features = ["full"] }Quick example:
use tgbotrs::{Bot, Poller, UpdateHandler};
#[tokio::main]
async fn main() {
let bot = Bot::new("YOUR_TOKEN").await.unwrap();
println!("Running as @{}", bot.me.username.as_deref().unwrap_or("unknown"));
let handler: UpdateHandler = Box::new(|bot, update| {
Box::pin(async move {
if let Some(msg) = update.message {
if let Some(text) = msg.text {
let _ = bot.send_message(msg.chat.id, text, None).await;
}
}
})
});
Poller::new(bot, handler).timeout(30).start().await.unwrap();
}Ankit Chaubey
📧 ankitchaubey.dev@gmail.com
💬 Telegram: @ankify
🐙 GitHub: @ankit-chaubey
| Resource | URL |
|---|---|
| 🤖 Bot | @RustaceBot |
| 📦 tgbotrs on crates.io | crates.io/crates/tgbotrs |
| 📖 Documentation | docs.rs/tgbotrs |
| 🐙 tgbotrs Library | github.com/ankit-chaubey/tgbotrs |
| 🤖 Bot Repository | github.com/ankit-chaubey/RustaceBot |
| 🌐 Telegram Bot API | core.telegram.org/bots/api |
MIT License — Copyright (c) 2024-present Ankit Chaubey
See LICENSE for details.
Made with 🦀 Rust and ❤️ by Ankit Chaubey