From 0ca6f4eebd8764dc80163232f9778301b8a84e8e Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Mon, 4 Nov 2019 18:41:25 +0000 Subject: [PATCH] Add fix for audio files sending as voice notes --- stdplugins/music_fix.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 stdplugins/music_fix.py diff --git a/stdplugins/music_fix.py b/stdplugins/music_fix.py new file mode 100644 index 0000000..267b574 --- /dev/null +++ b/stdplugins/music_fix.py @@ -0,0 +1,24 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from telethon import events + +@borg.on(events.NewMessage(outgoing=True)) +async def _(e): + if e.fwd_from or e.via_bot_id: + return + + if e.voice: + f = e.file + if f.title and f.performer: + caption = f"{f.performer} - {f.title}" + elif f.title: + caption = f.title + elif f.name: + caption = f.name + else: + caption = None + + if caption: + await e.edit(caption)