Added audio support for spoilers

This commit is contained in:
Profitroll 2023-01-10 12:11:29 +01:00
parent b67b1daf7c
commit 00a408ac6c
4 changed files with 16 additions and 3 deletions

View File

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

View File

@ -36,6 +36,8 @@ async def cmd_start(app: Client, msg: Message):
await msg.reply_cached_media(spoiler["photo"], caption=spoiler["caption"]) await msg.reply_cached_media(spoiler["photo"], caption=spoiler["caption"])
if spoiler["video"] is not None: if spoiler["video"] is not None:
await msg.reply_cached_media(spoiler["video"], caption=spoiler["caption"]) await msg.reply_cached_media(spoiler["video"], caption=spoiler["caption"])
if spoiler["audio"] is not None:
await msg.reply_cached_media(spoiler["audio"], caption=spoiler["caption"])
if spoiler["animation"] is not None: if spoiler["animation"] is not None:
await msg.reply_cached_media(spoiler["animation"], caption=spoiler["caption"]) await msg.reply_cached_media(spoiler["animation"], caption=spoiler["caption"])
if spoiler["document"] is not None: if spoiler["document"] is not None:

View File

@ -89,7 +89,7 @@ async def any_stage(app: Client, msg: Message):
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user))) await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
return return
if spoiler["description"] is None and (spoiler["photo"] is None and spoiler["video"] is None and spoiler["animation"] is None and spoiler["text"] is None): if spoiler["description"] is None and (spoiler["photo"] is None and spoiler["video"] is None and spoiler["audio"] is None and spoiler["animation"] is None and spoiler["text"] is None):
# for lc in all_locales("spoiler_description", "keyboard"): # for lc in all_locales("spoiler_description", "keyboard"):
# if msg.text == lc[-1][0]: # if msg.text == lc[-1][0]:
@ -115,7 +115,12 @@ async def any_stage(app: Client, msg: Message):
if msg.video is not None: if msg.video is not None:
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"video": msg.video.file_id, "caption": msg.caption, "completed": True}} ) col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"video": msg.video.file_id, "caption": msg.caption, "completed": True}} )
logWrite(f"Adding video with id {msg.video.file_id} to {msg.from_user.id}'s spoiler") logWrite(f"Adding audio with id {msg.video.file_id} to {msg.from_user.id}'s spoiler")
ready = True
if msg.audio is not None:
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"audio": msg.audio.file_id, "caption": msg.caption, "completed": True}} )
logWrite(f"Adding video with id {msg.audio.file_id} to {msg.from_user.id}'s spoiler")
ready = True ready = True
if msg.animation is not None: if msg.animation is not None:
@ -128,7 +133,7 @@ async def any_stage(app: Client, msg: Message):
logWrite(f"Adding document with id {msg.document.file_id} to {msg.from_user.id}'s spoiler") logWrite(f"Adding document with id {msg.document.file_id} to {msg.from_user.id}'s spoiler")
ready = True 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 spoiler["photo"] is None and spoiler["video"] is None and spoiler["audio"] is None and spoiler["animation"] is None and spoiler["document"] is None and spoiler["text"] is None:
if msg.text is not 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}} ) 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") logWrite(f"Adding text '{msg.text}' to {msg.from_user.id}'s spoiler")

View File

@ -7,6 +7,7 @@
"description", "description",
"photo", "photo",
"video", "video",
"audio",
"animation", "animation",
"document", "document",
"caption", "caption",
@ -38,6 +39,10 @@
"bsonType": ["string", "null"], "bsonType": ["string", "null"],
"description": "Spoilered video" "description": "Spoilered video"
}, },
"audio": {
"bsonType": ["string", "null"],
"description": "Spoilered audio"
},
"animation": { "animation": {
"bsonType": ["string", "null"], "bsonType": ["string", "null"],
"description": "Spoilered animation/GIF" "description": "Spoilered animation/GIF"