Skip to content

Commit 4fd5a7d

Browse files
committed
Added the new method setChatAdministratorCustomTitle to manage the custom titles of administrators promoted by the bot
1 parent 220448e commit 4fd5a7d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.pengrad.telegrambot.request;
2+
3+
import com.pengrad.telegrambot.response.BaseResponse;
4+
5+
/**
6+
* Stas Parshin
7+
* 01 January 2020
8+
*/
9+
public class SetChatAdministratorCustomTitle extends BaseRequest<SetChatAdministratorCustomTitle, BaseResponse> {
10+
11+
public SetChatAdministratorCustomTitle(Object chatId, int userId, String customTitle) {
12+
super(BaseResponse.class);
13+
add("chat_id", chatId).add("user_id", userId).add("custom_title", customTitle);
14+
}
15+
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,20 @@ private PreCheckoutQuery getLastPreCheckoutQuery() {
10541054
return null;
10551055
}
10561056

1057+
@Test
1058+
public void setChatAdministratorCustomTitle() {
1059+
BaseResponse response = bot.execute(new PromoteChatMember(groupId, memberBot).canPromoteMembers(true));
1060+
assertTrue(response.isOk());
1061+
1062+
String customTitle = "aqi " + new Random().nextInt(999999);
1063+
response = bot.execute(new SetChatAdministratorCustomTitle(groupId, memberBot, customTitle));
1064+
assertTrue(response.isOk());
1065+
1066+
ChatMember member = bot.execute(new GetChatMember(groupId, memberBot)).chatMember();
1067+
ChatMemberTest.check(member);
1068+
assertEquals(customTitle, member.customTitle());
1069+
}
1070+
10571071
@Test
10581072
public void setChatPermissions() throws InterruptedException {
10591073
for (boolean bool : new boolean[]{true, false}) {

0 commit comments

Comments
 (0)