Inspired by https://icanhazip.com/ (which is also hosted on Cloudflare Workers), this bot simply replies the current chat's ID for info when started or invited to the chat.
You can get your own user ID by just tagging @icanhazidbot
in any chat, if required, you can tap on the ID to send it in the active chat. Alternatively, you can talk to the bot directly.
If you need the ID of a group chat, you should invite the bot @ http://t.me/icanhazidbot to the group, and it would immediately print out the ID in the group chat.
If you need the file ID of a sticker, you can also send it to the bot to get it.
id - Get the bot to respond with the ID of the current chat
- Clone this repository
- Run
npm ci
oryarn install
- Run
npx wrangler secret put TELEGRAM_BOT_TOKEN
and set the Telegram bot token - Run
npx wrangler publish
to deploy to Cloudflare Workers - Replace
{TELEGRAM_BOT_TOKEN}
and{WORKERS_NAMESPACE}
on the followinghttps://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/setWebhook?allowed_updates=%5B%22message%22%2C%22inline_query%22%5D&url=https%3A%2F%2Fcf-workers-icanhazid-telegram-bot.{WORKERS_NAMESPACE}.workers.dev%2F{TELEGRAM_BOT_TOKEN}
and access it on your browser