commit
7f0e848cf7
@ -27,12 +27,12 @@ Just import add the library to your project with one of these options:
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<version>2.4.4</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/v2.4.3)
|
||||
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.4.3)
|
||||
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/v2.4.4)
|
||||
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.4.4)
|
||||
|
||||
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||
|
||||
@ -110,4 +110,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
@ -8,4 +8,13 @@
|
||||
7. In `SentCallback` method `onError` changed second parameter to `TelegramApiRequestException` and `onResult` now receives the deserialized answer (of type `T`) instead of a `JSONObject` as second parameter
|
||||
8. Moved to MIT license
|
||||
|
||||
**[[How to update to version 2.4.3|How-To-Update#2.4.3]]**
|
||||
**[[How to update to version 2.4.3|How-To-Update#2.4.3]]**
|
||||
|
||||
### <a id="2.4.4"></a>2.4.4 ###
|
||||
1. Added `cache_time` to ÀnswerCallbackQuery method
|
||||
2. Added field `forward_from_message_id` to `Message` object
|
||||
3. Renamed `ReplyKeyboardHide` to `ReplyKeyboardRemove` and its field `hide_keyboard` to `remove_keyboard`
|
||||
4. Added field `force` and `disable_edit_message` to `SetGameScore`, removed `edit_message` one.
|
||||
5. Added `channel_post` and `edited_channel_post` to `Update` object.
|
||||
|
||||
**[[How to update to version 2.4.4|How-To-Update#2.4.4]]**
|
@ -8,4 +8,10 @@
|
||||
3. **Deprecated** (will be removed in next version):
|
||||
* `org.telegram.telegrambots.bots.BotOptions`. Use `org.telegram.telegrambots.bots.DefaultBotOptions` instead.
|
||||
* `getPersonal` from `AnswerInlineQuery`. Use `isPersonal` instead.
|
||||
* `FILEBASEURL` from `File`. Use `getFileUrl` instead.
|
||||
* `FILEBASEURL` from `File`. Use `getFileUrl` instead.
|
||||
|
||||
|
||||
### <a id="2.4.4"></a>To version 2.4.4 ###
|
||||
1. Replace `ReplyKeyboardHide` by `ReplyKeyboardRemove` and its field `hideKeyboard` by `removeKeyboard` (remember getter and setters)
|
||||
2. Replace usage of `edit_message` by `disable_edit_message` (see [this post](https://telegram.me/BotNews/22))
|
||||
3. Removed deprecated stuff from version 2.4.3
|
4
pom.xml
4
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.4.3</version>
|
||||
<version>2.4.4</version>
|
||||
|
||||
<modules>
|
||||
<module>telegrambots</module>
|
||||
@ -24,6 +24,6 @@
|
||||
|
||||
<properties>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
<bots.version>2.4.3</bots.version>
|
||||
<bots.version>2.4.4</bots.version>
|
||||
</properties>
|
||||
</project>
|
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-meta</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<version>2.4.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Telegram Bots Meta</name>
|
||||
|
@ -28,6 +28,7 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
private static final String TEXT_FIELD = "text";
|
||||
private static final String SHOWALERT_FIELD = "show_alert";
|
||||
private static final String URL_FIELD = "url";
|
||||
private static final String CACHETIME_FIELD = "cache_time";
|
||||
|
||||
@JsonProperty(CALLBACKQUERYID_FIELD)
|
||||
private String callbackQueryId; ///< Unique identifier for the query to be answered
|
||||
@ -35,14 +36,22 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
private String text; ///< Optional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
|
||||
@JsonProperty(SHOWALERT_FIELD)
|
||||
private Boolean showAlert; ///< Optional. If true, an alert will be shown by the client instead of a notificaiton at the top of the chat screen. Defaults to false.
|
||||
@JsonProperty(URL_FIELD)
|
||||
/**
|
||||
* Optional. URL that will be opened by the user's client.
|
||||
* If you have created a Game and accepted the conditions via @Botfather,
|
||||
* specify the URL that opens your game. Otherwise you may use links
|
||||
* InlineQueryResultGamelike telegram.me/your_bot?start=XXXX that open your bot with a parameter.
|
||||
*/
|
||||
@JsonProperty(URL_FIELD)
|
||||
private String url;
|
||||
@JsonProperty(CACHETIME_FIELD)
|
||||
/**
|
||||
* Optional The maximum amount of time in seconds that the result of the callback query
|
||||
* may be cached client-side.
|
||||
*
|
||||
* @note Telegram apps will support caching starting in version 3.14. Defaults to 0.
|
||||
*/
|
||||
private Integer cacheTime;
|
||||
|
||||
public AnswerCallbackQuery() {
|
||||
super();
|
||||
@ -84,6 +93,14 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCacheTime() {
|
||||
return cacheTime;
|
||||
}
|
||||
|
||||
public void setCacheTime(Integer cacheTime) {
|
||||
this.cacheTime = cacheTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -118,6 +135,7 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
", text='" + text + '\'' +
|
||||
", showAlert=" + showAlert +
|
||||
", url='" + url + '\'' +
|
||||
", cacheTime=" + cacheTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -81,12 +81,6 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public Boolean getPersonal() {
|
||||
return isPersonal;
|
||||
}
|
||||
|
||||
public Boolean isPersonal() {
|
||||
return isPersonal;
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ import java.util.Objects;
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 2.4
|
||||
* @brief Use this method to set the score of the specified user in a game.
|
||||
* Use this method to set the score of the specified user in a game.
|
||||
* On success, if the message was sent by the bot, returns the edited Message,
|
||||
* otherwise returns True.
|
||||
* If the new score is not greater than the user's current score in the chat,
|
||||
* returns an error with the description “BOT_SCORE_NOT_MODIFIED”.
|
||||
* @date 16 of September of 2016
|
||||
*
|
||||
* Returns an error, if the new score is not greater than the user's current score in
|
||||
* the chat and force is False.
|
||||
*/
|
||||
public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
public static final String PATH = "setGameScore";
|
||||
@ -48,7 +48,8 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
private static final String MESSAGEID_FIELD = "message_id";
|
||||
private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
|
||||
private static final String EDIT_MESSAGE_FIELD = "edit_message";
|
||||
private static final String DISABLEEDITMESSAGE_FIELD = "disable_edit_message";
|
||||
private static final String FORCE_FIELD = "force";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
private String chatId; ///< Optional Required if inline_message_id is not specified. Unique identifier for the target chat (or username of the target channel in the format @channelusername)
|
||||
@ -56,12 +57,14 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
private Integer messageId; ///< Optional Required if inline_message_id is not specified. Unique identifier of the sent message
|
||||
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
|
||||
private String inlineMessageId; ///< Optional Required if chat_id and message_id are not specified. Identifier of the inline message
|
||||
@JsonProperty(EDIT_MESSAGE_FIELD)
|
||||
private Boolean editMessage; ///< Optional Pass True, if the message should be edited to include the current scoreboard
|
||||
@JsonProperty(DISABLEEDITMESSAGE_FIELD)
|
||||
private Boolean disableEditMessage; ///< Optional Pass True, if the game message should not be automatically edited to include the current scoreboard. Defaults to False
|
||||
@JsonProperty(USER_ID_FIELD)
|
||||
private Integer userId; ///< User identifier
|
||||
@JsonProperty(SCORE_FIELD)
|
||||
private Integer score; ///< New score, must be positive
|
||||
@JsonProperty(FORCE_FIELD)
|
||||
private Boolean force; ///< Opfional. Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters
|
||||
|
||||
public SetGameScore() {
|
||||
super();
|
||||
@ -79,8 +82,8 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public Boolean getEditMessage() {
|
||||
return editMessage;
|
||||
public Boolean getDisableEditMessage() {
|
||||
return disableEditMessage;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
@ -91,6 +94,10 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
return score;
|
||||
}
|
||||
|
||||
public Boolean getForce() {
|
||||
return force;
|
||||
}
|
||||
|
||||
public SetGameScore setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
@ -112,8 +119,8 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setEditMessage(Boolean editMessage) {
|
||||
this.editMessage = editMessage;
|
||||
public SetGameScore setDisableEditMessage(Boolean disableEditMessage) {
|
||||
this.disableEditMessage = disableEditMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -127,6 +134,11 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setForce(Boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -189,9 +201,10 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", editMessage=" + editMessage +
|
||||
", disableEditMessage=" + disableEditMessage +
|
||||
", userId=" + userId +
|
||||
", score=" + score +
|
||||
", force=" + force +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.telegram.telegrambots.api.objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.telegram.telegrambots.api.interfaces.BotApiObject;
|
||||
@ -15,14 +14,6 @@ import java.text.MessageFormat;
|
||||
* @date 24 of June of 2015
|
||||
*/
|
||||
public class File implements BotApiObject {
|
||||
@JsonIgnore
|
||||
/**
|
||||
* @deprecated It is still public for backward compatibility, will be removed in next big release.
|
||||
* use {@link #getFileUrl(String, String)} or {@link #getFileUrl(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String FILEBASEURL = "https://api.telegram.org/file/bot{0}/{1}";
|
||||
|
||||
private static final String FILE_ID = "file_id";
|
||||
private static final String FILE_SIZE_FIELD = "file_size";
|
||||
private static final String FILE_PATH_FIELD = "file_path";
|
||||
|
@ -47,6 +47,7 @@ public class Message implements BotApiObject {
|
||||
private static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id";
|
||||
private static final String EDITDATE_FIELD = "edit_date";
|
||||
private static final String GAME_FIELD = "game";
|
||||
private static final String FORWARDFROMMESSAGEID_FIELD = "forward_from_message_id";
|
||||
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
private Integer messageId; ///< Integer Unique message identifier
|
||||
@ -146,6 +147,8 @@ public class Message implements BotApiObject {
|
||||
private Integer editDate; ///< Optional. Date the message was last edited in Unix time
|
||||
@JsonProperty(GAME_FIELD)
|
||||
private Game game; ///< Optional. Message is a game, information about the game
|
||||
@JsonProperty(FORWARDFROMMESSAGEID_FIELD)
|
||||
private Integer forwardFromMessageId; ///< Optional. For forwarded channel posts, identifier of the original message in the channel
|
||||
|
||||
public Message() {
|
||||
super();
|
||||
@ -272,6 +275,10 @@ public class Message implements BotApiObject {
|
||||
return migrateFromChatId;
|
||||
}
|
||||
|
||||
public Integer getForwardFromMessageId() {
|
||||
return forwardFromMessageId;
|
||||
}
|
||||
|
||||
public boolean isGroupMessage() {
|
||||
return chat.isGroupChat();
|
||||
}
|
||||
@ -380,6 +387,7 @@ public class Message implements BotApiObject {
|
||||
", migrateFromChatId=" + migrateFromChatId +
|
||||
", editDate=" + editDate +
|
||||
", game=" + game +
|
||||
", forwardFromMessageId=" + forwardFromMessageId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ public class Update implements BotApiObject {
|
||||
private static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result";
|
||||
private static final String CALLBACKQUERY_FIELD = "callback_query";
|
||||
private static final String EDITEDMESSAGE_FIELD = "edited_message";
|
||||
private static final String CHANNELPOST_FIELD = "channel_post";
|
||||
private static final String EDITEDCHANNELPOST_FIELD = "edited_channel_post";
|
||||
|
||||
@JsonProperty(UPDATEID_FIELD)
|
||||
private Integer updateId;
|
||||
@ -33,6 +35,11 @@ public class Update implements BotApiObject {
|
||||
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
|
||||
@JsonProperty(CHANNELPOST_FIELD)
|
||||
private Message channelPost; ///< Optional. New incoming channel post of any kind — text, photo, sticker, etc.
|
||||
@JsonProperty(EDITEDCHANNELPOST_FIELD)
|
||||
private Message editedChannelPost; ///< Optional. New version of a channel post that is known to the bot and was edited
|
||||
|
||||
|
||||
public Update() {
|
||||
super();
|
||||
@ -62,6 +69,14 @@ public class Update implements BotApiObject {
|
||||
return editedMessage;
|
||||
}
|
||||
|
||||
public Message getChannelPost() {
|
||||
return channelPost;
|
||||
}
|
||||
|
||||
public Message getEditedChannelPost() {
|
||||
return editedChannelPost;
|
||||
}
|
||||
|
||||
public boolean hasMessage() {
|
||||
return message != null;
|
||||
}
|
||||
@ -82,6 +97,14 @@ public class Update implements BotApiObject {
|
||||
return editedMessage != null;
|
||||
}
|
||||
|
||||
public boolean hasChannelPost() {
|
||||
return channelPost != null;
|
||||
}
|
||||
|
||||
public boolean hasEditedChannelPost() {
|
||||
return editedChannelPost != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Update{" +
|
||||
@ -91,6 +114,8 @@ public class Update implements BotApiObject {
|
||||
", chosenInlineQuery=" + chosenInlineQuery +
|
||||
", callbackQuery=" + callbackQuery +
|
||||
", editedMessage=" + editedMessage +
|
||||
", channelPost=" + channelPost +
|
||||
", editedChannelPost=" + editedChannelPost +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
||||
* hidden immediately after the user presses a button (@see ReplyKeyboardMarkup).
|
||||
* @date 20 of June of 2015
|
||||
*/
|
||||
public class ReplyKeyboardHide implements ReplyKeyboard {
|
||||
private static final String HIDEKEYBOARD_FIELD = "hide_keyboard";
|
||||
public class ReplyKeyboardRemove implements ReplyKeyboard {
|
||||
private static final String REMOVEKEYBOARD_FIELD = "remove_keyboard";
|
||||
private static final String SELECTIVE_FIELD = "selective";
|
||||
|
||||
@JsonProperty(HIDEKEYBOARD_FIELD)
|
||||
private Boolean hideKeyboard; ///< Requests clients to hide the custom keyboard
|
||||
@JsonProperty(REMOVEKEYBOARD_FIELD)
|
||||
private Boolean removeKeyboard; ///< Requests clients to remove the custom keyboard
|
||||
/**
|
||||
* Optional. Use this parameter if you want to show the keyboard to specific users only.
|
||||
* Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's
|
||||
@ -27,35 +27,35 @@ public class ReplyKeyboardHide implements ReplyKeyboard {
|
||||
@JsonProperty(SELECTIVE_FIELD)
|
||||
private Boolean selective;
|
||||
|
||||
public ReplyKeyboardHide() {
|
||||
public ReplyKeyboardRemove() {
|
||||
super();
|
||||
this.hideKeyboard = true;
|
||||
this.removeKeyboard = true;
|
||||
}
|
||||
|
||||
public Boolean getHideKeyboard() {
|
||||
return hideKeyboard;
|
||||
public Boolean getRemoveKeyboard() {
|
||||
return removeKeyboard;
|
||||
}
|
||||
|
||||
public Boolean getSelective() {
|
||||
return selective;
|
||||
}
|
||||
|
||||
public ReplyKeyboardHide setSelective(Boolean selective) {
|
||||
public ReplyKeyboardRemove setSelective(Boolean selective) {
|
||||
this.selective = selective;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (hideKeyboard == null) {
|
||||
throw new TelegramApiValidationException("Hidekeyboard parameter can't be null", this);
|
||||
if (removeKeyboard == null) {
|
||||
throw new TelegramApiValidationException("RemoveKeyboard parameter can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplyKeyboardHide{" +
|
||||
"hideKeyboard=" + hideKeyboard +
|
||||
return "ReplyKeyboardRemove{" +
|
||||
"removeKeyboard=" + removeKeyboard +
|
||||
", selective=" + selective +
|
||||
'}';
|
||||
}
|
@ -24,7 +24,7 @@ public class TestSetGameScore {
|
||||
public void setUp() throws Exception {
|
||||
setGameScore = new SetGameScore();
|
||||
setGameScore.setChatId("12345");
|
||||
setGameScore.setEditMessage(true);
|
||||
setGameScore.setDisableEditMessage(true);
|
||||
setGameScore.setMessageId(54321);
|
||||
setGameScore.setScore(12);
|
||||
setGameScore.setUserId(98765);
|
||||
@ -34,7 +34,7 @@ public class TestSetGameScore {
|
||||
public void TestGetUpdatesMustBeSerializable() throws Exception {
|
||||
String json = mapper.writeValueAsString(setGameScore);
|
||||
Assert.assertNotNull(json);
|
||||
Assert.assertEquals("{\"chat_id\":\"12345\",\"message_id\":54321,\"edit_message\":true,\"user_id\":98765,\"score\":12,\"method\":\"setGameScore\"}", json);
|
||||
Assert.assertEquals("{\"chat_id\":\"12345\",\"message_id\":54321,\"disable_edit_message\":true,\"user_id\":98765,\"score\":12,\"method\":\"setGameScore\"}", json);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<version>2.4.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Telegram Bots</name>
|
||||
@ -65,7 +65,7 @@
|
||||
<json.version>20160810</json.version>
|
||||
<jackson.version>2.8.5</jackson.version>
|
||||
<commonio.version>2.5</commonio.version>
|
||||
<bots.version>2.4.3</bots.version>
|
||||
<bots.version>2.4.4</bots.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -1,61 +0,0 @@
|
||||
package org.telegram.telegrambots.bots;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.telegram.telegrambots.Constants;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* @deprecated Use {@link DefaultBotOptions} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class BotOptions extends DefaultBotOptions {
|
||||
private String proxyHost;
|
||||
private int proxyPort;
|
||||
|
||||
public boolean hasProxy() {
|
||||
return proxyHost != null && !proxyHost.isEmpty() && proxyPort > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setRequestConfig(RequestConfig)} instead to configure custom request config
|
||||
* @param proxyHost Host for the proxy
|
||||
*
|
||||
* @apiNote This method will be removed in the future
|
||||
*/
|
||||
public void setProxyHost(String proxyHost) {
|
||||
this.proxyHost = proxyHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setRequestConfig(RequestConfig)} instead to configure custom request config
|
||||
* @param proxyPort Port for the proxy
|
||||
*
|
||||
* @apiNote This method will be removed in the future
|
||||
*/
|
||||
public void setProxyPort(int proxyPort) {
|
||||
this.proxyPort = proxyPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestConfig getRequestConfig() {
|
||||
if (super.getRequestConfig() == null) {
|
||||
if (hasProxy()) { // For backward compatibility
|
||||
return RequestConfig.copy(RequestConfig.custom().build())
|
||||
.setProxy(new HttpHost(proxyHost, proxyPort))
|
||||
.setSocketTimeout(Constants.SOCKET_TIMEOUT)
|
||||
.setConnectTimeout(Constants.SOCKET_TIMEOUT)
|
||||
.setConnectionRequestTimeout(Constants.SOCKET_TIMEOUT)
|
||||
.build();
|
||||
}
|
||||
return RequestConfig.copy(RequestConfig.custom().build())
|
||||
.setSocketTimeout(Constants.SOCKET_TIMEOUT)
|
||||
.setConnectTimeout(Constants.SOCKET_TIMEOUT)
|
||||
.setConnectionRequestTimeout(Constants.SOCKET_TIMEOUT)
|
||||
.build();
|
||||
}
|
||||
|
||||
return super.getRequestConfig();
|
||||
}
|
||||
}
|
@ -279,7 +279,7 @@ public final class BotApiMethodHelperFactory {
|
||||
public static BotApiMethod getSetGameScore() {
|
||||
return new SetGameScore()
|
||||
.setInlineMessageId("12345")
|
||||
.setEditMessage(true)
|
||||
.setDisableEditMessage(true)
|
||||
.setScore(12)
|
||||
.setUserId(98765);
|
||||
}
|
||||
|
@ -106,29 +106,7 @@ public class TestRestApi extends JerseyTest {
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, AnswerInlineQuery.class);
|
||||
|
||||
assertEquals("{\"inline_query_id\":\"id\",\"results\":[{\"@class\":\"org." +
|
||||
"telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResultArticle\"," +
|
||||
"\"type\":\"article\",\"id\":\"0\",\"title\":\"Title\",\"input_message_content\":{\"@class\":\"org." +
|
||||
"telegram.telegrambots.api.objects.inlinequery.inputmessagecontent." +
|
||||
"InputTextMessageContent\",\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"}," +
|
||||
"\"reply_markup\":{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard" +
|
||||
".InlineKeyboardMarkup\",\"inline_keyboard\":[[{\"@class\":\"org.telegram." +
|
||||
"telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton\",\"text\":" +
|
||||
"\"Button1\",\"callback_data\":\"Callback\"}]]},\"url\":\"Url\",\"hide_url\":false," +
|
||||
"\"description\":\"Description\",\"thumb_url\":\"ThumbUrl\",\"thumb_width\":10," +
|
||||
"\"thumb_height\":20},{\"@class\":\"org.telegram.telegrambots.api.objects." +
|
||||
"inlinequery.result.InlineQueryResultPhoto\",\"type\":\"photo\",\"id\":\"1\",\"photo_url\":\"PhotoUrl" +
|
||||
"\",\"mime_type\":\"image/jpg\",\"photo_width\":10,\"photo_height\":20,\"thumb_url" +
|
||||
"\":\"ThumbUrl\",\"title\":\"Title\",\"description\":\"Description\",\"caption\":" +
|
||||
"\"Caption\",\"input_message_content\":{\"@class\":\"org.telegram.telegrambots." +
|
||||
"api.objects.inlinequery.inputmessagecontent.InputTextMessageContent\",\"" +
|
||||
"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"@class\":" +
|
||||
"\"org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup\"," +
|
||||
"\"inline_keyboard\":[[{\"@class\":\"org.telegram.telegrambots.api.objects." +
|
||||
"replykeyboard.buttons.InlineKeyboardButton\",\"text\":\"Button1\"," +
|
||||
"\"callback_data\":\"Callback\"}]]}}],\"cache_time\":100,\"is_personal\":true," +
|
||||
"\"next_offset\":\"3\",\"switch_pm_text\":\"pmText\",\"switch_pm_parameter\":" +
|
||||
"\"PmParameter\",\"method\":\"answerInlineQuery\"}", map(result));
|
||||
assertEquals("{\"personal\":true,\"inline_query_id\":\"id\",\"results\":[{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResultArticle\",\"type\":\"article\",\"id\":\"0\",\"title\":\"Title\",\"input_message_content\":{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent\",\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup\",\"inline_keyboard\":[[{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton\",\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"url\":\"Url\",\"hide_url\":false,\"description\":\"Description\",\"thumb_url\":\"ThumbUrl\",\"thumb_width\":10,\"thumb_height\":20},{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResultPhoto\",\"type\":\"photo\",\"id\":\"1\",\"photo_url\":\"PhotoUrl\",\"mime_type\":\"image/jpg\",\"photo_width\":10,\"photo_height\":20,\"thumb_url\":\"ThumbUrl\",\"title\":\"Title\",\"description\":\"Description\",\"caption\":\"Caption\",\"input_message_content\":{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent\",\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup\",\"inline_keyboard\":[[{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton\",\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]}}],\"cache_time\":100,\"is_personal\":true,\"next_offset\":\"3\",\"switch_pm_text\":\"pmText\",\"switch_pm_parameter\":\"PmParameter\",\"method\":\"answerInlineQuery\"}", map(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -417,7 +395,7 @@ public class TestRestApi extends JerseyTest {
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SetGameScore.class);
|
||||
|
||||
assertEquals("{\"inline_message_id\":\"12345\",\"edit_message\":true,\"user_id\":98765,\"score\":12,\"method\":\"setGameScore\"}", map(result));
|
||||
assertEquals("{\"inline_message_id\":\"12345\",\"disable_edit_message\":true,\"user_id\":98765,\"score\":12,\"method\":\"setGameScore\"}", map(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user