💬 Refactor some prompt text

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: xtaodada <xtao@xtaolink.cn>
This commit is contained in:
Nahida 2024-06-07 22:58:13 +08:00 committed by GitHub
parent c1b401879a
commit f05c332a45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 32 additions and 21 deletions

View File

@ -95,7 +95,11 @@ LOGGER_FILTERED_NAMES=["uvicorn","ErrorPush","ApiHelper"]
# ERROR_SENTRY_DSN=
# Notice
NOTICE_USER_MISMATCH="再乱点我叫西风骑士团、千岩军、天领奉行、三十人团和风纪官了!"
NOTICE_BOT_NAME="彦卿"
NOTICE_USER_NOT_FOUND="${NOTICE_BOT_NAME}没有找到您所绑定的账号信息,请先私聊${NOTICE_BOT_NAME}绑定账号"
NOTICE_USER_MISMATCH="再乱点我叫银鬃铁卫、云骑军和猎犬家族了!"
# 拒绝加入群聊
NOTICE_QUIT_STATUS="${NOTICE_BOT_NAME}不想进去!不是开拓者的邀请!"
# Plugin
# PLUGIN_DOWNLOAD_FILE_MAX_SIZE=5

@ -1 +1 @@
Subproject commit b1399182760c135ed8fe2479e329abb3084c7abb
Subproject commit 213ae6eda5b29da7f736b1a393771195158c26dc

View File

@ -2,6 +2,7 @@ from telegram import Update, ReplyKeyboardRemove
from telegram.ext import CallbackContext, CommandHandler
from telegram.helpers import escape_markdown
from core.config import config
from core.plugin import handler, Plugin
from utils.log import logger
@ -16,7 +17,9 @@ class StartPlugin(Plugin):
logger.info("用户 %s[%s] 发出start命令 args[%s]", user.full_name, user.id, args_text)
if args is not None and len(args) >= 1:
return
await message.reply_markdown_v2(f"你好 {user.mention_markdown_v2()} {escape_markdown('!我是彦卿 ')}")
await message.reply_markdown_v2(
f"你好 {user.mention_markdown_v2()} {escape_markdown(f'!我是{config.notice.bot_name}')}"
)
@staticmethod
async def unknown_command(update: Update, _: CallbackContext) -> None:

View File

