diff --git a/.env.example b/.env.example index 5533906b..81103511 100644 --- a/.env.example +++ b/.env.example @@ -81,4 +81,7 @@ LOGGER_FILTERED_NAMES=["uvicorn","ErrorPush","ApiHelper"] # ERROR_SENTRY_DSN= # Notice -NOTICE_USER_MISMATCH="再乱点我叫西风骑士团、千岩军、天领奉行、三十人团和风纪官了!" \ No newline at end of file +NOTICE_USER_MISMATCH="再乱点我叫西风骑士团、千岩军、天领奉行、三十人团和风纪官了!" + +# Plugin +# PLUGIN_DOWNLOAD_FILE_MAX_SIZE=5 diff --git a/core/config.py b/core/config.py index 9c928d8d..8c626577 100644 --- a/core/config.py +++ b/core/config.py @@ -104,6 +104,13 @@ class NoticeConfig(Settings): env_prefix = "notice_" +class PluginConfig(Settings): + download_file_max_size: int = 5 + + class Config(Settings.Config): + env_prefix = "plugin_" + + class BotConfig(Settings): debug: bool = False @@ -134,6 +141,7 @@ class BotConfig(Settings): mtproto: MTProtoConfig = MTProtoConfig() error: ErrorConfig = ErrorConfig() notice: NoticeConfig = NoticeConfig() + plugin: PluginConfig = PluginConfig() BotConfig.update_forward_refs() diff --git a/plugins/genshin/gacha/gacha_log.py b/plugins/genshin/gacha/gacha_log.py index c6dc4216..c69495d0 100644 --- a/plugins/genshin/gacha/gacha_log.py +++ b/plugins/genshin/gacha/gacha_log.py @@ -11,6 +11,7 @@ from telegram.helpers import create_deep_linked_url from core.base.assets import AssetsService from core.baseplugin import BasePlugin +from core.config import config from core.cookies import CookiesService from core.cookies.error import CookiesNotFoundError from core.plugin import Plugin, handler, conversation @@ -115,8 +116,8 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation): else: await message.reply_text("文件格式错误,请发送符合 UIGF 标准的抽卡记录文件或者 paimon.moe、非小酋导出的 xlsx 格式的抽卡记录文件") return - if document.file_size > 2 * 1024 * 1024: - await message.reply_text("文件过大,请发送小于 2 MB 的文件") + if document.file_size > config.plugin.download_file_max_size * 1024 * 1024: + await message.reply_text(f"文件过大,请发送小于 {config.plugin.download_file_max_size} MB 的文件") return try: out = BytesIO()