@Test public void answerInline() { InlineQuery inlineQuery = BotUtils.parseUpdate(testInlineQuery).inlineQuery(); String inlineQueryId = inlineQuery.id(); assertFalse(inlineQueryId.isEmpty()); UserTest.checkUser(inlineQuery.from(), true); assertEquals(Integer.valueOf(12345), inlineQuery.from().id()); assertEquals("if", inlineQuery.query()); assertEquals("offset", inlineQuery.offset()); assertNull(inlineQuery.location()); InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup( new InlineKeyboardButton("inline game").callbackGame("pengrad test game description"), new InlineKeyboardButton("inline ok").callbackData("callback ok"), new InlineKeyboardButton("cancel").callbackData("callback cancel"), new InlineKeyboardButton("url").url(someUrl), new InlineKeyboardButton("switch inline").switchInlineQuery("query"), new InlineKeyboardButton("switch inline current").switchInlineQueryCurrentChat("query")); InlineQueryResult<?>[] results = new InlineQueryResult[]{ new InlineQueryResultArticle("1", "title", new InputTextMessageContent("message").disableWebPagePreview(false).parseMode(ParseMode.HTML)) .url(someUrl).hideUrl(true).description("desc").thumbUrl(someUrl).thumbHeight(100).thumbWidth(100), new InlineQueryResultArticle("2", "title", new InputContactMessageContent("123123123", "na,e").lastName("lastName").vcard("qr vcard")), new InlineQueryResultArticle("3", "title", new InputLocationMessageContent(50f, 50f).livePeriod(60)), new InlineQueryResultArticle("4", "title", new InputVenueMessageContent(50f, 50f, "title", "address").foursquareId("sqrId").foursquareType("frType")), new InlineQueryResultArticle("5", "title", "message"), new InlineQueryResultAudio("6", someUrl, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML).performer("perf").audioDuration(100), new InlineQueryResultContact("7", "123123123", "name").lastName("lastName").vcard("tt vcard") .thumbUrl(someUrl).thumbHeight(100).thumbWidth(100), new InlineQueryResultDocument("8", someUrl, "title", "application/pdf").caption("cap <b>bold</b>").parseMode(ParseMode.HTML).description("desc") .thumbUrl(someUrl).thumbHeight(100).thumbWidth(100), new InlineQueryResultGame("9", "pengrad_test_game").replyMarkup(keyboardMarkup), new InlineQueryResultGif("10", someUrl, someUrl).caption("cap <b>bold</b>").parseMode(ParseMode.HTML).title("title") .thumbMimeType("image/gif") .gifHeight(100).gifWidth(100).gifDuration(100), new InlineQueryResultLocation("11", 50f, 50f, "title").livePeriod(60) .thumbUrl(someUrl).thumbHeight(100).thumbWidth(100), new InlineQueryResultMpeg4Gif("12", someUrl, someUrl).caption("cap <b>bold</b>").parseMode(ParseMode.HTML).title("title") .thumbMimeType("image/gif") .mpeg4Height(100).mpeg4Width(100).mpeg4Duration(100), new InlineQueryResultPhoto("13", someUrl, someUrl).photoWidth(100).photoHeight(100).title("title") .description("desc").caption("cap <b>bold</b>").parseMode(ParseMode.HTML), new InlineQueryResultVenue("14", 54f, 55f, "title", "address").foursquareId("frsqrId").foursquareType("frType") .thumbUrl(someUrl).thumbHeight(100).thumbWidth(100), new InlineQueryResultVideo("15", someUrl, VIDEO_MIME_TYPE, "text", someUrl, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML) .videoWidth(100).videoHeight(100).videoDuration(100).description("desc"), new InlineQueryResultVoice("16", someUrl, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML).voiceDuration(100), new InlineQueryResultCachedAudio("17", audioFileId).caption("cap <b>bold</b>").parseMode(ParseMode.HTML), new InlineQueryResultCachedDocument("18", stickerId, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML).description("desc"), new InlineQueryResultCachedGif("19", gifFileId).caption("cap <b>bold</b>").parseMode(ParseMode.HTML).title("title"), new InlineQueryResultCachedMpeg4Gif("21", gifFileId).caption("cap <b>bold</b>").parseMode(ParseMode.HTML).title("title"), new InlineQueryResultCachedPhoto("22", photoFileId).caption("cap <b>bold</b>").parseMode(ParseMode.HTML).description("desc").title("title"), new InlineQueryResultCachedSticker("23", stickerId), new InlineQueryResultCachedVideo("24", videoFileId, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML).description("desc"), new InlineQueryResultCachedVoice("25", voiceFileId, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML), }; BaseResponse response = bot.execute(new AnswerInlineQuery(inlineQueryId, results) .cacheTime(100) .isPersonal(true) .nextOffset("offset") .switchPmText("go pm") .switchPmParameter("my_pm_parameter") ); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description()); } }
public <T extends BaseRequest<T, R>, R extends BaseResponse> R execute(BaseRequest<T, R> request) { return api.send(request); }
TelegramBot { public <T extends BaseRequest<T, R>, R extends BaseResponse> R execute(BaseRequest<T, R> request) { return api.send(request); } }
TelegramBot { public <T extends BaseRequest<T, R>, R extends BaseResponse> R execute(BaseRequest<T, R> request) { return api.send(request); } TelegramBot(String botToken);   TelegramBot(Builder builder); }
TelegramBot { public <T extends BaseRequest<T, R>, R extends BaseResponse> R execute(BaseRequest<T, R> request) { return api.send(request); } TelegramBot(String botToken);   TelegramBot(Builder builder); R execute(BaseRequest<T, R> request); void execute(T request, Callback<T, R> callback); String getFullFilePath(File file); byte[] getFileContent(File file); void setUpdatesListener(UpdatesListener listener); void setUpdatesListener(UpdatesListener listener, GetUpdates request); void setUpdatesListener(UpdatesListener listener, ExceptionHandler exceptionHandler); void setUpdatesListener(UpdatesListener listener, ExceptionHandler exceptionHandler, GetUpdates request); void removeGetUpdatesListener(); }
TelegramBot { public <T extends BaseRequest<T, R>, R extends BaseResponse> R execute(BaseRequest<T, R> request) { return api.send(request); } TelegramBot(String botToken);   TelegramBot(Builder builder); R execute(BaseRequest<T, R> request); void execute(T request, Callback<T, R> callback); String getFullFilePath(File file); byte[] getFileContent(File file); void setUpdatesListener(UpdatesListener listener); void setUpdatesListener(UpdatesListener listener, GetUpdates request); void setUpdatesListener(UpdatesListener listener, ExceptionHandler exceptionHandler); void setUpdatesListener(UpdatesListener listener, ExceptionHandler exceptionHandler, GetUpdates request); void removeGetUpdatesListener();  }