Skip to content

Commit 37aa812

Browse files
committed
[merge] 合并 nubeslove/DicePP- 仓库改动
- 新增 LOG 日志系统、COC 角色卡、业力骰子、Mode 模式等 13 个功能模块 - 修改 19 个现有模块文件 - 更新配置和依赖 Co-authored-by: nubeslove <nubeslove@gmail.com> Co-authored-by: kagangtuya-star <kagangtuya@star-kagangtuya.cn>
1 parent 4436096 commit 37aa812

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+11481
-1029
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Created by https://www.toptal.com/developers/gitignore/api/python
32
# Edit at https://www.toptal.com/developers/gitignore?templates=python
43

@@ -148,6 +147,7 @@ dmypy.json
148147

149148
# DicePP
150149
src/plugins/DicePP/Data/
150+
src/plugins/DicePP/module/misc/log_command.py
151151

152152
# Poetry
153153
poetry.lock

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
2-
3-
RUN python3 -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
4-
5-
RUN python3 -m pip install poetry && poetry config virtualenvs.create false --local
6-
7-
COPY ./pyproject.toml ./poetry.lock* /app/
8-
9-
RUN poetry install --no-root --no-dev
1+
FROM python:3.8-slim
2+
WORKDIR /app
3+
ENV PYTHONDONTWRITEBYTECODE 1
4+
ENV PYTHONUNBUFFERED 1
5+
COPY requirements.txt .
6+
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
7+
COPY . .
8+
CMD ["python", "bot.py"]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
基于Python的DND骰娘机器人, 可作为机器人项目Nonebot的插件使用
33

44
请加入交流群861919492获取整合包和部署指南
5+
6+
V2.0.5更新内容:
7+
- 修复部分bug
8+
- 优化log代码,新增外部接口

bot.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,28 @@
33
import os
44
import sys
55
import nonebot
6+
from nonebot.log import logger, default_format
67
from nonebot.adapters.onebot.v11 import Adapter as OneBot_V11_Adapter
78

89
# Fix import path problem in server
910
dir_path = os.path.abspath(os.path.dirname(__file__))
1011
sys.path.insert(0, dir_path)
1112

12-
# Custom your logger
13-
#
14-
# from nonebot.log import logger, default_format
15-
# logger.add("error.log",
16-
# rotation="00:00",
17-
# diagnose=False,
18-
# level="ERROR",
19-
# format=default_format)
13+
# Custom your logger: reduce console noise and persist errors to file
14+
# Console shows WARNING and above, while errors are written to error.log
15+
try:
16+
# remove default sinks to customize
17+
logger.remove()
18+
except Exception:
19+
pass
20+
logger.add(sys.stderr,
21+
level="WARNING",
22+
format=default_format)
23+
logger.add("error.log",
24+
rotation="10 MB",
25+
diagnose=False,
26+
level="ERROR",
27+
format=default_format)
2028

2129
# You can pass some keyword args config to init function
2230
nonebot.init()

docker-compose.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
version: "2"
1+
version: "3"
2+
23
services:
3-
# 其他配置参考 https://hub.docker.com/r/tiangolo/uvicorn-gunicorn-fastapi/
4-
nonebot:
5-
container_name: dicepp
4+
bot:
65
build: .
7-
volumes:
8-
- "/etc/localtime:/etc/localtime:ro"
9-
- "./:/app/"
10-
# ports:
11-
# - "8080:8080" # 映射端口到宿主机 宿主机端口:容器端口
6+
container_name: dicepp_nonebot_bot
7+
restart: always
8+
ports:
9+
- "8080:8080" # 将容器的 8080 端口映射到主机的 8080 端口
1210
env_file:
11+
- .env # 加载 .env 文件中的环境变量
1312
- ".env.linux" # fastapi 使用的环境变量文件
1413
environment:
1514
- ENVIRONMENT=linux # 配置 nonebot 运行环境,此项会被 .env 文件覆盖
1615
- APP_MODULE=bot:app # 配置 asgi 入口
1716
- SECRET # 通过 SECRET=xxx nb up -d 传递密钥
1817
- ACCESS_TOKEN # 通过 ACCESS_TOKEN=xxx nb up -d 传递密钥
1918
- MAX_WORKERS=1 # 如果你有多个QQ,且存在 self_id 指定,多个 worker 会导致无法找到其他 websocket 连接
20-
logging:
21-
driver: json-file
22-
options:
23-
max-size: "200k"
24-
max-file: "10"
25-
networks:
26-
default:
27-
external:
28-
name: dice-net
19+
volumes:
20+
# 挂载整个项目目录,实现代码热更新
21+
- .:/app
22+
# 将插件的数据目录挂载到宿主机,实现数据持久化
23+
- ./src/plugins/DicePP/data:/app/src/plugins/DicePP/data # <--- 新增的挂载点

pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
[tool.poetry]
22
name = "DicePP"
3-
version = "1.0.0"
3+
version = "1.0.0 Beta2"
44
description = "DicePP"
55
authors = ["Pear"]
66
readme = "README.md"
77

8-
[tool.nonebot]
8+
[tool.poetry.dependencies]
99
python = "^3.8"
10+
aiohttp = "^4.0.2"
1011
nonebot2 = "^2.0.0b1"
1112
nb-cli = "^0.6.4"
1213
openpyxl = "^3.0.9"
1314
rsa = "^4.8"
1415
nonebot-adapter-cqhttp = "^2.0.0b1"
1516
gitpython = "3.1.26"
17+
python-docx = "^0.8.11"
18+
lxml = "^4.9.2"
1619

1720
[nonebot.plugins]
1821
plugins = []
@@ -25,4 +28,8 @@ build-backend = "poetry.masonry.api"
2528
[[tool.poetry.source]]
2629
name = "tsinghua"
2730
default = true
28-
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
31+
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
32+
33+
[tool.nonebot]
34+
plugins = []
35+
plugin_dirs = ["src/plugins"]

requirements.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
fastapi>=0.68.0
2-
pydantic>=1.8.0
3-
uvicorn>=0.15.0
1+
wheel
2+
uvicorn[standard]
43
nb-cli==0.6.4
54
nonebot-adapter-onebot==2.0.0b1
6-
nonebot2==2.0.0b1
5+
fastapi>=0.68.0
76
openpyxl==3.0.9
87
rsa==4.8
9-
gitpython==3.1.26
8+
gitpython==3.1.26
9+
python-docx==0.8.11
10+
zhconv==1.4.3
11+
psutil>=5.9.0

0 commit comments

Comments
 (0)