Skip to content

Commit

Permalink
Merge pull request #89 from MinatoAquaCrews/dev-v0.4.x
Browse files Browse the repository at this point in the history
🔖 v0.4.12
  • Loading branch information
KafCoppelia authored Jul 15, 2023
2 parents a65e122 + 855cd5f commit 136a6db
Show file tree
Hide file tree
Showing 144 changed files with 124 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/poetry-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
ref: ${{ env.TAG_NAME }}

- name: Publish python poetry package
uses: JRubics/poetry-publish@v1.16
uses: JRubics/poetry-publish@v1.17
with:
python_version: "3.10"
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ repos:
stages: [commit]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
rev: v3.0.0
hooks:
- id: prettier
types_or: [markdown, yaml, json]
Expand Down
34 changes: 8 additions & 26 deletions How-to-add-new-theme.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
## 如何在`v0.4.2` 或更早版本上更新抽签主题资源
## 如何添加更多的抽签主题资源

`v0.4.3` 新增东方归言录(touhou_lostword)全新抽签主题资源!
1. 将新的主题目录放置在 `./img` 下;

1. 将新资源文件夹放置在`./img`下;

2. 修改`config.py``ThemesFlagConfig`,添加`touhou_lostword_flag` 标志,例如:
2. 修改 `config.py` 中的 `ThemesFlagConfig`,添加 `new_theme_flag` 标志,例如:

```python
...
touhou_flag: bool = True
touhou_lostword_flag: bool = True
touhou_olg_flag: bool = True
new_theme_flag: bool = True
...
```

之后可在`.env`下设置以启用或关闭该主题:
之后可在 `.env` 下设置以启用或关闭该主题:

```python
TOUHOU_LOSTWORD_FLAG=true
```

3. 修改`utils.py``FortuneThemesDict`,添加键值对:


```python
...
"touhou": ["东方", "touhou", "Touhou", "车万"],
"touhou_old":
["旧东方", "旧版东方", "老东方", "老版东方", "经典东方"],
...
NEW_THEME_FLAG=true
```

3. 修改 `utils.py` 中的 `FortuneThemesDict`,添加键值对:

```python
...
"touhou": ["东方", "touhou", "Touhou", "车万"],
"touhou_lostword":
["东方归言录", "东方lostword", "touhou lostword", "Touhou dlc"],
"touhou_old":
["旧东方", "旧版东方", "老东方", "老版东方", "经典东方"],
"new_theme":["新主题", "新的主题"],
...
```

Expand Down
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ _🙏 今日运势 🙏_
</a>

<a href="https://github.com/nonebot/nonebot2">
<img src="https://img.shields.io/badge/nonebot2-2.0.0rc4+-green">
<img src="https://img.shields.io/badge/nonebot2-^2.0.0rc4-green">
</a>

<a href="https://github.com/MinatoAquaCrews/nonebot_plugin_fortune/releases/tag/v0.4.11.post1">
<a href="https://github.com/MinatoAquaCrews/nonebot_plugin_fortune/releases/tag/v0.4.12">
<img src="https://img.shields.io/github/v/release/MinatoAquaCrews/nonebot_plugin_fortune?color=orange">
</a>

Expand All @@ -35,52 +35,53 @@ _🙏 今日运势 🙏_

## 版本

