I’m having trouble sending executable files through a Telegram bot. For instance, I attempted to use this download link for 7-Zip: http://www.7-zip.org/a/7z1604-x64.exe
.
https://api.telegram.org/botToken/sendDocument?chat_id=chatId&document=http://www.7-zip.org/a/7z1604-x64.exe
However, when I try to send this file, I receive the following error response:
{"ok":false,"error_code":400,"description":"Bad Request: wrong file identifier/HTTP URL specified"}
Is it possible to send executable files through a Telegram bot?
Sending executable files directly via Telegram bot can be tricky due to restrictions and security policies involved. One workaround is to compress the executable into a zip or other archive format before uploading. This can often bypass the restrictions associated with sending executables directly. You can code your bot to handle this by first downloading the executable server-side, compressing it, and then sending the compressed file using sendDocument
. Ensure to use proper error handling during the file conversion and sending process to detect any issues promptly.
You might also consider using a file hosting service which provides you with a direct download link. Use that direct link with your bot’s sendDocument function. Some services create temporary URLs which expire, so ensure you’re using a stable one. Security settings are strict, so this could bypass those restrictions.
it looks like the url isn’t being accepted directly. try downloading the file first, then use the sendDocument api with multipart/form-data
to upload it. telegram’s stricter about urls for files due to security, so local upload might work better! ps: double check bot permissions too.