mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🎨 Add Download File Size Setting
This commit is contained in:
parent
73d204d497
commit
38cd0925d0
@ -82,3 +82,6 @@ LOGGER_FILTERED_NAMES=["uvicorn","ErrorPush","ApiHelper"]
|
||||
|
||||
# Notice
|
||||
NOTICE_USER_MISMATCH="再乱点我叫西风骑士团、千岩军、天领奉行、三十人团和风纪官了!"
|
||||
|
||||
# Plugin
|
||||
# PLUGIN_DOWNLOAD_FILE_MAX_SIZE=5
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user