Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加备用dockerfile文件;增加部署好的Docker镜像 #87

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions Dockerfile → Dockerfile.2
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
FROM node:16-slim
FROM ubuntu


WORKDIR /code

ADD package.json package-lock.json /code/


RUN apt-get update && apt-get install -y apt-utils

RUN apt-get update -qq && apt-get install -y -qq curl

RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get update -qq && apt-get install -y -qq nodejs

RUN npm config set registry https://registry.npm.taobao.org \
&& npm config set disturl https://npm.taobao.org/dist \
&& npm config set puppeteer_download_host https://npm.taobao.org/mirrors
RUN npm install \
&& npm run puppet-install



# Suppress an apt-key warning about standard out not being a terminal. Use in this script is safe.
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
#去除了wget的安装,将wget的安装和chrome的安装都打包成了docker镜像。
#在没有科学上网的设备上,可能因为网络问题无法下载linux_signing_key.pub文件而进度卡住(如服务器搭建不方便搭梯子)

RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& wget -q -O - https://gitlab.com/yyc5/test/-/raw/a7ed9e5920614037a6c35a1076c2197dae8f5b0f/linux_signing_key.pub?inline=false | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ADD . /code
RUN npm i
RUN npm install -g npm@9.2.0



RUN npm run build
CMD ["node", "lib/bundle.esm.js"]
#此dockerfile文件引导完,需要进一步操作,请看readme文件。引导过程有部分爆红不影响,进度一直向下等待build 好即可。
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteery
86 changes: 84 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
</a>
</p>



> 几步即可获得一个基于 ChatGPT 的微信机器人 🤖。
> [English](README.md) | 中文文档

Expand All @@ -20,6 +22,19 @@
- [ ] 捕获错误并重试。
- [ ] 其他



## 注意 ❎

chatGPT 开启了 Cloudflare 保护。现在暂时不能用了。
<https://github.com/transitive-bullshit/chatgpt-api/issues/96>

小伙伴们可尝试一下这种方法

<https://github.com/transitive-bullshit/chatgpt-api#update-december-11-2022>



## 默认配置

```
Expand All @@ -41,7 +56,53 @@
}
```

## 用 Docker 运行




## 部署好的Docker镜像

```
docker pull telepuryang/botgpt //拉取远程镜像文件
```

#### 运行镜像

```
docker run -dit telepuryang/botgpt bash //让容器不自动退出
```



#### 第一次使用前需要设置token

**进入主目录code/src/下修改config文件,填写token值**

```
docker exec -it [containersname] bash //主目录为code,[containersname]填写你的容器名称
cd src
编辑src目录下的config文件
```



### 正式运行

**设置好后回到主目录下执行:**

```
npm run dev
```



#### 至此你的终端界面中应该出现了微信登录二维码。

![img.png](https://s3.bmp.ovh/imgs/2022/12/12/572e65548d3851f9.png)



## 用主Dockerfile文件引导Docker 运行

```
// build
Expand All @@ -53,7 +114,28 @@ docker run --name wechatbot wechatbot:latest

```

## 开始设置机器人 🤖


## 用Dockerfile.2文件引导Docker 运行

```
// build
//Dockerfile文件目录下运行
docker build -t [imagename] . //自定义镜像名


// 运行镜像
docker run -dit [imagename] /bin/bash

后按之前docker部署方法运行。

```





## 非Docker的机器人本地项目设置 🤖

1. 首先,需要按照以下步骤获你的 ChatGPT 的 session token.

Expand Down
7 changes: 2 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/chatgpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function replyMessage(contact, content, contactId) {
content.trim().toLocaleLowerCase() === config.resetKey.toLocaleLowerCase()
) {
resetConversation(contactId);
await contact.say('Previous conversation has been reset.');
await contact.say('对话已重置');
return;
}
const message = await retryRequest(
Expand Down