telegram.sh
telegram.sh copied to clipboard
Send image with message
What is the correct way to send an image along with a message? In my bash script 'bash telegram.sh - i image.png "message" only shows the message but no image.
I can't reproduce this... Was the image file a valid image file? What size did it have? Does it still not work for you?
I tried with .png files of different sizes. the image sends when there is so message so i solved this by sending twice one for message and one for image. I think the issue is related to that the message is in this for: "${output7}" it is the console log output from selenium java.
Maybe try again. I had the same issue a while ago and solved it the same way: send image and message separately.
I just tried again now and it's working fine.
telegram -i test.jpg "message"
displays image and message combined.
I've the same error on Centos 6.4... maybe problem is curl option?
./telegram -t xxx -c xxx -i foto.jpg
curl reported an error. Exit code was: 26.
Response was:
Quitting.
root@# ll
-rw-rw-rw- 1 admin admin 36316 17 giu 23:12 foto.jpg
-rw-rw-rw- 1 admin admin 208690 17 giu 23:16 foto.png
I have the same error with file
-f results.txt
How can i resolve this issue?
UPDATE: I' ve debugged adding this line:
for id in "${CHATS[@]}"; do
MY_CURL_OPTIONS="$CURL_OPTIONS --form-string chat_id=$id $URL$TOKEN/$METHOD"
echo curl $MY_CURL_OPTIONS <<< "$TEXT"
./telegram_test -t xxx -c xxx -i foto.jpg
curl -s --form photo=@"foto.jpg" --form caption=<- --form-string chat_id=xxx https://api.telegram.org/botxxx:xxx/sendPhoto
curl reported an error. Exit code was: 26.
Response was:
Quitting.
If I launch curl command I have:
curl -s --form photo=@"foto.jpg" --form caption=<- --form-string chat_id=xxx https://api.telegram.org/botxxx:xxx/sendPhoto
zsh: no such file or directory: -
The problem is
form caption=<-
indeed if i launch this with '--form "caption=title_image"' it's ok
curl -s --form photo=@"foto.jpg" --form "caption=title_image" --form-string chat_id=xxx https://api.telegram.org/botxxx:xxx/sendPhoto
{"ok":true,"result":{"message_id":34,"from":{
The same with simple text:
./telegram_test -t xxx:xxx -c xxx "Ciao"
curl -s --form text=<- --form-string chat_id=xxx "https://api.telegram.org/botxxx:xxx/sendMessage"
I must run this command with '--form "text=ciao"'
curl -s --form "text=ciao" --form-string chat_id=xxx https://api.telegram.org/botxxx:xxx/sendMessage
Then I've tried this fix:
elif [ -n "$IMAGE_FILE" ]; then
check_file "$IMAGE_FILE"
CURL_OPTIONS="$CURL_OPTIONS --form photo=@\"$IMAGE_FILE\""
#CURL_OPTIONS="$CURL_OPTIONS --form caption=<-"
CURL_OPTIONS="$CURL_OPTIONS --form \"caption=text\""
But the problem remain:
./telegram_test -t xxx:xxx -c xxx -i foto.jpg
curl -s --form photo=@"foto.jpg" --form "caption=ciao" --form-string chat_id=xxx https://api.telegram.org/botxxx:xxx/sendPhoto
curl reported an error. Exit code was: 26.
Response was:
Quitting.
But the command curl is fixed:
curl -s --form photo=@"foto.jpg" --form "caption=ciao" --form-string chat_id=xxx https://api.telegram.org/botxxx:xxx/sendPhoto
{"ok":true,"result":{"
I'don' understand why you use "<-" for example in:
CURL_OPTIONS="$CURL_OPTIONS --form caption=<-"
Do you think it's possible fix this in your shell script?