exclam: !upl: Add support for HTTP/HTTPS URL for file upload
patch d523591db91c8bf0ceb6ea65bac6358e5080f35a
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun Apr 21 20:59:04 CEST 2024
* exclam: !upl: Add support for HTTP/HTTPS URL for file upload
diff -rN -u old-irgramd/exclam.py new-irgramd/exclam.py
--- old-irgramd/exclam.py 2024-05-18 06:56:04.940892973 +0200
+++ new-irgramd/exclam.py 2024-05-18 06:56:04.940892973 +0200
@@ -147,7 +147,10 @@
async def handle_command_upl(self, file=None, caption=None, help=None):
if not help:
try:
- file_path = os.path.join(self.tg.telegram_upload_dir, file)
+ if file[:8] == 'https://' or file[:7] == 'http://':
+ file_path = file
+ else:
+ file_path = os.path.join(self.tg.telegram_upload_dir, file)
self.tmp_tg_msg = await self.tg.telegram_client.send_file(self.tmp_telegram_id, file_path, caption=caption)
reply = True
except:
@@ -157,9 +160,9 @@
if help == HELP.desc: # rest of HELP.desc
reply += \
(
- ' !upl <file name> [<optional caption>]',
- 'Upload the file referenced by <file name> to current ',
+ ' !upl <file name/URL> [<optional caption>]',
+ 'Upload the file referenced by <file name/URL> to current',
'channel/chat, the file must be present in "upload"',
- 'local directory.'
+ 'irgramd local directory or be an external HTTP/HTTPS URL.'
)
return reply