Skip to content

Commit 6c008df

Browse files
committed
The method restrictChatMember now takes the new user permissions in a single argument of the type ChatPermissions
1 parent 9118d0c commit 6c008df

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.pengrad.telegrambot.request;
22

3+
import com.pengrad.telegrambot.model.ChatPermissions;
34
import com.pengrad.telegrambot.response.BaseResponse;
45

56
/**
@@ -13,6 +14,11 @@ public RestrictChatMember(Object chatId, int userId) {
1314
add("chat_id", chatId).add("user_id", userId);
1415
}
1516

17+
public RestrictChatMember(Object chatId, int userId, ChatPermissions permissions) {
18+
super(BaseResponse.class);
19+
add("chat_id", chatId).add("user_id", userId).add("permissions", gson.toJson(permissions));
20+
}
21+
1622
public RestrictChatMember untilDate(int untilDate) {
1723
return add("until_date", untilDate);
1824
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,15 @@ public void unbanChatMember() {
149149

150150
@Test
151151
public void restrictChatMember() {
152-
BaseResponse response = bot.execute(
152+
ChatPermissions permissions = new ChatPermissions()
153+
.canChangeInfo(true)
154+
.canInviteUsers(true)
155+
.canPinMessages(true)
156+
.canSendPolls(true);
157+
BaseResponse response = bot.execute(new RestrictChatMember(groupId, memberBot, permissions));
158+
assertTrue(response.isOk());
159+
160+
response = bot.execute(
153161
new RestrictChatMember(groupId, memberBot)
154162
.untilDate(100)
155163
.canSendMessages(false)

0 commit comments

Comments
 (0)