Skip to content

Commit 08ecf48

Browse files
authored
Merge pull request #250 from mircoianese/api_5.3
BOT API v5.3
2 parents 194741d + d144e90 commit 08ecf48

20 files changed

+300
-3
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import com.pengrad.telegrambot.model.botcommandscope.BotCommandScope;
4+
import com.pengrad.telegrambot.request.BaseRequest;
5+
import com.pengrad.telegrambot.response.BaseResponse;
6+
7+
public class DeleteMyCommands extends BaseRequest<DeleteMyCommands, BaseResponse> {
8+
9+
public DeleteMyCommands() {
10+
super(BaseResponse.class);
11+
}
12+
13+
/**
14+
*
15+
* @param scope An object that extends the BotCommandScope class. For example: new BotCommandScopeAllPrivateChats()
16+
* @return
17+
*/
18+
public DeleteMyCommands scope(BotCommandScope scope) {
19+
add("scope", scope);
20+
return this;
21+
}
22+
23+
/**
24+
*
25+
* @param languageCode A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
26+
* @return
27+
*/
28+
public DeleteMyCommands languageCode(String languageCode) {
29+
add("language_code", languageCode);
30+
return this;
31+
}
32+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
import java.io.Serializable;
4+
5+
public abstract class BotCommandScope implements Serializable {
6+
private final static long serialVersionUID = 0L;
7+
8+
protected String type = "default";
9+
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
public class BotCommandScopeAllChatAdministrators extends BotCommandScope {
4+
5+
public BotCommandScopeAllChatAdministrators() {
6+
this.type = "all_chat_administrators";
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
public class BotCommandScopeAllGroupChats extends BotCommandScope {
4+
5+
public BotCommandScopeAllGroupChats() {
6+
this.type = "all_group_chats";
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
public class BotCommandScopeAllPrivateChats extends BotCommandScope {
4+
5+
public BotCommandScopeAllPrivateChats() {
6+
this.type = "all_private_chats";
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
public class BotCommandScopeDefault extends BotCommandScope {
4+
5+
public BotCommandScopeDefault() {
6+
this.type = "default";
7+
}
8+
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
public class BotCommandsScopeChat extends BotCommandScope {
4+
5+
private Object chat_id;
6+
7+
/**
8+
*
9+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
10+
*/
11+
public BotCommandsScopeChat(Object chatId) {
12+
this.type = "chat";
13+
this.chat_id = chatId;
14+
}
15+
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
public class BotCommandsScopeChatAdministrators extends BotCommandScope {
4+
5+
private Object chat_id;
6+
7+
/**
8+
*
9+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
10+
*/
11+
public BotCommandsScopeChatAdministrators(Object chatId) {
12+
this.type = "chat_administrators";
13+
this.chat_id = chatId;
14+
}
15+
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.pengrad.telegrambot.model.botcommandscope;
2+
3+
public class BotCommandsScopeChatMember extends BotCommandScope {
4+
5+
private Object chat_id;
6+
private long user_id;
7+
8+
/**
9+
*
10+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
11+
* @param userId Unique identifier of the target user
12+
*/
13+
public BotCommandsScopeChatMember(Object chatId, long userId) {
14+
this.type = "chat_member";
15+
this.chat_id = chatId;
16+
this.user_id = userId;
17+
}
18+
19+
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public class ForceReply extends Keyboard implements Serializable {
1010
private final static long serialVersionUID = 0L;
1111

1212
private final boolean force_reply = true;
13-
private final boolean selective;
13+
private String input_field_placeholder = "";
14+
private boolean selective = false;
1415

1516
public ForceReply() {
1617
this(false);
@@ -19,4 +20,13 @@ public ForceReply() {
1920
public ForceReply(boolean selective) {
2021
this.selective = selective;
2122
}
23+
24+
// API v5.3 - added field input_field_placeholder
25+
public ForceReply(boolean selective, String input_field_placeholder) {
26+
this.selective = selective;
27+
this.input_field_placeholder = input_field_placeholder;
28+
}
29+
public ForceReply(String input_field_placeholder) {
30+
this.input_field_placeholder = input_field_placeholder;
31+
}
2232
}

0 commit comments

Comments
 (0)