如何在nodejs中发送消息之前发送照片
how to sendphoto before sendmessage in nodejs
在 telegram bot 中,使用 nodejs,我想发送照片,然后将消息发送给用户
我使用这个代码:
bot.sendPhoto(chatId, photo);
bot.sendMessage(chatId, caption, opts);
但我的问题是:消息显示在照片之前,内联按钮显示在照片上方 :(
我喜欢显示的第一张照片,然后是带有内联按钮的消息
我用这个:
bot.sendPhoto(chatId, photo, function(){bot.sendMessage(chatId, caption, opts)});
但显示了此代码照片,但未显示任何消息
抱歉英语不好!
使用承诺。您可以使用 q library.
来实现它
确保 sendPhoto 函数 returns 一个承诺。以便您可以执行以下操作
bot.sendPhoto(chatId, photo).then(function(resultFromSendPhoto){
bot.sendMessage(chatId, caption, opts);
//your further code goes here if you want
}).catch(function(error){
console.log(error);
}).done();
在 telegram bot 中,使用 nodejs,我想发送照片,然后将消息发送给用户
我使用这个代码:
bot.sendPhoto(chatId, photo);
bot.sendMessage(chatId, caption, opts);
但我的问题是:消息显示在照片之前,内联按钮显示在照片上方 :( 我喜欢显示的第一张照片,然后是带有内联按钮的消息
我用这个:
bot.sendPhoto(chatId, photo, function(){bot.sendMessage(chatId, caption, opts)});
但显示了此代码照片,但未显示任何消息
抱歉英语不好!
使用承诺。您可以使用 q library.
来实现它确保 sendPhoto 函数 returns 一个承诺。以便您可以执行以下操作
bot.sendPhoto(chatId, photo).then(function(resultFromSendPhoto){
bot.sendMessage(chatId, caption, opts);
//your further code goes here if you want
}).catch(function(error){
console.log(error);
}).done();