Submission: stage 2

This commit is contained in:
Profitroll 2022-08-09 13:50:59 +02:00
parent 5d29bfeff4
commit e18af786cf

47
main.py
View File

@ -178,9 +178,56 @@ def subLimited(user):
@app.on_message(filters.photo | filters.video | filters.animation) @app.on_message(filters.photo | filters.video | filters.animation)
def get_submission(_, msg): def get_submission(_, msg):
if not subLimited(msg.from_user): if not subLimited(msg.from_user):
msg.copy(configGet("admin", "reports"), reply_markup=InlineKeyboardMarkup(
[
InlineKeyboardButton(text="✅ Accept", callback_data=f"sub_yes_{msg.from_user.id}_{msg.id}"),
InlineKeyboardButton(text="❌ Deny", callback_data=f"sub_no_{msg.from_user.id}_{msg.id}")
],
[
InlineKeyboardButton(text="☠️ Block sender", callback_data=f"sub_block_{msg.from_user.id}")
]
))
msg.reply_text(f"Media has been submitten.\nWe'll notify you whether it will be accepted or not soon.")
subLimit(msg.from_user) subLimit(msg.from_user)
else: else:
msg.reply_text(f'You can only submit 1 media per {configGet("limit", "submission")} seconds') msg.reply_text(f'You can only submit 1 media per {configGet("limit", "submission")} seconds')
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*_[\s\S]*")) # type: ignore
def callback_query_yes(app, clb): # type: ignore
fullclb = clb.data.split("_")
try:
submission = app.get_messages(fullclb[2], fullclb[3])
except:
clb.answer(text=f"Submission message no longer exist", show_alert=True)
return
try:
app.download_media(submission, file_name=configGet("queue", "locations")+os.sep)
except:
clb.answer(text=f"Could not download submission", show_alert=True)
return
submission.reply_text(f"✅ Submission approved and accepted")
clb.answer(text=f"✅ Submission approved", show_alert=True)
@app.on_callback_query(filters.regex("sub_no_[\s\S]*_[\s\S]*")) # type: ignore
def callback_query_no(app, clb): # type: ignore
fullclb = clb.data.split("_")
try:
submission = app.get_messages(fullclb[2], fullclb[3])
except:
clb.answer(text=f"Submission message no longer exist", show_alert=True)
return
submission.reply_text(f"❌ Submission reviewed and declined")
clb.answer(text=f"❌ Submission declined", show_alert=True)
@app.on_callback_query(filters.regex("sub_block_[\s\S]*")) # type: ignore
def callback_query_block(app, clb): # type: ignore
fullclb = clb.data.split("_")
app.send_message(fullclb[2], "You were blocked and you can't submit media anymore.")
blocked = app.block_user(fullclb[2])
if blocked:
clb.answer(text=f"User {fullclb[2]} has been blocked", show_alert=True)
else:
clb.answer(text=f"Could not block {fullclb[2]}", show_alert=True)
#=========================================================================================================================================== #===========================================================================================================================================