Metadata-Version: 2.4
Name: nonebot-plugin-yrr-fortune
Version: 1.0.0
Summary: NoneBot 每日运势卡片：七档运势、六维雷达、幸运信息、宜忌与六套模板
Author: YRR
License: MIT
Project-URL: Homepage, https://github.com/YRRLYB/nonebot-plugin-yrr-fortune
Project-URL: Repository, https://github.com/YRRLYB/nonebot-plugin-yrr-fortune
Project-URL: Issues, https://github.com/YRRLYB/nonebot-plugin-yrr-fortune/issues
Keywords: nonebot,nonebot2,plugin,fortune,运势,onebot
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Games/Entertainment
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: nonebot2>=2.2.0
Requires-Dist: nonebot-adapter-onebot>=2.4.0
Requires-Dist: nonebot-plugin-apscheduler>=0.4.0
Requires-Dist: nonebot-plugin-htmlrender>=0.6.0
Requires-Dist: nonebot-plugin-localstore>=0.7.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: pillow>=9.0.0
Dynamic: license-file

# YRR 运势

> 每日一张运势卡：七档运势、六维雷达、幸运色 / 数字 / 方位、宜忌活动，六套模板随意切换。

![模板总览](https://raw.githubusercontent.com/YRRLYB/nonebot-plugin-yrr-fortune/main/nonebot_plugin_yrr_fortune/help.jpg)

## 功能

- **今日运势**：每天 0 点后自动刷新，同一天重复发送结果稳定不变。
- **七档运势**：大凶 / 小凶 / 末吉 / 小吉 / 中吉 / 大吉 / 天命。
- **六维雷达**：财运、事业、健康、人缘、爱情、智慧。
- **幸运信息**：幸运色、幸运数字、幸运方位、宜做与忌做。
- **互斥宜忌**：同一维度不会同时出现在「宜」和「忌」，避免「宜早睡、忌熬夜」式矛盾。
- **六套模板**：鎏金流年、霓虹潮流、光影定格、水墨山河、星舰指挥、分镜奇谭。
- **背景图**：回复运势图发送 `/背景图` 可获取本次使用的原图。
- **无网络也能出图**：背景接口或头像失败时自动使用内置渐变与占位头像。

## 安装

```bash
nb plugin install nonebot-plugin-yrr-fortune
```

或者：

```bash
pip install nonebot-plugin-yrr-fortune
```

依赖 `nonebot-plugin-htmlrender`，首次使用前请确保 Playwright 的 Chromium 已安装：

```bash
playwright install chromium
```

## 指令

| 指令 | 说明 | 权限 |
| --- | --- | --- |
| `运势` / `今日运势` | 查看今日运势卡片 | 所有人 |
| `运势模板` | 查看六套模板总览 | 所有人 |
| `运势模板 1-6` | 切换自己的模板 | 所有人 |
| `/背景图` / `/运势背景图` | 回复运势图获取原图；不回复则随机取一张 | 所有人 |
| `/重置运势` | 清空所有人的今日运势（回复 `y` 确认） | 群管 / 群主 |

## 模板

| 编号 | 名称 |
| --- | --- |
| 1 | 鎏金流年 |
| 2 | 霓虹潮流 |
| 3 | 光影定格 |
| 4 | 水墨山河 |
| 5 | 星舰指挥 |
| 6 | 分镜奇谭 |

## 配置

所有配置都有默认值，插件可以零配置加载。需要修改时在 `.env` 中写：

```dotenv
# 背景图接口，返回图片字节即可
FORTUNE_BACKGROUND_URL=https://photo.yrrlyb.top/api.php?sort=mplyb

# 预加载背景图数量，0 表示关闭预加载
FORTUNE_PRELOAD_COUNT=4

# 背景图下载超时（秒）
FORTUNE_HTTP_TIMEOUT=30

# 记住多少条运势消息用于 /背景图 回复，默认 500
FORTUNE_MAX_MESSAGE_MAP=500

# 背景接口证书异常时才打开；默认校验 TLS
FORTUNE_INSECURE_SSL=false
```

数据与缓存由 `nonebot-plugin-localstore` 管理：

- 数据：`get_plugin_data_dir()/user_data.json`
- 缓存：`get_plugin_cache_dir()/backgrounds`、`/avatars`
- 字体：`数据目录/fonts/msyh.ttc`，找不到时使用系统字体

从旧版 `data/YRR_database/user_data.json` 升级时，首次启动会自动迁移用户数据。

## 兼容性

- NoneBot 2.2+
- OneBot V11 适配器
- Python 3.9+

## 开发

```bash
pip install -e .
python -m unittest discover -s tests -v
```

模板是 `nonebot_plugin_yrr_fortune/templates/*.html`，使用 Python `str.format` 占位符；修改模板时 CSS 花括号需要写成 `{{` 和 `}}`。

## 许可

MIT
