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.
Cloudflare Workers, TypeScript, Bun, grammY, and roll-parser.
The bot runs on Cloudflare Workers using Telegram webhooks.
Cloudflare requires these encrypted Worker secrets:
| Key | Description |
|---|---|
TOKEN |
Token generated by BotFather. |
WEBHOOK_SECRET |
Random value used to authenticate Telegram webhook requests. |
The Worker exposes GET /health and accepts authenticated Telegram POST requests at
/webhook. It does not register or modify the Telegram webhook during deployment.
Install the dependencies, authenticate Wrangler, generate a Telegram-compatible secret, and store both secrets in Cloudflare:
bun install
bunx wrangler login
openssl rand -hex 32
bunx wrangler secret put TOKEN
bunx wrangler secret put WEBHOOK_SECRETCreate an ignored .env file in the repository root. Bun loads it automatically for
telegram:configure, and Wrangler uses it for local Worker development:
TOKEN=0123456789:replace-with-telegram-bot-token
WEBHOOK_SECRET=replace-with-a-random-webhook-secret
WEBHOOK_URL=https://rollrobot.<account-subdomain>.workers.dev/webhookKeep .env local. It does not upload secrets to Cloudflare; the wrangler secret put
commands above are still required for the deployed Worker.
Run the Worker locally, then deploy it when /health and webhook authentication have
been verified:
bun run worker:dev
bun run worker:deployAfter deployment, update WEBHOOK_URL in .env with the actual Worker URL and configure
Telegram:
bun run telegram:configure
curl "https://api.telegram.org/bot<telegram-bot-token>/getWebhookInfo"The setup command registers message, inline_query, and chosen_inline_result
updates. It preserves queued updates unless DROP_PENDING_UPDATES=true is explicitly
set. Test private, group, supergroup, and inline requests after configuration, then
monitor the Worker logs for errors.