Integrated previous commits
This commit is contained in:
@@ -4,9 +4,10 @@ from traceback import format_exc
|
||||
from uuid import uuid4
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
||||
from pyrogram.enums.chat_action import ChatAction
|
||||
from classes.exceptions import SubmissionDuplicatesError
|
||||
from classes.poster_client import PosterClient
|
||||
|
||||
from modules.app import app
|
||||
from modules.database import col_banned, col_submitted
|
||||
@@ -16,13 +17,15 @@ from modules.utils import configGet, locale
|
||||
from classes.enums.submission_types import SubmissionType
|
||||
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
||||
async def get_submission(_: Client, msg: Message):
|
||||
@app.on_message(~filters.scheduled & filters.private & filters.photo | filters.video | filters.animation | filters.document)
|
||||
async def get_submission(app: PosterClient, msg: Message):
|
||||
|
||||
try:
|
||||
|
||||
if col_banned.find_one( {"user": msg.from_user.id} ) is not None:
|
||||
return
|
||||
|
||||
await app.send_chat_action(msg.chat.id, ChatAction.TYPING)
|
||||
|
||||
user_locale = msg.from_user.language_code
|
||||
save_tmp = True
|
||||
@@ -74,7 +77,7 @@ async def get_submission(_: Client, msg: Message):
|
||||
inserted = col_submitted.insert_one(
|
||||
{
|
||||
"user": msg.from_user.id,
|
||||
"date": datetime.now(tz=timezone.utc),
|
||||
"date": datetime.now(),
|
||||
"done": False,
|
||||
"type": contents[1].value,
|
||||
"temp": {
|
||||
@@ -97,7 +100,7 @@ async def get_submission(_: Client, msg: Message):
|
||||
inserted = col_submitted.insert_one(
|
||||
{
|
||||
"user": msg.from_user.id,
|
||||
"date": datetime.now(tz=timezone.utc),
|
||||
"date": datetime.now(),
|
||||
"done": False,
|
||||
"type": contents[1].value,
|
||||
"temp": {
|
||||
@@ -143,31 +146,31 @@ async def get_submission(_: Client, msg: Message):
|
||||
if msg.from_user.phone_number is not None:
|
||||
caption += f" ({msg.from_user.phone_number})"
|
||||
|
||||
if msg.from_user.id == configGet("admin") and configGet("admins", "submission", "require_confirmation") is False:
|
||||
if msg.from_user.id in app.admins and configGet("admins", "submission", "require_confirmation") is False:
|
||||
try:
|
||||
await app.submit_photo(str(inserted.inserted_id))
|
||||
await msg.copy(configGet("admin"), caption=caption)
|
||||
await msg.copy(app.owner, caption=caption)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
await msg.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(exp.duplicates)))
|
||||
await msg.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(exp.duplicates)), quote=True)
|
||||
return
|
||||
except Exception as exp:
|
||||
await msg.reply_text(format_exc())
|
||||
return
|
||||
elif msg.from_user.id != configGet("admin") and configGet("users", "submission", "require_confirmation") is False:
|
||||
elif msg.from_user.id not in app.admins and configGet("users", "submission", "require_confirmation") is False:
|
||||
try:
|
||||
await app.submit_photo(str(inserted.inserted_id))
|
||||
await msg.copy(configGet("admin"), caption=caption)
|
||||
await msg.copy(app.owner, caption=caption)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
await msg.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(exp.duplicates)))
|
||||
await msg.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(exp.duplicates)), quote=True)
|
||||
return
|
||||
except Exception as exp:
|
||||
await app.send_message(configGet("admin"), f"User {msg.from_user.id} could not submit photo without additional confirmation due to:\n```\n{format_exc()}\n```")
|
||||
await app.send_message(app.owner, f"User {msg.from_user.id} could not submit photo without additional confirmation due to:\n```\n{format_exc()}\n```")
|
||||
await msg.reply_text("Could not upload this image. Admins are advised.")
|
||||
return
|
||||
|
||||
if msg.from_user.id != configGet("admin"):
|
||||
if msg.from_user.id not in app.admins:
|
||||
buttons += [
|
||||
[
|
||||
InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}")
|
||||
@@ -177,10 +180,12 @@ async def get_submission(_: Client, msg: Message):
|
||||
# ]
|
||||
]
|
||||
|
||||
await msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
||||
subLimit(msg.from_user)
|
||||
|
||||
await msg.copy(configGet("admin"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
|
||||
if msg.from_user.id != app.owner:
|
||||
await msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
||||
|
||||
await msg.copy(app.owner, caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
|
||||
|
||||
except AttributeError:
|
||||
logWrite(f"from_user in function get_submission does not seem to contain id")
|
Reference in New Issue
Block a user