@ -5,6 +5,7 @@ from telegram.constants import ChatAction, ChatMemberStatus, ParseMode
from telegram.error import BadRequest, Forbidden
from telegram.ext import filters
from core.config import config
from core.plugin import Plugin, handler
from gram_core.services.channels.models import ChannelAliasDataBase as ChannelAlias
from gram_core.services.channels.services import ChannelAliasService
@ -19,13 +20,15 @@ if TYPE_CHECKING:
__all__ = ("ChannelAliasPlugin",)
CHANNEL_ALIAS_OPEN = """成功开启频道透视模式,彦卿将会把你当做普通用户,现在你可以使用频道身份执行命令
CHANNEL_ALIAS_OPEN = f"""成功开启频道透视模式,{config.notice.bot_name}将会把你当做普通用户,现在你可以使用频道身份执行命令
- 此功能可能使其他人能看到你的个人账号身份
- 此功能开启后对所有群组均有效
- 在转让频道前请务必关闭此功能
"""
CHANNEL_ALIAS_CLOSE = """成功关闭频道透视模式,彦卿将不会把你当做普通用户,现在你无法使用频道身份执行命令"""
CHANNEL_ALIAS_CLOSE = (
f"""成功关闭频道透视模式,{config.notice.bot_name}将不会把你当做普通用户,现在你无法使用频道身份执行命令"""
)
CHANNEL_ADMIN_HELP = (
"参数错误,可用命令:\n\n- disable <id> 关闭频道透视模式\n- change <cid> <uid> 强制设置频道透视对应的用户 id"
)

View File

@ -85,7 +85,7 @@ class DailyNoteTasksPlugin(Plugin.Conversation):
except SimnetBadRequest as e:
return f"获取便签失败,可能遇到验证码风控,请尝试重新绑定账号。{e}"
except (CookiesNotFoundError, PlayerNotFoundError):
return "未查询到您所绑定的账号信息,请先私聊彦卿绑定账号"
return config.notice.user_not_found
@conversation.state(state=SET_BY_WEB)
@handler.message(filters=filters.TEXT & ~filters.COMMAND, block=False)

View File

@ -38,7 +38,7 @@ class Sign(Plugin):
try:
await self.genshin_helper.get_genshin_client(user_id)
except (PlayerNotFoundError, CookiesNotFoundError):
return "未查询到账号信息,请先私聊彦卿绑定账号"
return config.notice.user_not_found
user: SignUser = await self.sign_service.get_by_user_id(user_id)
if user:
if method == "关闭":

View File

@ -46,6 +46,8 @@ if TYPE_CHECKING:
from gram_core.services.template.models import RenderResult
INPUT_URL, INPUT_FILE, CONFIRM_DELETE = range(10100, 10103)
WAITING = f"{config.notice.bot_name}正在从服务器获取数据,请稍后"
WISHLOG_NOT_FOUND = f"{config.notice.bot_name}没有找到你的抽卡记录,快来私聊{config.notice.bot_name}导入吧~"
class WishLogPlugin(Plugin.Conversation):
@ -96,7 +98,7 @@ class WishLogPlugin(Plugin.Conversation):
new_num = await self.gacha_log.import_gacha_log_data(user.id, player_id, data, verify_uid)
return "更新完成,本次没有新增数据" if new_num == 0 else f"更新完成,本次共新增{new_num}条跃迁记录"
except GachaLogNotFound:
return "彦卿没有找到你的跃迁记录,快来私聊彦卿导入吧~"
return WISHLOG_NOT_FOUND
except GachaLogAccountNotFound:
return "导入失败,可能文件包含的跃迁记录所属 uid 与你当前绑定的 uid 不同"
except GachaLogFileError:
@ -109,7 +111,7 @@ class WishLogPlugin(Plugin.Conversation):
return "导入失败,你已经通过其他方式导入过跃迁记录了,本次无法导入"
except PlayerNotFoundError:
logger.info("未查询到用户 %s[%s] 所绑定的账号信息", user.full_name, user.id)
return "彦卿没有找到您所绑定的账号信息,请先私聊彦卿绑定账号"
return config.notice.user_not_found
async def import_from_file(self, user: User, message: Message, document: Document = None) -> None:
if not document:
@ -174,7 +176,7 @@ class WishLogPlugin(Plugin.Conversation):
parse_mode="html",
)
return INPUT_URL
text = "小彦卿正在从服务器获取数据,请稍后"
text = WAITING
if not args:
text += "\n\n> 由于你绑定的 Cookie 中存在 stoken ,本次通过 stoken 自动刷新数据"
reply = await message.reply_text(text)
@ -195,7 +197,7 @@ class WishLogPlugin(Plugin.Conversation):
await message.reply_text("请发送文件或链接")
return INPUT_URL
authkey = from_url_get_authkey(message.text)
reply = await message.reply_text("小彦卿正在从服务器获取数据,请稍后")
reply = await message.reply_text(WAITING)
await message.reply_chat_action(ChatAction.TYPING)
text = await self._refresh_user_data(user, authkey=authkey)
await reply.edit_text(text)
@ -213,7 +215,7 @@ class WishLogPlugin(Plugin.Conversation):
context.chat_data["uid"] = player_id
except PlayerNotFoundError:
logger.info("未查询到用户 %s[%s] 所绑定的账号信息", user.full_name, user.id)
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
await message.reply_text(config.notice.user_not_found)
return ConversationHandler.END
_, status = await self.gacha_log.load_history_info(str(user.id), str(player_id), only_status=True)
if not status:
@ -278,16 +280,14 @@ class WishLogPlugin(Plugin.Conversation):
buttons = [
[InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "warp_log_import"))]
]
await message.reply_text(
"彦卿没有找到你的跃迁记录,快来私聊彦卿导入吧~", reply_markup=InlineKeyboardMarkup(buttons)
)
await message.reply_text(WISHLOG_NOT_FOUND, reply_markup=InlineKeyboardMarkup(buttons))
except GachaLogAccountNotFound:
await message.reply_text("导入失败,可能文件包含的跃迁记录所属 uid 与你当前绑定的 uid 不同")
except GachaLogFileError:
await message.reply_text("导入失败,数据格式错误")
except PlayerNotFoundError:
logger.info("未查询到用户 %s[%s] 所绑定的账号信息", user.full_name, user.id)
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号")
await message.reply_text(config.notice.user_not_found)
async def rander_wish_log_analysis(
self, user_id: int, player_id: int, pool_type: StarRailBannerType
@ -394,7 +394,7 @@ class WishLogPlugin(Plugin.Conversation):
[InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "warp_log_import"))]
]
await message.reply_text(
"彦卿没有找到你此卡池的跃迁记录,快来点击按钮私聊彦卿导入吧~",
WISHLOG_NOT_FOUND,
reply_markup=InlineKeyboardMarkup(buttons),
)

View File

@ -80,7 +80,7 @@ class ChatMember(Plugin):
quit_status = True
if quit_status:
try:
await context.bot.send_message(chat.id, "彦卿不想进去!不是开拓者的邀请!")
await context.bot.send_message(chat.id, config.notice.quit_status)
except Forbidden as exc:
logger.info("发送消息失败 %s", exc.message)
except NetworkError as exc:
@ -90,7 +90,9 @@ class ChatMember(Plugin):
await context.bot.leave_chat(chat.id)
else:
try:
await context.bot.send_message(chat.id, "感谢邀请小彦卿到本群!请使用 /help 查看咱已经学会的功能。")
await context.bot.send_message(
chat.id, f"感谢邀请小{config.notice.bot_name}到本群!请使用 /help 查看咱已经学会的功能。"
)
except Forbidden as exc:
logger.info("发送消息失败 %s", exc.message)
except NetworkError as exc:

View File

@ -265,8 +265,7 @@ class ErrorHandler(Plugin):
context.error, (CookiesNotFoundError, PlayerNotFoundError, GenshinPlayerNotFoundError)
) or not isinstance(update, Update):
return
notice = "未查询到您所绑定的账号信息,请先私聊彦卿绑定账号"
self.create_notice_task(update, context, notice)
self.create_notice_task(update, context, config.notice.user_not_found)
raise ApplicationHandlerStop
@error_handler(block=False)