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.logger 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) async def get_submission(_: Client, msg: Message): try: if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")): user_locale = msg.from_user.language_code if not subLimited(msg.from_user): if msg.document != None: if msg.document.mime_type not in configGet("mime_types", "submission"): 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.video != None: if msg.video.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 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})" await msg.copy(configGet("admin"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons)) 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}") ] ] await msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True) subLimit(msg.from_user) else: await msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission")))) except AttributeError: logWrite(f"from_user in function get_submission does not seem to contain id")