Closed moshed closed 2 years ago
https://core.telegram.org/bots/api#sendaudio Caption must be passed in options
@windkh It seems to work even when not inside options but I have moved it into options and it doesnt seem to affect sending title, performer and thumb
options = {
performer: 'test2',
thumb: msg.payload.album.images[2].url + '.jpg',
disable_notification: true,
parse_mode: 'MarkdownV2',
reply_to_message_id: msg.message_id,
caption: '*Song Transfer*\nplease choose a service below',
reply_markup: JSON.stringify({
"inline_keyboard": [
[
{
"text": "Spotify",
"callback_data": "spotify"
},
{
"text": "Apple Music",
"callback_data": "appleMusic"
},
{
"text": "YouTube",
"callback_data": "youtube"
},
],
[
{
"text": "Amazon Music",
"callback_data": "amazonMusic"
},
{
"text": "Deezer",
"callback_data": "deezer"
},
{
"text": "Tidal",
"callback_data": "tidal"
},
],
[
{
"text": "Napster",
"callback_data": "napster"
},
{
"text": "Pandora",
"callback_data": "pandora"
},
{
"text": "Soundcloud",
"callback_data": "soundcloud"
},
],
[
{
"text": "YouTube Music",
"callback_data": "youtubeMusic"
},
{
"text": "Amazon Store",
"callback_data": "amazonStore"
},
{
"text": "iTunes",
"callback_data": "itunes"
},
]
]
})
}
if (msg.payload.preview_url !== null) {
msg = {
payload: {
type: 'audio',
content: msg.payload.preview_url + '.mp3',
chatId: msg.chat_id,
options
},
url: 'https://api.song.link/v1-alpha.1/links?url=' + link + '&key=[redacted]',
}
You should set the options in payload:
payload: { type: 'audio', content: msg.payload.preview_url + '.mp3', chatId: msg.chat_id, options : options
@windkh (not sure if you get notified if something is closed so im tagging you) setting that seems to have no effect. the other options work (like the inline keyboard) but the audio options seem to be not working.
if (msg.payload.preview_url !== null) {
msg = {
payload: {
type: 'audio',
content: msg.payload.preview_url + '.mp3',
chatId: msg.chat_id,
options : options
},
url: 'https://api.song.link/v1-alpha.1/links?url=' + link + '&[redacted]',
}
}
@windkh can you reopen this? im not sure its resolved
I made a quick check and the result looks like:
The code is here
So the only thing which does not work here is the thumb: I guess my image does not meet the requirements
I tried with below code and still got same thing, then i mirrored the way you did it exactly in case there was some weird bug (I added the chatID since your code seemed to be missing) both snippets pasted below
msg = {
payload: {
type: 'audio',
content: 'https://p.scdn.co/mp3-preview/c3d5cf3ff922ca2e2cb6f27c60ff88ba47580a59?cid=c738780a34f44c298e60d163414be6f3.mp3',
chatId: -635631974,
options : {
title: 'test1',
performer: 'test2',
thumb: 'https://i.scdn.co/image/ab67616d000048518f9f218b386e6aeb27184307.jpg',
disable_notification: true,
parse_mode: 'MarkdownV2',
caption: 'Caption'
}
}
}
return msg
msg.payload = {}
let audio = 'https://p.scdn.co/mp3-preview/c3d5cf3ff922ca2e2cb6f27c60ff88ba47580a59?cid=c738780a34f44c298e60d163414be6f3.mp3'
let options = {
title: 'test1',
performer: 'test2',
disable_notification: true,
parse_mode: 'MarkdownV2',
caption: 'Caption',
};
msg.payload.type = 'audio';
msg.payload.content = audio;
msg.payload.options = options;
msg.payload.chatId = -635631974;
return msg
edit: attached below is the output of my sender node
{
"payload": {
"type": "audio",
"content": {
"message_id": 4877,
"from": {
"id": 5075525057,
"is_bot": true,
"first_name": "Song Transfer",
"username": "songtransferbot"
},
"chat": {
"id": -635631974,
"title": "Song Transfer Test",
"type": "group",
"all_members_are_administrators": true
},
"date": 1652929487,
"audio": {
"duration": 29,
"file_name": "c3d5cf3ff922ca2e2cb6f27c60ff88ba47580a59.mp3",
"mime_type": "audio/mpeg",
"file_id": "CQACAgQAAxkDAAITDWKFs8-7UXgiQh_hQ3L2x3Ce9dS7AAJvAwACF0skULmhb17nKNfcJAQ",
"file_unique_id": "AgADbwMAAhdLJFA",
"file_size": 361921
},
"caption": "Caption"
},
"chatId": -635631974,
"options": {
"title": "test1",
"performer": "test2",
"thumb": "https://i.scdn.co/image/ab67616d000048518f9f218b386e6aeb27184307.jpg",
"disable_notification": true,
"parse_mode": "MarkdownV2",
"caption": "Caption",
"chat_id": -635631974,
"audio": "https://p.scdn.co/mp3-preview/c3d5cf3ff922ca2e2cb6f27c60ff88ba47580a59?cid=c738780a34f44c298e60d163414be6f3.mp3"
},
"sentMessageId": 4877
},
"_msgid": "133a91dfd8ec582b"
}
The chatId came from a receiver node in my example. What client do you use? I guess it depends on the capabilities of the client.
Telegram macOS 8.7.1, macOS 12.3 and Telegram iOS 8.7.2, iOS 15.4.1
I have discovered something weird though. When I use a different audio link the title and performer come out correct as song and performer but not to what I set it to (I set it to test1 and test2 but the actually correct "like a prayer - madonna" is output)
msg = {
payload: {
type: 'audio',
content: 'https://p.scdn.co/mp3-preview/ffc2bc6380ec8c8cb47f4aae185c319a8c130cb7?cid=c738780a34f44c298e60d163414be6f3.mp3',
chatId: -635631974,
options : {
title: 'test1',
performer: 'test2',
thumb: 'https://i.scdn.co/image/ab67616d000048518f9f218b386e6aeb27184307.jpg',
disable_notification: true,
parse_mode: 'MarkdownV2',
caption: 'Caption'
}
}
}
return msg
exported flow here
[{"id":"7d8673afd577061e","type":"function","z":"f5ea9811929d9baa","name":"","func":"msg = {\n payload: {\n type: 'audio',\n content: 'https://p.scdn.co/mp3-preview/ffc2bc6380ec8c8cb47f4aae185c319a8c130cb7?cid=c738780a34f44c298e60d163414be6f3.mp3',\n chatId: -635631974,\n options : {\n title: 'test1',\n performer: 'test2',\n thumb: 'https://i.scdn.co/image/ab67616d000048518f9f218b386e6aeb27184307.jpg',\n disable_notification: true,\n parse_mode: 'MarkdownV2',\n caption: 'Caption'\n }\n }\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":220,"wires":[["63028c7dacff0446"]]}]
I am trying to send audio with a custom title preformer and thumb and im having no luck. the message sends fine but the title and other things aren't customized.