mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
✨ 新增圣遗物图鉴
和poetry.lock
This commit is contained in:
parent
d68eae7df1
commit
2fe89dc961
@ -1,16 +1,18 @@
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from littlepaimon_utils.files import load_json_from_url
|
|
||||||
from nonebot import on_endswith, on_command, on_regex
|
from nonebot import on_endswith, on_command, on_regex
|
||||||
from nonebot.adapters.onebot.v11 import MessageEvent, Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import MessageEvent, Message, MessageSegment
|
||||||
from nonebot.params import RegexDict
|
from nonebot.adapters.onebot.v11.helpers import is_cancellation
|
||||||
|
from nonebot.adapters.onebot.v11.exception import ActionFailed
|
||||||
|
from nonebot.adapters import MessageTemplate
|
||||||
|
from nonebot.params import RegexDict, ArgPlainText
|
||||||
from nonebot.plugin import PluginMetadata
|
from nonebot.plugin import PluginMetadata
|
||||||
from nonebot.typing import T_State
|
from nonebot.typing import T_State
|
||||||
|
|
||||||
from .abyss_rate_draw import draw_rate_rank, draw_teams_rate
|
|
||||||
from ..utils.alias_handler import get_match_alias
|
|
||||||
from ..utils.message_util import MessageBuild
|
from ..utils.message_util import MessageBuild
|
||||||
|
from ..utils.alias_handler import get_match_alias
|
||||||
|
from .abyss_rate_draw import draw_rate_rank, draw_teams_rate
|
||||||
|
|
||||||
__paimon_help__ = {
|
__paimon_help__ = {
|
||||||
'type': '原神Wiki',
|
'type': '原神Wiki',
|
||||||
@ -18,9 +20,9 @@ __paimon_help__ = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__plugin_meta__ = PluginMetadata(
|
__plugin_meta__ = PluginMetadata(
|
||||||
name="Paimon_Wiki",
|
name='Paimon_Wiki',
|
||||||
description="小派蒙的wiki查询模块",
|
description='原神WIKI百科',
|
||||||
usage=(
|
usage="""
|
||||||
"1.[xx角色攻略]查看西风驿站出品的角色一图流攻略\n"
|
"1.[xx角色攻略]查看西风驿站出品的角色一图流攻略\n"
|
||||||
"2.[xx角色材料]查看惜月出品的角色材料统计\n"
|
"2.[xx角色材料]查看惜月出品的角色材料统计\n"
|
||||||
"3.[xx参考面板]查看blue菌hehe出品的参考面板攻略\n"
|
"3.[xx参考面板]查看blue菌hehe出品的参考面板攻略\n"
|
||||||
@ -30,7 +32,7 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
"7.[深渊上半/下半阵容出场率]查看2.6深渊阵容出场率\n"
|
"7.[深渊上半/下半阵容出场率]查看2.6深渊阵容出场率\n"
|
||||||
"8.[xx武器攻略]查看武器攻略\n"
|
"8.[xx武器攻略]查看武器攻略\n"
|
||||||
"9.[xx原魔图鉴]查看原魔图鉴\n"
|
"9.[xx原魔图鉴]查看原魔图鉴\n"
|
||||||
),
|
""",
|
||||||
extra={
|
extra={
|
||||||
'type': '原神Wiki',
|
'type': '原神Wiki',
|
||||||
'range': ['private', 'group', 'guild'],
|
'range': ['private', 'group', 'guild'],
|
||||||
@ -39,13 +41,6 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
attribute = on_endswith('参考面板', priority=6, block=True)
|
|
||||||
attribute.__paimon_help__ = {
|
|
||||||
"usage": '<角色名> 参考面板',
|
|
||||||
"introduce": "查看该角色的小毕业参考面板",
|
|
||||||
"priority": 3
|
|
||||||
}
|
|
||||||
daily_material = on_endswith(('材料', '天赋材料', '突破材料'), priority=6, block=True)
|
daily_material = on_endswith(('材料', '天赋材料', '突破材料'), priority=6, block=True)
|
||||||
daily_material.__paimon_help__ = {
|
daily_material.__paimon_help__ = {
|
||||||
"usage": '<今日|周x>材料',
|
"usage": '<今日|周x>材料',
|
||||||
@ -60,57 +55,42 @@ abyss_rate.__paimon_help__ = {
|
|||||||
}
|
}
|
||||||
abyss_team = on_regex(r'^(深渊|深境螺旋)(?P<floor>上半|下半)阵容(排行|出场率)?$', priority=5, block=True)
|
abyss_team = on_regex(r'^(深渊|深境螺旋)(?P<floor>上半|下半)阵容(排行|出场率)?$', priority=5, block=True)
|
||||||
abyss_team.__paimon_help__ = {
|
abyss_team.__paimon_help__ = {
|
||||||
"usage": '深渊<上半|下半>阵容排行',
|
'name': '深渊阵容出场率排行',
|
||||||
"introduce": "查看本期深渊的阵容出场率排行",
|
'description': '查看本期深渊的阵容出场率排行',
|
||||||
"priority": 5
|
'usage': '深渊<上半|下半>阵容排行'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@attribute.handle()
|
|
||||||
async def genshinAttribute(event: MessageEvent):
|
|
||||||
name = event.message.extract_plain_text().replace('参考面板', '').strip()
|
|
||||||
realname = get_match_alias(name)
|
|
||||||
if realname:
|
|
||||||
blue = await load_json_from_url('https://static.cherishmoon.fun/LittlePaimon/blue/blue.json')
|
|
||||||
if realname in blue.keys():
|
|
||||||
img = await MessageBuild.StaticImage(url=f'LittlePaimon/blue/{blue[realname][0]}.jpg',
|
|
||||||
crop=(0, int(blue[realname][1][0]), 1080, int(blue[realname][1][1])))
|
|
||||||
else:
|
|
||||||
img = MessageBuild.Text(f'没有找到{name}的参考面板')
|
|
||||||
await attribute.finish(img)
|
|
||||||
else:
|
|
||||||
await attribute.finish(MessageBuild.Text(f'没有找到{name}的参考面板'), at_sender=True)
|
|
||||||
|
|
||||||
|
|
||||||
@daily_material.handle()
|
@daily_material.handle()
|
||||||
async def daily_material_handle(event: MessageEvent):
|
async def daily_material_handle(event: MessageEvent):
|
||||||
week = event.message.extract_plain_text().replace('材料', '').replace('天赋材料', '').replace('突破材料', '').strip()
|
if not (
|
||||||
if week:
|
week := event.message.extract_plain_text().replace('材料', '').replace('天赋材料', '').replace('突破材料',
|
||||||
find_week = re.search(r'(?P<week>今日|今天|现在|明天|明日|后天|后日|周一|周二|周三|周四|周五|周六|周日)', week)
|
'').strip()):
|
||||||
if find_week:
|
return
|
||||||
if find_week.group('week') in ['今日', '今天', '现在']:
|
if find_week := re.search('(?P<week>今日|今天|现在|明天|明日|后天|后日|周一|周二|周三|周四|周五|周六|周日)', week):
|
||||||
week = time.strftime("%w")
|
if find_week['week'] in ['今日', '今天', '现在']:
|
||||||
elif find_week.group('week') in ['明日', '明天']:
|
week = time.strftime("%w")
|
||||||
week = str(int(time.strftime("%w")) + 1)
|
elif find_week['week'] in ['明日', '明天']:
|
||||||
elif find_week.group('week') in ['后日', '后天']:
|
week = str(int(time.strftime("%w")) + 1)
|
||||||
week = str(int(time.strftime("%w")) + 2)
|
elif find_week['week'] in ['后日', '后天']:
|
||||||
elif find_week.group('week') in ['周一', '周四']:
|
week = str(int(time.strftime("%w")) + 2)
|
||||||
week = '1'
|
elif find_week['week'] in ['周一', '周四']:
|
||||||
elif find_week.group('week') in ['周二', '周五']:
|
week = '1'
|
||||||
week = '2'
|
elif find_week['week'] in ['周二', '周五']:
|
||||||
elif find_week.group('week') in ['周三', '周六']:
|
week = '2'
|
||||||
week = '3'
|
elif find_week['week'] in ['周三', '周六']:
|
||||||
else:
|
week = '3'
|
||||||
week = '0'
|
else:
|
||||||
if week == "0":
|
week = '0'
|
||||||
await daily_material.finish('周日所有材料都可以刷哦!', at_sender=True)
|
if week == "0":
|
||||||
elif week in ['1', '4']:
|
await daily_material.finish('周日所有材料都可以刷哦!', at_sender=True)
|
||||||
url = 'LittlePaimon/DailyMaterials/周一周四.jpg'
|
elif week in ['1', '4']:
|
||||||
elif week in ['2', '5']:
|
url = 'LittlePaimon/DailyMaterials/周一周四.jpg'
|
||||||
url = 'LittlePaimon/DailyMaterials/周二周五.jpg'
|
elif week in ['2', '5']:
|
||||||
else:
|
url = 'LittlePaimon/DailyMaterials/周二周五.jpg'
|
||||||
url = 'LittlePaimon/DailyMaterials/周三周六.jpg'
|
else:
|
||||||
await daily_material.finish(await MessageBuild.StaticImage(url=url))
|
url = 'LittlePaimon/DailyMaterials/周三周六.jpg'
|
||||||
|
await daily_material.finish(await MessageBuild.StaticImage(url=url))
|
||||||
|
|
||||||
|
|
||||||
@abyss_rate.handle()
|
@abyss_rate.handle()
|
||||||
@ -125,71 +105,96 @@ async def abyss_team_handler(event: MessageEvent, reGroup=RegexDict()):
|
|||||||
await abyss_team.finish(abyss_img)
|
await abyss_team.finish(abyss_img)
|
||||||
|
|
||||||
|
|
||||||
def create_choice_command(endswith: str, type_: str, url: str, tips: str = None, help_tips: str = None):
|
def create_wiki_matcher(pattern: str, help_fun: str, help_name: str):
|
||||||
command = on_endswith(endswith, priority=6, block=True)
|
maps = on_regex(pattern, priority=10, block=True)
|
||||||
command.plugin_name = 'Paimon_Wiki'
|
maps.plugin_name = 'Paimon_Wiki'
|
||||||
command.__paimon_help__ = {
|
maps.__paimon_help__ = {'introduce': f"查看该{help_name}的{help_fun}",
|
||||||
"usage": f'<{help_tips}名> ' + endswith,
|
'usage': f'<{help_name}名> {help_fun}', 'priority': 3}
|
||||||
"introduce": f"查看该{help_tips}的{endswith}",
|
|
||||||
"priority": 3
|
|
||||||
}
|
|
||||||
|
|
||||||
@command.handle()
|
@maps.handle()
|
||||||
async def _(event: MessageEvent, state: T_State):
|
async def _(event: MessageEvent, state: T_State, regex_dict: dict = RegexDict()):
|
||||||
name = event.message.extract_plain_text().replace(endswith, '').strip()
|
name = regex_dict['name1'] or regex_dict['name2']
|
||||||
|
state['type'] = regex_dict['type']
|
||||||
|
if '武器' in state['type']:
|
||||||
|
state['type'] = '武器'
|
||||||
|
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/WeaponMaps/{}.jpg'
|
||||||
|
elif '圣遗物' in state['type']:
|
||||||
|
state['type'] = '圣遗物'
|
||||||
|
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/ArtifactMaps/{}.jpg'
|
||||||
|
elif '怪物' in state['type'] or '原魔' in state['type']:
|
||||||
|
state['type'] = '原魔'
|
||||||
|
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/MonsterMaps/{}.jpg'
|
||||||
|
elif state['type'] == '角色攻略':
|
||||||
|
state['type'] = '角色'
|
||||||
|
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/XFGuide/{}.jpg'
|
||||||
|
elif state['type'] == '角色材料':
|
||||||
|
state['type'] = '角色'
|
||||||
|
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/RoleMaterials/{}.jpg'
|
||||||
|
elif state['type'] == '收益曲线':
|
||||||
|
state['type'] = '角色'
|
||||||
|
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/blue/{}.jpg'
|
||||||
|
elif state['type'] == '参考面板':
|
||||||
|
state['type'] = '角色'
|
||||||
|
state['img_url'] = 'https://static.cherishmoon.fun/LittlePaimon/blueRefer/{}.jpg'
|
||||||
if name:
|
if name:
|
||||||
state['name'] = name
|
state['name'] = name
|
||||||
|
|
||||||
@command.got('name', prompt=f'请把要查询的{help_tips}告诉我哦~')
|
@maps.got('name', prompt=Message.template('请提供要查询的{type}'))
|
||||||
async def _(event: MessageEvent, state: T_State):
|
async def _(event: MessageEvent, state: T_State):
|
||||||
name = state['name']
|
name = state['name']
|
||||||
if isinstance(name, Message):
|
if isinstance(name, Message):
|
||||||
|
if is_cancellation(name):
|
||||||
|
await maps.finish()
|
||||||
name = name.extract_plain_text().strip()
|
name = name.extract_plain_text().strip()
|
||||||
if name == 'q':
|
match_alias = get_match_alias(name, state['type'])
|
||||||
await command.finish()
|
true_name = match_alias[0] if (
|
||||||
match_alias = get_match_alias(name, type_)
|
isinstance(match_alias, list) and len(match_alias) == 1) else match_alias if isinstance(match_alias,
|
||||||
if isinstance(match_alias, str):
|
str) else None
|
||||||
await command.finish(
|
if true_name:
|
||||||
await MessageBuild.StaticImage(url=url.format(match_alias), tips=tips.format(match_alias)))
|
try:
|
||||||
elif isinstance(match_alias, list) and len(match_alias) == 1:
|
await maps.finish(MessageSegment.image(state['img_url'].format(match_alias)))
|
||||||
await command.finish(
|
except ActionFailed:
|
||||||
await MessageBuild.StaticImage(url=url.format(match_alias[0]), tips=tips.format(match_alias[0])))
|
await maps.finish(f'没有找到该{state["type"]}的图鉴')
|
||||||
|
elif match_alias:
|
||||||
|
if isinstance(match_alias, dict):
|
||||||
|
match_alias = list(match_alias.keys())
|
||||||
|
if 'choice' not in state:
|
||||||
|
msg = f'你要查询的{state["type"]}是:\n'
|
||||||
|
msg += '\n'.join([f'{int(i) + 1}. {name}' for i, name in enumerate(match_alias)])
|
||||||
|
await maps.send(msg + '\n回答\"取消\"来取消查询', at_sender=True)
|
||||||
|
state['match_alias'] = match_alias
|
||||||
else:
|
else:
|
||||||
if not match_alias:
|
await maps.finish(f'没有找到该{state["type"]}的图鉴')
|
||||||
await command.finish(MessageBuild.Text(f'没有{state["name"]}的{endswith}哦~'), at_sender=True)
|
|
||||||
else:
|
|
||||||
if isinstance(match_alias, dict):
|
|
||||||
match_alias = list(match_alias.keys())
|
|
||||||
if 'choice' not in state:
|
|
||||||
msg = f'你要找的{endswith[0:2]}是哪个呀:\n'
|
|
||||||
msg += '\n'.join([f'{int(i) + 1}. {name}' for i, name in enumerate(match_alias)])
|
|
||||||
await command.send(msg + '\n回答\"q\"可以取消查询', at_sender=True)
|
|
||||||
state['match_alias'] = match_alias
|
|
||||||
|
|
||||||
@command.got('choice')
|
@maps.got('choice')
|
||||||
async def _(event: MessageEvent, state: T_State):
|
async def _(event: MessageEvent, state: T_State, choice: str = ArgPlainText('choice')):
|
||||||
match_alias = state['match_alias']
|
match_alias = state['match_alias']
|
||||||
choice = state['choice']
|
if is_cancellation(choice):
|
||||||
choice = choice.extract_plain_text().strip().replace(endswith, '')
|
await maps.finish()
|
||||||
if choice == 'q':
|
|
||||||
await command.finish()
|
|
||||||
if choice.isdigit() and (1 <= int(choice) <= len(match_alias)):
|
if choice.isdigit() and (1 <= int(choice) <= len(match_alias)):
|
||||||
await command.finish(
|
try:
|
||||||
await MessageBuild.StaticImage(url=url.format(match_alias[int(choice) - 1]),
|
await maps.finish(MessageSegment.image(state['img_url'].format(match_alias[int(choice) - 1])))
|
||||||
tips=tips.format(match_alias[int(choice) - 1])))
|
except ActionFailed:
|
||||||
|
await maps.finish(f'没有找到该{state["type"]}的图鉴')
|
||||||
if choice not in match_alias:
|
if choice not in match_alias:
|
||||||
state['times'] = state['times'] + 1 if 'times' in state else 1
|
state['times'] = state['times'] + 1 if 'times' in state else 1
|
||||||
if state['times'] == 1:
|
if state['times'] == 1:
|
||||||
await command.reject(f'请旅行者从上面的{endswith[0:2]}中选一个问派蒙\n回答\"q\"可以取消查询', at_sender=True)
|
await maps.reject(f'请旅行者从上面的{state["type"]}中选一个问派蒙\n回答\"q\"可以取消查询', at_sender=True)
|
||||||
|
|
||||||
elif state['times'] == 2:
|
elif state['times'] == 2:
|
||||||
await command.reject(f'别调戏派蒙啦,快选一个吧,不想问了请回答\"q\"!', at_sender=True)
|
await maps.reject(f'别调戏派蒙啦,快选一个吧,不想问了请回答\"q\"!', at_sender=True)
|
||||||
elif state['times'] >= 3:
|
elif state['times'] >= 3:
|
||||||
await command.finish(f'看来旅行者您有点神志不清哦(,下次再问派蒙吧' + MessageSegment.face(146), at_sender=True)
|
await maps.finish(f'看来旅行者您有点神志不清哦(,下次再问派蒙吧{MessageSegment.face(146)}', at_sender=True)
|
||||||
await command.finish(await MessageBuild.StaticImage(url=url.format(choice), tips=tips.format(choice)))
|
try:
|
||||||
|
await maps.finish(MessageSegment.image(state['img_url'].format(choice)))
|
||||||
|
except ActionFailed:
|
||||||
|
await maps.finish(f'没有找到该{state["type"]}的图鉴')
|
||||||
|
|
||||||
|
|
||||||
create_choice_command('原魔图鉴', 'monsters', 'LittlePaimon/MonsterMaps/{}.jpg', '暂时没有{}的原魔图鉴哦~', '原魔')
|
create_wiki_matcher(r'(?P<name1>\w*)(?P<type>(原魔|怪物)(图鉴|攻略))(?P<name2>\w*)', '原魔图鉴', '原魔')
|
||||||
create_choice_command('武器攻略', 'weapons', 'LittlePaimon/WeaponGuild/{}.png', '暂时没有{}的武器攻略哦~', '武器')
|
create_wiki_matcher(r'(?P<name1>\w*)(?P<type>武器(图鉴|攻略))(?P<name2>\w*)', '武器图鉴', '武器')
|
||||||
create_choice_command('角色攻略', 'roles', 'LittlePaimon/XFGuide/{}.jpg', '暂时没有{}的角色攻略哦~', '角色')
|
create_wiki_matcher(r'(?P<name1>\w*)(?P<type>圣遗物(图鉴|攻略))(?P<name2>\w*)', '圣遗物图鉴', '圣遗物')
|
||||||
create_choice_command('角色材料', 'roles', 'LittlePaimon/RoleMaterials/{}材料.jpg', '暂时没有{}的角色材料哦~', '角色')
|
create_wiki_matcher(r'(?P<name1>\w*)(?P<type>角色攻略)(?P<name2>\w*)', '角色攻略', '角色')
|
||||||
create_choice_command('收益曲线', 'roles', 'LittlePaimon/blue/{}.jpg', '暂时没有{}的收益曲线哦~', '角色')
|
create_wiki_matcher(r'(?P<name1>\w*)(?P<type>角色材料)(?P<name2>\w*)', '角色材料', '角色')
|
||||||
|
create_wiki_matcher(r'(?P<name1>\w*)(?P<type>收益曲线)(?P<name2>\w*)', '收益曲线', '角色')
|
||||||
|
create_wiki_matcher(r'(?P<name1>\w*)(?P<type>参考面板)(?P<name2>\w*)', '参考面板', '角色')
|
||||||
|
13
README.md
13
README.md
@ -59,16 +59,6 @@
|
|||||||
|
|
||||||
### 近期进行全新版本重构,具体详见`Bot`分支,本分支暂缓更新,预计一到两周内重构完成。
|
### 近期进行全新版本重构,具体详见`Bot`分支,本分支暂缓更新,预计一到两周内重构完成。
|
||||||
|
|
||||||
+ 7.17
|
|
||||||
- `ysd`新增`班尼特、莫娜、七七、琴、温迪`伤害计算
|
|
||||||
- `mys自动签到`支持私聊
|
|
||||||
- `sy`修正深渊信息时间介绍
|
|
||||||
- `sy`没有绑定cookie时将不再错误的展示空阵容信息
|
|
||||||
- `ssbq`修复没有派遣时会报错的bug
|
|
||||||
+ 7.19
|
|
||||||
- 新增`米游币自动获取`#124,不确保一定可用,如产生其他bug请反馈
|
|
||||||
+ 7.23
|
|
||||||
- 深渊登场率数据改为2.8
|
|
||||||
+ 8.2
|
+ 8.2
|
||||||
- `点餐`功能恢复,但又引入了2个新依赖库,为不影响使用,默认关闭,有需要者请自行`pip install cssselect aiohttp`后,将`Paimon_plugins/_order.py`的`_`去掉 [#154](https://github.com/CMHopeSunshine/LittlePaimon/pull/154)
|
- `点餐`功能恢复,但又引入了2个新依赖库,为不影响使用,默认关闭,有需要者请自行`pip install cssselect aiohttp`后,将`Paimon_plugins/_order.py`的`_`去掉 [#154](https://github.com/CMHopeSunshine/LittlePaimon/pull/154)
|
||||||
- 修复无法关闭和删除ssbq提醒的bug [#154](https://github.com/CMHopeSunshine/LittlePaimon/pull/154)
|
- 修复无法关闭和删除ssbq提醒的bug [#154](https://github.com/CMHopeSunshine/LittlePaimon/pull/154)
|
||||||
@ -79,6 +69,9 @@
|
|||||||
+ 8.4
|
+ 8.4
|
||||||
- 补充`斫峰之刃`抽卡资源
|
- 补充`斫峰之刃`抽卡资源
|
||||||
- 修复`获取抽卡记录`可能出现的bug
|
- 修复`获取抽卡记录`可能出现的bug
|
||||||
|
+ 8.17
|
||||||
|
- 新增`圣遗物图鉴`
|
||||||
|
- 补充`poetry.lock`
|
||||||
|
|
||||||
## 丨功能列表
|
## 丨功能列表
|
||||||
|
|
||||||
|
@ -104,3 +104,6 @@
|
|||||||
+ 8.4
|
+ 8.4
|
||||||
- 补充`斫峰之刃`抽卡资源
|
- 补充`斫峰之刃`抽卡资源
|
||||||
- 修复`获取抽卡记录`可能出现的bug
|
- 修复`获取抽卡记录`可能出现的bug
|
||||||
|
+ 8.17
|
||||||
|
- 新增`圣遗物图鉴`
|
||||||
|
- 补充`poetry.lock`
|
2145
poetry.lock
generated
Normal file
2145
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -33,7 +33,7 @@ url = "https://mirrors.aliyun.com/pypi/simple/"
|
|||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.8"
|
python = "^3.8"
|
||||||
nonebot2 = "^2.0.0-beta.4"
|
nonebot2 = "^2.0.0-beta.4"
|
||||||
nonebot-adapter-onebot = "^2.0.0-beta.1"
|
nonebot-adapter-onebot = "^2.1.3"
|
||||||
nonebot-plugin-apscheduler = "^0.1.2"
|
nonebot-plugin-apscheduler = "^0.1.2"
|
||||||
nonebot-plugin-htmlrender = "^0.0.4.6"
|
nonebot-plugin-htmlrender = "^0.0.4.6"
|
||||||
beautifulsoup4 = "^4.10.0"
|
beautifulsoup4 = "^4.10.0"
|
||||||
|
@ -56,7 +56,7 @@ def get_alias_by_name(name: str):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_match_alias(msg: str, type: str = 'roles', single_to_dict: bool = False) -> Union[str, list, dict]:
|
def get_match_alias(msg: str, type: str = '角色', single_to_dict: bool = False) -> Union[str, list, dict]:
|
||||||
"""
|
"""
|
||||||
根据字符串消息,获取与之相似或匹配的角色、武器、原魔名
|
根据字符串消息,获取与之相似或匹配的角色、武器、原魔名
|
||||||
:param msg: 消息
|
:param msg: 消息
|
||||||
@ -66,9 +66,9 @@ def get_match_alias(msg: str, type: str = 'roles', single_to_dict: bool = False)
|
|||||||
"""
|
"""
|
||||||
alias_file = load_json(path=Path(__file__).parent / 'json_data' / 'alias.json')
|
alias_file = load_json(path=Path(__file__).parent / 'json_data' / 'alias.json')
|
||||||
alias_list = alias_file[type]
|
alias_list = alias_file[type]
|
||||||
if msg in ['风主', '岩主', '雷主']:
|
if msg in {'风主', '岩主', '雷主'}:
|
||||||
return msg
|
return msg
|
||||||
elif type == 'roles':
|
elif type == '角色':
|
||||||
possible = {}
|
possible = {}
|
||||||
for role_id, alias in alias_list.items():
|
for role_id, alias in alias_list.items():
|
||||||
match_list = difflib.get_close_matches(msg, alias, cutoff=0.6, n=3)
|
match_list = difflib.get_close_matches(msg, alias, cutoff=0.6, n=3)
|
||||||
@ -79,7 +79,7 @@ def get_match_alias(msg: str, type: str = 'roles', single_to_dict: bool = False)
|
|||||||
if len(possible) == 1:
|
if len(possible) == 1:
|
||||||
return {list(possible.keys())[0]: possible[list(possible.keys())[0]]} if single_to_dict else list(possible.keys())[0]
|
return {list(possible.keys())[0]: possible[list(possible.keys())[0]]} if single_to_dict else list(possible.keys())[0]
|
||||||
return possible
|
return possible
|
||||||
elif type == 'weapons':
|
elif type in ['武器', '圣遗物']:
|
||||||
possible = []
|
possible = []
|
||||||
for name, alias in alias_list.items():
|
for name, alias in alias_list.items():
|
||||||
match_list = difflib.get_close_matches(msg, alias, cutoff=0.4, n=3)
|
match_list = difflib.get_close_matches(msg, alias, cutoff=0.4, n=3)
|
||||||
@ -88,6 +88,6 @@ def get_match_alias(msg: str, type: str = 'roles', single_to_dict: bool = False)
|
|||||||
elif match_list:
|
elif match_list:
|
||||||
possible.append(name)
|
possible.append(name)
|
||||||
return possible
|
return possible
|
||||||
elif type == 'monsters':
|
elif type == '原魔':
|
||||||
match_list = difflib.get_close_matches(msg, alias_list, cutoff=0.4, n=5)
|
match_list = difflib.get_close_matches(msg, alias_list, cutoff=0.4, n=5)
|
||||||
return match_list[0] if len(match_list) == 1 else match_list
|
return match_list[0] if len(match_list) == 1 else match_list
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"roles":{
|
"角色":{
|
||||||
"10000002": ["神里绫华", "绫华", "大小姐", "小乌龟", "白鹭公主", "0华", "神里妹", "凌华", "神里凌华"],
|
"10000002": ["神里绫华", "绫华", "大小姐", "小乌龟", "白鹭公主", "0华", "神里妹", "凌华", "神里凌华"],
|
||||||
"10000003": ["琴", "团长", "琴团长", "蒲公英骑士"],
|
"10000003": ["琴", "团长", "琴团长", "蒲公英骑士"],
|
||||||
"10000005": ["空", "空哥", "龙哥", "哥哥", "旅行者", "主角"],
|
"10000005": ["空", "空哥", "龙哥", "哥哥", "旅行者", "主角"],
|
||||||
@ -53,7 +53,7 @@
|
|||||||
"10000065": ["久岐忍", "忍者", "阿卡丽", "97忍", "97人"],
|
"10000065": ["久岐忍", "忍者", "阿卡丽", "97忍", "97人"],
|
||||||
"10000059": ["鹿野院平藏", "近战法师", "平藏", "小鹿"]
|
"10000059": ["鹿野院平藏", "近战法师", "平藏", "小鹿"]
|
||||||
},
|
},
|
||||||
"weapons": {
|
"武器": {
|
||||||
"磐岩结绿": [
|
"磐岩结绿": [
|
||||||
"磐岩结绿",
|
"磐岩结绿",
|
||||||
"绿箭",
|
"绿箭",
|
||||||
@ -593,7 +593,156 @@
|
|||||||
"一心传名刀"
|
"一心传名刀"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"monsters": [
|
"圣遗物": {
|
||||||
|
"游医": [
|
||||||
|
"游医"
|
||||||
|
],
|
||||||
|
"冒险家": [
|
||||||
|
"冒险家"
|
||||||
|
],
|
||||||
|
"幸运儿": [
|
||||||
|
"幸运儿"
|
||||||
|
],
|
||||||
|
"学士": [
|
||||||
|
"学士"
|
||||||
|
],
|
||||||
|
"战狂": [
|
||||||
|
"战狂"
|
||||||
|
],
|
||||||
|
"赌徒": [
|
||||||
|
"赌徒"
|
||||||
|
],
|
||||||
|
"武人": [
|
||||||
|
"武人"
|
||||||
|
],
|
||||||
|
"守护之心": [
|
||||||
|
"守护之心"
|
||||||
|
],
|
||||||
|
"流放者": [
|
||||||
|
"流放者"
|
||||||
|
],
|
||||||
|
"行者之心": [
|
||||||
|
"行者之心"
|
||||||
|
],
|
||||||
|
"奇迹": [
|
||||||
|
"奇迹"
|
||||||
|
],
|
||||||
|
"勇士之心": [
|
||||||
|
"勇士之心"
|
||||||
|
],
|
||||||
|
"教官": [
|
||||||
|
"教官"
|
||||||
|
],
|
||||||
|
"如雷的盛怒": [
|
||||||
|
"如雷的盛怒",
|
||||||
|
"如雷"
|
||||||
|
],
|
||||||
|
"追忆之注连": [
|
||||||
|
"追忆之注连",
|
||||||
|
"追忆"
|
||||||
|
],
|
||||||
|
"冰风迷途的勇士": [
|
||||||
|
"冰风迷途的勇士",
|
||||||
|
"冰套"
|
||||||
|
],
|
||||||
|
"染血的骑士道": [
|
||||||
|
"染血的骑士道",
|
||||||
|
"染血",
|
||||||
|
"骑士"
|
||||||
|
],
|
||||||
|
"饰金之梦生之花": [
|
||||||
|
"饰金之梦生之花",
|
||||||
|
"饰金"
|
||||||
|
],
|
||||||
|
"华馆梦醒形骸记": [
|
||||||
|
"华馆梦醒形骸记",
|
||||||
|
"华馆",
|
||||||
|
"防御"
|
||||||
|
],
|
||||||
|
"昔日宗室之仪": [
|
||||||
|
"昔日宗室之仪",
|
||||||
|
"宗室"
|
||||||
|
],
|
||||||
|
"沉沦之心": [
|
||||||
|
"沉沦之心",
|
||||||
|
"水套"
|
||||||
|
],
|
||||||
|
"悠古的磐岩": [
|
||||||
|
"悠古的磐岩",
|
||||||
|
"岩套"
|
||||||
|
],
|
||||||
|
"海染砗磲": [
|
||||||
|
"海染砗磲",
|
||||||
|
"海染",
|
||||||
|
"毒奶"
|
||||||
|
],
|
||||||
|
"翠绿之影": [
|
||||||
|
"翠绿之影",
|
||||||
|
"风套"
|
||||||
|
],
|
||||||
|
"苍白之火": [
|
||||||
|
"苍白之火",
|
||||||
|
"苍白",
|
||||||
|
"物理"
|
||||||
|
],
|
||||||
|
"流浪大地的乐团": [
|
||||||
|
"流浪大地的乐团",
|
||||||
|
"流浪"
|
||||||
|
],
|
||||||
|
"逆飞的流星": [
|
||||||
|
"逆飞的流星",
|
||||||
|
"逆飞",
|
||||||
|
"流星"
|
||||||
|
],
|
||||||
|
"平息鸣雷的尊者": [
|
||||||
|
"平息鸣雷的尊者",
|
||||||
|
"平雷"
|
||||||
|
],
|
||||||
|
"辰砂往生录": [
|
||||||
|
"辰砂往生录",
|
||||||
|
"辰砂",
|
||||||
|
"掉血"
|
||||||
|
],
|
||||||
|
"渡过烈火的贤人": [
|
||||||
|
"渡过烈火的贤人",
|
||||||
|
"渡火"
|
||||||
|
],
|
||||||
|
"千岩牢固": [
|
||||||
|
"千岩牢固",
|
||||||
|
"千岩",
|
||||||
|
"生命"
|
||||||
|
],
|
||||||
|
"被怜爱的少女": [
|
||||||
|
"被怜爱的少女",
|
||||||
|
"治疗",
|
||||||
|
"少女"
|
||||||
|
],
|
||||||
|
"来歆余响": [
|
||||||
|
"来歆余响",
|
||||||
|
"普攻",
|
||||||
|
"余响"
|
||||||
|
],
|
||||||
|
"炽烈的炎之魔女": [
|
||||||
|
"炽烈的炎之魔女",
|
||||||
|
"火套",
|
||||||
|
"魔女"
|
||||||
|
],
|
||||||
|
"绝缘之旗印": [
|
||||||
|
"绝缘之旗印",
|
||||||
|
"充能",
|
||||||
|
"绝缘"
|
||||||
|
],
|
||||||
|
"角斗士的终幕礼": [
|
||||||
|
"角斗士的终幕礼",
|
||||||
|
"角斗"
|
||||||
|
],
|
||||||
|
"深林的记忆生之花": [
|
||||||
|
"深林的记忆生之花",
|
||||||
|
"草套",
|
||||||
|
"艹套"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"原魔": [
|
||||||
"「公子」",
|
"「公子」",
|
||||||
"「女士」",
|
"「女士」",
|
||||||
"丘丘人",
|
"丘丘人",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user