2023-01-10 13:52:44 +02:00
|
|
|
from pyrogram import filters
|
|
|
|
from pyrogram.client import Client
|
|
|
|
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
|
|
|
|
from modules.utils import jsonLoad, configGet, locale
|
|
|
|
from modules.logging import logWrite
|
|
|
|
from modules.app import app
|
|
|
|
from modules.submissions import subLimited, subLimit
|
|
|
|
|
|
|
|
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
2023-01-10 14:06:24 +02:00
|
|
|
async def get_submission(_: Client, msg: Message):
|
|
|
|
|
2023-01-10 13:52:44 +02:00
|
|
|
try:
|
2023-01-10 14:06:24 +02:00
|
|
|
|
2023-01-10 13:52:44 +02:00
|
|
|
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
|
2023-01-10 14:06:24 +02:00
|
|
|
|
2023-01-10 13:52:44 +02:00
|
|
|
user_locale = msg.from_user.language_code
|
2023-01-10 14:06:24 +02:00
|
|
|
|
2023-01-10 13:52:44 +02:00
|
|
|
if not subLimited(msg.from_user):
|
|
|
|
|
|
|
|
if msg.document != None:
|
|
|
|
if msg.document.mime_type not in configGet("mime_types", "submission"):
|
2023-01-10 14:06:24 +02:00
|
|
|
await msg.reply_text(locale("mime_not_allowed", "message", locale=user_locale), quote=True)
|
2023-01-10 13:52:44 +02:00
|
|
|
return
|
|
|
|
if msg.document.file_size > configGet("file_size", "submission"):
|
2023-01-10 14:06:24 +02:00
|
|
|
await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
2023-01-10 13:52:44 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
if msg.video != None:
|
|
|
|
if msg.video.file_size > configGet("file_size", "submission"):
|
2023-01-10 14:06:24 +02:00
|
|
|
await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
2023-01-10 13:52:44 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
buttons = [
|
|
|
|
[
|
|
|
|
InlineKeyboardButton(text=locale("sub_yes", "button", locale=configGet("locale")), callback_data=f"sub_yes_{msg.from_user.id}_{msg.id}")
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
if msg.caption != None:
|
|
|
|
caption = str(msg.caption)
|
|
|
|
buttons[0].append(
|
|
|
|
InlineKeyboardButton(text=locale("sub_yes_caption", "button", locale=configGet("locale")), callback_data=f"sub_yes_{msg.from_user.id}_{msg.id}_caption")
|
|
|
|
)
|
|
|
|
buttons[0].append(
|
|
|
|
InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{msg.from_user.id}_{msg.id}")
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
caption = ""
|
|
|
|
buttons[0].append(
|
|
|
|
InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{msg.from_user.id}_{msg.id}")
|
|
|
|
)
|
|
|
|
|
|
|
|
caption += locale("sub_by", "message", locale=locale(configGet("locale")))
|
|
|
|
|
|
|
|
if msg.from_user.first_name != None:
|
|
|
|
caption += f" {msg.from_user.first_name}"
|
|
|
|
if msg.from_user.last_name != None:
|
|
|
|
caption += f" {msg.from_user.last_name}"
|
|
|
|
if msg.from_user.username != None:
|
|
|
|
caption += f" (@{msg.from_user.username})"
|
|
|
|
if msg.from_user.phone_number != None:
|
|
|
|
caption += f" ({msg.from_user.phone_number})"
|
|
|
|
|
2023-01-10 14:06:24 +02:00
|
|
|
await msg.copy(configGet("admin"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
|
2023-01-10 13:52:44 +02:00
|
|
|
|
|
|
|
if msg.from_user.id != configGet("admin"):
|
|
|
|
buttons += [
|
|
|
|
[
|
|
|
|
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}")
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2023-01-10 14:06:24 +02:00
|
|
|
await msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
2023-01-10 13:52:44 +02:00
|
|
|
subLimit(msg.from_user)
|
|
|
|
|
|
|
|
else:
|
2023-01-10 14:06:24 +02:00
|
|
|
await msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission"))))
|
|
|
|
|
2023-01-10 13:52:44 +02:00
|
|
|
except AttributeError:
|
|
|
|
logWrite(f"from_user in function get_submission does not seem to contain id")
|