pengrad / java-telegram-bot-api

Telegram Bot API for Java

Home Page:https://core.telegram.org/bots

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

submit many articles

boyzoon opened this issue · comments

can you help me to find out why when i use this code the bot does not return any results?

int cont = 0;
InlineQueryResultArticle[] results = new InlineQueryResultArticle[50];

for ( Article article : json.articles ){

results[cont] = new InlineQueryResultArticle(article.id , article.name , article.url).hideUrl(false).description(article.description).thumbUrl(article.iconUrl);
cont++;
        }

bot.execute(new AnswerInlineQuery( message.inlineQuery().id() , results ));

but when i use it this way it works. the problem is that this way I can send only one article and I need to send all those in the "results" variable

bot.execute(new AnswerInlineQuery( message.inlineQuery().id() , new InlineQueryResult[]{results[0]} )); 

hi?

I don't know why.
The similar test code was working fine.

InlineQueryResult<?>[] results = new InlineQueryResult[]{

I suggest you to debug API requests and responses and check HTTP logs.
bot = new TelegramBot.Builder(token()).debug().build();