Home

Awesome

ChatGPT Telegram Bot

badge:version docker image size license

English | δΈ­ζ–‡

A ChatGPT bot for Telegram based on Node.js. Support both browserless and browser-based APIs.

Updates

<strong>πŸŽ‰ v2 has been released!</strong>

<details open> <summary><b>πŸ”” Apr. 3, 2023 (v2.5.0)</b></summary>
</details> <details> <summary><strong>Previous Updates</strong></summary> <details> <summary><b>πŸ”” Mar. 10, 2023 (v2.4.0)</b></summary>
</details> <details> <summary><b>πŸ”” Mar. 07, 2023 (v2.3.2)</b></summary>
</details> <details> <summary><b>πŸ”” Mar. 02, 2023 (v2.3.0)</b></summary>

We strongly advice you to use the official API. There are rumors that OpenAI may ban your account if you continue to use the unofficial and browser API.

</details> <details> <summary><b>πŸ”” Feb. 28, 2023 (v2.2.0)</b></summary>
</details> <details> <summary><b>πŸ”” Feb. 22, 2023 (v2.1.1)</b></summary>
</details> <details> <summary><b>πŸ”” Feb. 19, 2023 (v2.1.0)</b></summary>

We have added support for the unofficial proxy API by @acheong08. This API uses a proxy server that allows users to bypass Cloudflare protection and use the real ChatGPT. Please see Usage for more details.

For previous users, we've updated our API options. api.version is now api.type, with options browser (previously v3), official (previously v4), and unofficial. Please update your config file accordingly.

</details> <details> <summary><b>πŸ”” Feb. 17, 2023</b></summary>

According to one of the maintainers of the reverse proxy servers, OpenAI has patched this method. So you have to either use the browserless Official API with official models (which costs money), or use the browser-based solution.

</details> <details> <summary><b>πŸ”” Feb. 15, 2023</b></summary>

We have release the v2.0.0 of this bot, which supports both browserless and browser-based APIs. You can switch between the two APIs at any time using the config file. Additionally, we have refactored the codebase to make it more maintainable and easier to extend.

For old users, you will need to switch from the .env file to json files under the config/ folder.

</details> </details>

Features

<table> <tr> <th>Private Chat</th> <th>Group Chat</th> </tr> <tr> <td><img src="./assets/private_chat.jpg" /></td> <td><img src="./assets/group_chat.jpg" /></td> </tr> </table>

Usage

Differences between the three types of APIs

Thank @transitive-bullshit for making this easy-to-understand table!

TypeFree?Robust?Quality?
official❌ Noβœ… Yesβœ… Real ChatGPT models
unofficialβœ… Yesβ˜‘οΈ Maybeβœ… Real ChatGPT
browserβœ… Yes❌ Noβœ… Real ChatGPT

Warning

There are rumors that OpenAI may ban your account if you continue to use the unofficial and browser API. Use it at your own risk.

Start the server

Option 1: Node

To get started, follow these steps:

  1. Clone this project.
  2. Create local.json under the config/ folder. You can copy the config/default.json as a template.
  3. Modify the local.json following the instructions in the file. The settings in local.json will override the default settings in default.json.

Then you can start the bot with:

pnpm install
pnpm build && pnpm start

Option 2: Docker

To get started, follow these steps:

  1. Create a folder named config and create a local.json file in it. You can follow the instructions in the "Choice #1: Node" section to customize the settings.

  2. Run the following command to start the bot:

    docker run -d -v ./config:/app/config raineggplant/chatgpt-telegram-bot:latest
    

    This will pull the latest image that only supports the browserless API. If you want to use the browser-based API, you can add a -browser suffix to the tag, e.g., raineggplant/chatgpt-telegram-bot:latest-browser.

Chat with the bot in Telegram

To chat with the bot in Telegram, you can:

Note Make sure you have enabled the privacy mode of your bot before adding it to a group, or it will reply to every message in the group.

The bot also has several commands.

Note When using a command in a group, make sure to include a mention after the command, like /help@chatgpt_bot.

Advanced

Running the bot using browser-based API on a headless server

You can use Xvfb to create a virtual framebuffer on a headless server and run this program:

xvfb-run -a --server-args="-screen 0 1280x800x24 -nolisten tcp -dpi 96 +extension RANDR" pnpm start

We recommend you to use Google auth to avoid the complicated login Recaptchas. If you use a OpenAI account, you may have to use nopecha or 2captcha or manually solve the Recaptcha (by connecting to the display server using x11vnc). For more details about CAPTCHA solving, please refer to the api repository.

Credits

LICENSE

MIT License.

Leave a star ⭐ if you find this project useful.