Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<dependency>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
<version>9.6.0</version>
<version>10.0.0</version>
</dependency>
```
[JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.pengrad.telegrambot.model

data class BotAccessSettings(
val isAccessRestricted: Boolean? = null,
@get:JvmName("addedUsers") val addedUsers: Array<User>? = 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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,6 +72,10 @@ public Document document() {
return document;
}

public LivePhoto livePhoto() {
return live_photo;
}

public PhotoSize[] photo() {
return photo;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 +
Expand Down
46 changes: 46 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/LivePhoto.kt
Original file line number Diff line number Diff line change
@@ -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<PhotoSize>? = 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
}
}
30 changes: 29 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -286,6 +290,10 @@ public Game game() {
return game;
}

public LivePhoto livePhoto() {
return live_photo;
}

public PhotoSize[] photo() {
return photo;
}
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 +
Expand Down Expand Up @@ -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 + '\'' +
'}';
}
}
30 changes: 29 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Poll.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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) +
'}';
}
}
Loading
Loading