A Telegram bot that can roll the dice like no one before.
Roll Robot is a telegram bot used for common "roll the dice" purposes which is working on group chats.
Roll the dice like no one before. Generate random numbers by default RPG pattern (x)d(y)±(n).
Bot recognizes several commands and can be used in inline mode:
@rollrobot [notation] -- inline request, recognizes both notations /roll [notation] -- default roll, recognizes both notations /full [notation] -- same to '/roll', but shows roll for each dice /random -- 'd100' roll
- Classic
[count]d[dice]±[modifier] - World of Darkness
[count]d[dice][!]>[success]f[fail] - Simplfied (classic, space separated)
[count] [dice] [modifier] - Single-valued
[dice]where ...
count-- number of rollsdice-- dice typemodifier-- value, that will be added or subtracted from result!-- sign, indicating to repeatsuccess-- minimum roll value, that counts as successfail-- maximum roll value, that counts as fail
/roll 20 ➜ 'd20'
/roll 2 10 -1 ➜ result of '2d10-1'
/roll 4d8+3 ➜ result of '4d8+3'
/wod 6d10!>6f1 ➜ number of successes for '6d10!>6f1'
/random ➜ 'd100'
Rate the bot, if you like it.
Your ideas on improvement are welcome.
Bun, TypeScript, grammY, roll-parser.
Deployed on Railway with webhook mode via Bun.serve.
Set the environment variables in the Railway dashboard:
| KEY | VALUE | DESCRIPTION |
|---|---|---|
| TOKEN | $TOKEN |
Token, generated by the BotFather. |
| WEBHOOK_URL | https://app.up.railway.app |
Public URL of the deployed app. |
| PORT | 3000 | Server port (Railway sets this automatically). |
The bot registers the webhook with Telegram on startup. No manual webhook setup is needed.
Set webhook:
https://api.telegram.org/bot$TOKEN/setWebhook?url=$WEBHOOK_URL/bot$TOKEN
Remove webhook:
https://api.telegram.org/bot$TOKEN/setWebhook?remove
Check webhook status:
https://api.telegram.org/bot$TOKEN/getWebhookInfo
Drop stale updates (re-register webhook, clearing the backlog):
https://api.telegram.org/bot$TOKEN/setWebhook?url=$WEBHOOK_URL/bot$TOKEN&drop_pending_updates=true
This is useful if the bot was offline for a long time — Telegram accumulates pending updates that can cause a flood of errors on restart (replies to deleted messages, messages from chats the bot was removed from, etc.).