[v0.4.11.post1](https://github.com/MinatoAquaCrews/nonebot_plugin_fortune/releases/tag/v0.4.11.post1)
[v0.4.12](https://github.com/MinatoAquaCrews/nonebot_plugin_fortune/releases/tag/v0.4.12)

⚠️ 适配nonebot2-2.0.0rc4+
⚠️ 适配nonebot2 `^2.0.0rc4`

👉 [如何添加自己的抽签主题资源?欢迎贡献!🙏](https://github.com/MinatoAquaCrews/nonebot_plugin_fortune/blob/master/How-to-add-new-theme.md)
👉 [如何添加更多的抽签主题资源?欢迎贡献!🙏](https://github.com/MinatoAquaCrews/nonebot_plugin_fortune/blob/master/How-to-add-new-theme.md)

## 安装

1. 安装方式:

- 通过 `pip``nb`;pypi无法发行过大安装包,由此安装的插件不包含 `resource/img`**所有抽签主题图片**,需单独下载。建议 `zip` 包下载后提取 `resource` 下所有资源至本地,后更改 `FORTUNE_PATH` 配置即可;
- 通过 `pip``nb` 安装:由于pypi无法发行过大安装包,由此安装的插件不包含 `resource/img`**所有抽签主题图片**。所有抽签主题图片资源在 [`v0.4.10 release`](https://github.com/MinatoAquaCrews/nonebot_plugin_fortune/releases/tag/v0.4.10) Assets提供,下载至本地后,更改 `FORTUNE_PATH` 配置即可;

- 通过 `zip``git clone` 安装:包含 `resource` 下所有插件资源;

2. 抽签主题图片 `img` 、字体 `font` 、文案 `fortune` 等资源均位于 `./resource` 下,可在 `env` 中设置 `FORTUNE_PATH`

```python
```shell
FORTUNE_PATH="your-path-to-resource" # For example, "./my-data/fortune",其下有img、font、fortune文件夹等资源
```

⚠️️ 插件启动时,将自动检查资源是否缺失(**除字体与图片**资源)

3.`env` 下设置 `xxx_FLAG` 以启用或关闭抽签随机主题(默认全部开启),例如:

```python
```shell
AMAZING_GRACE_FLAG=false # 奇异恩典·圣夜的小镇
ARKNIGHTS_FLAG=true # 明日方舟
ASOUL_FLAG=true # A-SOUL
AZURE_FLAG=true # 碧蓝航线
DC4_FLAG=false # dc4
EINSTEIN_FLAG=true # 爱因斯坦携爱敬上
GENSHIN_FLAG=true # 原神
GRANBLUE_FANTASY_FLAG=true # 碧蓝幻想
HOLOLIVE_FLAG=true # Hololive
HOSHIZORA_FLAG=true # 星空列车与白的旅行
LIQINGGE_FLAG=true # 李清歌
ONMYOJI_FLAG=false # 阴阳师
PCR_FLAG=true # 公主连结
TOUHOU_FLAG=true # 东方
TOUHOU_LOSTWORD_FLAG=true # 东方归言录
TOUHOU_OLD_FLAG=false # 东方旧版
HOLOLIVE_FLAG=true # Hololive
PUNISHING_FLAG=true # 战双帕弥什
GRANBLUE_FANTASY_FLAG=true # 碧蓝幻想
PRETTY_DERBY_FLAG=true # 赛马娘
DC4_FLAG=false # dc4
EINSTEIN_FLAG=true # 爱因斯坦携爱敬上
SWEET_ILLUSION_FLAG=true # 灵感满溢的甜蜜创想
LIQINGGE_FLAG=true # 李清歌
HOSHIZORA_FLAG=true # 星空列车与白的旅行
PUNISHING_FLAG=true # 战双帕弥什
SAKURA_FLAG=true # 樱色之云绯色之恋
SUMMER_POCKETS_FLAG=false # 夏日口袋
AMAZING_GRACE_FLAG=false # 奇异恩典·圣夜的小镇
SWEET_ILLUSION_FLAG=true # 灵感满溢的甜蜜创想
TOUHOU_FLAG=true # 东方
TOUHOU_LOSTWORD_FLAG=true # 东方归言录
TOUHOU_OLD_FLAG=false # 东方旧版
WARSHIP_GIRLS_R_FLAG=true # 战舰少女R
```

**请确保不全为 `false`,否则会抛出错误**
Expand Down Expand Up @@ -131,7 +132,7 @@ _🙏 今日运势 🙏_
- [ ] 文案排版算法;
- [ ] 新增功能:每日星座运势;
- [x] 新增功能:资源缺失检查、自动下载;
- [ ] 新增资源:新的抽签主题资源!
- [x] 新增资源:新的抽签主题资源!

## 命令

Expand Down Expand Up @@ -175,4 +176,6 @@ _🙏 今日运势 🙏_

4. [FloatTech-zbpdata/Fortune](https://github.com/FloatTech/zbpdata):其余主题签;

5. 运势文案:[KafCoppelia](https://github.com/KafCoppelia)`copywriting.json` 整合了関係運、全体運、勉強運、金運、仕事運、恋愛運、総合運、大吉、中吉、小吉、吉、半吉、末吉、末小吉、凶、小凶、半凶、末凶、大凶及700+条运势文案!来源于Hololive早安系列2019年第6.10~9.22期,有修改。
5. 战舰少女R(Warship Girls R):[veadex](https://github.com/veadex)[EsfahanMakarov](https://github.com/EsfahanMakarov)

6. 运势文案:[KafCoppelia](https://github.com/KafCoppelia)`copywriting.json` 整合了関係運、全体運、勉強運、金運、仕事運、恋愛運、総合運、大吉、中吉、小吉、吉、半吉、末吉、末小吉、凶、小凶、半凶、末凶、大凶及700+条运势文案!来源于Hololive早安系列2019年第6.10~9.22期,有修改。
7 changes: 5 additions & 2 deletions nonebot_plugin_fortune/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
from nonebot.permission import SUPERUSER
from nonebot.plugin import PluginMetadata

from .config import FortuneThemesDict
from .config import FortuneConfig, FortuneThemesDict
from .data_source import FortuneManager, fortune_manager

require("nonebot_plugin_apscheduler")
from nonebot_plugin_apscheduler import scheduler # isort:skip

__fortune_version__ = "v0.4.11.post1"
__fortune_version__ = "v0.4.12"
__fortune_usages__ = f"""
[今日运势/抽签/运势] 一般抽签
[xx抽签] 指定主题抽签
Expand All @@ -35,6 +35,9 @@
name="今日运势",
description="抽签!占卜你的今日运势🙏",
usage=__fortune_usages__,
type="application",
homepage="https://github.com/MinatoAquaCrews/nonebot_plugin_fortune",
config=FortuneConfig,
extra={
"author": "KafCoppelia <[email protected]>",
"version": __fortune_version__,
Expand Down
58 changes: 32 additions & 26 deletions nonebot_plugin_fortune/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,28 @@
"""
FortuneThemesDict: Dict[str, List[str]] = {
"random": ["随机"],
"pcr": ["PCR", "公主链接", "公主连结", "Pcr", "pcr"],
"genshin": ["原神", "Genshin Impact", "genshin", "Genshin", "op", "原批"],
"hololive": ["Hololive", "hololive", "Vtb", "vtb", "管人", "Holo", "holo", "猴楼"],
"touhou": ["东方", "touhou", "Touhou", "车万"],
"touhou_lostword": ["东方归言录", "东方lostword", "touhou lostword"],
"touhou_old": ["旧东方", "旧版东方", "老东方", "老版东方", "经典东方"],
"onmyoji": ["阴阳师", "yys", "Yys", "痒痒鼠"],
"azure": ["碧蓝航线", "碧蓝", "azure", "Azure"],
"asoul": ["Asoul", "asoul", "a手", "A手", "as", "As"],
"amazing_grace": ["奇异恩典"],
"arknights": ["明日方舟", "方舟", "arknights", "鹰角", "Arknights", "舟游"],
"granblue_fantasy": ["碧蓝幻想", "Granblue Fantasy", "granblue fantasy", "幻想"],
"punishing": ["战双", "战双帕弥什"],
"pretty_derby": ["赛马娘", "马", "马娘", "赛马"],
"asoul": ["Asoul", "asoul", "a手", "A手", "as", "As"],
"azure": ["碧蓝航线", "碧蓝", "azure", "Azure"],
"dc4": ["dc4", "DC4", "Dc4"],
"einstein": ["爱因斯坦携爱敬上", "爱因斯坦", "einstein", "Einstein"],
"sweet_illusion": ["灵感满溢的甜蜜创想", "甜蜜一家人", "富婆妹"],
"liqingge": ["李清歌", "清歌"],
"genshin": ["原神", "Genshin Impact", "genshin", "Genshin", "op", "原批"],
"granblue_fantasy": ["碧蓝幻想", "Granblue Fantasy", "granblue fantasy", "幻想"],
"hololive": ["Hololive", "hololive", "Vtb", "vtb", "管人", "Holo", "holo", "管人痴"],
"hoshizora": ["星空列车与白的旅行", "星空列车"],
"liqingge": ["李清歌", "清歌"],
"onmyoji": ["阴阳师", "yys", "Yys", "痒痒鼠"],
"pcr": ["PCR", "公主链接", "公主连结", "Pcr", "pcr"],
"pretty_derby": ["赛马娘", "马", "马娘", "赛马"],
"punishing": ["战双", "战双帕弥什"],
"sakura": ["樱色之云绯色之恋", "樱云之恋", "樱云绯恋", "樱云"],
"summer_pockets": ["夏日口袋", "夏兜", "sp", "SP"],
"amazing_grace": ["奇异恩典"],
"sweet_illusion": ["灵感满溢的甜蜜创想", "甜蜜一家人", "富婆妹"],
"touhou": ["东方", "touhou", "Touhou", "车万"],
"touhou_lostword": ["东方归言录", "东方lostword", "touhou lostword"],
"touhou_old": ["旧东方", "旧版东方", "老东方", "老版东方", "经典东方"],
"warship_girls_r": ["战舰少女R", "舰r", "舰R", "wsgr", "WSGR", "战舰少女r"],
}


Expand All @@ -53,23 +54,24 @@ class ThemesFlagConfig(BaseModel, extra=Extra.ignore):
arknights_flag: bool = True
asoul_flag: bool = True
azure_flag: bool = True
dc4_flag: bool = True
einstein_flag: bool = True
genshin_flag: bool = True
granblue_fantasy_flag: bool = True
hololive_flag: bool = True
hoshizora_flag: bool = True
liqingge_flag: bool = True
onmyoji_flag: bool = True
pcr_flag: bool = True
touhou_flag: bool = True
touhou_lostword_flag: bool = True
touhou_old_flag: bool = True
hololive_flag: bool = True
granblue_fantasy_flag: bool = True
punishing_flag: bool = True
pretty_derby_flag: bool = True
dc4_flag: bool = True
einstein_flag: bool = True
sweet_illusion_flag: bool = True
liqingge_flag: bool = True
hoshizora_flag: bool = True
punishing_flag: bool = True
sakura_flag: bool = True
summer_pockets_flag: bool = True
sweet_illusion_flag: bool = True
touhou_flag: bool = True
touhou_lostword_flag: bool = True
touhou_old_flag: bool = True
warship_girls_r_flag: bool = True

@root_validator
def check_all_disabled(cls, values) -> None:
Expand All @@ -86,6 +88,10 @@ def check_all_disabled(cls, values) -> None:
return values


class FortuneConfig(PluginConfig, ThemesFlagConfig):
pass


class DateTimeEncoder(json.JSONEncoder):
def default(self, obj) -> Union[str, Any]:
if isinstance(obj, datetime):
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 136a6db

Please sign in to comment.