🎨 Add Download File Size Setting

This commit is contained in:
omg-xtao 2023-02-18 13:03:58 +08:00 committed by GitHub
parent 73d204d497
commit 38cd0925d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -81,4 +81,7 @@ LOGGER_FILTERED_NAMES=["uvicorn","ErrorPush","ApiHelper"]
# ERROR_SENTRY_DSN= # ERROR_SENTRY_DSN=
# Notice # Notice
NOTICE_USER_MISMATCH="再乱点我叫西风骑士团、千岩军、天领奉行、三十人团和风纪官了!" NOTICE_USER_MISMATCH="再乱点我叫西风骑士团、千岩军、天领奉行、三十人团和风纪官了!"
# Plugin
# PLUGIN_DOWNLOAD_FILE_MAX_SIZE=5

View File

@ -104,6 +104,13 @@ class NoticeConfig(Settings):
env_prefix = "notice_" env_prefix = "notice_"
class PluginConfig(Settings):
download_file_max_size: int = 5
class Config(Settings.Config):
env_prefix = "plugin_"
class BotConfig(Settings): class BotConfig(Settings):
debug: bool = False debug: bool = False
@ -134,6 +141,7 @@ class BotConfig(Settings):
mtproto: MTProtoConfig = MTProtoConfig() mtproto: MTProtoConfig = MTProtoConfig()
error: ErrorConfig = ErrorConfig() error: ErrorConfig = ErrorConfig()
notice: NoticeConfig = NoticeConfig() notice: NoticeConfig = NoticeConfig()
plugin: PluginConfig = PluginConfig()
BotConfig.update_forward_refs() BotConfig.update_forward_refs()

View File

@ -11,6 +11,7 @@ from telegram.helpers import create_deep_linked_url
from core.base.assets import AssetsService from core.base.assets import AssetsService
from core.baseplugin import BasePlugin from core.baseplugin import BasePlugin
from core.config import config
from core.cookies import CookiesService from core.cookies import CookiesService
from core.cookies.error import CookiesNotFoundError from core.cookies.error import CookiesNotFoundError
from core.plugin import Plugin, handler, conversation from core.plugin import Plugin, handler, conversation
@ -115,8 +116,8 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
else: else:
await message.reply_text("文件格式错误,请发送符合 UIGF 标准的抽卡记录文件或者 paimon.moe、非小酋导出的 xlsx 格式的抽卡记录文件") await message.reply_text("文件格式错误,请发送符合 UIGF 标准的抽卡记录文件或者 paimon.moe、非小酋导出的 xlsx 格式的抽卡记录文件")
return return
if document.file_size > 2 * 1024 * 1024: if document.file_size > config.plugin.download_file_max_size * 1024 * 1024:
await message.reply_text("文件过大,请发送小于 2 MB 的文件") await message.reply_text(f"文件过大,请发送小于 {config.plugin.download_file_max_size} MB 的文件")
return return
try: try:
out = BytesIO() out = BytesIO()