mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-24 23:29:40 +00:00
🎨 优化报错提醒
This commit is contained in:
parent
619ae76027
commit
bf90ca55f9
@ -113,7 +113,7 @@ class Abyss(Plugin, BasePlugin):
|
||||
floor, total, previous = get_args(message.text)
|
||||
|
||||
if floor > 12 or floor < 0:
|
||||
reply_msg = await message.reply_text("深渊层数输入错误,请重新输入")
|
||||
reply_msg = await message.reply_text("深渊层数输入错误,请重新输入。支持的参数为: 1-12 或 all")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, reply_msg.chat_id, reply_msg.message_id, 10)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 10)
|
||||
@ -132,28 +132,27 @@ class Abyss(Plugin, BasePlugin):
|
||||
await client.get_record_cards()
|
||||
uid = client.uid
|
||||
except UserNotFoundError: # 若未找到账号
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
reply_msg = await message.reply_text(
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_msg.chat_id, reply_msg.message_id, 30)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先私聊派蒙绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
except CookiesNotFoundError: # 若未找到cookie
|
||||
client, uid = await get_public_genshin_client(user.id)
|
||||
except TooManyRequestPublicCookies:
|
||||
reply_msg = await message.reply_text(
|
||||
"查询次数太多,请您稍后重试",
|
||||
)
|
||||
reply_msg = await message.reply_text("查询次数太多,请您稍后重试")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, reply_msg.chat_id, reply_msg.message_id, 10)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 10)
|
||||
return
|
||||
|
||||
async def reply_message(content: str) -> None:
|
||||
async def reply_message_func(content: str) -> None:
|
||||
_user = await client.get_genshin_user(uid)
|
||||
_reply_msg = await message.reply_text(
|
||||
f"旅行者 {_user.info.nickname}(<code>{uid}</code>) {content}", parse_mode=ParseMode.HTML
|
||||
@ -169,19 +168,19 @@ class Abyss(Plugin, BasePlugin):
|
||||
try:
|
||||
images = await self.get_rendered_pic(client, uid, floor, total, previous)
|
||||
except AbyssUnlocked: # 若深渊未解锁
|
||||
await reply_message("还未解锁深渊哦~")
|
||||
await reply_message_func("还未解锁深渊哦~")
|
||||
return
|
||||
except NoMostKills: # 若深渊还未挑战
|
||||
await reply_message("还没有挑战本次深渊呢,咕咕咕~")
|
||||
await reply_message_func("还没有挑战本次深渊呢,咕咕咕~")
|
||||
return
|
||||
except AbyssNotFoundError:
|
||||
await reply_message("无法查询玩家挑战队伍详情,只能查询统计详情哦~")
|
||||
await reply_message_func("无法查询玩家挑战队伍详情,只能查询统计详情哦~")
|
||||
return
|
||||
except IndexError: # 若深渊为挑战此层
|
||||
await reply_message("还没有挑战本层呢,咕咕咕~")
|
||||
await reply_message_func("还没有挑战本层呢,咕咕咕~")
|
||||
return
|
||||
if images is None:
|
||||
await reply_message(f"还没有第 {floor} 层的挑战数据")
|
||||
await reply_message_func(f"还没有第 {floor} 层的挑战数据")
|
||||
return
|
||||
|
||||
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
||||
|
@ -40,8 +40,8 @@ class AbyssTeam(Plugin, BasePlugin):
|
||||
try:
|
||||
client = await get_genshin_client(user.id)
|
||||
except (CookiesNotFoundError, UserNotFoundError):
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -49,7 +49,7 @@ class AbyssTeam(Plugin, BasePlugin):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
|
||||
await message.reply_chat_action(ChatAction.TYPING)
|
||||
|
@ -39,7 +39,7 @@ class ArtifactRate(Plugin.Conversation, BasePlugin.Conversation):
|
||||
if rate_result_req.status_code == 400:
|
||||
artifact_attr = rate_result_req.json()
|
||||
return artifact_attr.get("message", "API请求错误")
|
||||
return "API请求错误"
|
||||
return "API请求错误,请稍后再试"
|
||||
rate_result = rate_result_req.json()
|
||||
return (
|
||||
"*圣遗物评分结果*\n"
|
||||
@ -68,11 +68,8 @@ class ArtifactRate(Plugin.Conversation, BasePlugin.Conversation):
|
||||
photo_file: Optional[File] = None
|
||||
if message is None:
|
||||
return ConversationHandler.END
|
||||
else:
|
||||
if message.reply_to_message is None:
|
||||
message_data = message
|
||||
else:
|
||||
message_data = message.reply_to_message
|
||||
message_data = message if message.reply_to_message is None else message.reply_to_message
|
||||
|
||||
if message_data.photo is not None and len(message_data.photo) >= 1:
|
||||
photo_file = await message_data.photo[-1].get_file() # 草 居然第一张是预览图我人都麻了
|
||||
elif message_data.document is not None:
|
||||
@ -80,7 +77,7 @@ class ArtifactRate(Plugin.Conversation, BasePlugin.Conversation):
|
||||
if "image" not in document.mime_type:
|
||||
await message.reply_text("错误的图片类型")
|
||||
return ConversationHandler.END
|
||||
if document.file_size / 1024 / 1024 >= 5:
|
||||
if document.file_size >= 5242880:
|
||||
await message.reply_text("图片太大啦")
|
||||
return ConversationHandler.END
|
||||
photo_file = await document.get_file()
|
||||
@ -92,9 +89,9 @@ class ArtifactRate(Plugin.Conversation, BasePlugin.Conversation):
|
||||
if artifact_attr_req.status_code != 200:
|
||||
if artifact_attr_req.status_code == 400:
|
||||
artifact_attr = artifact_attr_req.json()
|
||||
await message.reply_text(artifact_attr.get("message", "API请求错误"))
|
||||
await message.reply_text(artifact_attr.get("message", "API请求错误,请稍后再试"))
|
||||
return ConversationHandler.END
|
||||
await message.reply_text("API请求错误")
|
||||
await message.reply_text("API请求错误,请稍后再试")
|
||||
return ConversationHandler.END
|
||||
artifact_attr = artifact_attr_req.json()
|
||||
context.user_data["artifact_attr"] = artifact_attr
|
||||
@ -117,7 +114,7 @@ class ArtifactRate(Plugin.Conversation, BasePlugin.Conversation):
|
||||
artifact_attr = context.user_data.get("artifact_attr")
|
||||
await query.answer()
|
||||
if artifact_attr is None:
|
||||
await query.edit_message_text("数据错误")
|
||||
await query.edit_message_text("数据错误,请重新发送图片")
|
||||
return ConversationHandler.END
|
||||
|
||||
def get_callback_data(callback_query_data: str) -> Tuple[str, int]:
|
||||
@ -136,7 +133,7 @@ class ArtifactRate(Plugin.Conversation, BasePlugin.Conversation):
|
||||
elif key_name == "star":
|
||||
artifact_attr["star"] = value
|
||||
else:
|
||||
await query.edit_message_text("数据错误")
|
||||
await query.edit_message_text("数据错误,请重新发送图片")
|
||||
return ConversationHandler.END
|
||||
if artifact_attr.get("level") is None:
|
||||
await query.edit_message_text("无法识别圣遗物等级,请选择圣遗物等级", reply_markup=InlineKeyboardMarkup(self.LEVEL_KEYBOARD))
|
||||
|
@ -41,18 +41,19 @@ class AvatarListPlugin(Plugin, BasePlugin):
|
||||
try:
|
||||
return await get_genshin_client(user.id)
|
||||
except UserNotFoundError: # 若未找到账号
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
reply_msg = await message.reply_text(
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_msg.chat_id, reply_msg.message_id, 30)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先私聊派蒙绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
except CookiesNotFoundError:
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
reply_msg = await message.reply_text(
|
||||
"此功能需要绑定<code>cookie</code>后使用,请先私聊派蒙绑定账号",
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
@ -61,7 +62,11 @@ class AvatarListPlugin(Plugin, BasePlugin):
|
||||
self._add_delete_message_job(context, reply_msg.chat_id, reply_msg.message_id, 30)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("此功能需要绑定<code>cookie</code>后使用,请先私聊派蒙进行绑定", parse_mode=ParseMode.HTML)
|
||||
await message.reply_text(
|
||||
"此功能需要绑定<code>cookie</code>后使用,请先私聊派蒙进行绑定",
|
||||
parse_mode=ParseMode.HTML,
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
)
|
||||
|
||||
async def get_avatar_data(self, character: Character, client: Client) -> Optional["AvatarData"]:
|
||||
detail = None
|
||||
@ -215,7 +220,7 @@ class AvatarListPlugin(Plugin, BasePlugin):
|
||||
"has_more": len(characters) != len(avatar_datas), # 是否显示了全部角色
|
||||
}
|
||||
|
||||
as_document = True if all_avatars and len(characters) > 20 else False
|
||||
as_document = all_avatars and len(characters) > 20
|
||||
|
||||
await message.reply_chat_action(ChatAction.UPLOAD_DOCUMENT if as_document else ChatAction.UPLOAD_PHOTO)
|
||||
|
||||
|
@ -15,7 +15,7 @@ import ujson as json
|
||||
from aiofiles import open as async_open
|
||||
from arkowrapper import ArkoWrapper
|
||||
from bs4 import BeautifulSoup
|
||||
from genshin import Client
|
||||
from genshin import Client, InvalidCookies
|
||||
from httpx import AsyncClient, HTTPError
|
||||
from pydantic import BaseModel
|
||||
from telegram import Message, Update, User
|
||||
@ -168,6 +168,8 @@ class DailyMaterial(Plugin, BasePlugin):
|
||||
)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
except InvalidCookies:
|
||||
logger.info(f"用户({user.full_name} {user.id}) 所绑定的账号信息已失效")
|
||||
return client, user_data
|
||||
|
||||
@handler.command("daily_material", block=False)
|
||||
@ -262,7 +264,7 @@ class DailyMaterial(Plugin, BasePlugin):
|
||||
materials.append(ItemData(id=mid, icon=path, name=material[1], rarity=material[2]))
|
||||
except AssetsCouldNotFound as exc:
|
||||
logger.error(f"出错了呜呜呜 ~ {repr(exc)}")
|
||||
await notice.edit_text(f"出错了呜呜呜 ~ 派蒙找不到一些素材")
|
||||
await notice.edit_text("出错了呜呜呜 ~ 派蒙找不到一些素材")
|
||||
return
|
||||
areas.append(
|
||||
AreaData(
|
||||
|
@ -102,8 +102,8 @@ class DailyNote(Plugin, BasePlugin):
|
||||
client = await get_genshin_client(user.id)
|
||||
render_result = await self._get_daily_note(client)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -111,10 +111,10 @@ class DailyNote(Plugin, BasePlugin):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
except DataNotPublic:
|
||||
reply_message = await message.reply_text("查询失败惹,可能是便签功能被禁用了?")
|
||||
reply_message = await message.reply_text("查询失败惹,可能是便签功能被禁用了?请尝试通过米游社或者 hoyolab 获取一次便签信息后重试。")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 300)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 300)
|
||||
|
@ -52,10 +52,7 @@ class GachaRedis:
|
||||
|
||||
class GachaHandle:
|
||||
def __init__(self, hyperion: Optional[GachaInfo] = None):
|
||||
if hyperion is None:
|
||||
self.hyperion = GachaInfo()
|
||||
else:
|
||||
self.hyperion = hyperion
|
||||
self.hyperion = GachaInfo() if hyperion is None else hyperion
|
||||
|
||||
async def de_banner(self, gacha_id: str, gacha_type: int) -> Optional[GachaBanner]:
|
||||
gacha_info = await self.hyperion.get_gacha_info(gacha_id)
|
||||
@ -90,7 +87,7 @@ class GachaHandle:
|
||||
banner.fallback_items4_pool1.append(avatar_to_game_id(r4_prob["item_name"]))
|
||||
elif r4_prob["item_type"] == "武器":
|
||||
banner.fallback_items4_pool1.append(weapon_to_game_id(r4_prob["item_name"]))
|
||||
if gacha_type in (301, 400):
|
||||
if gacha_type in {301, 400}:
|
||||
banner.wish_max_progress = 1
|
||||
banner.banner_type = BannerType.EVENT
|
||||
banner.weight4 = ((1, 510), (8, 510), (10, 10000))
|
||||
@ -132,7 +129,7 @@ class GachaHandle:
|
||||
re_color = re.search(r"<color=#(.*?)>", title, flags=0)
|
||||
if re_color is None:
|
||||
return title_html.text, None
|
||||
color = re_color.group(1)
|
||||
color = re_color[1]
|
||||
title_html.color.name = "span"
|
||||
title_html.span["style"] = f"color:#{color};"
|
||||
return title_html.text, title_html.p
|
||||
@ -178,7 +175,7 @@ class Gacha(Plugin, BasePlugin):
|
||||
try:
|
||||
gacha_base_info = await self.handle.gacha_base_info(gacha_name)
|
||||
except GachaNotFound as exc:
|
||||
await message.reply_text(f"没有找到名为 {exc.gacha_name} 的卡池")
|
||||
await message.reply_text(f"没有找到名为 {exc.gacha_name} 的卡池,可能是卡池不存在或者卡池已经结束,请检查后重试。如果你想抽取默认卡池,请不要输入参数。")
|
||||
return
|
||||
else:
|
||||
gacha_base_info = await self.handle.gacha_base_info(default=True)
|
||||
@ -188,8 +185,10 @@ class Gacha(Plugin, BasePlugin):
|
||||
banner = await self.get_banner(gacha_base_info)
|
||||
player_gacha_info = await self.gacha_db.get(user.id)
|
||||
# 检查 wish_item_id
|
||||
if banner.banner_type == BannerType.WEAPON:
|
||||
if player_gacha_info.event_weapon_banner.wish_item_id not in banner.rate_up_items5:
|
||||
if (
|
||||
banner.banner_type == BannerType.WEAPON
|
||||
and player_gacha_info.event_weapon_banner.wish_item_id not in banner.rate_up_items5
|
||||
):
|
||||
player_gacha_info.event_weapon_banner.wish_item_id = 0
|
||||
# 执行抽卡
|
||||
item_list = self.banner_system.do_pulls(player_gacha_info, banner, 10)
|
||||
@ -238,28 +237,39 @@ class Gacha(Plugin, BasePlugin):
|
||||
message = update.effective_message
|
||||
user = update.effective_user
|
||||
args = get_all_args(context)
|
||||
try:
|
||||
gacha_base_info = await self.handle.gacha_base_info("武器活动")
|
||||
except GachaNotFound:
|
||||
reply_message = await message.reply_text("当前还没有武器正在 UP,可能是卡池不存在或者卡池已经结束。")
|
||||
if filters.ChatType.GROUPS.filter(reply_message):
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 10)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 10)
|
||||
return
|
||||
banner = await self.get_banner(gacha_base_info)
|
||||
up_weapons = {}
|
||||
for rate_up_items5 in banner.rate_up_items5:
|
||||
weapon = WEAPON_DATA.get(str(rate_up_items5))
|
||||
if weapon is None:
|
||||
continue
|
||||
up_weapons[weapon["name"]] = rate_up_items5
|
||||
up_weapons_text = "当前 UP 武器有:" + "、".join(up_weapons.keys())
|
||||
if len(args) >= 1:
|
||||
weapon_name = args[0]
|
||||
else:
|
||||
reply_message = await message.reply_text("参数错误")
|
||||
reply_message = await message.reply_text(f"输入的参数不正确,请输入需要定轨的武器名称。\n{up_weapons_text}")
|
||||
if filters.ChatType.GROUPS.filter(reply_message):
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 10)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 10)
|
||||
return
|
||||
weapon_name = weaponToName(weapon_name)
|
||||
player_gacha_info = await self.gacha_db.get(user.id)
|
||||
for rate_up_items5 in banner.rate_up_items5:
|
||||
weapon = WEAPON_DATA.get(str(rate_up_items5))
|
||||
if weapon is None:
|
||||
continue
|
||||
if weapon["name"] == weapon_name:
|
||||
player_gacha_info.event_weapon_banner.wish_item_id = rate_up_items5
|
||||
if weapon_name in up_weapons:
|
||||
player_gacha_info.event_weapon_banner.wish_item_id = up_weapons[weapon_name]
|
||||
player_gacha_info.event_weapon_banner.failed_chosen_item_pulls = 0
|
||||
break
|
||||
else:
|
||||
reply_message = await message.reply_text(f"没有找到 {weapon_name} 武器或该武器不存在UP卡池中")
|
||||
reply_message = await message.reply_text(
|
||||
f"输入的参数不正确,可能是没有名为 {weapon_name} 的武器或该武器不存在当前 UP 卡池中\n{up_weapons_text}"
|
||||
)
|
||||
if filters.ChatType.GROUPS.filter(reply_message):
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 10)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 10)
|
||||
|
@ -232,7 +232,17 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
client = await get_genshin_client(user.id, need_cookie=False)
|
||||
context.chat_data["uid"] = client.uid
|
||||
except UserNotFoundError:
|
||||
await message.reply_text("你还没有导入抽卡记录哦~")
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return ConversationHandler.END
|
||||
_, status = await self.gacha_log.load_history_info(str(user.id), str(client.uid), only_status=True)
|
||||
if not status:
|
||||
@ -275,11 +285,7 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
status = await self.gacha_log.remove_history_info(str(cid), str(client.uid))
|
||||
await message.reply_text("抽卡记录已强制删除" if status else "抽卡记录删除失败")
|
||||
except GachaLogNotFound:
|
||||
await message.reply_text("派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~")
|
||||
except GachaLogAccountNotFound:
|
||||
await message.reply_text("导入失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同")
|
||||
except GachaLogFileError:
|
||||
await message.reply_text("导入失败,数据格式错误")
|
||||
await message.reply_text("该用户还没有导入抽卡记录")
|
||||
except UserNotFoundError:
|
||||
await message.reply_text("该用户暂未绑定账号")
|
||||
except (ValueError, IndexError):
|
||||
@ -300,18 +306,26 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
await message.reply_chat_action(ChatAction.UPLOAD_DOCUMENT)
|
||||
await message.reply_document(document=open(path, "rb+"), caption="抽卡记录导出文件 - UIGF V2.2")
|
||||
except GachaLogNotFound:
|
||||
await message.reply_text("派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~")
|
||||
buttons = [
|
||||
[InlineKeyboardButton("点我导入", url=f"https://t.me/{context.bot.username}?start=gacha_log_import")]
|
||||
]
|
||||
await message.reply_text("派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
except GachaLogAccountNotFound:
|
||||
await message.reply_text("导入失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同")
|
||||
except GachaLogFileError:
|
||||
await message.reply_text("导入失败,数据格式错误")
|
||||
except UserNotFoundError:
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
|
||||
@handler(CommandHandler, command="gacha_log", block=False)
|
||||
@handler(MessageHandler, filters=filters.Regex("^抽卡记录(.*)"), block=False)
|
||||
@ -343,15 +357,14 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
)
|
||||
await png_data.reply_photo(message)
|
||||
except GachaLogNotFound:
|
||||
await message.reply_text("派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~")
|
||||
except GachaLogAccountNotFound:
|
||||
await message.reply_text("导入失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同")
|
||||
except GachaLogFileError:
|
||||
await message.reply_text("导入失败,数据格式错误")
|
||||
buttons = [
|
||||
[InlineKeyboardButton("点我导入", url=f"https://t.me/{context.bot.username}?start=gacha_log_import")]
|
||||
]
|
||||
await message.reply_text("派蒙没有找到你的抽卡记录,快来点击按钮私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
except UserNotFoundError:
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -359,7 +372,7 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
|
||||
@handler(CommandHandler, command="gacha_count", block=True)
|
||||
@handler(MessageHandler, filters=filters.Regex("^抽卡统计(.*)"), block=True)
|
||||
@ -403,15 +416,14 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
else:
|
||||
await png_data.reply_photo(message)
|
||||
except GachaLogNotFound:
|
||||
await message.reply_text("派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~")
|
||||
except GachaLogAccountNotFound:
|
||||
await message.reply_text("导入失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同")
|
||||
except GachaLogFileError:
|
||||
await message.reply_text("导入失败,数据格式错误")
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
buttons = [
|
||||
[InlineKeyboardButton("点我导入", url=f"https://t.me/{context.bot.username}?start=gacha_log_import")]
|
||||
]
|
||||
await message.reply_text("派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
except (UserNotFoundError):
|
||||
logger.info(f"未查询到用户({user.full_name} {user.id}) 所绑定的账号信息")
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -419,4 +431,4 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
|
@ -124,8 +124,8 @@ class Ledger(Plugin, BasePlugin):
|
||||
client = await get_genshin_client(user.id)
|
||||
render_result = await self._start_get_ledger(client, month)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -133,10 +133,10 @@ class Ledger(Plugin, BasePlugin):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
except DataNotPublic:
|
||||
reply_message = await message.reply_text("查询失败惹,可能是旅行札记功能被禁用了?")
|
||||
reply_message = await message.reply_text("查询失败惹,可能是旅行札记功能被禁用了?请先通过米游社或者 hoyolab 获取一次旅行札记后重试。")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
|
@ -57,10 +57,8 @@ class PlayerCards(Plugin, BasePlugin):
|
||||
return "Enka.Network 服务请求超时,请稍后重试"
|
||||
except HTTPException:
|
||||
return "Enka.Network HTTP 服务请求错误,请稍后重试"
|
||||
except UIDNotFounded:
|
||||
return "UID 未找到"
|
||||
except VaildateUIDError:
|
||||
return "UID 未找到"
|
||||
except (UIDNotFounded, VaildateUIDError):
|
||||
return "UID 未找到,可能为服务器抽风,请稍后重试"
|
||||
|
||||
@handler(CommandHandler, command="player_card", block=False)
|
||||
@handler(MessageHandler, filters=filters.Regex("^角色卡片查询(.*)"), block=False)
|
||||
@ -78,8 +76,8 @@ class PlayerCards(Plugin, BasePlugin):
|
||||
else:
|
||||
uid = user_info.genshin_uid
|
||||
except UserNotFoundError:
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -87,14 +85,14 @@ class PlayerCards(Plugin, BasePlugin):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
data = await self._fetch_user(uid)
|
||||
if isinstance(data, str):
|
||||
await message.reply_text(data)
|
||||
return
|
||||
if data.characters is None:
|
||||
await message.reply_text("请先将角色加入到角色展柜并允许查看角色详情")
|
||||
await message.reply_text("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试")
|
||||
return
|
||||
if len(args) == 1:
|
||||
character_name = roleToName(args[0])
|
||||
@ -120,7 +118,7 @@ class PlayerCards(Plugin, BasePlugin):
|
||||
else:
|
||||
photo = open("resources/img/kitsune.png", "rb")
|
||||
reply_message = await message.reply_photo(
|
||||
photo=photo, caption="请选择你要查询的角色", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
photo=photo, caption="请选择你要查询的角色,部分角色数据存在缓存,更新可能不及时", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
if reply_message.photo:
|
||||
self.temp_photo = reply_message.photo[-1].file_id
|
||||
@ -129,7 +127,7 @@ class PlayerCards(Plugin, BasePlugin):
|
||||
if characters.name == character_name:
|
||||
break
|
||||
else:
|
||||
await message.reply_text(f"角色展柜中未找到 {character_name}")
|
||||
await message.reply_text(f"角色展柜中未找到 {character_name} ,请检查角色是否存在于角色展柜中,或者等待角色数据更新后重试")
|
||||
return
|
||||
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
||||
render_result = await RenderTemplate(uid, characters, self.template_service).render() # pylint: disable=W0631
|
||||
@ -161,13 +159,13 @@ class PlayerCards(Plugin, BasePlugin):
|
||||
await message.reply_text(data)
|
||||
return
|
||||
if data.characters is None:
|
||||
await message.edit_text("请先将角色加入到角色展柜并允许查看角色详情")
|
||||
await message.edit_text("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试")
|
||||
return
|
||||
for characters in data.characters:
|
||||
if characters.name == result:
|
||||
break
|
||||
else:
|
||||
await message.edit_text(f"角色展柜中未找到 {result}")
|
||||
await message.edit_text(f"角色展柜中未找到 {result} ,请检查角色是否存在于角色展柜中,或者等待角色数据更新后重试")
|
||||
return
|
||||
await callback_query.answer(text="正在渲染图片中 请稍等 请不要重复点击按钮", show_alert=False)
|
||||
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
|
||||
|
@ -284,8 +284,8 @@ class Sign(Plugin, BasePlugin):
|
||||
if filters.ChatType.GROUPS.filter(reply_message):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id)
|
||||
except (UserNotFoundError, CookiesNotFoundError):
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -293,5 +293,4 @@ class Sign(Plugin, BasePlugin):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
return
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
|
@ -54,8 +54,8 @@ class UserStatsPlugins(Plugin, BasePlugin):
|
||||
client, uid = await get_public_genshin_client(user.id)
|
||||
render_result = await self.render(client, uid)
|
||||
except UserNotFoundError:
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
buttons = [[InlineKeyboardButton("点我私聊", url=f"https://t.me/{context.bot.username}?start=set_uid")]]
|
||||
reply_message = await message.reply_text(
|
||||
"未查询到您所绑定的账号信息,请先私聊派蒙绑定账号", reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
@ -63,7 +63,7 @@ class UserStatsPlugins(Plugin, BasePlugin):
|
||||
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
else:
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
except TooManyRequestPublicCookies:
|
||||
await message.reply_text("用户查询次数过多 请稍后重试")
|
||||
|
@ -19,18 +19,18 @@ class StartPlugin(Plugin):
|
||||
f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}\n"
|
||||
f"{escape_markdown('发送 /help 命令即可查看命令帮助')}"
|
||||
)
|
||||
return
|
||||
elif args[0] == "set_cookie":
|
||||
await message.reply_markdown_v2(
|
||||
f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}\n"
|
||||
f"{escape_markdown('发送 /setcookie 命令进入绑定账号流程')}"
|
||||
)
|
||||
return
|
||||
elif args[0] == "set_uid":
|
||||
await message.reply_markdown_v2(
|
||||
f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}\n"
|
||||
f"{escape_markdown('发送 /setuid 或 /setcookie 命令进入绑定账号流程')}"
|
||||
)
|
||||
else:
|
||||
await message.reply_html(f"你好 {user.mention_html()} !我是派蒙 !\n请点击 /{args[0]} 命令进入对应流程")
|
||||
return
|
||||
await message.reply_markdown_v2(f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是派蒙 !')}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user