简体   繁体   English

如何在nodejs电报机器人(telegraf)中回复带有标题的照片

[英]how to reply a photo with caption in nodejs telegram bot (telegraf)

I'm writing a telegram bot with telegraf .我正在用telegraf编写一个电报机器人。 I want to send a photo with a text under it in the reply message.我想在回复消息中发送一张带有文字的照片。 I have written this:我写过这个:

    serviceDetailsScene.on('callback_query', async ({replyWithPhoto}) => {
        await replyWithPhoto({url: <url>})
}

It works and sends image properly, but I don't know how to append the message to it.它可以正常工作并正确发送图像,但我不知道如何将消息附加到它。

Thanks for any help.感谢您的帮助。

You can do this for replying with image src and caption:您可以使用图像 src 和标题进行回复:

bot.hears('photo', ctx.replyWithPhoto({ source: <pic-src> }, { caption: "cat photo" });

And if you want to send image url you can write this:如果你想发送图片网址,你可以这样写:

bot.hears('photo', ctx.replyWithPhoto({ url: <pic-url> }, { caption: "cat photo" });

试试看:

await replyWithPhoto({url: <url>}, {caption: 'Your caption'})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM