Improved logging

This commit is contained in:
2023-03-17 14:13:28 +01:00
parent 95351f247c
commit 717586a9f0
3 changed files with 39 additions and 1 deletions

View File

@@ -43,6 +43,10 @@ async def get_submission(app: PosterClient, msg: Message):
return
if msg.document is not None:
logWrite(
f"User {msg.from_user.id} is trying to submit a file of type '{msg.document.mime_type}' with name '{msg.document.file_name}' and size of {msg.document.file_size / 1024 / 1024} MB",
debug=True,
)
if msg.document.mime_type not in configGet("mime_types", "submission"):
await msg.reply_text(
locale("mime_not_allowed", "message", locale=user_locale),
@@ -65,6 +69,10 @@ async def get_submission(app: PosterClient, msg: Message):
) # , msg.document.file_name
if msg.video is not None:
logWrite(
f"User {msg.from_user.id} is trying to submit a video with name '{msg.video.file_name}' and size of {msg.video.file_size / 1024 / 1024} MB",
debug=True,
)
if msg.video.file_size > configGet("file_size", "submission"):
await msg.reply_text(
locale("document_too_large", "message", locale=user_locale).format(
@@ -78,6 +86,10 @@ async def get_submission(app: PosterClient, msg: Message):
contents = msg.video.file_id, SubmissionType.VIDEO # , msg.video.file_name
if msg.animation is not None:
logWrite(
f"User {msg.from_user.id} is trying to submit an animation with name '{msg.animation.file_name}' and size of {msg.animation.file_size / 1024 / 1024} MB",
debug=True,
)
if msg.animation.file_size > configGet("file_size", "submission"):
await msg.reply_text(
locale("document_too_large", "message", locale=user_locale).format(
@@ -94,6 +106,10 @@ async def get_submission(app: PosterClient, msg: Message):
) # , msg.animation.file_name
if msg.photo is not None:
logWrite(
f"User {msg.from_user.id} is trying to submit a photo with ID '{msg.photo.file_id}' and size of {msg.photo.file_size / 1024 / 1024} MB",
debug=True,
)
contents = msg.photo.file_id, SubmissionType.PHOTO # , "please_generate"
if save_tmp is not None: