2021-05-05 11:16:16 +00:00
|
|
|
|
## 有问题请加群组反馈
|
|
|
|
|
|
|
|
|
|
Telegram 交流反馈群组 [点击加入](https://t.me/joinchat/HO9r-CLAudrxugPY)
|
|
|
|
|
|
2021-05-05 11:13:49 +00:00
|
|
|
|
## 演示
|
|
|
|
|
|
|
|
|
|
![xq9iR.png](https://s3.jpg.cm/2021/05/05/xq9iR.png)
|
|
|
|
|
|
2021-05-05 10:28:26 +00:00
|
|
|
|
## 配置要求
|
|
|
|
|
|
|
|
|
|
内存:1G以上
|
|
|
|
|
|
|
|
|
|
## 安装方法
|
2021-05-05 09:29:49 +00:00
|
|
|
|
|
|
|
|
|
### 使用 Docker 安装
|
2021-05-05 10:28:26 +00:00
|
|
|
|
Docker官方安装地址:[点击访问](https://docs.docker.com/engine/install/)
|
2021-05-05 09:25:02 +00:00
|
|
|
|
|
|
|
|
|
```angular2html
|
|
|
|
|
cd /root
|
|
|
|
|
|
2021-05-05 09:29:49 +00:00
|
|
|
|
# 拉取Redis镜像
|
2021-05-05 09:25:02 +00:00
|
|
|
|
docker pull redis
|
|
|
|
|
|
2021-05-05 09:29:49 +00:00
|
|
|
|
# 创建 entrypoint.sh 入口文件
|
2021-05-05 09:25:02 +00:00
|
|
|
|
echo '#! /bin/sh \
|
|
|
|
|
cd /root/word_cloud_bot && python3 main.py >> output 2>&1 &
|
|
|
|
|
tail -f /dev/null' > /root/entrypoint.sh
|
|
|
|
|
|
2021-05-05 09:29:49 +00:00
|
|
|
|
# 创建 Dockerfile
|
2021-05-05 09:25:02 +00:00
|
|
|
|
wget -O /root/Dockerfile https://github.com/devourbots/word_cloud_bot/raw/master/Dockerfile
|
|
|
|
|
|
2021-05-05 09:29:49 +00:00
|
|
|
|
# 修改机器人TOKEN
|
2021-05-05 09:25:02 +00:00
|
|
|
|
vi /root/Dockerfile
|
|
|
|
|
|
2021-05-05 11:09:41 +00:00
|
|
|
|
在第8行修改你的机器人TOKEN
|
|
|
|
|
|
|
|
|
|
修改后:
|
|
|
|
|
RUN echo 'TOKEN = "1749418611:AAGcpouQ4EWSDITLQXFozHjMgT_-MsVSmDM"' > /root/word_cloud_bot/config.py
|
|
|
|
|
|
2021-05-05 09:25:02 +00:00
|
|
|
|
|
2021-05-05 09:29:49 +00:00
|
|
|
|
# 根据 Dockerfile 创建镜像
|
2021-05-05 09:25:02 +00:00
|
|
|
|
docker build . -t world_cloud_bot:latest
|
|
|
|
|
|
2021-05-05 09:29:49 +00:00
|
|
|
|
# 运行 Redis 镜像,此步在前
|
2021-05-05 09:25:02 +00:00
|
|
|
|
docker run -d -p 6379:6379 redis:latest
|
|
|
|
|
|
2021-05-05 09:29:49 +00:00
|
|
|
|
# 运行 机器人,此步在后
|
2021-05-05 09:25:02 +00:00
|
|
|
|
docker run -d --net=host world_cloud_bot:latest
|
2021-05-05 10:28:26 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 使用方法
|
|
|
|
|
|
|
|
|
|
使用 `/start` 指令测试机器人与 Redis 数据库的连通情况
|
|
|
|
|
|
|
|
|
|
将机器人拉入群组,设置为管理员(不需要其他权限),设置完毕
|
|
|
|
|
|
2021-05-05 11:13:49 +00:00
|
|
|
|
![xqyvt.png](https://s3.jpg.cm/2021/05/05/xqyvt.png)
|
|
|
|
|
|
2021-05-05 10:28:26 +00:00
|
|
|
|
### 将机器人设置为仅自己群组可用
|
|
|
|
|
|
|
|
|
|
如果您不想让别人使用你的机器人,那么可以将 func.py 文件中的
|
|
|
|
|
```angular2html
|
|
|
|
|
# if chat_id not in ["1231242141"]:
|
|
|
|
|
# return
|
|
|
|
|
```
|
|
|
|
|
该段注释取消,并将自己的群组ID加入到列表中。
|
|
|
|
|
|
|
|
|
|
例如我两个的群组ID分别为:-127892174935、-471892571924
|
|
|
|
|
|
|
|
|
|
那么修改后为:
|
|
|
|
|
```angular2html
|
|
|
|
|
if chat_id not in ["-127892174935", "-471892571924"]:
|
|
|
|
|
return
|
|
|
|
|
```
|
|
|
|
|
|