Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
v1.0.15
Browse files Browse the repository at this point in the history
猜干员与干员信息功能可以使用干员昵称(可自行增删改查)
  • Loading branch information
NumberSir committed Mar 28, 2023
1 parent c6ef2aa commit 6ba810b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
Empty file added .idea/.gitignore
Empty file.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ draw_rate_3 = 0.42 # 三
<img src="https://user-images.githubusercontent.com/52584526/219335891-37933d79-1b52-4452-8959-04861087f4e8.png" width="700" />
</div>


## 干员昵称
位置默认在 `data/arknights/processed_data/nicknames.json` 键为干员中文名称,值为昵称,可自行修改。

## 指令
<details>
<summary>点击展开</summary>
Expand Down Expand Up @@ -238,6 +242,9 @@ xxx/yyy 代表 xxx 或 yyy
<details>
<summary>点击展开</summary>

> 2023-03-28 v1.0.15
> - 猜干员与干员信息功能可以使用干员昵称(可自行增删改查)
>
> 2023-03-24 v1.0.14
> - 修复阿米娅与近卫阿米娅冲突的问题 [@zx-issue/13](https://github.com/NumberSir/zhenxun_arktools/issues/13)
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
"自爆小车",
"自爆车"
],
"正义骑士号": [],
"泰拉大陆调查团": [],
"正义骑士号": [
"狙击小车",
"狙击车"
],
"泰拉大陆调查团": [
"艾露猫"
],
"夜刀": [],
"黑角": [],
"巡林者": [],
Expand Down Expand Up @@ -67,7 +72,8 @@
"松果": [],
"安比尔": [
"挂B",
"瓜天使"
"瓜天使",
"茄子"
],
"酸糖": [],
"铅踝": [],
Expand Down Expand Up @@ -170,7 +176,9 @@
"D32"
],
"铸铁": [],
"赤冬": [],
"赤冬": [
"螃蟹"
],
"火龙S黑角": [],
"羽毛笔": [],
"海沫": [],
Expand All @@ -179,7 +187,9 @@
"蓝呱呱",
"脆脆蛙"
],
"白金": [],
"白金": [
"大位"
],
"灰喉": [],
"四月": [],
"寒芒克洛丝": [
Expand Down Expand Up @@ -325,7 +335,8 @@
"早子姐"
],
"迷迭香": [
"香香"
"香香",
"小女儿"
],
"假日威龙陈": [
"水陈"
Expand Down Expand Up @@ -503,6 +514,7 @@
],
"玛恩纳": [
"老马",
"老玛",
"叔叔"
],
"暴行": [],
Expand Down
2 changes: 2 additions & 0 deletions nonebot_plugin_arktools/src/game_guess_operator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from .data_source import *
from ..core.models_v3 import Character
from ..utils.general import nickname_swap


GAMES: Dict[str, GuessCharacter] = {} # 记录游戏数据
Expand Down Expand Up @@ -90,6 +91,7 @@ async def send(message: Optional[str] = None, image: Optional[BytesIO] = None):
if options.hint:
await send(message=await game.get_hint())

options.cht_name = await nickname_swap(options.cht_name)
cht = await Character.parse_name(options.cht_name)
result = await game.guess(cht)
if result in [GuessResult.WIN, GuessResult.LOSE]:
Expand Down
2 changes: 2 additions & 0 deletions nonebot_plugin_arktools/src/tool_operator_info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .data_source import BuildOperatorInfo
from ..core.models_v3 import Character
from ..exceptions import *
from ..utils.general import nickname_swap

operator_info = on_command("方舟干员", aliases={"干员"})

Expand All @@ -26,6 +27,7 @@ async def _(arg: Message = CommandArg()):
await operator_info.finish()

try:
name = await nickname_swap(name)
cht = await Character.parse_name(name)
except NamedCharacterNotExistException as e:
await operator_info.finish(e.msg, at_sender=True)
Expand Down
12 changes: 8 additions & 4 deletions nonebot_plugin_arktools/src/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Union, Dict, List
from nonebot import get_driver
from aiofiles import open as aopen
from nonebot import logger

from ..configs import PathConfig

Expand Down Expand Up @@ -159,13 +160,14 @@ async def gacha_rule_swap(value: str, type_: str = "name2code") -> str:
async def nickname_swap(value: str) -> str:
"""干员昵称/外号转换"""
swap_file = SWAP_PATH / "nicknames.json"
if not swap_file.exists():
os.makedirs(swap_file.parent, exist_ok=True)
return None

async with aopen(swap_file, "r", encoding="utf-8") as fp:
data = json.loads(await fp.read())

for k, v in data.items():
if value == k or value in v:
logger.info(f"{value} -> {k}")
return k
return value

async def get_recruitment_available() -> List[str]:
"""获取可以公招获取的干员id们"""
Expand All @@ -190,5 +192,7 @@ async def get_recruitment_available() -> List[str]:
"faction_swap",
"gacha_rule_swap",

"nickname_swap",

"get_recruitment_available"
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="nonebot_plugin_arktools",
version="1.0.14",
version="1.0.15",
author="Number_Sir",
author_email="[email protected]",
keywords=["pip", "nonebot2", "nonebot", "nonebot_plugin"],
Expand Down

0 comments on commit 6ba810b

Please sign in to comment.