Fixed caption being added explicitly
This commit is contained in:
parent
c99f22b1b8
commit
818afa0b74
@ -139,7 +139,7 @@ class PyroClient(PyroClient):
|
|||||||
await super().stop()
|
await super().stop()
|
||||||
|
|
||||||
async def submit_media(
|
async def submit_media(
|
||||||
self, id: str
|
self, id: str, purge_caption: bool = False
|
||||||
) -> Tuple[Union[Message, None], Union[str, None]]:
|
) -> Tuple[Union[Message, None], Union[str, None]]:
|
||||||
db_entry = await col_submitted.find_one({"_id": ObjectId(id)})
|
db_entry = await col_submitted.find_one({"_id": ObjectId(id)})
|
||||||
submission = None
|
submission = None
|
||||||
@ -224,7 +224,13 @@ class PyroClient(PyroClient):
|
|||||||
)
|
)
|
||||||
raise SubmissionDuplicatesError(str(filepath), duplicates)
|
raise SubmissionDuplicatesError(str(filepath), duplicates)
|
||||||
|
|
||||||
await col_submitted.update_one({"_id": ObjectId(id)}, {"$set": {"done": True}})
|
db_update = (
|
||||||
|
{"$set": {"done": True, "caption": None}}
|
||||||
|
if purge_caption
|
||||||
|
else {"$set": {"done": True}}
|
||||||
|
)
|
||||||
|
|
||||||
|
await col_submitted.update_one({"_id": ObjectId(id)}, db_update)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if db_entry["temp"]["uuid"] is not None:
|
if db_entry["temp"]["uuid"] is not None:
|
||||||
|
@ -28,7 +28,10 @@ async def callback_query_yes(app: PyroClient, callback: CallbackQuery):
|
|||||||
db_entry = await col_submitted.find_one({"_id": ObjectId(fullcallback[2])})
|
db_entry = await col_submitted.find_one({"_id": ObjectId(fullcallback[2])})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
submission = await app.submit_media(fullcallback[2])
|
submission = await app.submit_media(
|
||||||
|
fullcallback[2],
|
||||||
|
purge_caption=("caption" not in fullcallback),
|
||||||
|
)
|
||||||
except SubmissionUnavailableError:
|
except SubmissionUnavailableError:
|
||||||
await callback.answer(
|
await callback.answer(
|
||||||
text=app._("sub_msg_unavail", "callback", locale=user.locale),
|
text=app._("sub_msg_unavail", "callback", locale=user.locale),
|
||||||
@ -120,6 +123,11 @@ async def callback_query_yes(app: PyroClient, callback: CallbackQuery):
|
|||||||
fullcallback[2],
|
fullcallback[2],
|
||||||
submission[1],
|
submission[1],
|
||||||
)
|
)
|
||||||
|
logger.info(
|
||||||
|
"Submission with ID '%s' accepted and uploaded with ID '%s'",
|
||||||
|
fullcallback[2],
|
||||||
|
submission[1],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
@Client.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
||||||
|
Reference in New Issue
Block a user