Merge branch 'dev' into typo-fix

This commit is contained in:
Victor 2018-12-12 17:10:18 +02:00
commit 9a6682688e
6 changed files with 19 additions and 11 deletions

View File

@ -9,9 +9,11 @@ package org.telegram.telegrambots.meta.api.methods;
public enum ActionType { public enum ActionType {
TYPING("typing"), TYPING("typing"),
RECORDVIDEO("record_video"), RECORDVIDEO("record_video"),
RECORDVIDEONOTE("record_video_note"),
RECORDAUDIO("record_audio"), RECORDAUDIO("record_audio"),
UPLOADPHOTO("upload_photo"), UPLOADPHOTO("upload_photo"),
UPLOADVIDEO("upload_video"), UPLOADVIDEO("upload_video"),
UPLOADVIDEONOTE("upload_video_note"),
UPLOADAUDIO("upload_audio"), UPLOADAUDIO("upload_audio"),
UPLOADDOCUMENT("upload_document"), UPLOADDOCUMENT("upload_document"),
FINDLOCATION("find_location"); FINDLOCATION("find_location");
@ -36,12 +38,16 @@ public enum ActionType {
return TYPING; return TYPING;
case "record_video": case "record_video":
return RECORDVIDEO; return RECORDVIDEO;
case "record_video_note":
return RECORDVIDEONOTE;
case "record_audio": case "record_audio":
return RECORDAUDIO; return RECORDAUDIO;
case "upload_photo": case "upload_photo":
return UPLOADPHOTO; return UPLOADPHOTO;
case "upload_video": case "upload_video":
return UPLOADVIDEO; return UPLOADVIDEO;
case "upload_video_note":
return UPLOADVIDEONOTE;
case "upload_audio": case "upload_audio":
return UPLOADAUDIO; return UPLOADAUDIO;
case "upload_document": case "upload_document":

View File

@ -136,8 +136,8 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
if (switchPmParameter.length() > 64) { if (switchPmParameter.length() > 64) {
throw new TelegramApiValidationException("SwitchPmParameter can't be longer than 64 chars", this); throw new TelegramApiValidationException("SwitchPmParameter can't be longer than 64 chars", this);
} }
if (!Pattern.matches("[A-Za-z0-9_]+", switchPmParameter.trim() )) { if (!Pattern.matches("[A-Za-z0-9_\\-]+", switchPmParameter.trim() )) {
throw new TelegramApiValidationException("SwitchPmParameter only allows A-Z, a-z, 0-9 and _ characters", this); throw new TelegramApiValidationException("SwitchPmParameter only allows A-Z, a-z, 0-9, _ and - characters", this);
} }
} }
for (InlineQueryResult result : results) { for (InlineQueryResult result : results) {

View File

@ -17,14 +17,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. * Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
*/ */
public class SetStickerPositionInSet extends BotApiMethod<Boolean> { public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
private static final String PATH = "getStickerSet"; private static final String PATH = "setStickerPositionInSet";
private static final String STICKER_FIELD = "sticker"; private static final String STICKER_FIELD = "sticker";
private static final String POSITION_FIELD = "position"; private static final String POSITION_FIELD = "position";
@JsonProperty(STICKER_FIELD) @JsonProperty(STICKER_FIELD)
private String sticker; ///< File identifier of the sticker private String sticker; ///< File identifier of the sticker
@JsonProperty(STICKER_FIELD) @JsonProperty(POSITION_FIELD)
private Integer position; ///< New sticker position in the set, zero-based private Integer position; ///< New sticker position in the set, zero-based
public SetStickerPositionInSet(String sticker, Integer position) { public SetStickerPositionInSet(String sticker, Integer position) {
@ -61,7 +61,7 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
if (sticker == null || sticker.isEmpty()) { if (sticker == null || sticker.isEmpty()) {
throw new TelegramApiValidationException("sticker can't be null", this); throw new TelegramApiValidationException("sticker can't be null", this);
} }
if (position == null || position > 0) { if (position == null || position < 0) {
throw new TelegramApiValidationException("position can't be null", this); throw new TelegramApiValidationException("position can't be null", this);
} }
} }
@ -71,7 +71,7 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
} }
public SetStickerPositionInSet setSticker(String sticker) { public SetStickerPositionInSet setSticker(String sticker) {
this.sticker = sticker; this.sticker = checkNotNull(sticker);
return this; return this;
} }
@ -80,7 +80,7 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
} }
public SetStickerPositionInSet setPosition(Integer position) { public SetStickerPositionInSet setPosition(Integer position) {
this.position = position; this.position = checkNotNull(position);
return this; return this;
} }

View File

@ -1,6 +1,7 @@
package org.telegram.telegrambots.meta.api.objects.stickers; package org.telegram.telegrambots.meta.api.objects.stickers;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.telegram.telegrambots.meta.api.interfaces.InputBotApiObject; import org.telegram.telegrambots.meta.api.interfaces.InputBotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable; import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -10,6 +11,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
* @version 3.2 * @version 3.2
* This object describes the position on faces where a mask should be placed by default. * This object describes the position on faces where a mask should be placed by default.
*/ */
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
public class MaskPosition implements InputBotApiObject, Validable { public class MaskPosition implements InputBotApiObject, Validable {
private static final String POINT_FIELD = "point"; private static final String POINT_FIELD = "point";
private static final String XSHIFT_FIELD = "x_shift"; private static final String XSHIFT_FIELD = "x_shift";

View File

@ -36,7 +36,7 @@ public class Sticker implements BotApiObject {
@JsonProperty(SETNAME_FIELD) @JsonProperty(SETNAME_FIELD)
private String setName; ///< Optional. Name of the sticker set to which the sticker belongs private String setName; ///< Optional. Name of the sticker set to which the sticker belongs
@JsonProperty(MASKPOSITON_FIELD) @JsonProperty(MASKPOSITON_FIELD)
private String maskPosition; ///< Optional. For mask stickers, the position where the mask should be placed private MaskPosition maskPosition; ///< Optional. For mask stickers, the position where the mask should be placed
public Sticker() { public Sticker() {
super(); super();
@ -70,7 +70,7 @@ public class Sticker implements BotApiObject {
return setName; return setName;
} }
public String getMaskPosition() { public MaskPosition getMaskPosition() {
return maskPosition; return maskPosition;
} }
@ -84,7 +84,7 @@ public class Sticker implements BotApiObject {
", fileSize=" + fileSize + ", fileSize=" + fileSize +
", emoji='" + emoji + '\'' + ", emoji='" + emoji + '\'' +
", setName='" + setName + '\'' + ", setName='" + setName + '\'' +
", maskPosition='" + maskPosition + '\'' + ", maskPosition=" + maskPosition +
'}'; '}';
} }
} }

View File

@ -113,7 +113,7 @@ public class TestAnswerInlineQuery {
try { try {
answerInlineQuery.validate(); answerInlineQuery.validate();
} catch (TelegramApiValidationException e) { } catch (TelegramApiValidationException e) {
Assert.assertEquals("SwitchPmParameter only allows A-Z, a-z, 0-9 and _ characters", e.getMessage()); Assert.assertEquals("SwitchPmParameter only allows A-Z, a-z, 0-9, _ and - characters", e.getMessage());
} }
} }
} }