Support Telegram Bots API 2.1

This commit is contained in:
Rubenlagus 2016-05-22 11:42:04 +02:00
parent 37eac08554
commit 0b6f4e1d06
12 changed files with 651 additions and 2 deletions

View File

@ -0,0 +1,79 @@
package org.telegram.telegrambots.api.methods.groupadministration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.Chat;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to get information about the chat. Returns Chat object on success.
* @date 20 of May of 2016
*/
public class GetChat extends BotApiMethod<Chat> {
public static final String PATH = "getChat";
private static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public GetChat() {
super();
}
public String getChatId() {
return chatId;
}
public GetChat setChatId(String chatId) {
this.chatId = chatId;
return this;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Chat deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
return new Chat(answer.getJSONObject(Constants.RESPONSEFIELDRESULT));
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "GetChat{" +
"chatId='" + chatId + '\'' +
'}';
}
}

View File

@ -0,0 +1,90 @@
package org.telegram.telegrambots.api.methods.groupadministration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONArray;
import org.json.JSONObject;
import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.ChatMember;
import java.io.IOException;
import java.util.ArrayList;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to get a list of administrators in a chat.
* An Array of ChatMember objects is returned on success,
* containing information about all chat administrators except other bots.
* If the chat is a group or a supergroup and no administrators were appointed,
* only the creator will be returned.
* @date 20 of May of 2016
*/
public class GetChatAdministrators extends BotApiMethod<ArrayList<ChatMember>> {
public static final String PATH = "getChatAdministrators";
private static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public GetChatAdministrators() {
super();
}
public String getChatId() {
return chatId;
}
public GetChatAdministrators setChatId(String chatId) {
this.chatId = chatId;
return this;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public ArrayList<ChatMember> deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
JSONArray admins = answer.getJSONArray(Constants.RESPONSEFIELDRESULT);
ArrayList<ChatMember> members = new ArrayList<>();
for (int i = 0; i < admins.length(); i++) {
members.add(new ChatMember(admins.getJSONObject(i)));
}
return members;
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "GetChatAdministrators{" +
"chatId='" + chatId + '\'' +
'}';
}
}

View File

@ -0,0 +1,94 @@
package org.telegram.telegrambots.api.methods.groupadministration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.ChatMember;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to get information about a member of a chat.
* Returns a ChatMember object on success.
* @date 20 of May of 2016
*/
public class GetChatMember extends BotApiMethod<ChatMember> {
public static final String PATH = "getChatAdministrators";
private static final String CHATID_FIELD = "chat_id";
private static final String USERID_FIELD = "user_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private Integer userId; ///< Unique identifier of the target user
public GetChatMember() {
super();
}
public String getChatId() {
return chatId;
}
public GetChatMember setChatId(String chatId) {
this.chatId = chatId;
return this;
}
public Integer getUserId() {
return userId;
}
public GetChatMember setUserId(Integer userId) {
this.userId = userId;
return this;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(USERID_FIELD, userId);
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public ChatMember deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
return new ChatMember(answer.getJSONObject(Constants.RESPONSEFIELDRESULT));
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeNumberField(USERID_FIELD, userId);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "GetChatMember{" +
"chatId='" + chatId + '\'' +
", userId='" + userId + '\'' +
'}';
}
}

View File

@ -0,0 +1,78 @@
package org.telegram.telegrambots.api.methods.groupadministration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to get the number of members in a chat. Returns Int on success.
* @date 20 of May of 2016
*/
public class GetChatMemberCount extends BotApiMethod<Integer> {
public static final String PATH = "getChatAdministrators";
private static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public GetChatMemberCount() {
super();
}
public String getChatId() {
return chatId;
}
public GetChatMemberCount setChatId(String chatId) {
this.chatId = chatId;
return this;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Integer deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
return answer.getInt(Constants.RESPONSEFIELDRESULT);
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "GetChatMemberCount{" +
"chatId='" + chatId + '\'' +
'}';
}
}

View File

@ -0,0 +1,78 @@
package org.telegram.telegrambots.api.methods.groupadministration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
* @date 20 of May of 2016
*/
public class LeaveChat extends BotApiMethod<Boolean> {
public static final String PATH = "leaveChat";
private static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public LeaveChat() {
super();
}
public String getChatId() {
return chatId;
}
public LeaveChat setChatId(String chatId) {
this.chatId = chatId;
return this;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Boolean deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
return answer.getBoolean(Constants.RESPONSEFIELDRESULT);
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "LeaveChat{" +
"chatId='" + chatId + '\'' +
'}';
}
}

View File

@ -0,0 +1,58 @@
package org.telegram.telegrambots.api.objects;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief This object contains information about one member of the chat.
* @date 20 of May of 2016
*/
public class ChatMember implements IBotApiObject {
private static final String USER_FIELD = "user";
private static final String STATUS_FIELD = "status";
private User user; ///< Information about the user
private String status; ///< The member's status in the chat. Can be creator, administrator, member, left or kicked
public ChatMember(JSONObject object) {
user = new User(object.getJSONObject(USER_FIELD));
status = object.getString(STATUS_FIELD);
}
public User getUser() {
return user;
}
public String getStatus() {
return status;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeObjectField(USER_FIELD, user);
gen.writeStringField(STATUS_FIELD, status);
gen.writeEndObject();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "ChatMember{" +
"user=" + user +
", status='" + status + '\'' +
'}';
}
}

View File

@ -17,6 +17,7 @@ public class EntityType {
public static final String CODE = "code"; ///< Monowidth string
public static final String PRE = "pre"; ///< Monowidth block
public static final String TEXTLINK = "text_link"; ///< Clickable urls
public static final String TEXTMENTION = "text_mention"; ///< for users without usernames
private EntityType() {
}

View File

@ -0,0 +1,15 @@
package org.telegram.telegrambots.api.objects;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Group members categories
* @date 22 of May of 2016
*/
public final class MemberStatus {
public static final String CREATOR = "creator";
public static final String ADMINISTRATOR = "administrator";
public static final String MEMBER = "member";
public static final String LEFT = "left";
public static final String KICKED = "kicked";
}

View File

@ -51,6 +51,7 @@ public class Message implements IBotApiObject {
private static final String CHANNELCHATCREATED_FIELD = "channel_chat_created";
private static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id";
private static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id";
private static final String EDITDATE_FIELD = "edit_date";
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier
@JsonProperty(FROM_FIELD)
@ -117,6 +118,8 @@ public class Message implements IBotApiObject {
private Long migrateToChatId; ///< Optional. The chat has been migrated to a chat with specified identifier, not exceeding 1e13 by absolute value
@JsonProperty(MIGRATEFROMCHAT_FIELD)
private Long migrateFromChatId; ///< Optional. The chat has been migrated from a chat with specified identifier, not exceeding 1e13 by absolute value
@JsonProperty(EDITDATE_FIELD)
private Integer editDate; ///< Optional. Date the message was last edited in Unix time
public Message() {
super();
@ -225,6 +228,9 @@ public class Message implements IBotApiObject {
if (jsonObject.has(MIGRATEFROMCHAT_FIELD)) {
this.migrateFromChatId = jsonObject.getLong(MIGRATEFROMCHAT_FIELD);
}
if (jsonObject.has(EDITDATE_FIELD)) {
editDate = jsonObject.getInt(EDITDATE_FIELD);
}
if (hasText() && entities != null) {
entities.forEach(x -> x.computeText(text));
@ -391,6 +397,10 @@ public class Message implements IBotApiObject {
return forwardFromChat;
}
public Integer getEditDate() {
return editDate;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
@ -485,6 +495,9 @@ public class Message implements IBotApiObject {
if (migrateFromChatId != null) {
gen.writeNumberField(MIGRATEFROMCHAT_FIELD, migrateFromChatId);
}
if (editDate != null) {
gen.writeNumberField(EDITDATE_FIELD, editDate);
}
gen.writeEndObject();
gen.flush();
}
@ -526,6 +539,7 @@ public class Message implements IBotApiObject {
", channelChatCreated=" + channelChatCreated +
", migrateToChatId=" + migrateToChatId +
", migrateFromChatId=" + migrateFromChatId +
", editDate=" + editDate +
'}';
}
}

View File

@ -23,6 +23,7 @@ public class MessageEntity implements IBotApiObject {
private static final String OFFSET_FIELD = "offset";
private static final String LENGTH_FIELD = "length";
private static final String URL_FIELD = "url";
private static final String USER_FIELD = "user";
@JsonProperty(TYPE_FIELD)
/**
* Type of the entity. One of
@ -36,6 +37,7 @@ public class MessageEntity implements IBotApiObject {
* code (monowidth string),
* pre (monowidth block),
* text_link (for clickable text URLs)
* text_mention (for users without usernames)
*/
private String type;
@JsonProperty(OFFSET_FIELD)
@ -44,6 +46,8 @@ public class MessageEntity implements IBotApiObject {
private Integer length; ///< Length of the entity in UTF-16 code units
@JsonProperty(URL_FIELD)
private String url; ///< Optional. For text_link only, url that will be opened after user taps on the text
@JsonProperty(USER_FIELD)
private User user; ///< Optional. For text_mention only, the mentioned user
private String text; ///< Text present in the entity. Computed from offset and length
@ -59,6 +63,9 @@ public class MessageEntity implements IBotApiObject {
if (EntityType.TEXTLINK.equals(type)) {
this.url = jsonObject.getString(URL_FIELD);
}
if (EntityType.TEXTMENTION.equals(type)) {
this.user = new User(jsonObject.getJSONObject(USER_FIELD));
}
}
public String getType() {
@ -81,6 +88,10 @@ public class MessageEntity implements IBotApiObject {
return text;
}
public User getUser() {
return user;
}
protected void computeText(String message) {
text = message.substring(offset, offset + length);
}
@ -94,6 +105,9 @@ public class MessageEntity implements IBotApiObject {
if (url != null && EntityType.TEXTLINK.equals(type)) {
gen.writeStringField(URL_FIELD, url);
}
if (user != null && EntityType.TEXTMENTION.equals(type)) {
gen.writeObjectField(USER_FIELD, user);
}
gen.writeEndObject();
gen.flush();
}
@ -110,6 +124,7 @@ public class MessageEntity implements IBotApiObject {
", offset=" + offset +
", length=" + length +
", url=" + url +
", user=" + user +
'}';
}
}

View File

@ -25,6 +25,7 @@ public class Update implements IBotApiObject {
private static final String INLINEQUERY_FIELD = "inline_query";
private static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result";
private static final String CALLBACKQUERY_FIELD = "callback_query";
private static final String EDITEDMESSAGE_FIELD = "callback_query";
@JsonProperty(UPDATEID_FIELD)
private Integer updateId;
@JsonProperty(MESSAGE_FIELD)
@ -35,6 +36,8 @@ public class Update implements IBotApiObject {
private ChosenInlineQuery chosenInlineQuery; ///< Optional. The result of a inline query that was chosen by a user and sent to their chat partner
@JsonProperty(CALLBACKQUERY_FIELD)
private CallbackQuery callbackQuery; ///< Optional. New incoming callback query
@JsonProperty(EDITEDMESSAGE_FIELD)
private Message editedMessage; ///< Optional. New version of a message that is known to the bot and was edited
public Update() {
super();
@ -55,6 +58,9 @@ public class Update implements IBotApiObject {
if (jsonObject.has(CALLBACKQUERY_FIELD)) {
callbackQuery = new CallbackQuery(jsonObject.getJSONObject(CALLBACKQUERY_FIELD));
}
if (jsonObject.has(EDITEDMESSAGE_FIELD)){
editedMessage = new Message(jsonObject.getJSONObject(EDITEDMESSAGE_FIELD));
}
}
public Integer getUpdateId() {
@ -77,6 +83,10 @@ public class Update implements IBotApiObject {
return callbackQuery;
}
public Message getEditedMessage() {
return editedMessage;
}
public boolean hasMessage() {
return message != null;
}
@ -93,6 +103,9 @@ public class Update implements IBotApiObject {
return callbackQuery != null;
}
public boolean hasEditedMessage() {
return editedMessage != null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
@ -109,6 +122,9 @@ public class Update implements IBotApiObject {
if (callbackQuery != null) {
gen.writeObjectField(CALLBACKQUERY_FIELD, callbackQuery);
}
if (editedMessage != null) {
gen.writeObjectField(EDITEDMESSAGE_FIELD, editedMessage);
}
gen.writeEndObject();
gen.flush();
}
@ -126,6 +142,7 @@ public class Update implements IBotApiObject {
", inlineQuery=" + inlineQuery +
", chosenInlineQuery=" + chosenInlineQuery +
", callbackQuery=" + callbackQuery +
", editedMessage=" + editedMessage +
'}';
}
}

View File

@ -18,13 +18,36 @@ import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.TelegramApiException;
import org.telegram.telegrambots.api.methods.*;
import org.telegram.telegrambots.api.methods.AnswerCallbackQuery;
import org.telegram.telegrambots.api.methods.AnswerInlineQuery;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.methods.ForwardMessage;
import org.telegram.telegrambots.api.methods.GetFile;
import org.telegram.telegrambots.api.methods.GetMe;
import org.telegram.telegrambots.api.methods.GetUserProfilePhotos;
import org.telegram.telegrambots.api.methods.groupadministration.GetChat;
import org.telegram.telegrambots.api.methods.groupadministration.GetChatAdministrators;
import org.telegram.telegrambots.api.methods.groupadministration.GetChatMember;
import org.telegram.telegrambots.api.methods.groupadministration.GetChatMemberCount;
import org.telegram.telegrambots.api.methods.groupadministration.KickChatMember;
import org.telegram.telegrambots.api.methods.groupadministration.LeaveChat;
import org.telegram.telegrambots.api.methods.groupadministration.UnbanChatMember;
import org.telegram.telegrambots.api.methods.send.*;
import org.telegram.telegrambots.api.methods.send.SendAudio;
import org.telegram.telegrambots.api.methods.send.SendChatAction;
import org.telegram.telegrambots.api.methods.send.SendContact;
import org.telegram.telegrambots.api.methods.send.SendDocument;
import org.telegram.telegrambots.api.methods.send.SendLocation;
import org.telegram.telegrambots.api.methods.send.SendMessage;
import org.telegram.telegrambots.api.methods.send.SendPhoto;
import org.telegram.telegrambots.api.methods.send.SendSticker;
import org.telegram.telegrambots.api.methods.send.SendVenue;
import org.telegram.telegrambots.api.methods.send.SendVideo;
import org.telegram.telegrambots.api.methods.send.SendVoice;
import org.telegram.telegrambots.api.methods.updatingmessages.EditMessageCaption;
import org.telegram.telegrambots.api.methods.updatingmessages.EditMessageReplyMarkup;
import org.telegram.telegrambots.api.methods.updatingmessages.EditMessageText;
import org.telegram.telegrambots.api.objects.Chat;
import org.telegram.telegrambots.api.objects.ChatMember;
import org.telegram.telegrambots.api.objects.File;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.User;
@ -146,6 +169,41 @@ public abstract class AbsSender {
return (Boolean) sendApiMethod(unbanChatMember);
}
public Boolean leaveChat(LeaveChat leaveChat) throws TelegramApiException {
if (leaveChat == null) {
throw new TelegramApiException("Parameter leaveChat can not be null");
}
return (Boolean) sendApiMethod(leaveChat);
}
public Chat getChat(GetChat getChat) throws TelegramApiException {
if (getChat == null) {
throw new TelegramApiException("Parameter getChat can not be null");
}
return (Chat) sendApiMethod(getChat);
}
public List<ChatMember> getChatAdministrators(GetChatAdministrators getChatAdministrators) throws TelegramApiException {
if (getChatAdministrators == null) {
throw new TelegramApiException("Parameter getChatAdministrators can not be null");
}
return (ArrayList<ChatMember>) sendApiMethod(getChatAdministrators);
}
public ChatMember getChatMember(GetChatMember getChatMember) throws TelegramApiException {
if (getChatMember == null) {
throw new TelegramApiException("Parameter getChatMember can not be null");
}
return (ChatMember) sendApiMethod(getChatMember);
}
public Integer getChatMemberCount(GetChatMemberCount getChatMemberCount) throws TelegramApiException {
if (getChatMemberCount == null) {
throw new TelegramApiException("Parameter getChatMemberCount can not be null");
}
return (Integer) sendApiMethod(getChatMemberCount);
}
public Message editMessageText(EditMessageText editMessageText) throws TelegramApiException {
if (editMessageText == null) {
throw new TelegramApiException("Parameter editMessageText can not be null");
@ -305,6 +363,58 @@ public abstract class AbsSender {
sendApiMethodAsync(unbanChatMember, sentCallback);
}
public void leaveChatAsync(LeaveChat leaveChat, SentCallback<Boolean> sentCallback) throws TelegramApiException {
if (leaveChat == null) {
throw new TelegramApiException("Parameter leaveChat can not be null");
}
if (sentCallback == null) {
throw new TelegramApiException("Parameter sentCallback can not be null");
}
sendApiMethodAsync(leaveChat, sentCallback);
}
public void getChatAsync(GetChat getChat, SentCallback<Chat> sentCallback) throws TelegramApiException {
if (getChat == null) {
throw new TelegramApiException("Parameter getChat can not be null");
}
if (sentCallback == null) {
throw new TelegramApiException("Parameter sentCallback can not be null");
}
sendApiMethodAsync(getChat, sentCallback);
}
public void getChatAdministratorsAsync(GetChatAdministrators getChatAdministrators, SentCallback<ArrayList<ChatMember>> sentCallback) throws TelegramApiException {
if (getChatAdministrators == null) {
throw new TelegramApiException("Parameter getChatAdministrators can not be null");
}
if (sentCallback == null) {
throw new TelegramApiException("Parameter sentCallback can not be null");
}
sendApiMethodAsync(getChatAdministrators, sentCallback);
}
public void getChatMemberAsync(GetChatMember getChatMember, SentCallback<ChatMember> sentCallback) throws TelegramApiException {
if (getChatMember == null) {
throw new TelegramApiException("Parameter getChatMember can not be null");
}
if (sentCallback == null) {
throw new TelegramApiException("Parameter sentCallback can not be null");
}
sendApiMethodAsync(getChatMember, sentCallback);
}
public void getChatMemberCountAsync(GetChatMemberCount getChatMemberCount, SentCallback<Integer> sentCallback) throws TelegramApiException {
if (getChatMemberCount == null) {
throw new TelegramApiException("Parameter getChatMemberCount can not be null");
}
if (sentCallback == null) {
throw new TelegramApiException("Parameter sentCallback can not be null");
}
sendApiMethodAsync(getChatMemberCount, sentCallback);
}
public void editMessageTextAsync(EditMessageText editMessageText, SentCallback<Message> sentCallback) throws TelegramApiException {
if (editMessageText == null) {
throw new TelegramApiException("Parameter editMessageText can not be null");