vikozo
2 February 2021 06:10
1
Hello
i found out to send telegram text in Bold you have to put them between asterix bold
if i do this in my node i got a syntax error, why?
it is also possible to add some url and a table?
[{"id":"31e1314d.271b4e","type":"function","z":"a31f62e6.bb022","name":"","func":"let payload = {\n\"chatId\":3884myid,\n\"type\":\"message\",\n\"content\": \"Wasserabfluss der Wigger\" +\"\\n\" +\"in Zofingen!\" +\"\\n\"\n**+msg.payload** +\" m³/s\" +\" = \" +msg.payload * 1000 +\" l\"\n+\"\\n\"\n+\" ... delay 60min ...\"\n\n};\nreturn {payload};","outputs":1,"noerr":7,"initialize":"","finalize":"","x":300,"y":160,"wires":[[]]}]
Try it like this:
msg.payload = {
"chatId":3884,
"type":"message",
"content": `Wasserabfluss der Wigger in Zofingen!\n**${msg.payload}** m³/s = ${msg.payload * 1000} l\n ... delay 60min ...`
};
return msg;
You get the errors because the double quotes are in the wrong places.
vikozo
2 February 2021 06:59
3
Hello
@bakman2 thanks for your fast feedback.
The ** Give now no error but they are just sendet like this and the telegram is with ** but not bold.
have a nice day
vinc
I think there is a bit more needed. The doc says that you'll need to include the optional parse_mode
parameter, but that probably is not supported by the node. (I tried with node-red-contrib-telegrambot 7.1.1, but there is newer versions)
Telegram uses single asterisks, but you will need to set the parse_mode to markdown as well.
edit @hotNipi was quicker
vikozo
2 February 2021 09:14
6
i do have
node-red-contrib-telegrambot 8.9.6
like this Wigger and Zofingen are bold but can't add the * msg-payload to become bold
[{"id":"ac646cfe.551fd","type":"function","z":"a31f62e6.bb022","name":"","func":"let payload = {\n\"chatId\":3884id,\n\"type\":\"message\",\n\"options\": {\"parse_mode\": \"Markdown\"},\n\"content\": \"Wasserabfluss der *Wigger*\" +\"\\n\" +\"in *Zofingen!*\" +\"\\n\"\n+msg.payload +\" m³/s\" +\" = \" +msg.payload * 1000 +\" l\"\n+\"\\n\"\n+\" ... delay 60min ...\"\n\n};\nreturn {payload};","outputs":1,"noerr":8,"initialize":"","finalize":"","x":320,"y":120,"wires":[[]]}]
Well there are no astericks around it ?
let payload = {
"chatId":id,
"type":"message",
"options": {"parse_mode": "Markdown"},
"content": "Wasserabfluss der *Wigger*" +"\n" +"in *Zofingen!* \n*"
+msg.payload +"* m³/s" +" = *" +msg.payload * 1000 +"* l"
+" \n ... delay 60min ..."
};
return {payload};
1 Like
The 'parse_mode' via options works
Try this
"Wasserabfluss der *Wigger*" +"\n" +"in *Zofingen!*" +"\n"
+"*"+msg.payload +"* m³/s" +" = *" +(msg.payload * 1000) +"* l"
+"\n"
+" ... delay 60min ..."
EDIT: Eh, now I was slow ...
4 Likes
vikozo
2 February 2021 22:25
9
thank you very much @hotNipi and @bakman2
both works now for me and all loks fine
Merci
system
Closed
16 February 2021 22:26
10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.