windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
260 stars 116 forks source link

Sending photo now throws an error #386

Open bdydrp opened 1 month ago

bdydrp commented 1 month ago

Ive had this flow working for some time, but now, every so often i get an error and no photo is sent This is my flow: [{"id":"6a47553ff51ce02d","type":"inject","z":"97ef67ae.095ef8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":600,"y":420,"wires":[["c3da02ef.bc0b3"]]},{"id":"c3da02ef.bc0b3","type":"http request","z":"97ef67ae.095ef8","name":"Front Door Cam","method":"GET","ret":"bin","paytoqs":"ignore","url":"http://192.168.10.5/cgi-bin/snapshot.cgi","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"digest","senderr":false,"headers":[],"x":980,"y":100,"wires":[["c875efea3d9fd45b"]]},{"id":"c875efea3d9fd45b","type":"function","z":"97ef67ae.095ef8","name":"send picture","func":"var pl = {\n content: msg.payload,\n type : 'photo',\n chatId : \"-525118101\"\n}\nmsg.payload = pl;\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1150,"y":100,"wires":[["d6bba8a703900e09","1bdc9d11d5bd2abd"]]},{"id":"d6bba8a703900e09","type":"debug","z":"97ef67ae.095ef8","name":"debug 69","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1260,"y":380,"wires":[]},{"id":"1bdc9d11d5bd2abd","type":"telegram sender","z":"97ef67ae.095ef8","name":"Adam Telegram","bot":"fa7a9376.321ce","haserroroutput":false,"outputs":1,"x":1320,"y":100,"wires":[["3d4e7826.e79fc8"]]},{"id":"3d4e7826.e79fc8","type":"debug","z":"97ef67ae.095ef8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1530,"y":100,"wires":[]},{"id":"fa7a9376.321ce","type":"telegram bot","z":"97ef67ae.095ef8","botname":"HubitatNRbot","usernames":"","chatids":"-525118101","baseapiurl":"","updatemode":"none","pollinterval":"","usesocks":false,"sockshost":"","socksport":"","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"","publicbotport":"","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

image

And this is the error: image Debug 69 is attached to the function node!

Any reason why it works sometimes but not others??

Cheers

windkh commented 1 month ago

Hm good question... no idea

bdydrp commented 1 month ago

I dont get it either - is there any other logs i can look at to diagnose?

Arjenlodder commented 3 weeks ago

Same here, even with the example from the docs page. It never sends the message. I'm using Node-Red 3.1.11. Any solution?

Edit: seems to be a problem with the image. When using a random test PNG, it works. My JPG (pulled from a security camera) doesn't.

windkh commented 3 weeks ago

There can be many reasons: please read: https://core.telegram.org/bots/api#sendphoto

In addition to that something changed in the underlying api: https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files --> I need some time to find out what exactly needs to be done

windkh commented 3 weeks ago

Idea: maybe the mime type should be specified explicitly like described for the audio example?

const fileOptions = { // Explicitly specify the file name. filename: 'customfilename', // Explicitly specify the MIME type. contentType: 'audio/mpeg', }; bot.sendAudio(chatId, data, {}, fileOptions);

windkh commented 3 weeks ago

Same here, even with the example from the docs page. It never sends the message. I'm using Node-Red 3.1.11. Any solution?

Edit: seems to be a problem with the image. When using a random test PNG, it works. My JPG (pulled from a security camera) doesn't.

Do you use JPG or JPEG as file extension?

windkh commented 3 weeks ago

msg.payload.fileOptions can be used for setting the mime type

windkh commented 3 weeks ago

see also #161