Small overnight project that is easily configurable and expandable. Bots reply to command with a audio note made from predefined audio files.
-
- Start chat with Botfather @BotFather
- Use /newbot command
- Follow the steps and give your bot a title and username
- Botfather will give you a token*. Save this token to use later. (Note: Token is a password to your bot. Do not share it with anyone)
-
- Follow the steps here https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
-
- Download this repository. Download link
- Extract zip
- Go into extracted directory and run
npm intall
command to install libraries required for this bot.
-
- Make a new folder in
/public
directory and save audio files in it. - Every new bot will have its own directory with unique name
(For example the files for Rizvi bots are saved in
/public/rizvi
directory) - Every audio file will be turned into a bot command by using its filename
- Telegram requires audio notes to be in OPUS .ogg format with size limit upto 50MB. Otherwise the notes will be sent as streamable audio files.
- Set token in .env file found in root directory. Every value is separated by a pipe
|
and new bot settings start with a semicolon;
- Config format:
bots=[Directory name]|[Bot Username]|[Bot Token]|[Bot Webhook Endpoint];[Another Directory name]|[Another Bot Username]|[Another Bot Token]|[Another Bot Webhook Endpoint]
- Config example:
bots=rizvi|khadimrizvi_bot|1234:asdhasdhajsdaldsjalsjdalsjdlasjdlasjdlasjdaj|asdhasdhajsdalds
- Config format:
-
- *Endpoints are ears to your bot. Telegram will send all messages to this url so your bot can process them
- **Endpoints can be anything but it is recommended that you make them a random string so no one can guess them. They are not secure and anyone can hijack your bot.
- ***Every bot must have a unique endpoint.
- Make a new folder in
-
- Open command prompt
- Start server with
node ./index.js
- Open a web browser and visit
localhost/refreshwebhooks
to setup webhooks and bot commands.
Option | Description | Required | Default |
---|---|---|---|
bots |
Bot details separated be | and new bot separated by ; |
YES | |
cores |
Number of cores server should use | NO | All available cores |
port |
Server port | NO | 80 |
publicDir |
Name of public directory. | NO | /public |
domain_name |
Domain name | NO | os.hostname() |
telegram_api |
Telegram API URL | NO | https://api.telegram.org |
disable_dotenv |
Disable .env file and use system environment variables |
NO | FALSE |