Skip to content

Commit 000bb90

Browse files
committed
Fix web_app_info to web_app in KeyboardButton and InlineKeyboardButton
1 parent b3a5192 commit 000bb90

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

library/src/main/java/com/pengrad/telegrambot/model/MenuButtonWebApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public int hashCode() {
4040
public String toString() {
4141
return "MenuButtonWebApp{" +
4242
"text='" + text + '\'' +
43-
", web_app_info=" + web_app +
43+
", web_app=" + web_app +
4444
'}';
4545
}
4646
}

library/src/main/java/com/pengrad/telegrambot/model/request/InlineKeyboardButton.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class InlineKeyboardButton implements Serializable {
2020
private String switch_inline_query_current_chat;
2121
private CallbackGame callback_game;
2222
private Boolean pay;
23-
private WebAppInfo web_app_info;
23+
private WebAppInfo web_app;
2424

2525
private InlineKeyboardButton() {
2626
}
@@ -66,8 +66,8 @@ public InlineKeyboardButton pay() {
6666
return this;
6767
}
6868

69-
public InlineKeyboardButton webAppInfo(WebAppInfo webAppInfo) {
70-
this.web_app_info = webAppInfo;
69+
public InlineKeyboardButton webApp(WebAppInfo webApp) {
70+
this.web_app = webApp;
7171
return this;
7272
}
7373

@@ -99,8 +99,8 @@ public boolean isPay() {
9999
return pay != null ? pay : false;
100100
}
101101

102-
public WebAppInfo webAppInfo() {
103-
return web_app_info;
102+
public WebAppInfo webApp() {
103+
return web_app;
104104
}
105105

106106
@Override
@@ -116,12 +116,12 @@ public boolean equals(Object o) {
116116
Objects.equals(switch_inline_query_current_chat, that.switch_inline_query_current_chat) &&
117117
Objects.equals(callback_game, that.callback_game) &&
118118
Objects.equals(pay, that.pay) &&
119-
Objects.equals(web_app_info, that.web_app_info);
119+
Objects.equals(web_app, that.web_app);
120120
}
121121

122122
@Override
123123
public int hashCode() {
124-
return Objects.hash(text, url, login_url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay, web_app_info);
124+
return Objects.hash(text, url, login_url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay, web_app);
125125
}
126126

127127
@Override
@@ -135,7 +135,7 @@ public String toString() {
135135
", switch_inline_query_current_chat='" + switch_inline_query_current_chat + '\'' +
136136
", callback_game=" + callback_game +
137137
", pay=" + pay +
138-
", web_app_info=" + web_app_info +
138+
", web_app=" + web_app +
139139
'}';
140140
}
141141
}

library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButton.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class KeyboardButton implements Serializable {
1515
private boolean request_contact;
1616
private boolean request_location;
1717
private KeyboardButtonPollType request_poll;
18-
private WebAppInfo web_app_info;
18+
private WebAppInfo web_app;
1919

2020
public KeyboardButton(String text) {
2121
this.text = text;
@@ -36,8 +36,8 @@ public KeyboardButton requestPoll(KeyboardButtonPollType poll) {
3636
return this;
3737
}
3838

39-
public KeyboardButton webAppInfo(WebAppInfo webAppInfo) {
40-
this.web_app_info = webAppInfo;
39+
public KeyboardButton webAppInfo(WebAppInfo webApp) {
40+
this.web_app = webApp;
4141
return this;
4242
}
4343
}

library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,4 +2039,29 @@ public void getChatMenuButton() {
20392039
assertTrue(response.isOk());
20402040
assertEquals(menu.type(), response.result().type());
20412041
}
2042+
2043+
@Test
2044+
public void sendWebAppInfo() {
2045+
String text = "gh_app";
2046+
String url = "https://github.com/";
2047+
SendResponse response = bot.execute(new SendMessage(chatId, "message with webApp")
2048+
.replyMarkup(new InlineKeyboardMarkup(new InlineKeyboardButton(text).webApp(new WebAppInfo(url))))
2049+
);
2050+
assertTrue(response.isOk());
2051+
2052+
InlineKeyboardMarkup markup = response.message().replyMarkup();
2053+
assertNotNull(markup);
2054+
assertEquals(1, markup.inlineKeyboard().length);
2055+
assertEquals(1, markup.inlineKeyboard()[0].length);
2056+
2057+
InlineKeyboardButton button = markup.inlineKeyboard()[0][0];
2058+
assertEquals(text, button.text());
2059+
assertNotNull(button.webApp());
2060+
assertEquals(url, button.webApp().url());
2061+
2062+
response = bot.execute(new SendMessage(chatId, "message with webApp")
2063+
.replyMarkup(new ReplyKeyboardMarkup(new KeyboardButton(text).webAppInfo(new WebAppInfo(url))))
2064+
);
2065+
assertTrue(response.isOk());
2066+
}
20422067
}

0 commit comments

Comments
 (0)