Disabled WIP warning
This commit is contained in:
parent
5b1afe2c9e
commit
05042f01c6
@ -17,146 +17,144 @@ from classes.enums.submission_types import SubmissionType
|
|||||||
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
||||||
async def get_submission(_: Client, msg: Message):
|
async def get_submission(_: Client, msg: Message):
|
||||||
|
|
||||||
locale("sub_wip", "message", locale=msg.from_user.language_code)
|
try:
|
||||||
|
|
||||||
# try:
|
if col_banned.find_one( {"user": msg.from_user.id} ) is not None:
|
||||||
|
return
|
||||||
|
|
||||||
# if col_banned.find_one( {"user": msg.from_user.id} ) is not None:
|
user_locale = msg.from_user.language_code
|
||||||
# return
|
save_tmp = True
|
||||||
|
contents = None
|
||||||
|
|
||||||
# user_locale = msg.from_user.language_code
|
if subLimited(msg.from_user):
|
||||||
# save_tmp = True
|
await msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission"))))
|
||||||
# contents = None
|
return
|
||||||
|
|
||||||
# if subLimited(msg.from_user):
|
if msg.document is not None:
|
||||||
# await msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission"))))
|
if msg.document.mime_type not in configGet("mime_types", "submission"):
|
||||||
# return
|
await msg.reply_text(locale("mime_not_allowed", "message", locale=user_locale), quote=True)
|
||||||
|
return
|
||||||
|
if msg.document.file_size > configGet("file_size", "submission"):
|
||||||
|
await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
||||||
|
return
|
||||||
|
if msg.document.file_size > configGet("tmp_size", "submission"):
|
||||||
|
save_tmp = False
|
||||||
|
contents = msg.document.file_id, SubmissionType.DOCUMENT #, msg.document.file_name
|
||||||
|
|
||||||
# if msg.document is not None:
|
if msg.video is not None:
|
||||||
# if msg.document.mime_type not in configGet("mime_types", "submission"):
|
if msg.video.file_size > configGet("file_size", "submission"):
|
||||||
# await msg.reply_text(locale("mime_not_allowed", "message", locale=user_locale), quote=True)
|
await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
||||||
# return
|
return
|
||||||
# if msg.document.file_size > configGet("file_size", "submission"):
|
if msg.video.file_size > configGet("tmp_size", "submission"):
|
||||||
# await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
save_tmp = False
|
||||||
# return
|
contents = msg.video.file_id, SubmissionType.VIDEO #, msg.video.file_name
|
||||||
# if msg.document.file_size > configGet("tmp_size", "submission"):
|
|
||||||
# save_tmp = False
|
|
||||||
# contents = msg.document.file_id, SubmissionType.DOCUMENT #, msg.document.file_name
|
|
||||||
|
|
||||||
# if msg.video is not None:
|
if msg.animation is not None:
|
||||||
# if msg.video.file_size > configGet("file_size", "submission"):
|
if msg.animation.file_size > configGet("file_size", "submission"):
|
||||||
# await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
||||||
# return
|
return
|
||||||
# if msg.video.file_size > configGet("tmp_size", "submission"):
|
if msg.animation.file_size > configGet("tmp_size", "submission"):
|
||||||
# save_tmp = False
|
save_tmp = False
|
||||||
# contents = msg.video.file_id, SubmissionType.VIDEO #, msg.video.file_name
|
contents = msg.animation.file_id, SubmissionType.ANIMATION #, msg.animation.file_name
|
||||||
|
|
||||||
# if msg.animation is not None:
|
if msg.photo is not None:
|
||||||
# if msg.animation.file_size > configGet("file_size", "submission"):
|
contents = msg.photo.file_id, SubmissionType.PHOTO #, "please_generate"
|
||||||
# await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
|
||||||
# return
|
|
||||||
# if msg.animation.file_size > configGet("tmp_size", "submission"):
|
|
||||||
# save_tmp = False
|
|
||||||
# contents = msg.animation.file_id, SubmissionType.ANIMATION #, msg.animation.file_name
|
|
||||||
|
|
||||||
# if msg.photo is not None:
|
if save_tmp is not None:
|
||||||
# contents = msg.photo.file_id, SubmissionType.PHOTO #, "please_generate"
|
|
||||||
|
|
||||||
# if save_tmp is not None:
|
if contents is None:
|
||||||
|
return
|
||||||
|
|
||||||
# if contents is None:
|
tmp_id = str(uuid4())
|
||||||
# return
|
# filename = tmp_id if contents[1] == "please_generate" else contents[1]
|
||||||
|
makedirs(path.join(configGet("data", "locations"), "submissions", tmp_id), exist_ok=True)
|
||||||
# tmp_id = str(uuid4())
|
downloaded = await app.download_media(msg, path.join(configGet("data", "locations"), "submissions", tmp_id)+sep)
|
||||||
# # filename = tmp_id if contents[1] == "please_generate" else contents[1]
|
inserted = col_submitted.insert_one(
|
||||||
# makedirs(path.join(configGet("data", "locations"), "submissions", tmp_id), exist_ok=True)
|
{
|
||||||
# downloaded = await app.download_media(msg, path.join(configGet("data", "locations"), "submissions", tmp_id)+sep)
|
"user": msg.from_user.id,
|
||||||
# inserted = col_submitted.insert_one(
|
"date": datetime.now(tz=timezone.utc),
|
||||||
# {
|
"done": False,
|
||||||
# "user": msg.from_user.id,
|
"type": contents[1].value,
|
||||||
# "date": datetime.now(tz=timezone.utc),
|
"temp": {
|
||||||
# "done": False,
|
"uuid": tmp_id,
|
||||||
# "type": contents[1].value,
|
"file": path.basename(str(downloaded))
|
||||||
# "temp": {
|
},
|
||||||
# "uuid": tmp_id,
|
"telegram": {
|
||||||
# "file": path.basename(str(downloaded))
|
"msg_id": msg.id,
|
||||||
# },
|
"file_id": contents[0]
|
||||||
# "telegram": {
|
},
|
||||||
# "msg_id": msg.id,
|
"caption": str(msg.caption) if msg.caption is not None else None
|
||||||
# "file_id": contents[0]
|
}
|
||||||
# },
|
)
|
||||||
# "caption": str(msg.caption) if msg.caption is not None else None
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
|
|
||||||
# else:
|
else:
|
||||||
|
|
||||||
# if contents is None:
|
if contents is None:
|
||||||
# return
|
return
|
||||||
|
|
||||||
# inserted = col_submitted.insert_one(
|
inserted = col_submitted.insert_one(
|
||||||
# {
|
{
|
||||||
# "user": msg.from_user.id,
|
"user": msg.from_user.id,
|
||||||
# "date": datetime.now(tz=timezone.utc),
|
"date": datetime.now(tz=timezone.utc),
|
||||||
# "done": False,
|
"done": False,
|
||||||
# "type": contents[1].value,
|
"type": contents[1].value,
|
||||||
# "temp": {
|
"temp": {
|
||||||
# "uuid": None,
|
"uuid": None,
|
||||||
# "file": None
|
"file": None
|
||||||
# },
|
},
|
||||||
# "telegram": {
|
"telegram": {
|
||||||
# "msg_id": msg.id,
|
"msg_id": msg.id,
|
||||||
# "file_id": contents[0]
|
"file_id": contents[0]
|
||||||
# },
|
},
|
||||||
# "caption": str(msg.caption) if msg.caption is not None else None
|
"caption": str(msg.caption) if msg.caption is not None else None
|
||||||
# }
|
}
|
||||||
# )
|
)
|
||||||
|
|
||||||
# buttons = [
|
buttons = [
|
||||||
# [
|
[
|
||||||
# InlineKeyboardButton(text=locale("sub_yes", "button", locale=configGet("locale")), callback_data=f"sub_yes_{str(inserted.inserted_id)}")
|
InlineKeyboardButton(text=locale("sub_yes", "button", locale=configGet("locale")), callback_data=f"sub_yes_{str(inserted.inserted_id)}")
|
||||||
# ]
|
]
|
||||||
# ]
|
]
|
||||||
|
|
||||||
# if msg.caption is not None:
|
if msg.caption is not None:
|
||||||
# caption = str(msg.caption)
|
caption = str(msg.caption)
|
||||||
# buttons[0].append(
|
buttons[0].append(
|
||||||
# InlineKeyboardButton(text=locale("sub_yes_caption", "button", locale=configGet("locale")), callback_data=f"sub_yes_{str(inserted.inserted_id)}_caption")
|
InlineKeyboardButton(text=locale("sub_yes_caption", "button", locale=configGet("locale")), callback_data=f"sub_yes_{str(inserted.inserted_id)}_caption")
|
||||||
# )
|
)
|
||||||
# buttons[0].append(
|
buttons[0].append(
|
||||||
# InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{str(inserted.inserted_id)}")
|
InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{str(inserted.inserted_id)}")
|
||||||
# )
|
)
|
||||||
# else:
|
else:
|
||||||
# caption = ""
|
caption = ""
|
||||||
# buttons[0].append(
|
buttons[0].append(
|
||||||
# InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{str(inserted.inserted_id)}")
|
InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{str(inserted.inserted_id)}")
|
||||||
# )
|
)
|
||||||
|
|
||||||
# caption += locale("sub_by", "message", locale=locale(configGet("locale")))
|
caption += locale("sub_by", "message", locale=locale(configGet("locale")))
|
||||||
|
|
||||||
# if msg.from_user.first_name is not None:
|
if msg.from_user.first_name is not None:
|
||||||
# caption += f" {msg.from_user.first_name}"
|
caption += f" {msg.from_user.first_name}"
|
||||||
# if msg.from_user.last_name is not None:
|
if msg.from_user.last_name is not None:
|
||||||
# caption += f" {msg.from_user.last_name}"
|
caption += f" {msg.from_user.last_name}"
|
||||||
# if msg.from_user.username is not None:
|
if msg.from_user.username is not None:
|
||||||
# caption += f" (@{msg.from_user.username})"
|
caption += f" (@{msg.from_user.username})"
|
||||||
# if msg.from_user.phone_number is not None:
|
if msg.from_user.phone_number is not None:
|
||||||
# caption += f" ({msg.from_user.phone_number})"
|
caption += f" ({msg.from_user.phone_number})"
|
||||||
|
|
||||||
# if msg.from_user.id != configGet("admin"):
|
if msg.from_user.id != configGet("admin"):
|
||||||
# buttons += [
|
buttons += [
|
||||||
# [
|
[
|
||||||
# InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}")
|
InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}")
|
||||||
# ]
|
]
|
||||||
# # [
|
# [
|
||||||
# # InlineKeyboardButton(text=locale("sub_unblock", "button", locale=configGet("locale")), callback_data=f"sub_unblock_{msg.from_user.id}")
|
# InlineKeyboardButton(text=locale("sub_unblock", "button", locale=configGet("locale")), callback_data=f"sub_unblock_{msg.from_user.id}")
|
||||||
# # ]
|
# ]
|
||||||
# ]
|
]
|
||||||
|
|
||||||
# await msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
await msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
||||||
# subLimit(msg.from_user)
|
subLimit(msg.from_user)
|
||||||
|
|
||||||
# await msg.copy(configGet("admin"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
|
await msg.copy(configGet("admin"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
|
||||||
|
|
||||||
# except AttributeError:
|
except AttributeError:
|
||||||
# logWrite(f"from_user in function get_submission does not seem to contain id")
|
logWrite(f"from_user in function get_submission does not seem to contain id")
|
Reference in New Issue
Block a user