A simple Telegram bot for rolling dice intended to be used for tabletop RPG games.
/start- Start the bot/help- Display available commands/r <format>- Roll dice using the specified format (e.g./r 3d6+2)
The bot supports the standard RPG dice notation:
XdY+Z where:
Xis the number of dice to roll (optional, defaults to 1)Yis the number of faces on each die (required)Zis an optional modifier to add to the total. This can be positive or negative.
Examples:
d20- Roll one 20-sided die2d6- Roll two 6-sided dice3d8+5- Roll three 8-sided dice and add 5 to the resultd10-3- Roll one 10-sided die and subtract 3 from the result
The bot requires the following environment variables:
TELOXIDE_TOKEN- Your Telegram Bot API tokenPORT- Port for the webhook serverHOST- Host address for the webhook serverWEBHOOK_URL- Public URL where Telegram can reach your webhook
- Clone the repository
- Set the required environment variables
- Install dependencies with Cargo:
cargo build - Run the bot with Cargo:
cargo run
This bot is designed to run with webhook integration, using a service like Railway. You can also run it locally using ngrok to expose your local server to the internet.
Contributions are welcome! Feel free to open issues or submit pull requests.