scraton / node-red-contrib-telegrambot-home

Useful Node RED nodes for connecting your home to Telegram.
MIT License
28 stars 11 forks source link

Unable to send a deleteMessage payload #25

Closed dadino closed 3 years ago

dadino commented 4 years ago

I'm trying to delete a message using the payload node, passing this msg with a function

msg.method = "deleteMessage"
msg.payload = { 
    chat_id: msg.payload.chat.id,
    message_id: msg.payload.message_id
}
return msg;

But all I'm getting is this response: "empty arguments after parsing payload".

Here are my test nodes (replace my_chat_id with your id and my_telegram_bot with the name of your bot):

[{"id":"4b00f9b6.c2d458","type":"function","z":"b14001cd.1afae","name":"Build Delete payload","func":"msg.method = \"deleteMessage\"\nmsg.payload = { \n    chat_id: msg.payload.chat.id,\n    message_id: msg.payload.message_id\n}\nreturn msg;","outputs":1,"noerr":0,"x":950,"y":1760,"wires":[["7893b40f.9bfcbc","d22bbdd5.4f7e7"]]},{"id":"b1ba71b.266ac9","type":"telegrambot-payload","z":"b14001cd.1afae","name":"Send message","bot":"e778d36b.3b5a6","chatId":"my_chat_id","sendMethod":"sendMessage","payload":"{\n    \"text\": \"test\"\n}","x":670,"y":1760,"wires":[["4b00f9b6.c2d458","350fb8f9.ddf4c8"]]},{"id":"350fb8f9.ddf4c8","type":"debug","z":"b14001cd.1afae","name":"Message Payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":920,"y":1840,"wires":[]},{"id":"7893b40f.9bfcbc","type":"debug","z":"b14001cd.1afae","name":"Build Delete Payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1200,"y":1840,"wires":[]},{"id":"5a4b1aca.557f14","type":"debug","z":"b14001cd.1afae","name":"Delete Payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1480,"y":1840,"wires":[]},{"id":"d22bbdd5.4f7e7","type":"telegrambot-payload","z":"b14001cd.1afae","name":"Delete message","bot":"e778d36b.3b5a6","chatId":"my_chat_id","sendMethod":"","payload":"","x":1240,"y":1760,"wires":[["5a4b1aca.557f14"]]},{"id":"e778d36b.3b5a6","type":"telegrambot-config","z":"","botname":"my_telegram_bot","usernames":"","chatIds":"","pollInterval":"30"}]

delete message can be found here: https://core.telegram.org/bots/api#deletemessage

scraton commented 3 years ago

Since this is using node-telegram-bot-api under the hood, you need to follow their API for deleting a message. Unfortunately it doesn't seem like you can do this with the current version of node-red-contrib-telegrambot-home.

I've issued a new release that adds support for deleteMessage via the payload node.

Maybe in the future it would be nice to have a fully generic "send" method where you could send the raw Telegram API payload, rather than having to translate to node-telegram-bot-api's API. But unfortunately I don't have time for that at the moment.