Added documents support for spoilers

This commit is contained in:
Profitroll
2023-01-05 21:15:34 +01:00
parent 67f1ce535f
commit 1195df894c
5 changed files with 16 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ async def cmd_spoiler(app: Client, msg: Message):
"photo": None,
"video": None,
"animation": None,
"document": None,
"caption": None,
"text": None
}

View File

@@ -38,6 +38,8 @@ async def cmd_start(app: Client, msg: Message):
await msg.reply_video(spoiler["video"], caption=spoiler["caption"])
if spoiler["animation"] is not None:
await msg.reply_animation(spoiler["animation"], caption=spoiler["caption"])
if spoiler["document"] is not None:
await msg.reply_document(spoiler["document"], caption=spoiler["caption"])
if spoiler["text"] is not None:
await msg.reply_text(spoiler["text"])
except InvalidId:

View File

@@ -121,7 +121,12 @@ async def any_stage(app: Client, msg: Message):
logWrite(f"Adding animation with id {msg.animation.file_id} to {msg.from_user.id}'s spoiler")
ready = True
if spoiler["photo"] is None and spoiler["video"] is None and spoiler["animation"] is None and spoiler["text"] is None:
if msg.document is not None:
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"document": msg.document.file_id, "caption": msg.caption, "completed": True}} )
logWrite(f"Adding document with id {msg.document.file_id} to {msg.from_user.id}'s spoiler")
ready = True
if spoiler["photo"] is None and spoiler["video"] is None and spoiler["animation"] is None and spoiler["document"] is None and spoiler["text"] is None:
if msg.text is not None:
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"text": msg.text, "completed": True}} )
logWrite(f"Adding text '{msg.text}' to {msg.from_user.id}'s spoiler")