Skip to content

Commit

Permalink
Fix web_app_info to web_app in KeyboardButton and InlineKeyboardButton
Browse files Browse the repository at this point in the history
  • Loading branch information
pengrad committed May 2, 2022
1 parent b3a5192 commit 000bb90
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public int hashCode() {
public String toString() {
return "MenuButtonWebApp{" +
"text='" + text + '\'' +
", web_app_info=" + web_app +
", web_app=" + web_app +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class InlineKeyboardButton implements Serializable {
private String switch_inline_query_current_chat;
private CallbackGame callback_game;
private Boolean pay;
private WebAppInfo web_app_info;
private WebAppInfo web_app;

private InlineKeyboardButton() {
}
Expand Down Expand Up @@ -66,8 +66,8 @@ public InlineKeyboardButton pay() {
return this;
}

public InlineKeyboardButton webAppInfo(WebAppInfo webAppInfo) {
this.web_app_info = webAppInfo;
public InlineKeyboardButton webApp(WebAppInfo webApp) {
this.web_app = webApp;
return this;
}

Expand Down Expand Up @@ -99,8 +99,8 @@ public boolean isPay() {
return pay != null ? pay : false;
}

public WebAppInfo webAppInfo() {
return web_app_info;
public WebAppInfo webApp() {
return web_app;
}

@Override
Expand All @@ -116,12 +116,12 @@ public boolean equals(Object o) {
Objects.equals(switch_inline_query_current_chat, that.switch_inline_query_current_chat) &&
Objects.equals(callback_game, that.callback_game) &&
Objects.equals(pay, that.pay) &&
Objects.equals(web_app_info, that.web_app_info);
Objects.equals(web_app, that.web_app);
}

@Override
public int hashCode() {
return Objects.hash(text, url, login_url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay, web_app_info);
return Objects.hash(text, url, login_url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay, web_app);
}

@Override
Expand All @@ -135,7 +135,7 @@ public String toString() {
", switch_inline_query_current_chat='" + switch_inline_query_current_chat + '\'' +
", callback_game=" + callback_game +
", pay=" + pay +
", web_app_info=" + web_app_info +
", web_app=" + web_app +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class KeyboardButton implements Serializable {
private boolean request_contact;
private boolean request_location;
private KeyboardButtonPollType request_poll;
private WebAppInfo web_app_info;
private WebAppInfo web_app;

public KeyboardButton(String text) {
this.text = text;
Expand All @@ -36,8 +36,8 @@ public KeyboardButton requestPoll(KeyboardButtonPollType poll) {
return this;
}

public KeyboardButton webAppInfo(WebAppInfo webAppInfo) {
this.web_app_info = webAppInfo;
public KeyboardButton webAppInfo(WebAppInfo webApp) {
this.web_app = webApp;
return this;
}
}
25 changes: 25 additions & 0 deletions library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2039,4 +2039,29 @@ public void getChatMenuButton() {
assertTrue(response.isOk());
assertEquals(menu.type(), response.result().type());
}

@Test
public void sendWebAppInfo() {
String text = "gh_app";
String url = "https://github.com/";
SendResponse response = bot.execute(new SendMessage(chatId, "message with webApp")
.replyMarkup(new InlineKeyboardMarkup(new InlineKeyboardButton(text).webApp(new WebAppInfo(url))))
);
assertTrue(response.isOk());

InlineKeyboardMarkup markup = response.message().replyMarkup();
assertNotNull(markup);
assertEquals(1, markup.inlineKeyboard().length);
assertEquals(1, markup.inlineKeyboard()[0].length);

InlineKeyboardButton button = markup.inlineKeyboard()[0][0];
assertEquals(text, button.text());
assertNotNull(button.webApp());
assertEquals(url, button.webApp().url());

response = bot.execute(new SendMessage(chatId, "message with webApp")
.replyMarkup(new ReplyKeyboardMarkup(new KeyboardButton(text).webAppInfo(new WebAppInfo(url))))
);
assertTrue(response.isOk());
}
}

0 comments on commit 000bb90

Please sign in to comment.