Files
YYeTsBot/DEVELOPMENT.md

167 lines
3.9 KiB
Markdown
Raw Normal View History

2021-04-24 20:51:03 +08:00
# 项目手册
2021-06-30 20:30:27 +08:00
# 网站部署方式
2021-07-24 13:45:57 +08:00
2021-06-30 20:30:27 +08:00
## 一键脚本
2021-07-24 13:45:57 +08:00
**支持amd64/arm64请先安装 docker、docker-compose和curl**
2022-10-06 21:10:38 +08:00
**为了安全考虑,安装完成后程序将监听在 127.0.0.1 。如有需要请自行修改 `docker-compose.yml`的127.0.0.1为0.0.0.0**
2023-03-10 23:05:49 +01:00
2021-07-24 13:45:57 +08:00
### Linux/macOS
2021-06-30 23:44:14 +08:00
```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/tgbot-collection/YYeTsBot/master/scripts/install.sh)"
````
2021-07-24 13:45:57 +08:00
2021-06-30 23:44:14 +08:00
### Windows
2021-07-24 13:45:57 +08:00
2021-06-30 23:44:14 +08:00
请再安装一个 [git for windows](https://gitforwindows.org/),然后桌面空白处右键,选择 `git bash here`
再然后
2021-07-24 13:45:57 +08:00
2021-06-30 23:44:14 +08:00
```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/tgbot-collection/YYeTsBot/master/scripts/install.sh)"
````
2021-06-30 20:30:27 +08:00
## docker-compose
2021-07-24 13:45:57 +08:00
2021-06-30 20:30:27 +08:00
参考 `yyetsweb`目录下的 `README`
2021-04-24 20:51:03 +08:00
2021-07-24 13:45:57 +08:00
# bot
2021-06-30 20:30:27 +08:00
可以选择docker也可以直接运行在机器上。
2021-07-24 13:45:57 +08:00
2021-04-24 20:51:03 +08:00
## docker-compose
* 参见 [这里](https://github.com/tgbot-collection/BotsRunner)
* 本目录下的 `docker-compose.yml` 也可以作为参考
* nginx reverse proxy可以[参考这里](https://github.com/BennyThink/WebsiteRunner)
* [参考这里获取数据库](yyetsweb/README.md)
2021-04-24 20:51:03 +08:00
```shell
# 启动数据库
docker-compose up -d mongo
# 导入数据库
2021-06-08 22:13:19 +08:00
docker yyets_mongo.gz 1234da:/tmp
2021-04-24 20:51:03 +08:00
# 进入容器
docker-compose exec mongo bash
2022-02-22 18:54:02 +08:00
mongorestore --gzip --archive=yyets_mongo.gz --nsFrom "share.*" --nsTo "zimuzu.*"
2021-04-24 20:51:03 +08:00
exit
# 开启服务
docker-compose up -d
```
2023-03-10 23:05:49 +01:00
## replica set 配置方式
```shell
ln -s docker-compose-replica.yml docker-compose.override.yml
docker-compose up -d mongo
# 进入shell
rs.initiate({
_id: "rs0",
members: [{
_id: 0,
host: "localhost:27017"
},
{
_id: 1,
host: "mongo2:27017"
}]
})
# 调整优先级
cfg = rs.conf()
cfg.members[0].priority = 0.5
cfg.members[1].priority = 0.5
cfg.members[2].priority = 1 # 最高
rs.reconfig(cfg)
```
2021-04-24 20:51:03 +08:00
## 常规方式
### 1. 环境
推荐使用Python 3.6+,环境要求
* redis
* 可选MongoDB
```bash
pip install -r requirements.txt
```
### 2. 配置TOKEN
修改`config.py`,根据需求修改如下配置项
* TOKENbot token
* USERNAME人人影视的有效的用户名
* PASSWORD :人人影视的有效的密码
* MAINTAINER维护者的Telegram UserID
* REDISredis的地址一般为localhost
* MONGODB: mongodb的地址
### 3. 导入数据(可选)
如果使用yyets那么需要导入数据到MongoDB。可以在将数据导入到MySQL之后使用如下脚本导入数据到MongoDB
```shell
python3 web/prepare/convert_db.py
```
### 4. 运行
```bash
python /path/to/YYeTsBot/yyetsbot/bot.py
```
### 5. systemd 单元文件
参考 `yyets.service`
2021-05-30 10:34:48 +08:00
# 添加新的资源网站
2021-02-10 15:15:38 +08:00
欢迎各位开发提交新的资源网站!方法非常简单,重写 `BaseFansub`,实现`search_preview``search_result`,按照约定的格式返回数据。
然后把类名字添加到 `FANSUB_ORDER` 就可以了!是不是很简单!
# 防爬
2021-02-10 15:15:38 +08:00
## 1. referer
2021-02-10 15:15:38 +08:00
网站使用referer验证请求
## 2. rate limit
2021-02-10 15:15:38 +08:00
2021-04-24 20:51:03 +08:00
404的访问会被计数超过10次会被拉入黑名单持续3600秒再次访问会持续叠加。
# 持续部署
使用[Docker Hub Webhook](https://docs.docker.com/docker-hub/webhooks/)
(顺便吐槽一句这是个什么垃圾文档……自己实现validation吧)
参考listener [Webhook listener](https://github.com/tgbot-collection/Webhook)
# 归档资源下载
2021-07-24 13:45:57 +08:00
2021-04-24 20:51:03 +08:00
## Telegram 频道分享
2021-07-24 13:45:57 +08:00
2023-03-10 23:05:49 +01:00
*
包含了2021年1月11日为止的人人影视最新资源MySQL为主。有兴趣的盆友可以用这个数据进行二次开发[戳我查看详情](https://t.me/mikuri520/668)
2021-04-24 20:51:03 +08:00
* 字幕侠离线数据库 [从这里下载](https://t.me/mikuri520/715),这个数据比较粗糙,并且字幕侠网站还在,因此不建议使用这个
## 本地下载
2021-07-24 13:45:57 +08:00
2021-04-24 20:51:03 +08:00
如果无法访问Telegram可以使用如下网址下载数据
2021-07-24 13:45:57 +08:00
2023-12-29 17:38:21 +01:00
* [MongoDB](https://yyets.click/data/yyets_mongo.gz)
2023-07-28 19:21:28 +02:00
* [MySQL](https://yyets.click/data/yyets_mysql.zip)
* [SQLite](https://yyets.click/data/yyets_sqlite.zip)
2021-05-30 10:34:48 +08:00
# API 文档
2021-07-24 13:45:57 +08:00
2022-10-06 21:10:38 +08:00
参考 [API.md](API.md)