Telegram Bots API:发送VideoNote作为内联查询结果

时间:2018-08-30 02:51:52

标签: java telegram telegram-bot

使用电报Bots API可以用视频注释回答内联查询。

我正在使用this

我尝试了以下方法:

List<InlineQueryResult> results = new ArrayList<>();
InlineQueryResultCachedVideo cv = new InlineQueryResultCachedVideo();
                    cv.setVideoFileId(d.getFileId());
                    cv.setId("" + i);
                    cv.setTitle("\uD83C\uDFAC " + d.getName());
                    cv.setDescription("\uD83D\uDCCE " + d.getMimeType().getName());
                    cv.setCaption(d.getName());
                    results.add(cv);

AnswerInlineQuery answer = new AnswerInlineQuery();
    answer.setInlineQueryId(inlineQuery.getId());
    answer.setResults(results);

    try {
        bot.execute(answer);
    } catch (TelegramApiException e) {
        e.printStackTrace();
    }

但是它抛出:

  

org.telegram.telegrambots.exceptions.TelegramApiRequestException:   回答内联查询时出错:[400]错误的请求:文件类型不匹配     在   org.telegram.telegrambots.api.methods.AnswerInlineQuery.deserializeResponse(AnswerInlineQuery.java:161)     在   org.telegram.telegrambots.api.methods.AnswerInlineQuery.deserializeResponse(AnswerInlineQuery.java:22)     在   org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:689)     在   org.telegram.telegrambots.bots.AbsSender.execute(AbsSender.java:53)     在   uz.tarv.file_saver.telegram.contorllers.InlineQueryController.handleUpdate(InlineQueryController.java:94)     在uz.tarv.file_saver.telegram.MyBot.onUpdateReceived(MyBot.java:86)     在java.util.ArrayList.forEach(ArrayList.java:1249)在   org.telegram.telegrambots.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27)     在   org.telegram.telegrambots.updatesreceivers.DefaultBotSession $ HandlerThread.run(DefaultBotSession.java:309)

0 个答案:

没有答案