From 2bc7ebc0559591f3a08e2592df77b601bd64d9ed Mon Sep 17 00:00:00 2001 From: gekoramy Date: Thu, 15 Feb 2018 15:19:34 +0100 Subject: [PATCH] Fixed Bot API methods ## AnswerCallbackQuery `setCacheTime(...)` now returns `AnswerCallbackQuery` ## EditMessageLiveLocation `setLongitud(...)` corrected requireNonNull check `setLatitude(...)` corrected requireNonNull check ## Suggestion Removed `Objects.requireNonNull(chatId)` check from methods which can have `inline_message_id` instead of `chat_id` --- .../telegrambots/api/methods/AnswerCallbackQuery.java | 3 ++- .../telegrambots/api/methods/StopMessageLiveLocation.java | 1 - .../telegrambots/api/methods/games/GetGameHighScores.java | 1 - .../telegram/telegrambots/api/methods/games/SetGameScore.java | 1 - .../api/methods/updatingmessages/EditMessageLiveLocation.java | 4 ++-- .../api/methods/updatingmessages/EditMessageReplyMarkup.java | 1 - .../api/methods/updatingmessages/EditMessageText.java | 1 - 7 files changed, 4 insertions(+), 8 deletions(-) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/AnswerCallbackQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/AnswerCallbackQuery.java index bff2cf55..e6759cc2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/AnswerCallbackQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/AnswerCallbackQuery.java @@ -97,8 +97,9 @@ public class AnswerCallbackQuery extends BotApiMethod { return cacheTime; } - public void setCacheTime(Integer cacheTime) { + public AnswerCallbackQuery setCacheTime(Integer cacheTime) { this.cacheTime = cacheTime; + return this; } @Override diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/StopMessageLiveLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/StopMessageLiveLocation.java index 9b8ff3ef..9042f5f8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/StopMessageLiveLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/StopMessageLiveLocation.java @@ -60,7 +60,6 @@ public class StopMessageLiveLocation extends BotApiMethod { } public StopMessageLiveLocation setChatId(Long chatId) { - Objects.requireNonNull(chatId); this.chatId = chatId.toString(); return this; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/GetGameHighScores.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/GetGameHighScores.java index 4c15322d..f3ad3953 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/GetGameHighScores.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/GetGameHighScores.java @@ -86,7 +86,6 @@ public class GetGameHighScores extends BotApiMethod> { } public GetGameHighScores setChatId(Long chatId) { - Objects.requireNonNull(chatId); this.chatId = chatId.toString(); return this; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/SetGameScore.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/SetGameScore.java index daa06841..50e3c1cb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/SetGameScore.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/games/SetGameScore.java @@ -104,7 +104,6 @@ public class SetGameScore extends BotApiMethod { } public SetGameScore setChatId(Long chatId) { - Objects.requireNonNull(chatId); this.chatId = chatId.toString(); return this; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageLiveLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageLiveLocation.java index 2260b035..ff0d79ec 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageLiveLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageLiveLocation.java @@ -104,7 +104,7 @@ public class EditMessageLiveLocation extends BotApiMethod { } public EditMessageLiveLocation setLatitude(Float latitude) { - Objects.requireNonNull(chatId); + Objects.requireNonNull(latitude); this.latitude = latitude; return this; } @@ -114,7 +114,7 @@ public class EditMessageLiveLocation extends BotApiMethod { } public EditMessageLiveLocation setLongitud(Float longitud) { - Objects.requireNonNull(chatId); + Objects.requireNonNull(longitud); this.longitud = longitud; return this; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageReplyMarkup.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageReplyMarkup.java index f34e6748..9952f3b4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageReplyMarkup.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageReplyMarkup.java @@ -63,7 +63,6 @@ public class EditMessageReplyMarkup extends BotApiMethod { } public EditMessageReplyMarkup setChatId(Long chatId) { - Objects.requireNonNull(chatId); this.chatId = chatId.toString(); return this; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageText.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageText.java index b87ae198..39376ec6 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageText.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageText.java @@ -79,7 +79,6 @@ public class EditMessageText extends BotApiMethod { } public EditMessageText setChatId(Long chatId) { - Objects.requireNonNull(chatId); this.chatId = chatId.toString(); return this; }