Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

javascript - (node:4) UnhandledPromiseRejectionWarning: Error: undefined is not a valid uri or options object

bot.onText(//igdl (.+)/i, async(msg, match) => {
  // 'msg' is the received Message from Telegram
  // 'match' is the result of executing the regexp above on the text content
  // of the message

  console.log("igdl command was executed")
  const chatId = msg.chat.id;
  const resp = match[1]; // the captured "whatever
  request(resp, async (error, response, html) => {
let $ = cheerio.load(html);
 url = $('meta[property="og:url"]').attr('content');
 title = $('meta[property="og:title"]').attr('content');
 video_link = $('meta[property="og:video"]').attr('content');
 bot.sendMessage(chatId,"Title : " + title) 
 bot.sendMessage(chatId,"Video Link : " + video_link)
const fileOptions = {filename: title,};
  const file = await request(video_link)
bot.sendVideo(chatId,file, {}, fileOptions)

  })

});

So I've sent a command that with "AN VALID LINK" Like this Sending valid link

but somehow it keeps saying sending that the link is not valid..

does someone know how to fix this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...