Skip to content

Commit

Permalink
Auto-translate README
Browse files Browse the repository at this point in the history
  • Loading branch information
Continuous Integration committed Sep 27, 2023
1 parent 2bfc11d commit bbaced4
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 165 deletions.
114 changes: 57 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,126 @@
# ChatGPT Telegram Bot

Join the [Telegram Group](https://t.me/+_01cz9tAkUc1YzZl) chat to share your user experience or report Bugs.
加入 [Telegram 群組](https://t.me/+_01cz9tAkUc1YzZl) 聊天,分享您的用戶體驗或報告錯誤。

[English](./README.md) | [Simplified Chinese](./README.zh-CN.md) | [Traditional Chinese](./README.zh-TW.md)
[英文](./README.md) | [簡體中文](./README.zh-CN.md) | [繁體中文](./README.zh-TW.md)

## Features
## 功能

Supports ChatGPT and GPT4 API
支持 ChatGPT GPT4 API

Supports online search using duckduckgo and Google🔍. DuckDuckGo search is provided by default, and the official API for Google search needs to be applied by the user. It can provide real-time information that GPT could not answer before, such as Weibo hot search today, weather in a certain place today, and the progress of a certain person or news.
支持使用 duckduckgo Google 进行在线搜索🔍。默认提供 DuckDuckGo 搜索,而 Google 搜索需要用户申请官方 API。它可以提供 GPT 以前无法回答的即时信息,例如今日微博热搜,某个地方今天的天气和某个人或新闻的进展情况。

Supports document QA based on the embedded vector database. In the search, for the searched PDF, automatic vector semantic search of PDF documents is performed, and pdf-related content is extracted based on the vector database. Supports using the "qa" command to vectorize the entire website with the "sitemap.xml" file, and answer questions based on the vector database, which is especially suitable for document websites and wiki websites of some projects.
支持基于嵌入式向量数据库的文档 QA。在搜索中,对于已搜索的 PDF,执行自动矢量语义搜索PDF文档,并根据矢量数据库提取与PDF相关的内容。支持使用“qa”命令向量化带有“sitemap.xml”文件的整个网站,并基于矢量数据库回答问题,特别适用于某些项目的文档网站和 wiki 网站。

Supports switching between GPT3.5, GPT4 and other models through the "info" command in the chat window
支持通过聊天窗口中的“info”命令在 GPT3.5GPT4 和其他模型之间切换

Asynchronously processes messages, multi-threadedly answers questions, supports isolated dialogues, and different users have different dialogues
异步处理消息,多线程回答问题,支持孤立的对话,不同的用户有不同的对话

Supports accurate Markdown rendering of messages, using another [project](https://github.com/yym68686/md2tgmd) of mine
支持准确的消息 Markdown 渲染,使用我另一个 [项目](https://github.com/yym68686/md2tgmd)

Supports streaming output, achieving typewriter effect
支持流式输出,实现打字机效果

Supports whitelisting to prevent abuse and information leakage
支持白名单,以防止滥用和信息泄漏

Cross-platform, breaking knowledge barriers anytime and anywhere with Telegram
跨平台,在 Telegram 上随时随地突破知识障碍

Supports one-click Zeabur, Replit deployment, true zero cost, idiotic deployment, and supports kuma anti-sleep. Also supports Docker, fly.io deployment
支持一键 ZeaburReplit 部署,真正的零费用,傻瓜式部署,并支持 kuma 防睡眠。还支持 Dockerfly.io 部署

## Environment variables
## 环境变量

| Variable Name | Comment |
| ---------------------- | ------------------------------------------------------------ |
| **BOT_TOKEN (required)** | Telegram bot token. Create a bot on [BotFather](https://t.me/BotFather) to get the BOT_TOKEN. |
| **WEB_HOOK (required)** | Whenever the telegram bot receives a user message, the message will be passed to WEB_HOOK, where the bot will listen to it and process the received messages in a timely manner. |
| **API (required)** | OpenAI or third-party API key. |
| API_URL(optional) | If you are using the OpenAI official API, you don't need to set this. If you using a third-party API, you need to fill in the third-party proxy website. The default is: https://api.openai.com/v1/chat/completions |
| GPT_ENGINE (optional) | Set the default QA model; the default is:`gpt-3.5-turbo`. This item can be freely switched using the bot's "info" command, and it doesn't need to be set in principle. |
| NICK (optional) | The default is empty, and NICK is the name of the bot. The bot will only respond when the message starts with NICK that the user inputs, otherwise the bot will respond to any message. Especially in group chats, if there is no NICK, the bot will reply to all messages. |
| PASS_HISTORY (optional) | The default is true. The bot remembers the conversation history and considers the context when replying next time. If set to false, the bot will forget the conversation history and only consider the current conversation. |
| GOOGLE_API_KEY (optional)| If you need to use Google search, you need to set it. If you do not set this environment variable, the bot will default to provide duckduckgo search. Create credentials in Google Cloud's [APIs & Services](https://console.cloud.google.com/apis/api/customsearch.googleapis.com) and the API Key will be GOOGLE_API_KEY on the credentials page. Google search can be queried 100 times a day, which is completely sufficient for light use. When the usage limit has been reached, the bot will automatically turn off Google search. |
| GOOGLE_CSE_ID (optional) | If you need to use Google search, you need to set it together with GOOGLE_API_KEY. Create a search engine in [Programmable Search Engine](https://programmablesearchengine.google.com/), where the search engine ID is the value of GOOGLE_CSE_ID. |
| whitelist (optional) | Set which users can access the bot, and connect the user IDs authorized to use the bot with ','. The default value is `None`, which means that the bot is open to everyone. |
| 变量名 | 注释 |
| ------------------- | ---------------------------------------- |
| *BOT_TOKEN (required)* | Telegram 机器人令牌。在 [BotFather](https://t.me/BotFather)上创建一个机器人以获取 BOT_TOKEN |
| *WEB_HOOK (required)* | 每当 Telegram 机器人接收到用户的消息,该消息将被传递给 WEB_HOOK,机器人将在那里侦听并及时处理收到的消息。 |
| *API (required)* | OpenAI 或第三方 API 密钥。 |
| API_URL(可选) | 如果使用 OpenAI 官方 API,则不需要设置此选项。如果使用第三方 API,则需要填写第三方代理网站。默认值为:https://api.openai.com/v1/chat/completions |
| GPT_ENGINE(可选) | 设置默认的 QA 模型;默认值为:`gpt-3.5-turbo`。此项可以使用机器人的“info”命令随意切换,并且原则上不需要设置。 |
| NICK(可选) | 默认为空,NICK 是机器人的名称。只有当用户输入的消息以 NICK 开头时,机器人才会响应,否则机器人将响应所有消息。特别是在群聊中,如果没有 NICK,则机器人将回复所有消息。 |
| PASS_HISTORY(可选) | 默认为 true。机器人记住对话历史记录,并在下次回复时考虑上下文。如果设置为 false,则机器人会忘记对话历史记录,只考虑当前对话。 |
| GOOGLE_API_KEY(可选) | 如果需要使用 Google 搜索,则需要设置它。如果未设置此环境变量,则机器人将默认提供 duckduckgo 搜索。在 Google Cloud[APIsServices](https://console.cloud.google.com/apis/api/customsearch.googleapis.com) 中创建凭据,API 密钥将是凭据页面上的 GOOGLE_API_KEYGoogle 搜索每天可以查询 100 次,对于轻度使用完全足够。使用量达到限制时,机器人将自动关闭 Google 搜索。 |
| GOOGLE_CSE_ID(可选) | 如果需要使用 Google 搜索,则需要与 GOOGLE_API_KEY 一起设置。在 [Programmable Search Engine](https://programmablesearchengine.google.com/) 中创建搜索引擎,搜索引擎 ID GOOGLE_CSE_ID 的值。 |
| 万能钥匙(可选) | 设置哪些用户可以访问机器人,并将授权使用机器人的用户 ID 与“,”连接起来。默认值为``,这意味着机器人向所有人开放。 |

## Zeabur Remote Deployment (Recommended)
## Zeabur 远程部署(推荐)

One-click deployment:
一键部署:

[![Deploy on Zeabur](https://zeabur.com/button.svg)](https://zeabur.com/templates/R5JY5O?referralCode=yym68686)

If you need follow-up function updates, the following deployment method is recommended:
如果您需要后续功能更新,则建议使用以下部署方法:

Fork this repository first, then register for [Zeabur](https://zeabur.com). The free quota is sufficient for light use. Import from your own Github repository, set the domain name (which must be consistent with WEB_HOOK) and environment variables, and redeploy. If you need function updates in the follow-up, just synchronize this repository in your own repository and redeploy in Zeabur to get the latest functions.
首先,Fork 此存储库,然后注册 [Zeabur](https://zeabur.com)。在轻度使用的情况下,免费配额是足够的。从您自己的 Github 存储库导入后,设置域名(必须与 WEB_HOOK 一致)和环境变量,并重新部署。如果需要随后的功能更新,请在自己的存储库中同步此存储库,然后在 Zeabur 中重新部署以获取最新功能。

## Replit Remote Deployment
## Replit 远程部署

[![Run on Repl.it](https://replit.com/badge/github/yym68686/ChatGPT-Telegram-Bot)](https://replit.com/new/github/yym68686/ChatGPT-Telegram-Bot)

After importing the Github repository, set the running command
导入 GitHub 存储库后,设置运行命令

```bash
pip install -r requirements.txt > /dev/null && python3 main.py
```

Select Secrets in the Tools sidebar, add the environment variables required by the bot, where:
选择 Tools 侧边栏中的 Secrets,添加机器人所需的环境变量,其中:

- WEB_HOOK: Replit will automatically assign a domain name to you, fill in `https://appname.username.repl.co`
- Remember to open "Always On"
- WEB_HOOKReplit 将为您自动分配一个域名,填写“https://appname.username.repl.co
- 记住要打开“始终开启”

Click the run button on the top of the screen to run the bot.
单击屏幕顶部的运行按钮以运行机器人。

## fly.io Remote Deployment
## fly.io 远程部署

Official documentation: https://fly.io/docs/
官方文档:https://fly.io/docs/

Use Docker image to deploy fly.io application
使用 Docker 镜像部署 fly.io 应用程序

```bash
flyctl launch --image yym68686/chatgpt:1.0
```

Enter the name of the application when prompted, and select No for initializing Postgresql or Redis.
提示输入应用程序名称,然后选择“不”以初始化 PostgreSQL 或 Redis

Follow the prompts to deploy. A secondary domain name will be provided in the official control panel, which can be used to access the service.
按照提示进行部署。官方控制面板中将提供第二个域名,可用于访问服务。

Set environment variables
设置环境变量

```bash
flyctl secrets set WEB_HOOK=https://flyio-app-name.fly.dev/
flyctl secrets set BOT_TOKEN=bottoken
flyctl secrets set API=
# optional
# 可选
flyctl secrets set NICK=javis
```

View all environment variables
查看所有环境变量

```bash
flyctl secrets list
```

Remove environment variables
删除环境变量

```bash
flyctl secrets unset MY_SECRET DATABASE_URL
```

ssh to fly.io container
ssh fly.io 容器

```bash
flyctl ssh issue --agent
# ssh connection
# ssh 连接
flyctl ssh establish
```

Check whether the webhook URL is correct
检查 Webhook URL 是否正确

```bash
https://api.telegram.org/bot<token>/getWebhookInfo
```

## Docker Local Deployment
## Docker 本地部署

Start the container
启动容器

```bash
docker run -p 80:8080 -dit \
Expand All @@ -131,7 +131,7 @@ docker run -p 80:8080 -dit \
yym68686/chatgpt:1.0
```

Or if you want to use Docker Compose, here is a docker-compose.yml example:
或者,如果要使用 Docker Compose,以下是 docker-compose.yml 示例:

```yaml
version: "3.5"
Expand All @@ -148,23 +148,23 @@ services:
- 80:8080
```
Run Docker Compose container in the background
在后台运行 Docker Compose 容器
```bash
docker-compose up -d
```

Package the Docker image in the repository and upload it to Docker Hub
在存储库中打包 Docker 镜像并将其上传到 Docker Hub

```bash
docker build --no-cache -t chatgpt:1.0 -f Dockerfile.build --platform linux/amd64 .
docker tag chatgpt:1.0 yym68686/chatgpt:1.0
docker push yym68686/chatgpt:1.0
```

## Reference
## 参考

Reference Projects:
参考项目:

https://core.telegram.org/bots/api

Expand All @@ -174,9 +174,9 @@ https://github.com/franalgaba/chatgpt-telegram-bot-serverless

https://github.com/gpchelkin/scdlbot/blob/d64d14f6c6d357ba818e80b8a0a9291c2146d6fe/scdlbot/__main__.py#L8

The markdown rendering of the message used is another [project](https://github.com/yym68686/md2tgmd) of mine.
消息的 Markdown 渲染使用了我另一个 [项目](https://github.com/yym68686/md2tgmd)

## Star History
## Star 历史记录

<a href="https://github.com/yym68686/ChatGPT-Telegram-Bot/stargazers">
<img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=yym68686/ChatGPT-Telegram-Bot&type=Date">
Expand Down
Loading

0 comments on commit bbaced4

Please sign in to comment.