mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-21 13:48:19 +00:00
➖ Remove role material query
This commit is contained in:
parent
82ca5b20dd
commit
e2302017b4
@ -9,18 +9,15 @@ class Raider(WikiModel):
|
||||
raider_role_path = WikiModel.BASE_PATH / "raiders" / "role"
|
||||
raider_guide_for_role_path = WikiModel.BASE_PATH / "raiders" / "guide_for_role"
|
||||
raider_light_cone_path = WikiModel.BASE_PATH / "raiders" / "light_cone"
|
||||
raider_role_material_path = WikiModel.BASE_PATH / "raiders" / "role_material"
|
||||
raider_relic_path = WikiModel.BASE_PATH / "raiders" / "relic"
|
||||
raider_info_path = WikiModel.BASE_PATH / "raiders" / "path.json"
|
||||
raider_role_path.mkdir(parents=True, exist_ok=True)
|
||||
raider_guide_for_role_path.mkdir(parents=True, exist_ok=True)
|
||||
raider_light_cone_path.mkdir(parents=True, exist_ok=True)
|
||||
raider_role_material_path.mkdir(parents=True, exist_ok=True)
|
||||
raider_relic_path.mkdir(parents=True, exist_ok=True)
|
||||
name_map = {
|
||||
"role": "role",
|
||||
"lightcone": "light_cone",
|
||||
"material for role": "role_material",
|
||||
"relic": "relic",
|
||||
"guide for role": "guide_for_role",
|
||||
}
|
||||
@ -30,14 +27,12 @@ class Raider(WikiModel):
|
||||
self.all_role_raiders: List[str] = []
|
||||
self.all_guide_for_role_raiders: List[str] = []
|
||||
self.all_light_cone_raiders: List[str] = []
|
||||
self.all_role_material_raiders: List[str] = []
|
||||
self.all_relic_raiders: List[str] = []
|
||||
|
||||
def clear_class_data(self) -> None:
|
||||
self.all_role_raiders.clear()
|
||||
self.all_guide_for_role_raiders.clear()
|
||||
self.all_light_cone_raiders.clear()
|
||||
self.all_role_material_raiders.clear()
|
||||
self.all_relic_raiders.clear()
|
||||
|
||||
async def refresh_task(self, name: str, path: str = "", start: str = ""):
|
||||
@ -66,5 +61,4 @@ class Raider(WikiModel):
|
||||
self.all_role_raiders.extend(datas["role"])
|
||||
self.all_guide_for_role_raiders.extend(datas["guide_for_role"])
|
||||
self.all_light_cone_raiders.extend(datas["light_cone"])
|
||||
self.all_role_material_raiders.extend(datas["role_material"])
|
||||
self.all_relic_raiders.extend(datas["relic"])
|
||||
|
@ -82,15 +82,6 @@ class Inline(Plugin):
|
||||
if character.startswith(key) or character.endswith(key):
|
||||
self.characters_list.append({"name": character, "icon": value})
|
||||
break
|
||||
# 角色培养素材
|
||||
for character in self.wiki_service.raider.all_role_material_raiders:
|
||||
if character in datas:
|
||||
self.characters_material_list.append({"name": character, "icon": datas[character]})
|
||||
else:
|
||||
for key, value in datas.items():
|
||||
if character.startswith(key) or character.endswith(key):
|
||||
self.characters_material_list.append({"name": character, "icon": value})
|
||||
break
|
||||
# 角色攻略
|
||||
for character in self.wiki_service.raider.all_guide_for_role_raiders:
|
||||
if character in datas:
|
||||
|
@ -1,87 +0,0 @@
|
||||
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
|
||||
from telegram.constants import ChatAction, ParseMode
|
||||
from telegram.ext import CallbackContext, filters
|
||||
|
||||
from core.plugin import Plugin, handler
|
||||
from core.services.game.services import GameCacheService
|
||||
from core.services.search.models import StrategyEntry
|
||||
from core.services.search.services import SearchServices
|
||||
from core.services.wiki.services import WikiService
|
||||
from metadata.shortname import roleToName, roleToTag
|
||||
from utils.log import logger
|
||||
|
||||
|
||||
class MaterialPlugin(Plugin):
|
||||
"""角色培养素材查询"""
|
||||
|
||||
KEYBOARD = [[InlineKeyboardButton(text="查看角色培养素材列表并查询", switch_inline_query_current_chat="查看角色培养素材列表并查询")]]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
cache_service: GameCacheService = None,
|
||||
wiki_service: WikiService = None,
|
||||
search_service: SearchServices = None,
|
||||
):
|
||||
self.cache_service = cache_service
|
||||
self.wiki_service = wiki_service
|
||||
self.search_service = search_service
|
||||
|
||||
@handler.command(command="material", block=False)
|
||||
@handler.message(filters=filters.Regex("^角色培养素材查询(.*)"), block=False)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> None:
|
||||
message = update.effective_message
|
||||
user = update.effective_user
|
||||
args = self.get_args(context)
|
||||
if len(args) >= 1:
|
||||
character_name = args[0]
|
||||
else:
|
||||
reply_message = await message.reply_text(
|
||||
"请回复你要查询的角色培养素材图鉴的角色名", reply_markup=InlineKeyboardMarkup(self.KEYBOARD)
|
||||
)
|
||||
if filters.ChatType.GROUPS.filter(reply_message):
|
||||
self.add_delete_message_job(message)
|
||||
self.add_delete_message_job(reply_message)
|
||||
return
|
||||
character_name = roleToName(character_name)
|
||||
file_path = self.wiki_service.raider.raider_role_material_path / f"{character_name}.png"
|
||||
if not file_path.exists():
|
||||
reply_message = await message.reply_text(
|
||||
f"没有找到 {character_name} 的角色培养素材图鉴", reply_markup=InlineKeyboardMarkup(self.KEYBOARD)
|
||||
)
|
||||
if filters.ChatType.GROUPS.filter(reply_message):
|
||||
self.add_delete_message_job(message)
|
||||
self.add_delete_message_job(reply_message)
|
||||
return
|
||||
logger.info("用户 %s[%s] 查询角色培养素材命令请求 || 参数 %s", user.full_name, user.id, character_name)
|
||||
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
||||
caption = "From 米游社@听语惊花"
|
||||
if file_id := await self.cache_service.get_material_cache(character_name):
|
||||
await message.reply_photo(
|
||||
photo=file_id,
|
||||
caption=caption,
|
||||
filename=f"{character_name}.png",
|
||||
allow_sending_without_reply=True,
|
||||
parse_mode=ParseMode.HTML,
|
||||
)
|
||||
else:
|
||||
reply_photo = await message.reply_photo(
|
||||
photo=open(file_path, "rb"),
|
||||
caption=caption,
|
||||
filename=f"{character_name}.png",
|
||||
allow_sending_without_reply=True,
|
||||
parse_mode=ParseMode.HTML,
|
||||
)
|
||||
if reply_photo.photo:
|
||||
tags = roleToTag(character_name)
|
||||
photo_file_id = reply_photo.photo[0].file_id
|
||||
await self.cache_service.set_material_cache(character_name, photo_file_id)
|
||||
entry = StrategyEntry(
|
||||
key=f"plugin:strategy:{character_name}",
|
||||
title=character_name,
|
||||
description=f"{character_name} 角色攻略",
|
||||
tags=tags,
|
||||
caption=caption,
|
||||
parse_mode="HTML",
|
||||
photo_file_id=photo_file_id,
|
||||
)
|
||||
await self.search_service.add_entry(entry)
|
Loading…
Reference in New Issue
Block a user