Serverless Telegram Bot for Nezha
Contributor:
Project URL: https://github.com/swkisdust/plain-nezha-bot
A single-user, single-instance, multi-language private chat Nezha Telegram bot that can be deployed on Cloudflare Workers.
Inspired by https://github.com/nezhahq/Nezha-Telegram-Bot-V1
Deployment
- Clone this project and run
npm install
to install dependencies. - Create a Workers KV namespace using your preferred method and save its ID.
- Modify
wrangler.toml
and update thekv_namespaces
field with your KV information. - Modify
wrangler.toml
undervars
:
NZ_BASEURL
: Panel address, e.g.,https://qio.ng
.LANG
: Language, options areen
andzh-CN
, default isen
.ENDPOINT_PATH
: Route path for receiving Telegram Webhook, e.g.,/endpoint
.
- Create the following Secrets:
TELEGRAM_BOT_TOKEN
: Bot token obtained from BotFather.TELEGRAM_SECRET
: Webhook authentication key.TELEGRAM_UID
: User UID, the bot will not interact with anyone other than this UID.PASSWORD
: Basic authentication password for register/unregister/refresh token operations.NZ_USERNAME
: Panel username for initial authentication and subsequent refreshes.NZ_PASSWORD
: Panel password for initial authentication and subsequent refreshes.
- Run
npx wrangler deploy
to deploy the project.
Usage
Access the /register
route to register the Webhook and start using the bot.
If you do not need the bot temporarily, you can access /unregister
to remove the Webhook.
By default, the token refresh operation is triggered every 30 minutes. You can modify this manually in wrangler.toml
or access /refresh
to refresh manually.