Jaeger87 / Botticelli

A Java framework for quick develop of Telegram bots
Other
6 stars 1 forks source link

I can not run a bot in inline mode, I do not get any result. #1

Closed orfeomorello closed 8 years ago

orfeomorello commented 8 years ago

This is a simple example

       @Override
    public void inLineQuery(InlineQuery arg0)
    {
        String name = arg0.getQuery();
                List<InlineQueryResult> results = new LinkedList<InlineQueryResult>();
                InlineQueryResultArticle article = new InlineQueryResultArticle("1", "title", "message_text");
                results.add(article);
                AnswerInlineQueryRequest aiq = new AnswerInlineQueryRequest(arg0.getId(), results);
                answerInlineQuery(aiq);
    }

This code make no errors while debugging, during execution, but on telegram I have no message. The code is wrong?

orfeomorello commented 8 years ago

I found the solution! The problem is the "id" of the reply message (InlineQueryResultArticle), the following code is executed perfectly. UUID class provides a simple means for generating unique ids.

       @Override
    public void inLineQuery(InlineQuery arg0)
    {
               UUID idOne = UUID.randomUUID();
               String name = arg0.getQuery();
                List<InlineQueryResult> results = new LinkedList<InlineQueryResult>();
                InlineQueryResultArticle article = new InlineQueryResultArticle(String.valueOf(idOne), "title", "message_text");
                results.add(article);
                AnswerInlineQueryRequest aiq = new AnswerInlineQueryRequest(arg0.getId(), results);
                answerInlineQuery(aiq);
    }
Jaeger87 commented 8 years ago

I'm sorry for answer you in late, i'm happy that you could solve the problem by yourself, maybe i have to write an article about inline mode!