diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java index 56c4f994..6b16949c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java @@ -9,9 +9,11 @@ package org.telegram.telegrambots.meta.api.methods; public enum ActionType { TYPING("typing"), RECORDVIDEO("record_video"), + RECORDVIDEONOTE("record_video_note"), RECORDAUDIO("record_audio"), UPLOADPHOTO("upload_photo"), UPLOADVIDEO("upload_video"), + UPLOADVIDEONOTE("upload_video_note"), UPLOADAUDIO("upload_audio"), UPLOADDOCUMENT("upload_document"), FINDLOCATION("find_location"); @@ -36,12 +38,16 @@ public enum ActionType { return TYPING; case "record_video": return RECORDVIDEO; + case "record_video_note": + return RECORDVIDEONOTE; case "record_audio": return RECORDAUDIO; case "upload_photo": return UPLOADPHOTO; case "upload_video": return UPLOADVIDEO; + case "upload_video_note": + return UPLOADVIDEONOTE; case "upload_audio": return UPLOADAUDIO; case "upload_document": diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java index 80fb9434..5c341c80 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java @@ -136,8 +136,8 @@ public class AnswerInlineQuery extends BotApiMethod { if (switchPmParameter.length() > 64) { throw new TelegramApiValidationException("SwitchPmParameter can't be longer than 64 chars", this); } - if (!Pattern.matches("[A-Za-z0-9_]+", switchPmParameter.trim() )) { - throw new TelegramApiValidationException("SwitchPmParameter only allows A-Z, a-z, 0-9 and _ characters", this); + if (!Pattern.matches("[A-Za-z0-9_\\-]+", switchPmParameter.trim() )) { + throw new TelegramApiValidationException("SwitchPmParameter only allows A-Z, a-z, 0-9, _ and - characters", this); } } for (InlineQueryResult result : results) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java index f24fe53c..d25aea17 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java @@ -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. */ public class SetStickerPositionInSet extends BotApiMethod { - private static final String PATH = "getStickerSet"; + private static final String PATH = "setStickerPositionInSet"; private static final String STICKER_FIELD = "sticker"; private static final String POSITION_FIELD = "position"; @JsonProperty(STICKER_FIELD) 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 public SetStickerPositionInSet(String sticker, Integer position) { @@ -61,7 +61,7 @@ public class SetStickerPositionInSet extends BotApiMethod { if (sticker == null || sticker.isEmpty()) { 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); } } @@ -71,7 +71,7 @@ public class SetStickerPositionInSet extends BotApiMethod { } public SetStickerPositionInSet setSticker(String sticker) { - this.sticker = sticker; + this.sticker = checkNotNull(sticker); return this; } @@ -80,7 +80,7 @@ public class SetStickerPositionInSet extends BotApiMethod { } public SetStickerPositionInSet setPosition(Integer position) { - this.position = position; + this.position = checkNotNull(position); return this; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java index 8f1e1306..647cec40 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java @@ -1,6 +1,7 @@ package org.telegram.telegrambots.meta.api.objects.stickers; 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.Validable; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @@ -10,6 +11,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; * @version 3.2 * 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 { private static final String POINT_FIELD = "point"; private static final String XSHIFT_FIELD = "x_shift"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java index c44356d3..f33033b1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java @@ -36,7 +36,7 @@ public class Sticker implements BotApiObject { @JsonProperty(SETNAME_FIELD) private String setName; ///< Optional. Name of the sticker set to which the sticker belongs @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() { super(); @@ -70,7 +70,7 @@ public class Sticker implements BotApiObject { return setName; } - public String getMaskPosition() { + public MaskPosition getMaskPosition() { return maskPosition; } @@ -84,7 +84,7 @@ public class Sticker implements BotApiObject { ", fileSize=" + fileSize + ", emoji='" + emoji + '\'' + ", setName='" + setName + '\'' + - ", maskPosition='" + maskPosition + '\'' + + ", maskPosition=" + maskPosition + '}'; } } diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java index 04f77a73..eea69669 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java @@ -113,7 +113,7 @@ public class TestAnswerInlineQuery { try { answerInlineQuery.validate(); } 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()); } } }