Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot API v8.3 #417

Merged
merged 18 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public enum Type {
private String custom_emoji_sticker_set_name;
private Long linked_chat_id;
private ChatLocation location;
private Boolean can_send_gift;

public Long id() {
return id;
Expand Down Expand Up @@ -262,6 +263,10 @@ public ChatLocation location() {
return location;
}

public Boolean canSendGift() {
return can_send_gift;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -310,7 +315,8 @@ public boolean equals(Object o) {
Objects.equals(can_set_sticker_set, chat.can_set_sticker_set) &&
Objects.equals(custom_emoji_sticker_set_name, chat.custom_emoji_sticker_set_name) &&
Objects.equals(linked_chat_id, chat.linked_chat_id) &&
Objects.equals(location, chat.location);
Objects.equals(location, chat.location) &&
Objects.equals(can_send_gift, chat.can_send_gift);
}

@Override
Expand Down Expand Up @@ -365,6 +371,7 @@ public String toString() {
", custom_emoji_sticker_set_name=" + custom_emoji_sticker_set_name +
", linked_chat_id=" + linked_chat_id +
", location=" + location +
", can_send_gift=" + can_send_gift +
'}';
}
}
103 changes: 0 additions & 103 deletions library/src/main/java/com/pengrad/telegrambot/model/Video.java

This file was deleted.

43 changes: 43 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/Video.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.pengrad.telegrambot.model

data class Video(
@get:JvmName("fileId") val fileId: String,
@get:JvmName("fileUniqueId") val fileUniqueId: String,

@JvmSynthetic val width: Int,
@JvmSynthetic val height: Int,
@JvmSynthetic val duration: Int,

@get:JvmName("thumbnail") val thumbnail: PhotoSize? = null,
@get:JvmName("cover") val cover: List<PhotoSize>? = null,

@get:JvmName("start_timestamp") val startTimestamp: Int? = null,

@get:JvmName("fileName") val fileName: String? = null,
@get:JvmName("mimeType") val mimeType: String? = null,
@get:JvmName("fileSize") val fileSize: Long? = null,

) {

/**
* Backwards compatability for Java code because of Kotlin optimization
*/
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
fun width() = width as Integer

/**
* Backwards compatability for Java code because of Kotlin optimization
*/
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
fun height() = height as Integer

/**
* Backwards compatability for Java code because of Kotlin optimization
*/
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
fun duration() = duration as Integer

@Deprecated("Use thumbnail instead", ReplaceWith("thumbnail"))
fun thumb(): PhotoSize? = thumbnail

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ data class Gift(
@get:JvmName("id") val id: String,
@get:JvmName("sticker") val sticker: Sticker,
@get:JvmName("starCount") val starCount: Int,
@get:JvmName("totalCount") val totalCount: Int,
@get:JvmName("remainingCount") val remainingCount: Int
@get:JvmName("upgradeStarCount") val upgradeStarCount: Int? = null,
@get:JvmName("totalCount") val totalCount: Int? = null,
@get:JvmName("remainingCount") val remainingCount: Int? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ public InlineQueryResultArticle url(String url) {
return this;
}

/**
* @deprecated hideUrl method is removed since <a href="https://core.telegram.org/bots/api#january-1-2025">Bot API 8.2</a>. This method removes url parameter to emulate hideUrl parameter behavior. It may break your code logic. Pass an empty string as url instead.
*/
@Deprecated
public InlineQueryResultArticle hideUrl(Boolean hideUrl) {
this.hide_url = hideUrl;
this.url = null;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,29 @@ public class InlineQueryResultVideo extends InlineQueryResult<InlineQueryResultV
private Integer video_duration;
private String description;

/**
* @deprecated use a constructor without messageText and inputMessageContent(new InputTextMessageContent(messageText)) instead
*/
@Deprecated
public InlineQueryResultVideo(String id, String videoUrl, String mimeType, String messageText, String thumbUrl, String title) {
this(id, videoUrl, mimeType, new InputTextMessageContent(messageText), thumbUrl, title);
}

/**
* @deprecated use a constructor without inputMessageContent and inputMessageContent(inputMessageContent) instead
*/
@Deprecated
public InlineQueryResultVideo(String id, String videoUrl, String mimeType, InputMessageContent inputMessageContent, String thumbnailUrl, String title) {
this(id, videoUrl, mimeType, thumbnailUrl, title);
inputMessageContent(inputMessageContent);
}

public InlineQueryResultVideo(String id, String videoUrl, String mimeType, String thumbnailUrl, String title) {
super("video", id);
this.video_url = videoUrl;
this.mime_type = mimeType;
this.thumbnail_url = thumbnailUrl;
this.title = title;
inputMessageContent(inputMessageContent);
}

public InlineQueryResultVideo caption(String caption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public Map<String, Object> getAttachments() {
return attachments;
}

protected String addAttachment(Object attachment) {
String attachName = AttachName.next();
attachments.put(attachName, attachment);
return "attach://" + attachName;
}

public InputFile inputFile() {
return inputFile;
}
Expand All @@ -67,9 +73,7 @@ public String getInputFileId() {
*/
@Deprecated
public T thumb(File thumb) {
String attachName = AttachName.next();
attachments.put(attachName, thumb);
this.thumbnail = "attach://" + attachName;
this.thumbnail = addAttachment(thumb);
return thisAsT;
}

Expand All @@ -83,23 +87,17 @@ public T showCaptionAboveMedia(Boolean showCaptionAboveMedia) {
*/
@Deprecated
public T thumb(byte[] thumb) {
String attachName = AttachName.next();
attachments.put(attachName, thumb);
this.thumbnail = "attach://" + attachName;
this.thumbnail = addAttachment(thumb);
return thisAsT;
}

public T thumbnail(File thumbnail) {
String attachName = AttachName.next();
attachments.put(attachName, thumbnail);
this.thumbnail = "attach://" + attachName;
this.thumbnail = addAttachment(thumbnail);
return thisAsT;
}

public T thumbnail(byte[] thumbnail) {
String attachName = AttachName.next();
attachments.put(attachName, thumbnail);
this.thumbnail = "attach://" + attachName;
this.thumbnail = addAttachment(thumbnail);
return thisAsT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class InputMediaVideo extends InputMedia<InputMediaVideo> implements Seri
private Integer width, height, duration;
private Boolean supports_streaming;
private Boolean has_spoiler;
private String cover;
private Integer start_timestamp;

public InputMediaVideo(String media) {
super("video", media);
Expand Down Expand Up @@ -43,6 +45,21 @@ public InputMediaVideo duration(Integer duration) {
return this;
}

public InputMediaVideo cover(File cover) {
this.cover = addAttachment(cover);
return this;
}

public InputMediaVideo cover(byte[] cover) {
this.cover = addAttachment(cover);
return this;
}

public InputMediaVideo startTimestamp(Integer startTimestamp) {
this.start_timestamp = startTimestamp;
return this;
}

public InputMediaVideo supportsStreaming(boolean supportsStreaming) {
this.supports_streaming = supportsStreaming;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public Map<String, Object> getAttachments() {
return attachments;
}

protected String addAttachment(Object attachment) {
String attachName = AttachName.next();
attachments.put(attachName, attachment);
return "attach://" + attachName;
}

public InputFile inputFile() {
return inputFile;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.pengrad.telegrambot.model.request;

import com.pengrad.telegrambot.AttachName;
import com.pengrad.telegrambot.request.ContentTypes;

import java.io.File;
import java.io.Serializable;
import java.util.Map;

public class InputPaidMediaVideo extends InputPaidMedia implements Serializable {

Expand All @@ -14,6 +12,8 @@ public class InputPaidMediaVideo extends InputPaidMedia implements Serializable
private Integer width, height, duration;
private Boolean supports_streaming;
private String thumbnail;
private String cover;
private Integer start_timestamp;

public InputPaidMediaVideo(String media) {
super("video", media);
Expand Down Expand Up @@ -48,16 +48,27 @@ public InputPaidMediaVideo supportsStreaming(boolean supportsStreaming) {
}

public InputPaidMediaVideo thumbnail(File thumbnail) {
String attachName = AttachName.next();
attachments.put(attachName, thumbnail);
this.thumbnail = "attach://" + attachName;
this.thumbnail = addAttachment(thumbnail);
return this;
}

public InputPaidMediaVideo thumbnail(byte[] thumbnail) {
String attachName = AttachName.next();
attachments.put(attachName, thumbnail);
this.thumbnail = "attach://" + attachName;
this.thumbnail = addAttachment(thumbnail);
return this;
}

public InputPaidMediaVideo cover(File cover) {
this.cover = addAttachment(cover);
return this;
}

public InputPaidMediaVideo cover(byte[] cover) {
this.cover = addAttachment(cover);
return this;
}

public InputPaidMediaVideo startTimestamp(Integer startTimestamp) {
this.start_timestamp = startTimestamp;
return this;
}

Expand Down
Loading