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 installto install dependencies. - Create a Workers KV namespace using your preferred method and save its ID.
- Modify
wrangler.tomland update thekv_namespacesfield with your KV information. - Modify
wrangler.tomlundervars:
NZ_BASEURL: Panel address, e.g.,https://qio.ng.LANG: Language, options areenandzh-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 deployto 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.