diff --git a/README.md b/README.md
index 1cc746fb..6a2b520b 100644
--- a/README.md
+++ b/README.md
@@ -13,14 +13,14 @@ Java library for interacting with [Telegram Bot API](https://core.telegram.org/b
Gradle:
```groovy
-implementation 'com.github.pengrad:java-telegram-bot-api:9.6.0'
+implementation 'com.github.pengrad:java-telegram-bot-api:10.0.0'
```
Maven:
```xml
com.github.pengrad
java-telegram-bot-api
- 9.6.0
+ 10.0.0
```
[JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases)
diff --git a/gradle.properties b/gradle.properties
index a63e0be3..69db2f62 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,5 +1,5 @@
GROUP=com.github.pengrad
-VERSION_NAME=9.6.0
+VERSION_NAME=10.0.0
POM_DESCRIPTION=Java API for Telegram Bot API
POM_URL=https://github.com/pengrad/java-telegram-bot-api/
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/BotAccessSettings.kt b/library/src/main/java/com/pengrad/telegrambot/model/BotAccessSettings.kt
new file mode 100644
index 00000000..1dc5c10f
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/BotAccessSettings.kt
@@ -0,0 +1,19 @@
+package com.pengrad.telegrambot.model
+
+data class BotAccessSettings(
+ val isAccessRestricted: Boolean? = null,
+ @get:JvmName("addedUsers") val addedUsers: Array? = null,
+) {
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is BotAccessSettings) return false
+ return isAccessRestricted == other.isAccessRestricted &&
+ addedUsers contentEquals other.addedUsers
+ }
+
+ override fun hashCode(): Int {
+ var result = isAccessRestricted?.hashCode() ?: 0
+ result = 31 * result + (addedUsers?.contentHashCode() ?: 0)
+ return result
+ }
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java
index 48817d3f..f3c2131f 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java
@@ -52,6 +52,7 @@ public enum Status {
private Boolean can_send_polls;
private Boolean can_send_other_messages;
private Boolean can_add_web_page_previews;
+ private Boolean can_react_to_messages;
public User user() {
return user;
@@ -193,6 +194,10 @@ public Boolean canAddWebPagePreviews() {
return can_add_web_page_previews != null && can_add_web_page_previews;
}
+ public Boolean canReactToMessages() {
+ return can_react_to_messages != null && can_react_to_messages;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -232,7 +237,8 @@ public boolean equals(Object o) {
Objects.equals(can_send_voice_notes, that.can_send_voice_notes) &&
Objects.equals(can_send_polls, that.can_send_polls) &&
Objects.equals(can_send_other_messages, that.can_send_other_messages) &&
- Objects.equals(can_add_web_page_previews, that.can_add_web_page_previews);
+ Objects.equals(can_add_web_page_previews, that.can_add_web_page_previews) &&
+ Objects.equals(can_react_to_messages, that.can_react_to_messages);
}
@Override
@@ -271,7 +277,8 @@ public int hashCode() {
can_send_voice_notes,
can_send_polls,
can_send_other_messages,
- can_add_web_page_previews);
+ can_add_web_page_previews,
+ can_react_to_messages);
}
@Override
@@ -312,6 +319,7 @@ public String toString() {
", can_send_polls=" + can_send_polls +
", can_send_other_messages=" + can_send_other_messages +
", can_add_web_page_previews=" + can_add_web_page_previews +
+ ", can_react_to_messages=" + can_react_to_messages +
'}';
}
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java
index 99d324ef..6006ad79 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java
@@ -31,6 +31,7 @@ public class ChatPermissions implements Serializable {
private Boolean can_edit_stories;
private Boolean can_delete_stories;
private Boolean can_edit_tag;
+ private Boolean can_react_to_messages;
public Boolean canSendMessages() {
return can_send_messages != null && can_send_messages;
@@ -104,6 +105,10 @@ public Boolean canEditTag() {
return can_edit_tag != null && can_edit_tag;
}
+ public Boolean canReactToMessages() {
+ return can_react_to_messages != null && can_react_to_messages;
+ }
+
public ChatPermissions canSendMessages(boolean canSendMessages) {
can_send_messages = canSendMessages;
return this;
@@ -194,6 +199,11 @@ public ChatPermissions canEditTag(boolean canEditTag) {
return this;
}
+ public ChatPermissions canReactToMessages(boolean canReactToMessages) {
+ this.can_react_to_messages = canReactToMessages;
+ return this;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -218,7 +228,8 @@ public boolean equals(Object o) {
Objects.equals(can_post_stories, that.can_post_stories) &&
Objects.equals(can_edit_stories, that.can_edit_stories) &&
Objects.equals(can_delete_stories, that.can_delete_stories) &&
- Objects.equals(can_edit_tag, that.can_edit_tag);
+ Objects.equals(can_edit_tag, that.can_edit_tag) &&
+ Objects.equals(can_react_to_messages, that.can_react_to_messages);
}
@Override
@@ -240,7 +251,8 @@ public int hashCode() {
can_post_stories,
can_edit_stories,
can_delete_stories,
- can_edit_tag);
+ can_edit_tag,
+ can_react_to_messages);
}
@Override
@@ -264,6 +276,7 @@ public String toString() {
", can_edit_stories=" + can_edit_stories +
", can_delete_stories=" + can_delete_stories +
", can_edit_tag=" + can_edit_tag +
+ ", can_react_to_messages=" + can_react_to_messages +
'}';
}
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java
index f45150f4..5550e48d 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java
@@ -22,6 +22,7 @@ public class ExternalReplyInfo implements Serializable {
private Audio audio;
private PaidMediaInfo paid_media;
private Document document;
+ private LivePhoto live_photo;
private PhotoSize[] photo;
private Sticker sticker;
private Story story;
@@ -71,6 +72,10 @@ public Document document() {
return document;
}
+ public LivePhoto livePhoto() {
+ return live_photo;
+ }
+
public PhotoSize[] photo() {
return photo;
}
@@ -144,12 +149,12 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ExternalReplyInfo that = (ExternalReplyInfo) o;
- return Objects.equals(origin, that.origin) && Objects.equals(chat, that.chat) && Objects.equals(message_id, that.message_id) && Objects.equals(link_preview_options, that.link_preview_options) && Objects.equals(animation, that.animation) && Objects.equals(audio, that.audio) && Objects.equals(paid_media, that.paid_media) && Objects.equals(document, that.document) && Arrays.equals(photo, that.photo) && Objects.equals(sticker, that.sticker) && Objects.equals(story, that.story) && Objects.equals(video, that.video) && Objects.equals(video_note, that.video_note) && Objects.equals(voice, that.voice) && Objects.equals(has_media_spoiler, that.has_media_spoiler) && Objects.equals(checklist, that.checklist) && Objects.equals(contact, that.contact) && Objects.equals(dice, that.dice) && Objects.equals(game, that.game) && Objects.equals(giveaway, that.giveaway) && Objects.equals(giveaway_winners, that.giveaway_winners) && Objects.equals(invoice, that.invoice) && Objects.equals(location, that.location) && Objects.equals(poll, that.poll) && Objects.equals(venue, that.venue);
+ return Objects.equals(origin, that.origin) && Objects.equals(chat, that.chat) && Objects.equals(message_id, that.message_id) && Objects.equals(link_preview_options, that.link_preview_options) && Objects.equals(animation, that.animation) && Objects.equals(audio, that.audio) && Objects.equals(paid_media, that.paid_media) && Objects.equals(document, that.document) && Objects.equals(live_photo, that.live_photo) && Arrays.equals(photo, that.photo) && Objects.equals(sticker, that.sticker) && Objects.equals(story, that.story) && Objects.equals(video, that.video) && Objects.equals(video_note, that.video_note) && Objects.equals(voice, that.voice) && Objects.equals(has_media_spoiler, that.has_media_spoiler) && Objects.equals(checklist, that.checklist) && Objects.equals(contact, that.contact) && Objects.equals(dice, that.dice) && Objects.equals(game, that.game) && Objects.equals(giveaway, that.giveaway) && Objects.equals(giveaway_winners, that.giveaway_winners) && Objects.equals(invoice, that.invoice) && Objects.equals(location, that.location) && Objects.equals(poll, that.poll) && Objects.equals(venue, that.venue);
}
@Override
public int hashCode() {
- int result = Objects.hash(origin, chat, message_id, link_preview_options, animation, audio, paid_media, document, sticker, story, video, video_note, voice, has_media_spoiler, checklist, contact, dice, game, giveaway, giveaway_winners, invoice, location, poll, venue);
+ int result = Objects.hash(origin, chat, message_id, link_preview_options, animation, audio, paid_media, document, live_photo, sticker, story, video, video_note, voice, has_media_spoiler, checklist, contact, dice, game, giveaway, giveaway_winners, invoice, location, poll, venue);
result = 31 * result + Arrays.hashCode(photo);
return result;
}
@@ -165,6 +170,7 @@ public String toString() {
", audio=" + audio +
", paid_media=" + paid_media +
", document=" + document +
+ ", live_photo=" + live_photo +
", photo=" + Arrays.toString(photo) +
", sticker=" + sticker +
", story=" + story +
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/LivePhoto.kt b/library/src/main/java/com/pengrad/telegrambot/model/LivePhoto.kt
new file mode 100644
index 00000000..7d257be2
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/LivePhoto.kt
@@ -0,0 +1,46 @@
+package com.pengrad.telegrambot.model
+
+import com.pengrad.telegrambot.utility.kotlin.JavaInteger
+
+data class LivePhoto(
+ @get:JvmName("fileId") val fileId: String,
+ @get:JvmName("fileUniqueId") val fileUniqueId: String,
+
+ @get:JvmSynthetic val width: Int,
+ @get:JvmSynthetic val height: Int,
+ @get:JvmSynthetic val duration: Int,
+
+ @get:JvmName("photo") val photo: Array? = null,
+ @get:JvmName("mimeType") val mimeType: String? = null,
+ @get:JvmName("fileSize") val fileSize: Long? = null,
+) {
+
+ fun width() = width as JavaInteger
+ fun height() = height as JavaInteger
+ fun duration() = duration as JavaInteger
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is LivePhoto) return false
+ return fileId == other.fileId &&
+ fileUniqueId == other.fileUniqueId &&
+ width == other.width &&
+ height == other.height &&
+ duration == other.duration &&
+ photo contentEquals other.photo &&
+ mimeType == other.mimeType &&
+ fileSize == other.fileSize
+ }
+
+ override fun hashCode(): Int {
+ var result = fileId.hashCode()
+ result = 31 * result + fileUniqueId.hashCode()
+ result = 31 * result + width.hashCode()
+ result = 31 * result + height.hashCode()
+ result = 31 * result + duration.hashCode()
+ result = 31 * result + (photo?.contentHashCode() ?: 0)
+ result = 31 * result + (mimeType?.hashCode() ?: 0)
+ result = 31 * result + (fileSize?.hashCode() ?: 0)
+ return result
+ }
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Message.java b/library/src/main/java/com/pengrad/telegrambot/model/Message.java
index 75da7201..9606ea51 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java
@@ -69,6 +69,7 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private Document document;
private Animation animation;
private Game game;
+ private LivePhoto live_photo;
private PhotoSize[] photo;
private Sticker sticker;
private Video video;
@@ -140,6 +141,9 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private PollOptionAdded poll_option_added;
private PollOptionDeleted poll_option_deleted;
private String reply_to_poll_option_id;
+ private User guest_bot_caller_user;
+ private Chat guest_bot_caller_chat;
+ private String guest_query_id;
public Long messageThreadId() {
return message_thread_id;
@@ -286,6 +290,10 @@ public Game game() {
return game;
}
+ public LivePhoto livePhoto() {
+ return live_photo;
+ }
+
public PhotoSize[] photo() {
return photo;
}
@@ -570,6 +578,18 @@ public String replyToPollOptionId() {
return reply_to_poll_option_id;
}
+ public User guestBotCallerUser() {
+ return guest_bot_caller_user;
+ }
+
+ public Chat guestBotCallerChat() {
+ return guest_bot_caller_chat;
+ }
+
+ public String guestQueryId() {
+ return guest_query_id;
+ }
+
/**
* Only for backwards-compatibility with MaybeInaccessibleMessage
*/
@@ -635,6 +655,7 @@ public boolean equals(Object o) {
Objects.equals(document, message.document) &&
Objects.equals(animation, message.animation) &&
Objects.equals(game, message.game) &&
+ Objects.equals(live_photo, message.live_photo) &&
Arrays.equals(photo, message.photo) &&
Objects.equals(sticker, message.sticker) &&
Objects.equals(video, message.video) &&
@@ -705,7 +726,10 @@ public boolean equals(Object o) {
Objects.equals(managed_bot_created, message.managed_bot_created) &&
Objects.equals(poll_option_added, message.poll_option_added) &&
Objects.equals(poll_option_deleted, message.poll_option_deleted) &&
- Objects.equals(reply_to_poll_option_id, message.reply_to_poll_option_id);
+ Objects.equals(reply_to_poll_option_id, message.reply_to_poll_option_id) &&
+ Objects.equals(guest_bot_caller_user, message.guest_bot_caller_user) &&
+ Objects.equals(guest_bot_caller_chat, message.guest_bot_caller_chat) &&
+ Objects.equals(guest_query_id, message.guest_query_id);
}
@Override
@@ -755,6 +779,7 @@ public String toString() {
", document=" + document +
", animation=" + animation +
", game=" + game +
+ ", live_photo=" + live_photo +
", photo=" + Arrays.toString(photo) +
", sticker=" + sticker +
", video=" + video +
@@ -826,6 +851,9 @@ public String toString() {
", poll_option_added=" + poll_option_added +
", poll_option_deleted=" + poll_option_deleted +
", reply_to_poll_option_id='" + reply_to_poll_option_id + '\'' +
+ ", guest_bot_caller_user=" + guest_bot_caller_user +
+ ", guest_bot_caller_chat=" + guest_bot_caller_chat +
+ ", guest_query_id='" + guest_query_id + '\'' +
'}';
}
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Poll.java b/library/src/main/java/com/pengrad/telegrambot/model/Poll.java
index cd5e0a4c..bdd6f2c3 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/Poll.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/Poll.java
@@ -31,6 +31,10 @@ public enum Type {
private Integer close_date;
private String description;
private MessageEntity[] description_entities;
+ private PollMedia media;
+ private PollMedia explanation_media;
+ private Boolean members_only;
+ private String[] country_codes;
public String id() {
return id;
@@ -104,6 +108,22 @@ public MessageEntity[] descriptionEntities() {
return description_entities;
}
+ public PollMedia media() {
+ return media;
+ }
+
+ public PollMedia explanationMedia() {
+ return explanation_media;
+ }
+
+ public Boolean membersOnly() {
+ return members_only;
+ }
+
+ public String[] countryCodes() {
+ return country_codes;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -130,7 +150,11 @@ public boolean equals(Object o) {
if (open_period != null ? !open_period.equals(poll.open_period) : poll.open_period != null) return false;
if (close_date != null ? !close_date.equals(poll.close_date) : poll.close_date != null) return false;
if (description != null ? !description.equals(poll.description) : poll.description != null) return false;
- return Arrays.equals(description_entities, poll.description_entities);
+ if (!Arrays.equals(description_entities, poll.description_entities)) return false;
+ if (media != null ? !media.equals(poll.media) : poll.media != null) return false;
+ if (explanation_media != null ? !explanation_media.equals(poll.explanation_media) : poll.explanation_media != null) return false;
+ if (members_only != null ? !members_only.equals(poll.members_only) : poll.members_only != null) return false;
+ return Arrays.equals(country_codes, poll.country_codes);
}
@Override
@@ -158,6 +182,10 @@ public String toString() {
", close_date=" + close_date +
", description='" + description + '\'' +
", description_entities=" + Arrays.toString(description_entities) +
+ ", media=" + media +
+ ", explanation_media=" + explanation_media +
+ ", members_only=" + members_only +
+ ", country_codes=" + Arrays.toString(country_codes) +
'}';
}
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollMedia.kt b/library/src/main/java/com/pengrad/telegrambot/model/PollMedia.kt
new file mode 100644
index 00000000..fa569af3
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/PollMedia.kt
@@ -0,0 +1,40 @@
+package com.pengrad.telegrambot.model
+
+data class PollMedia(
+ @get:JvmName("animation") val animation: Animation? = null,
+ @get:JvmName("audio") val audio: Audio? = null,
+ @get:JvmName("document") val document: Document? = null,
+ @get:JvmName("livePhoto") val livePhoto: LivePhoto? = null,
+ @get:JvmName("location") val location: Location? = null,
+ @get:JvmName("photo") val photo: Array? = null,
+ @get:JvmName("sticker") val sticker: Sticker? = null,
+ @get:JvmName("venue") val venue: Venue? = null,
+ @get:JvmName("video") val video: Video? = null,
+) {
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is PollMedia) return false
+ return animation == other.animation &&
+ audio == other.audio &&
+ document == other.document &&
+ livePhoto == other.livePhoto &&
+ location == other.location &&
+ photo contentEquals other.photo &&
+ sticker == other.sticker &&
+ venue == other.venue &&
+ video == other.video
+ }
+
+ override fun hashCode(): Int {
+ var result = animation?.hashCode() ?: 0
+ result = 31 * result + (audio?.hashCode() ?: 0)
+ result = 31 * result + (document?.hashCode() ?: 0)
+ result = 31 * result + (livePhoto?.hashCode() ?: 0)
+ result = 31 * result + (location?.hashCode() ?: 0)
+ result = 31 * result + (photo?.contentHashCode() ?: 0)
+ result = 31 * result + (sticker?.hashCode() ?: 0)
+ result = 31 * result + (venue?.hashCode() ?: 0)
+ result = 31 * result + (video?.hashCode() ?: 0)
+ return result
+ }
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollOption.java b/library/src/main/java/com/pengrad/telegrambot/model/PollOption.java
index b88aa346..c7413918 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/PollOption.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/PollOption.java
@@ -18,6 +18,7 @@ public class PollOption implements Serializable {
private User added_by_user;
private Chat added_by_chat;
private Integer addition_date;
+ private PollMedia media;
public String persistentId() {
return persistent_id;
@@ -47,6 +48,10 @@ public Integer additionDate() {
return addition_date;
}
+ public PollMedia media() {
+ return media;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -61,7 +66,8 @@ public boolean equals(Object o) {
if (voter_count != null ? !voter_count.equals(that.voter_count) : that.voter_count != null) return false;
if (!Objects.equals(added_by_user, that.added_by_user)) return false;
if (!Objects.equals(added_by_chat, that.added_by_chat)) return false;
- return Objects.equals(addition_date, that.addition_date);
+ if (!Objects.equals(addition_date, that.addition_date)) return false;
+ return Objects.equals(media, that.media);
}
@Override
@@ -72,6 +78,7 @@ public int hashCode() {
result = 31 * result + (added_by_user != null ? added_by_user.hashCode() : 0);
result = 31 * result + (added_by_chat != null ? added_by_chat.hashCode() : 0);
result = 31 * result + (addition_date != null ? addition_date.hashCode() : 0);
+ result = 31 * result + (media != null ? media.hashCode() : 0);
return result;
}
@@ -85,6 +92,7 @@ public String toString() {
", added_by_user=" + added_by_user +
", added_by_chat=" + added_by_chat +
", addition_date=" + addition_date +
+ ", media=" + media +
'}';
}
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/SentGuestMessage.kt b/library/src/main/java/com/pengrad/telegrambot/model/SentGuestMessage.kt
new file mode 100644
index 00000000..8a0fd655
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/SentGuestMessage.kt
@@ -0,0 +1,5 @@
+package com.pengrad.telegrambot.model
+
+data class SentGuestMessage(
+ @get:JvmName("inlineMessageId") val inlineMessageId: String? = null,
+)
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Update.java b/library/src/main/java/com/pengrad/telegrambot/model/Update.java
index 997c780b..ffd68e65 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/Update.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/Update.java
@@ -41,6 +41,7 @@ public class Update implements Serializable {
private ChatBoostRemoved removed_chat_boost;
private PaidMediaPurchased purchased_paid_media;
private ManagedBotUpdated managed_bot;
+ private Message guest_message;
public Integer updateId() {
return update_id;
@@ -142,6 +143,10 @@ public ManagedBotUpdated managedBot() {
return managed_bot;
}
+ public Message guestMessage() {
+ return guest_message;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -171,7 +176,8 @@ public boolean equals(Object o) {
Objects.equals(chat_boost, update.chat_boost) &&
Objects.equals(removed_chat_boost, update.removed_chat_boost) &&
Objects.equals(purchased_paid_media, update.purchased_paid_media) &&
- Objects.equals(managed_bot, update.managed_bot);
+ Objects.equals(managed_bot, update.managed_bot) &&
+ Objects.equals(guest_message, update.guest_message);
}
@Override
@@ -207,6 +213,7 @@ public String toString() {
", removed_chat_boost=" + removed_chat_boost +
", purchased_paid_media=" + purchased_paid_media +
", managed_bot=" + managed_bot +
+ ", guest_message=" + guest_message +
'}';
}
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/User.java b/library/src/main/java/com/pengrad/telegrambot/model/User.java
index ea8c7e1e..89629475 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/User.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/User.java
@@ -26,6 +26,7 @@ public class User implements Serializable {
private Boolean has_topics_enabled;
private Boolean allows_users_to_create_topics;
private Boolean can_manage_bots;
+ private Boolean supports_guest_queries;
private User() {
}
@@ -98,6 +99,10 @@ public Boolean canManageBots() {
return can_manage_bots != null && can_manage_bots;
}
+ public Boolean supportsGuestQueries() {
+ return supports_guest_queries != null && supports_guest_queries;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -110,7 +115,8 @@ public boolean equals(Object o) {
&& Objects.equals(supports_inline_queries, user.supports_inline_queries) && Objects.equals(can_connect_to_business, user.can_connect_to_business)
&& Objects.equals(has_main_web_app, user.has_main_web_app) && Objects.equals(has_topics_enabled, user.has_topics_enabled)
&& Objects.equals(allows_users_to_create_topics, user.allows_users_to_create_topics)
- && Objects.equals(can_manage_bots, user.can_manage_bots);
+ && Objects.equals(can_manage_bots, user.can_manage_bots)
+ && Objects.equals(supports_guest_queries, user.supports_guest_queries);
}
@Override
@@ -137,6 +143,7 @@ public String toString() {
", has_topics_enabled=" + has_topics_enabled +
", allows_users_to_create_topics=" + allows_users_to_create_topics +
", can_manage_bots=" + can_manage_bots +
+ ", supports_guest_queries=" + supports_guest_queries +
'}';
}
}
\ No newline at end of file
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/paidmedia/PaidMediaLivePhoto.kt b/library/src/main/java/com/pengrad/telegrambot/model/paidmedia/PaidMediaLivePhoto.kt
new file mode 100644
index 00000000..7a09c94a
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/paidmedia/PaidMediaLivePhoto.kt
@@ -0,0 +1,24 @@
+package com.pengrad.telegrambot.model.paidmedia
+
+import com.pengrad.telegrambot.model.LivePhoto
+
+class PaidMediaLivePhoto : PaidMedia("live_photo") {
+
+ companion object {
+ const val TYPE = "live_photo"
+ }
+
+ @get:JvmName("livePhoto")
+ val livePhoto: LivePhoto? = null
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other == null || javaClass != other.javaClass) return false
+ val that = other as PaidMediaLivePhoto
+ return type() == that.type() && livePhoto == that.livePhoto
+ }
+
+ override fun hashCode(): Int = 31 * type().hashCode() + (livePhoto?.hashCode() ?: 0)
+
+ override fun toString(): String = "PaidMediaLivePhoto{livePhoto=$livePhoto}"
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAnimation.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAnimation.java
index 343f1504..8a1e4d27 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAnimation.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAnimation.java
@@ -9,7 +9,7 @@
* Stas Parshin
* 28 July 2018
*/
-public class InputMediaAnimation extends InputMedia implements Serializable {
+public class InputMediaAnimation extends InputMedia implements Serializable, InputPollMedia, InputPollOptionMedia {
private final static long serialVersionUID = 0L;
private Integer width, height, duration;
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAudio.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAudio.java
index e6ace37a..14989773 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAudio.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaAudio.java
@@ -9,7 +9,7 @@
* Stas Parshin
* 28 July 2018
*/
-public class InputMediaAudio extends InputMedia implements Serializable {
+public class InputMediaAudio extends InputMedia implements Serializable, InputPollMedia {
private final static long serialVersionUID = 0L;
private Integer duration;
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaDocument.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaDocument.java
index bc40cb31..c8c3c95f 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaDocument.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaDocument.java
@@ -9,7 +9,7 @@
* Stas Parshin
* 28 July 2018
*/
-public class InputMediaDocument extends InputMedia implements Serializable {
+public class InputMediaDocument extends InputMedia implements Serializable, InputPollMedia {
private final static long serialVersionUID = 0L;
private Boolean disable_content_type_detection;
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaLivePhoto.kt b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaLivePhoto.kt
new file mode 100644
index 00000000..ca0a9f8c
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaLivePhoto.kt
@@ -0,0 +1,42 @@
+package com.pengrad.telegrambot.model.request
+
+import com.pengrad.telegrambot.request.ContentTypes
+import java.io.File
+
+class InputMediaLivePhoto : InputMedia, InputPollMedia, InputPollOptionMedia {
+
+ private var photo: String? = null
+ private var has_spoiler: Boolean? = null
+
+ constructor(media: String, photo: File) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: String, photo: ByteArray) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: File, photo: File) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: File, photo: ByteArray) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: ByteArray, photo: File) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: ByteArray, photo: ByteArray) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ fun hasSpoiler(hasSpoiler: Boolean): InputMediaLivePhoto {
+ this.has_spoiler = hasSpoiler
+ return this
+ }
+
+ override fun getDefaultFileName(): String = ContentTypes.VIDEO_FILE_NAME
+ override fun getDefaultContentType(): String = ContentTypes.VIDEO_MIME_TYPE
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaLocation.kt b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaLocation.kt
new file mode 100644
index 00000000..a5b84fda
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaLocation.kt
@@ -0,0 +1,17 @@
+package com.pengrad.telegrambot.model.request
+
+import java.io.Serializable
+
+class InputMediaLocation(
+ val latitude: Float,
+ val longitude: Float,
+) : InputPollMedia, InputPollOptionMedia, Serializable {
+
+ val type: String = "location"
+ var horizontalAccuracy: Float? = null
+
+ fun horizontalAccuracy(horizontalAccuracy: Float): InputMediaLocation {
+ this.horizontalAccuracy = horizontalAccuracy
+ return this
+ }
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaPhoto.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaPhoto.java
index 4071a0b3..5ccf8eaa 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaPhoto.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaPhoto.java
@@ -9,7 +9,7 @@
* Stas Parshin
* 23 November 2017
*/
-public class InputMediaPhoto extends InputMedia implements Serializable {
+public class InputMediaPhoto extends InputMedia implements Serializable, InputPollMedia, InputPollOptionMedia {
private final static long serialVersionUID = 1L;
private Boolean has_spoiler;
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaSticker.kt b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaSticker.kt
new file mode 100644
index 00000000..4c2bb82d
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaSticker.kt
@@ -0,0 +1,20 @@
+package com.pengrad.telegrambot.model.request
+
+import java.io.File
+
+class InputMediaSticker : InputMedia, InputPollOptionMedia {
+
+ constructor(media: String) : super("sticker", media)
+ constructor(media: File) : super("sticker", media)
+ constructor(media: ByteArray) : super("sticker", media)
+
+ private var emoji: String? = null
+
+ fun emoji(emoji: String): InputMediaSticker {
+ this.emoji = emoji
+ return this
+ }
+
+ override fun getDefaultFileName(): String = "file.webp"
+ override fun getDefaultContentType(): String = "image/webp"
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaVenue.kt b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaVenue.kt
new file mode 100644
index 00000000..7d8fddac
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaVenue.kt
@@ -0,0 +1,37 @@
+package com.pengrad.telegrambot.model.request
+
+import java.io.Serializable
+
+class InputMediaVenue(
+ val latitude: Float,
+ val longitude: Float,
+ val title: String,
+ val address: String,
+) : InputPollMedia, InputPollOptionMedia, Serializable {
+
+ val type: String = "venue"
+ var foursquareId: String? = null
+ var foursquareType: String? = null
+ var googlePlaceId: String? = null
+ var googlePlaceType: String? = null
+
+ fun foursquareId(foursquareId: String): InputMediaVenue {
+ this.foursquareId = foursquareId
+ return this
+ }
+
+ fun foursquareType(foursquareType: String): InputMediaVenue {
+ this.foursquareType = foursquareType
+ return this
+ }
+
+ fun googlePlaceId(googlePlaceId: String): InputMediaVenue {
+ this.googlePlaceId = googlePlaceId
+ return this
+ }
+
+ fun googlePlaceType(googlePlaceType: String): InputMediaVenue {
+ this.googlePlaceType = googlePlaceType
+ return this
+ }
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaVideo.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaVideo.java
index ff8ef964..fd186608 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaVideo.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputMediaVideo.java
@@ -9,7 +9,7 @@
* Stas Parshin
* 23 November 2017
*/
-public class InputMediaVideo extends InputMedia implements Serializable {
+public class InputMediaVideo extends InputMedia implements Serializable, InputPollMedia, InputPollOptionMedia {
private final static long serialVersionUID = 1L;
private Integer width, height, duration;
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputPaidMediaLivePhoto.kt b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPaidMediaLivePhoto.kt
new file mode 100644
index 00000000..568be1bd
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPaidMediaLivePhoto.kt
@@ -0,0 +1,36 @@
+package com.pengrad.telegrambot.model.request
+
+import com.pengrad.telegrambot.request.ContentTypes
+import java.io.File
+
+class InputPaidMediaLivePhoto : InputPaidMedia {
+
+ private var photo: String? = null
+
+ constructor(media: String, photo: File) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: String, photo: ByteArray) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: File, photo: File) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: File, photo: ByteArray) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: ByteArray, photo: File) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ constructor(media: ByteArray, photo: ByteArray) : super("live_photo", media) {
+ this.photo = addAttachment(photo)
+ }
+
+ override fun getDefaultFileName(): String = ContentTypes.VIDEO_FILE_NAME
+ override fun getDefaultContentType(): String = ContentTypes.VIDEO_MIME_TYPE
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollMedia.kt b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollMedia.kt
new file mode 100644
index 00000000..dc2cd7d7
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollMedia.kt
@@ -0,0 +1,3 @@
+package com.pengrad.telegrambot.model.request
+
+interface InputPollMedia
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollOption.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollOption.java
index bc9143ce..816721b1 100644
--- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollOption.java
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollOption.java
@@ -13,6 +13,7 @@ public class InputPollOption implements Serializable {
private String text;
private String text_parse_mode;
private MessageEntity[] text_entities;
+ private InputPollOptionMedia media;
public InputPollOption(String text) {
this.text = text;
@@ -27,7 +28,12 @@ public InputPollOption textParseMode(String textParseMode) {
public InputPollOption textEntities(MessageEntity... entities) {
this.text_entities = entities;
return this;
- }
+ }
+
+ public InputPollOption media(InputPollOptionMedia media) {
+ this.media = media;
+ return this;
+ }
@Override
public boolean equals(Object o) {
@@ -36,12 +42,13 @@ public boolean equals(Object o) {
InputPollOption that = (InputPollOption) o;
return Objects.equals(text, that.text)
&& Objects.equals(text_parse_mode, that.text_parse_mode)
- && Arrays.equals(text_entities, that.text_entities);
+ && Arrays.equals(text_entities, that.text_entities)
+ && Objects.equals(media, that.media);
}
@Override
public int hashCode() {
- return Objects.hash(text, text_parse_mode, text_entities);
+ return Objects.hash(text, text_parse_mode, text_entities, media);
}
@Override
@@ -50,6 +57,7 @@ public String toString() {
"text='" + text + '\'' +
", text_parse_mode='" + text_parse_mode + '\'' +
", text_entities=" + Arrays.toString(text_entities) +
+ ", media=" + media +
'}';
}
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollOptionMedia.kt b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollOptionMedia.kt
new file mode 100644
index 00000000..03680b34
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputPollOptionMedia.kt
@@ -0,0 +1,3 @@
+package com.pengrad.telegrambot.model.request
+
+interface InputPollOptionMedia
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AnswerGuestQuery.kt b/library/src/main/java/com/pengrad/telegrambot/request/AnswerGuestQuery.kt
new file mode 100644
index 00000000..93710a30
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/request/AnswerGuestQuery.kt
@@ -0,0 +1,15 @@
+package com.pengrad.telegrambot.request
+
+import com.pengrad.telegrambot.model.request.InlineQueryResult
+import com.pengrad.telegrambot.response.SentGuestMessageResponse
+import com.pengrad.telegrambot.utility.kotlin.requestParameter
+
+class AnswerGuestQuery(
+ guestQueryId: String,
+ result: InlineQueryResult<*>,
+) : KBaseRequest(SentGuestMessageResponse::class) {
+
+ val guestQueryId: String by requestParameter(guestQueryId)
+ val result: InlineQueryResult<*> by requestParameter(result)
+
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/DeleteAllMessageReactions.kt b/library/src/main/java/com/pengrad/telegrambot/request/DeleteAllMessageReactions.kt
new file mode 100644
index 00000000..62b255d5
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteAllMessageReactions.kt
@@ -0,0 +1,30 @@
+package com.pengrad.telegrambot.request
+
+import com.pengrad.telegrambot.response.BaseResponse
+import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
+
+class DeleteAllMessageReactions private constructor(
+ chatId: Long?,
+ channelUsername: String?,
+) : KBaseRequest(BaseResponse::class) {
+
+ constructor(chatId: Long) : this(
+ chatId = chatId,
+ channelUsername = null,
+ )
+
+ constructor(channelUsername: String) : this(
+ chatId = null,
+ channelUsername = channelUsername,
+ )
+
+ val chatId: Long? by optionalRequestParameter(chatId, customParameterName = "chat_id")
+ val channelUsername: String? by optionalRequestParameter(channelUsername, customParameterName = "chat_id")
+
+ var userId: Long? by optionalRequestParameter()
+ var actorChatId: Long? by optionalRequestParameter()
+
+ fun userId(userId: Long) = applySelf { this.userId = userId }
+ fun actorChatId(actorChatId: Long) = applySelf { this.actorChatId = actorChatId }
+
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/DeleteMessageReaction.kt b/library/src/main/java/com/pengrad/telegrambot/request/DeleteMessageReaction.kt
new file mode 100644
index 00000000..972d0159
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteMessageReaction.kt
@@ -0,0 +1,35 @@
+package com.pengrad.telegrambot.request
+
+import com.pengrad.telegrambot.response.BaseResponse
+import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
+import com.pengrad.telegrambot.utility.kotlin.requestParameter
+
+class DeleteMessageReaction private constructor(
+ chatId: Long?,
+ channelUsername: String?,
+ messageId: Int,
+) : KBaseRequest(BaseResponse::class) {
+
+ constructor(chatId: Long, messageId: Int) : this(
+ chatId = chatId,
+ channelUsername = null,
+ messageId = messageId,
+ )
+
+ constructor(channelUsername: String, messageId: Int) : this(
+ chatId = null,
+ channelUsername = channelUsername,
+ messageId = messageId,
+ )
+
+ val chatId: Long? by optionalRequestParameter(chatId, customParameterName = "chat_id")
+ val channelUsername: String? by optionalRequestParameter(channelUsername, customParameterName = "chat_id")
+ val messageId: Int by requestParameter(messageId)
+
+ var userId: Long? by optionalRequestParameter()
+ var actorChatId: Long? by optionalRequestParameter()
+
+ fun userId(userId: Long) = applySelf { this.userId = userId }
+ fun actorChatId(actorChatId: Long) = applySelf { this.actorChatId = actorChatId }
+
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java b/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java
index f4a7a1e1..db895f82 100644
--- a/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java
+++ b/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java
@@ -12,4 +12,8 @@ public GetChatAdministrators(Object chatId) {
super(GetChatAdministratorsResponse.class);
add("chat_id", chatId);
}
+
+ public GetChatAdministrators returnBots(boolean returnBots) {
+ return add("return_bots", returnBots);
+ }
}
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetManagedBotAccessSettings.kt b/library/src/main/java/com/pengrad/telegrambot/request/GetManagedBotAccessSettings.kt
new file mode 100644
index 00000000..0e23ea8a
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/request/GetManagedBotAccessSettings.kt
@@ -0,0 +1,11 @@
+package com.pengrad.telegrambot.request
+
+import com.pengrad.telegrambot.response.BotAccessSettingsResponse
+import com.pengrad.telegrambot.utility.kotlin.requestParameter
+
+class GetManagedBotAccessSettings(
+ userId: Long,
+) : KBaseRequest(BotAccessSettingsResponse::class) {
+
+ val userId: Long by requestParameter(userId)
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetUserPersonalChatMessages.kt b/library/src/main/java/com/pengrad/telegrambot/request/GetUserPersonalChatMessages.kt
new file mode 100644
index 00000000..34455ce3
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/request/GetUserPersonalChatMessages.kt
@@ -0,0 +1,13 @@
+package com.pengrad.telegrambot.request
+
+import com.pengrad.telegrambot.response.MessagesResponse
+import com.pengrad.telegrambot.utility.kotlin.requestParameter
+
+class GetUserPersonalChatMessages(
+ userId: Long,
+ limit: Int,
+) : KBaseRequest(MessagesResponse::class) {
+
+ val userId: Long by requestParameter(userId)
+ val limit: Int by requestParameter(limit)
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendLivePhoto.kt b/library/src/main/java/com/pengrad/telegrambot/request/SendLivePhoto.kt
new file mode 100644
index 00000000..ad855c8e
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/request/SendLivePhoto.kt
@@ -0,0 +1,145 @@
+package com.pengrad.telegrambot.request
+
+import com.pengrad.telegrambot.model.MessageEntity
+import com.pengrad.telegrambot.model.request.ParseMode
+import com.pengrad.telegrambot.utility.kotlin.checkDeprecatedConstructorParameters
+import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
+import java.io.File
+
+class SendLivePhoto private constructor(
+ chatId: Long? = null,
+ channelUsername: String? = null,
+
+ livePhotoFile: File? = null,
+ livePhotoBytes: ByteArray? = null,
+
+ photoFile: File? = null,
+ photoBytes: ByteArray? = null,
+) : AbstractMultipartRequest(
+ chatId = chatId,
+ channelUsername = channelUsername,
+
+ contentParameterName = "live_photo",
+ contentUrl = null,
+ contentFile = livePhotoFile,
+ contentBytes = livePhotoBytes,
+
+ defaultFileName = ContentTypes.VIDEO_FILE_NAME,
+ defaultContentType = ContentTypes.VIDEO_MIME_TYPE,
+) {
+
+ constructor(chatId: Long, livePhotoFile: File, photoFile: File) : this(
+ chatId = chatId,
+ channelUsername = null,
+ livePhotoFile = livePhotoFile,
+ photoFile = photoFile,
+ )
+
+ constructor(channelUsername: String, livePhotoFile: File, photoFile: File) : this(
+ chatId = null,
+ channelUsername = channelUsername,
+ livePhotoFile = livePhotoFile,
+ photoFile = photoFile,
+ )
+
+ constructor(chatId: Long, livePhotoFile: File, photoBytes: ByteArray) : this(
+ chatId = chatId,
+ channelUsername = null,
+ livePhotoFile = livePhotoFile,
+ photoBytes = photoBytes,
+ )
+
+ constructor(channelUsername: String, livePhotoFile: File, photoBytes: ByteArray) : this(
+ chatId = null,
+ channelUsername = channelUsername,
+ livePhotoFile = livePhotoFile,
+ photoBytes = photoBytes,
+ )
+
+ constructor(chatId: Long, livePhotoBytes: ByteArray, photoFile: File) : this(
+ chatId = chatId,
+ channelUsername = null,
+ livePhotoBytes = livePhotoBytes,
+ photoFile = photoFile,
+ )
+
+ constructor(channelUsername: String, livePhotoBytes: ByteArray, photoFile: File) : this(
+ chatId = null,
+ channelUsername = channelUsername,
+ livePhotoBytes = livePhotoBytes,
+ photoFile = photoFile,
+ )
+
+ constructor(chatId: Long, livePhotoBytes: ByteArray, photoBytes: ByteArray) : this(
+ chatId = chatId,
+ channelUsername = null,
+ livePhotoBytes = livePhotoBytes,
+ photoBytes = photoBytes,
+ )
+
+ constructor(channelUsername: String, livePhotoBytes: ByteArray, photoBytes: ByteArray) : this(
+ chatId = null,
+ channelUsername = channelUsername,
+ livePhotoBytes = livePhotoBytes,
+ photoBytes = photoBytes,
+ )
+
+ @Deprecated("Use constructor with chatId or channelUsername instead", ReplaceWith("SendLivePhoto(chatId, livePhoto, photo)"))
+ constructor(chatId: Any, livePhoto: File, photo: File) : this(
+ chatId = (chatId as? Number)?.toLong(),
+ channelUsername = chatId as? String,
+ livePhotoFile = livePhoto,
+ photoFile = photo,
+ ) {
+ checkDeprecatedConstructorParameters()
+ }
+
+ @Deprecated("Use constructor with chatId or channelUsername instead", ReplaceWith("SendLivePhoto(chatId, livePhoto, photo)"))
+ constructor(chatId: Any, livePhoto: File, photo: ByteArray) : this(
+ chatId = (chatId as? Number)?.toLong(),
+ channelUsername = chatId as? String,
+ livePhotoFile = livePhoto,
+ photoBytes = photo,
+ ) {
+ checkDeprecatedConstructorParameters()
+ }
+
+ @Deprecated("Use constructor with chatId or channelUsername instead", ReplaceWith("SendLivePhoto(chatId, livePhoto, photo)"))
+ constructor(chatId: Any, livePhoto: ByteArray, photo: File) : this(
+ chatId = (chatId as? Number)?.toLong(),
+ channelUsername = chatId as? String,
+ livePhotoBytes = livePhoto,
+ photoFile = photo,
+ ) {
+ checkDeprecatedConstructorParameters()
+ }
+
+ @Deprecated("Use constructor with chatId or channelUsername instead", ReplaceWith("SendLivePhoto(chatId, livePhoto, photo)"))
+ constructor(chatId: Any, livePhoto: ByteArray, photo: ByteArray) : this(
+ chatId = (chatId as? Number)?.toLong(),
+ channelUsername = chatId as? String,
+ livePhotoBytes = livePhoto,
+ photoBytes = photo,
+ ) {
+ checkDeprecatedConstructorParameters()
+ }
+
+ val photoFile: File? by optionalRequestParameter(photoFile, customParameterName = "photo")
+ val photoBytes: ByteArray? by optionalRequestParameter(photoBytes, customParameterName = "photo")
+
+ override val isMultipartRequest: Boolean
+ get() = super.isMultipartRequest || photoFile != null || photoBytes != null
+
+ var caption: String? by optionalRequestParameter()
+ var parseMode: ParseMode? by optionalRequestParameter()
+ var captionEntities: List? by optionalRequestParameter()
+ var showCaptionAboveMedia: Boolean? by optionalRequestParameter()
+ var hasSpoiler: Boolean? by optionalRequestParameter()
+
+ fun caption(caption: String) = applySelf { this.caption = caption }
+ fun parseMode(parseMode: ParseMode) = applySelf { this.parseMode = parseMode }
+ fun captionEntities(captionEntities: List) = applySelf { this.captionEntities = captionEntities }
+ fun captionEntities(vararg captionEntities: MessageEntity) = applySelf { this.captionEntities = captionEntities.toList() }
+ fun showCaptionAboveMedia(showCaptionAboveMedia: Boolean) = applySelf { this.showCaptionAboveMedia = showCaptionAboveMedia }
+ fun hasSpoiler(hasSpoiler: Boolean) = applySelf { this.hasSpoiler = hasSpoiler }
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendMessageDraft.kt b/library/src/main/java/com/pengrad/telegrambot/request/SendMessageDraft.kt
index 73b48456..428f4445 100644
--- a/library/src/main/java/com/pengrad/telegrambot/request/SendMessageDraft.kt
+++ b/library/src/main/java/com/pengrad/telegrambot/request/SendMessageDraft.kt
@@ -9,17 +9,22 @@ import com.pengrad.telegrambot.utility.kotlin.requestParameter
class SendMessageDraft(
chatId: Long,
draftId: Int,
- text: String
) : KBaseRequest(BaseResponse::class) {
+ constructor(chatId: Long, draftId: Int, text: String) : this(chatId, draftId) {
+ this.text = text
+ }
+
val chatId: Long by requestParameter(chatId)
val draftId: Int by requestParameter(draftId)
- val text: String by requestParameter(text)
+ var text: String? by optionalRequestParameter()
var messageThreadId: Long? by optionalRequestParameter()
var parseMode: ParseMode? by optionalRequestParameter()
var entities: List? by optionalRequestParameter()
+ fun text(text: String) = applySelf { this.text = text }
+
fun messageThreadId(messageThreadId: Long) = applySelf { this.messageThreadId = messageThreadId }
fun parseMode(parseMode: ParseMode) = applySelf { this.parseMode = parseMode }
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.kt b/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.kt
index eb41fc8b..2860e6b5 100644
--- a/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.kt
+++ b/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.kt
@@ -2,6 +2,7 @@ package com.pengrad.telegrambot.request
import com.pengrad.telegrambot.model.MessageEntity
import com.pengrad.telegrambot.model.Poll
+import com.pengrad.telegrambot.model.request.InputPollMedia
import com.pengrad.telegrambot.model.request.InputPollOption
import com.pengrad.telegrambot.model.request.ParseMode
import com.pengrad.telegrambot.utility.kotlin.checkDeprecatedConstructorParameters
@@ -132,4 +133,19 @@ class SendPoll private constructor(
fun descriptionEntities(vararg descriptionEntities: MessageEntity) = descriptionEntities(descriptionEntities.toList())
+ var media: InputPollMedia? by optionalRequestParameter()
+ var explanationMedia: InputPollMedia? by optionalRequestParameter()
+ var membersOnly: Boolean? by optionalRequestParameter()
+ var countryCodes: List? by optionalRequestParameter()
+
+ fun media(media: InputPollMedia) = applySelf { this.media = media }
+
+ fun explanationMedia(explanationMedia: InputPollMedia) = applySelf { this.explanationMedia = explanationMedia }
+
+ fun membersOnly(membersOnly: Boolean) = applySelf { this.membersOnly = membersOnly }
+
+ fun countryCodes(countryCodes: List) = applySelf { this.countryCodes = countryCodes }
+
+ fun countryCodes(vararg countryCodes: String) = countryCodes(countryCodes.toList())
+
}
\ No newline at end of file
diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetManagedBotAccessSettings.kt b/library/src/main/java/com/pengrad/telegrambot/request/SetManagedBotAccessSettings.kt
new file mode 100644
index 00000000..7859528f
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/request/SetManagedBotAccessSettings.kt
@@ -0,0 +1,18 @@
+package com.pengrad.telegrambot.request
+
+import com.pengrad.telegrambot.response.BaseResponse
+import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
+import com.pengrad.telegrambot.utility.kotlin.requestParameter
+
+class SetManagedBotAccessSettings(
+ userId: Long,
+ isAccessRestricted: Boolean,
+) : KBaseRequest(BaseResponse::class) {
+
+ val userId: Long by requestParameter(userId)
+ val isAccessRestricted: Boolean by requestParameter(isAccessRestricted)
+ var addedUserIds: List? by optionalRequestParameter()
+
+ fun addedUserIds(addedUserIds: List) = applySelf { this.addedUserIds = addedUserIds }
+ fun addedUserIds(vararg addedUserIds: Long) = applySelf { this.addedUserIds = addedUserIds.toList() }
+}
diff --git a/library/src/main/java/com/pengrad/telegrambot/response/BotAccessSettingsResponse.kt b/library/src/main/java/com/pengrad/telegrambot/response/BotAccessSettingsResponse.kt
new file mode 100644
index 00000000..96cae0a9
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/response/BotAccessSettingsResponse.kt
@@ -0,0 +1,5 @@
+package com.pengrad.telegrambot.response
+
+import com.pengrad.telegrambot.model.BotAccessSettings
+
+data class BotAccessSettingsResponse(val result: BotAccessSettings) : BaseResponse()
diff --git a/library/src/main/java/com/pengrad/telegrambot/response/SentGuestMessageResponse.kt b/library/src/main/java/com/pengrad/telegrambot/response/SentGuestMessageResponse.kt
new file mode 100644
index 00000000..d48f205d
--- /dev/null
+++ b/library/src/main/java/com/pengrad/telegrambot/response/SentGuestMessageResponse.kt
@@ -0,0 +1,5 @@
+package com.pengrad.telegrambot.response
+
+import com.pengrad.telegrambot.model.SentGuestMessage
+
+data class SentGuestMessageResponse(val result: SentGuestMessage) : BaseResponse()
diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/OwnedGiftTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/OwnedGiftTypeAdapter.java
index 0a82708d..f2d1ce7c 100644
--- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/OwnedGiftTypeAdapter.java
+++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/OwnedGiftTypeAdapter.java
@@ -4,10 +4,6 @@
import com.pengrad.telegrambot.model.gift.owned.OwnedGift;
import com.pengrad.telegrambot.model.gift.owned.OwnedGiftRegular;
import com.pengrad.telegrambot.model.gift.owned.OwnedGiftUnique;
-import com.pengrad.telegrambot.model.paidmedia.PaidMedia;
-import com.pengrad.telegrambot.model.paidmedia.PaidMediaPhoto;
-import com.pengrad.telegrambot.model.paidmedia.PaidMediaPreview;
-import com.pengrad.telegrambot.model.paidmedia.PaidMediaVideo;
import java.lang.reflect.Type;
diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/PaidMediaTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/PaidMediaTypeAdapter.java
index 968a3b7f..91877129 100644
--- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/PaidMediaTypeAdapter.java
+++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/PaidMediaTypeAdapter.java
@@ -2,6 +2,7 @@
import com.google.gson.*;
import com.pengrad.telegrambot.model.paidmedia.PaidMedia;
+import com.pengrad.telegrambot.model.paidmedia.PaidMediaLivePhoto;
import com.pengrad.telegrambot.model.paidmedia.PaidMediaPhoto;
import com.pengrad.telegrambot.model.paidmedia.PaidMediaPreview;
import com.pengrad.telegrambot.model.paidmedia.PaidMediaVideo;
@@ -22,6 +23,8 @@ public PaidMedia deserialize(JsonElement element, Type type, JsonDeserialization
return context.deserialize(object, PaidMediaPhoto.class);
} else if (PaidMediaVideo.TYPE.equals(discriminator)) {
return context.deserialize(object, PaidMediaVideo.class);
+ } else if (PaidMediaLivePhoto.TYPE.equals(discriminator)) {
+ return context.deserialize(object, PaidMediaLivePhoto.class);
}
return new PaidMedia(discriminator);
diff --git a/pom.xml b/pom.xml
index 62380923..8c2b3f8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
4.0.0
com.github.pengrad
java-telegram-bot-api
- 9.6.0
+ 10.0.0
JavaTelegramBotApi
Java API for Telegram Bot API
https://github.com/pengrad/java-telegram-bot-api/