新增星铁角色攻略 (#473)

This commit is contained in:
forchannot 2023-09-27 15:04:43 +08:00 committed by GitHub
parent bb6706043a
commit 7a2510a065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,7 @@ wiki_data: Dict[str, Dict[str, str]] = {}
last_update_time: datetime.datetime = datetime.datetime.now() last_update_time: datetime.datetime = datetime.datetime.now()
GAME_ALIAS = ['星穹铁道', '星铁', '崩铁', '穹轨', '铁轨', '铁道', escape('*'), ''] GAME_ALIAS = ['星穹铁道', '星铁', '崩铁', '穹轨', '铁轨', '铁道', escape('*'), '']
BASE_TYPE = ['图鉴', '材料', '角色图鉴', '角色材料', '遗器图鉴', '光锥图鉴'] BASE_TYPE = ['图鉴', '材料', '角色图鉴', '角色材料', '攻略', '角色攻略', '遗器图鉴', '光锥图鉴']
GAME_ALIAS_RE = '(' + '|'.join(GAME_ALIAS) + ')' GAME_ALIAS_RE = '(' + '|'.join(GAME_ALIAS) + ')'
BASE_TYPE_RE = '(' + '|'.join(BASE_TYPE) + ')' BASE_TYPE_RE = '(' + '|'.join(BASE_TYPE) + ')'
WIKI_RE = fr'{COMMAND_START_RE}(?P<name>\w{{0,10}}?)(?P<game>{GAME_ALIAS_RE})(?P<type>{BASE_TYPE_RE})' WIKI_RE = fr'{COMMAND_START_RE}(?P<name>\w{{0,10}}?)(?P<game>{GAME_ALIAS_RE})(?P<type>{BASE_TYPE_RE})'
@ -28,7 +28,8 @@ TYPE_MAP = {
'角色图鉴': 'role', '角色图鉴': 'role',
'角色材料': 'material for role', '角色材料': 'material for role',
'遗器图鉴': 'relic', '遗器图鉴': 'relic',
'光锥图鉴': 'lightcone' '光锥图鉴': 'lightcone',
'角色攻略': 'guide for role'
} }
__plugin_meta__ = PluginMetadata( __plugin_meta__ = PluginMetadata(
@ -47,8 +48,8 @@ wiki = on_regex(WIKI_RE,
block=False, block=False,
state={ state={
'pm_name': '星穹铁道wiki', 'pm_name': '星穹铁道wiki',
'pm_description': '支持查询:角色、光锥、遗器图鉴和角色材料\n示例:希儿星铁图鉴、与行星相会光锥图鉴', 'pm_description': '支持查询:角色、光锥、遗器图鉴和角色材料,攻略\n示例:希儿星铁图鉴、与行星相会光锥图鉴',
'pm_usage': '<对象名><星铁图鉴|材料>', 'pm_usage': '<对象名><星铁图鉴|材料|攻略>',
'pm_priority': 1 'pm_priority': 1
}) })
@ -58,12 +59,14 @@ async def sr_wiki_handler(state: T_State, regex_dict: dict = RegexDict()):
name: str = regex_dict['name'] name: str = regex_dict['name']
game: str = regex_dict['game'] game: str = regex_dict['game']
type: str = regex_dict['type'] type: str = regex_dict['type']
if type in {'图鉴', '材料', '角色图鉴', '角色材料'} and not game: if type in {'图鉴', '材料', '攻略', '角色图鉴', '角色材料', '角色攻略'} and not game:
await wiki.finish() await wiki.finish()
if not wiki_data or datetime.datetime.now() - last_update_time > datetime.timedelta(hours=2): if not wiki_data or datetime.datetime.now() - last_update_time > datetime.timedelta(hours=2):
await init_data() await init_data()
if not wiki_data: if not wiki_data:
await wiki.finish('无法获取到星穹铁道资源列表,可能是网络问题~') await wiki.finish('无法获取到星穹铁道资源列表,可能是网络问题~')
if type in {'攻略', '角色攻略'}:
type = '角色攻略'
if type in {'图鉴', '角色图鉴'}: if type in {'图鉴', '角色图鉴'}:
type = '角色图鉴' type = '角色图鉴'
elif type in {'材料', '角色材料'}: elif type in {'材料', '角色材料'}: