更加现代化的 NoneBot2 每日人品插件,支持查询今日、本周、本月和历史平均人品,自定义运势,以及数据持久化存储。
Project description
📖 介绍
nonebot_plugin_jrrp2 的现代化 Fork。
一个功能完善的每日人品查询插件,支持查询今日、本周、本月和历史平均人品,自定义运势,以及数据持久化存储。
主要功能和特点
- 完全使用 Alconna 指令解析器重写逻辑,减少误触,增加反应速度
- 使用 Localstore 插件管理数据存储路径
- 完善的安全控制和异常处理
- 支持原 jrrp2 插件数据库无缝迁移
- 支持通过配置文件自定义运势范围和描述
💿 安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装nb plugin install nonebot-plugin-jrrp3
使用包管理器安装
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令pip
pip install nonebot-plugin-jrrp3
pdm
pdm add nonebot-plugin-jrrp3
poetry
poetry add nonebot-plugin-jrrp3
conda
conda install nonebot-plugin-jrrp3
打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入
plugins = ["nonebot-plugin-jrrp3"]
⚙️ 配置
数据存储配置
本插件使用 nonebot_plugin_localstore 自动管理数据存储路径,无需手动配置数据库路径。数据默认存储在 NoneBot 的标准插件数据目录。
[!NOTE] 插件设计上兼容 nonebot_plugin_jrrp2 的数据库格式,您可以将原数据库文件直接复制到插件的数据目录中,实现数据迁移。
自定义运势配置
插件支持通过 YAML 配置文件自定义运势范围和描述。
配置文件路径如下:
$LOCALSTORE_CONFIG_DIR/nonebot_plugin_jrrp3/jrrp_config.yaml
首次运行插件的时候会自动生成配置文件。
配置文件示例
完整的默认配置文件 config/nonebot_plugin_jrrp3/jrrp_config.yaml 如下:
ranges:
- description: 100!100诶!!你就是欧皇?
level: 超吉
max: 100
min: 100
- description: 好耶!今天运气真不错呢
level: 大吉
max: 99
min: 76
- description: 哦豁,今天运气还顺利哦
level: 吉
max: 75
min: 66
- description: emm,今天运气一般般呢
level: 半吉
max: 65
min: 63
- description: 还……还行吧,今天运气稍差一点点呢
level: 小吉
max: 62
min: 59
- description: 唔……今天运气有点差哦
level: 末小吉
max: 58
min: 54
- description: 呜哇,今天运气应该不太好
level: 末吉
max: 53
min: 19
- description: 啊这……(没错……是百分制),今天还是吃点好的吧
level: 凶
max: 18
min: 10
- description: 啊这……(个位数可还行),今天还是吃点好的吧
level: 大凶
max: 9
min: 1
- description: ???反向欧皇?
level: 超凶(大寄)
max: 0
min: 0
自定义配置示例
如果你想自定义运势范围,可以直接修改 jrrp_config.yaml 。例如:
ranges:
- min: 90
max: 100
level: "极佳"
description: "今天你是天选之子!"
- min: 70
max: 89
level: "很好"
description: "今天运势不错哦~"
- min: 50
max: 69
level: "一般"
description: "平平无奇的一天"
- min: 30
max: 49
level: "较差"
description: "今天可能需要小心点"
- min: 0
max: 29
level: "极差"
description: "建议今天躺平休息"
配置参数说明
ranges:运势范围配置数组,每个元素定义一个运势等级的数值范围和描述min:该范围的最小值(包含)max:该范围的最大值(包含)level:运势等级名称description:运势描述文本
min max 范围严格遵循 Python random.randint() 的左闭右闭原则,即 [min, max] 包含两端边界值。
注意事项:
- 范围配置中的数值应该连续且不重叠,确保每个可能的随机数都能匹配到唯一的运势等级
- 配置文件会在插件加载时自动读取,如果配置文件不存在,将使用默认配置
- 修改配置后,需要重启 Bot 才能生效(后期将增加热重载机制)
🎉 使用
指令表
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|---|---|---|---|---|
| jrrp/今日人品/今日运势 | 群员 | 否 | 群聊/私聊 | 查询今日人品指数 |
| weekjrrp/本周人品/本周运势/周运势 | 群员 | 否 | 群聊/私聊 | 查询本周平均人品 |
| monthjrrp/本月人品/本月运势/月运势 | 群员 | 否 | 群聊/私聊 | 查询本月平均人品 |
| alljrrp/总人品/平均人品/平均运势 | 群员 | 否 | 群聊/私聊 | 查询历史平均人品 |
🧐 底层原理
- 随机数种子基于用户 ID 和当前日期,确保同一用户在同一天获得的幸运指数固定
- 随机数生成后会进行安全检查,防止生成超出合理范围的值
📦 依赖
- nonebot2 >= 2.3.0
- nonebot-plugin-alconna >= 0.50.0
- nonebot-plugin-localstore >= 0.6.0
- PyYAML >= 6.0
- Python >= 3.9, < 4.0
📝 许可证
本项目使用 MIT 许可证,详见 LICENSE 文件。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_jrrp3-3.4.0.tar.gz.
File metadata
- Download URL: nonebot_plugin_jrrp3-3.4.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbee3850331342523400a62d522b8c5e8a1642478fca9a1401532f8783483053
|
|
| MD5 |
2a8aa03b80dbf94985a6ec4ff1862eb3
|
|
| BLAKE2b-256 |
8cf670ccf1e03134ef5c311fab9a0b00e56884e3a61e073396e88fda89319b2f
|
Provenance
The following attestation bundles were made for nonebot_plugin_jrrp3-3.4.0.tar.gz:
Publisher:
publish.yml on GT-610/nonebot-plugin-jrrp3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_jrrp3-3.4.0.tar.gz -
Subject digest:
dbee3850331342523400a62d522b8c5e8a1642478fca9a1401532f8783483053 - Sigstore transparency entry: 791088623
- Sigstore integration time:
-
Permalink:
GT-610/nonebot-plugin-jrrp3@d85c091786543aabde00f7b3a9327d9992e15573 -
Branch / Tag:
refs/tags/v3.4.0 - Owner: https://github.com/GT-610
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d85c091786543aabde00f7b3a9327d9992e15573 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_jrrp3-3.4.0-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_jrrp3-3.4.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
101f8d97e4365b177e359c22a682e228fee01b1ab66ace990cc9636a3ffcf4e4
|
|
| MD5 |
8ad18b25b8e1e007c5ff366f4c22bb76
|
|
| BLAKE2b-256 |
bec34be9eb85aa99bf479456b2407dff2266848a97b93c452796e95b192d6950
|
Provenance
The following attestation bundles were made for nonebot_plugin_jrrp3-3.4.0-py3-none-any.whl:
Publisher:
publish.yml on GT-610/nonebot-plugin-jrrp3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_jrrp3-3.4.0-py3-none-any.whl -
Subject digest:
101f8d97e4365b177e359c22a682e228fee01b1ab66ace990cc9636a3ffcf4e4 - Sigstore transparency entry: 791088631
- Sigstore integration time:
-
Permalink:
GT-610/nonebot-plugin-jrrp3@d85c091786543aabde00f7b3a9327d9992e15573 -
Branch / Tag:
refs/tags/v3.4.0 - Owner: https://github.com/GT-610
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d85c091786543aabde00f7b3a9327d9992e15573 -
Trigger Event:
push
-
Statement type: