Fix wrong class and method names
This commit is contained in:
parent
aa3e1fcf63
commit
ce05d68e81
@ -0,0 +1,91 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 3.4
|
||||
* Use this method to delete a group sticker set from a supergroup.
|
||||
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.
|
||||
* Returns True on success.
|
||||
*/
|
||||
public class DeleteChatStickerSet extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "deleteChatStickerSet";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public DeleteChatStickerSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet(String chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet(Long chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
|
||||
new TypeReference<ApiResponse<Boolean>>(){});
|
||||
if (result.getOk()) {
|
||||
return result.getResult();
|
||||
} else {
|
||||
throw new TelegramApiRequestException("Error deleting chat sticker set", result);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeleteChatStickerSet{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -19,7 +19,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.
|
||||
* Returns True on success.
|
||||
* @deprecated Replaced by {@link DeleteChatStickerSet}
|
||||
*/
|
||||
@Deprecated
|
||||
public class DeleteStickerSetName extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "deleteChatStickerSet";
|
||||
|
||||
|
@ -16,7 +16,9 @@ import java.util.Objects;
|
||||
* @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
|
||||
* @deprecated Replaced by {@link GetChatMembersCount}
|
||||
*/
|
||||
@Deprecated
|
||||
public class GetChatMemberCount extends BotApiMethod<Integer> {
|
||||
public static final String PATH = "getChatMembersCount";
|
||||
|
||||
|
@ -0,0 +1,78 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
/**
|
||||
* @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 GetChatMembersCount extends BotApiMethod<Integer> {
|
||||
public static final String PATH = "getChatMembersCount";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public GetChatMembersCount() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public GetChatMembersCount setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetChatMembersCount setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
ApiResponse<Integer> result = OBJECT_MAPPER.readValue(answer,
|
||||
new TypeReference<ApiResponse<Integer>>(){});
|
||||
if (result.getOk()) {
|
||||
return result.getResult();
|
||||
} else {
|
||||
throw new TelegramApiRequestException("Error getting chat members count", result);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetChatMembersCount{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.updatingmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
@ -50,7 +51,7 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
@JsonProperty(LATITUDE_FIELD)
|
||||
private Float latitude; ///< Latitude of new location
|
||||
@JsonProperty(LONGITUDE_FIELD)
|
||||
private Float longitud; ///< Longitude of new location
|
||||
private Float longitude; ///< Longitude of new location
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
||||
|
||||
@ -109,13 +110,31 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #getLongitude()}
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public Float getLongitud() {
|
||||
return longitud;
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setLongitud(Float longitud) {
|
||||
Objects.requireNonNull(longitud);
|
||||
this.longitud = longitud;
|
||||
public Float getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #setLongitude(Float)}
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public EditMessageLiveLocation setLongitud(Float longitude) {
|
||||
return setLongitude(longitude);
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setLongitude(Float longitude) {
|
||||
Objects.requireNonNull(longitude);
|
||||
this.longitude = longitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -170,8 +189,8 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
if (latitude == null) {
|
||||
throw new TelegramApiValidationException("Latitude parameter can't be empty", this);
|
||||
}
|
||||
if (longitud == null) {
|
||||
throw new TelegramApiValidationException("Longitud parameter can't be empty", this);
|
||||
if (longitude == null) {
|
||||
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
@ -185,7 +204,7 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", latitude=" + latitude +
|
||||
", longitud=" + longitud +
|
||||
", longitude=" + longitude +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import org.telegram.telegrambots.meta.api.methods.games.SetGameScore;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChat;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatAdministrators;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMember;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMemberCount;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMembersCount;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.KickChatMember;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.LeaveChat;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.UnbanChatMember;
|
||||
@ -123,8 +123,8 @@ public final class BotApiMethodHelperFactory {
|
||||
.setUserId(98765);
|
||||
}
|
||||
|
||||
public static BotApiMethod getChatMemberCount() {
|
||||
return new GetChatMemberCount()
|
||||
public static BotApiMethod getChatMembersCount() {
|
||||
return new GetChatMembersCount()
|
||||
.setChatId("12345");
|
||||
}
|
||||
|
||||
|
@ -196,14 +196,14 @@ public class TestRestApi extends JerseyTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestGetChatMemberCount() {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatMemberCount());
|
||||
public void TestGetChatMembersCount() {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatMembersCount());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetChatMemberCount.class);
|
||||
.post(entity, GetChatMembersCount.class);
|
||||
|
||||
assertEquals("{\"chat_id\":\"12345\",\"method\":\"getChatMembersCount\"}", map(result));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user