From 803d71a04a598f823b1cce2b60690a9a32f20f82 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Wed, 10 Jan 2024 21:59:42 +0100 Subject: [PATCH 01/28] Added the class ExternalReplyInfo and the field external_reply of type ExternalReplyInfo to the class Message --- .../telegrambot/model/ExternalReplyInfo.java | 171 ++++++++++++++++++ .../telegrambot/model/LinkPreviewOptions.java | 69 +++++++ .../pengrad/telegrambot/model/Message.java | 7 + .../telegrambot/model/giveaway/Giveaway.java | 83 +++++++++ .../model/giveaway/GiveawayCompleted.java | 54 ++++++ .../model/giveaway/GiveawayWinners.java | 99 ++++++++++ .../model/messageorigin/MessageOrigin.java | 42 +++++ .../messageorigin/MessageOriginChannel.java | 54 ++++++ .../messageorigin/MessageOriginChat.java | 46 +++++ .../MessageOriginHiddenUser.java | 37 ++++ .../messageorigin/MessageOriginUser.java | 39 ++++ 11 files changed, 701 insertions(+) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayCompleted.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOrigin.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java new file mode 100644 index 00000000..3b28caf2 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java @@ -0,0 +1,171 @@ +package com.pengrad.telegrambot.model; + +import com.pengrad.telegrambot.model.giveaway.Giveaway; +import com.pengrad.telegrambot.model.giveaway.GiveawayCompleted; +import com.pengrad.telegrambot.model.giveaway.GiveawayWinners; +import com.pengrad.telegrambot.model.messageorigin.MessageOrigin; + +import java.io.Serializable; +import java.util.Objects; + + +public class ExternalReplyInfo implements Serializable { + private final static long serialVersionUID = 0L; + + private MessageOrigin origin; + private Chat chat; + private Integer message_id; + private LinkPreviewOptions link_preview_options; + private Animation animation; + private Audio audio; + private Document document; + private PhotoSize[] photo; + private Sticker sticker; + private Story story; + private Video video; + private VideoNote video_note; + private Voice voice; + private Boolean has_media_spoiler; + private Contact contact; + private Dice dice; + private Game game; + private Giveaway giveaway; + private GiveawayWinners giveaway_winners; + private Invoice invoice; + private Location location; + private Poll poll; + private Venue venue; + + public MessageOrigin origin() { + return origin; + } + public Chat chat() { + return chat; + } + public Integer messageId() { + return message_id; + } + public LinkPreviewOptions linkPreviewOptions() { + return link_preview_options; + } + public Animation animation() { + return animation; + } + public Audio audio() { + return audio; + } + public Document document() { + return document; + } + public PhotoSize[] photo() { + return photo; + } + public Sticker sticker() { + return sticker; + } + public Story story() { + return story; + } + public Video video() { + return video; + } + public VideoNote videoNote() { + return video_note; + } + public Voice voice() { + return voice; + } + public Boolean hasMediaSpoiler() { + return has_media_spoiler; + } + public Contact contact() { + return contact; + } + public Dice dice() { + return dice; + } + public Game game() { + return game; + } + public Giveaway giveaway() { + return giveaway; + } + public GiveawayWinners giveawayWinners() { + return giveaway_winners; + } + public Invoice invoice() { + return invoice; + } + public Location location() { + return location; + } + public Poll poll() { + return poll; + } + public Venue venue() { + return venue; + } + + + @Override + 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(document, that.document) + && Objects.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(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() { + return Objects.hash(origin, chat, message_id, link_preview_options, animation, audio,document,photo,sticker,story,video,video_note,voice,has_media_spoiler,contact,dice,game,giveaway,giveaway_winners,invoice,location,poll,venue); + } + + @Override + public String toString() { + return "ExternalReplyInfo{" + + "origin='" + origin + "'," + + "chat='" + chat + "'," + + "message_id='" + message_id + "'," + + "link_preview_options='" + link_preview_options + "'," + + "animation='" + animation + "'," + + "document='" + document + "'," + + "photo='" + photo + "'," + + "story='" + story + "'," + + "video='" + video + "'," + + "video_note='" + video_note + "'," + + "voice='" + voice + "'," + + "has_media_spoiler='" + has_media_spoiler + "'," + + "contact='" + contact + "'," + + "dice='" + dice + "'," + + "game='" + game + "'," + + "giveaway='" + giveaway + "'," + + "giveaway_winners='" + giveaway_winners + "'," + + "invoice='" + invoice + "'," + + "location='" + location + "'," + + "poll='" + poll + "'," + + "venue='" + venue + "'" + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java b/library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java new file mode 100644 index 00000000..228b0d62 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java @@ -0,0 +1,69 @@ +package com.pengrad.telegrambot.model; + +import com.pengrad.telegrambot.model.messageorigin.MessageOriginChat; + +import java.io.Serializable; +import java.util.Objects; + +public class LinkPreviewOptions implements Serializable { + + private final static long serialVersionUID = 0L; + + + private Boolean is_disabled; + private String url; + private Boolean prefer_small_media; + private Boolean prefer_large_media; + private Boolean show_above_text; + + + public Boolean isDisabled() { + return is_disabled; + } + + public String url() { + return url; + } + + public Boolean preferSmallMedia() { + return prefer_small_media; + } + + public Boolean preferLargeMedia() { + return prefer_large_media; + } + + public Boolean showAboveText() { + return show_above_text; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LinkPreviewOptions that = (LinkPreviewOptions) o; + return Objects.equals(is_disabled, that.is_disabled) + && Objects.equals(url, that.url) + && Objects.equals(prefer_small_media, that.prefer_small_media) + && Objects.equals(prefer_large_media, that.prefer_large_media) + && Objects.equals(show_above_text, that.show_above_text); + } + + @Override + public int hashCode() { + return Objects.hash(is_disabled, url, prefer_small_media, prefer_large_media, show_above_text); + } + + @Override + public String toString() { + return "LinkPreviewOptions{" + + "is_disabled='" + is_disabled + "'," + + "url='" + url + "'," + + "prefer_small_media='" + prefer_small_media + "'," + + "prefer_large_media='" + prefer_large_media + "'," + + "show_above_text='" + show_above_text + "'" + + '}'; + } + +} 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 d77479b7..78fe4dea 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -2,6 +2,7 @@ import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.passport.PassportData; +import jdk.javadoc.internal.doclets.toolkit.util.Extern; import java.io.Serializable; import java.util.Arrays; @@ -29,6 +30,7 @@ public class Message implements Serializable { private Boolean is_topic_message; private Boolean is_automatic_forward; private Message reply_to_message; + private ExternalReplyInfo external_reply; private User via_bot; private Integer edit_date; private Boolean has_protected_content; @@ -147,6 +149,9 @@ public Boolean isAutomaticForward() { public Message replyToMessage() { return reply_to_message; } + public ExternalReplyInfo externalReply() { + return external_reply; + } public User viaBot() { return via_bot; @@ -397,6 +402,7 @@ public boolean equals(Object o) { Objects.equals(is_topic_message, message.is_topic_message) && Objects.equals(is_automatic_forward, message.is_automatic_forward) && Objects.equals(reply_to_message, message.reply_to_message) && + Objects.equals(external_reply, message.external_reply) && Objects.equals(via_bot, message.via_bot) && Objects.equals(edit_date, message.edit_date) && Objects.equals(has_protected_content, message.has_protected_content) && @@ -479,6 +485,7 @@ public String toString() { ", is_topic_message=" + is_topic_message + ", is_automatic_forward=" + is_automatic_forward + ", reply_to_message=" + reply_to_message + + ", external_reply=" + external_reply + ", via_bot=" + via_bot + ", edit_date=" + edit_date + ", has_protected_content=" + has_protected_content+ diff --git a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java new file mode 100644 index 00000000..7809bfee --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java @@ -0,0 +1,83 @@ +package com.pengrad.telegrambot.model.giveaway; + +import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.LinkPreviewOptions; + +import java.io.Serializable; +import java.util.Objects; + +public class Giveaway implements Serializable { + + private final static long serialVersionUID = 0L; + + private Chat[] chats; + private Integer winners_selection_date; + private Integer winner_count; + private Boolean only_new_members; + private Boolean has_public_winners; + private String prize_description; + private String[] country_codes; + private Integer premium_subscription_month_count; + + + public Chat[] chats() { + return chats; + } + public Integer winnersSelectionDate() { + return winners_selection_date; + } + public Integer winnerCount() { + return winner_count; + } + public Boolean onlyNewMembers() { + return only_new_members; + } + public Boolean hasPublicWinners() { + return has_public_winners; + } + public String prizeDescription() { + return prize_description; + } + public String[] countryCodes() { + return country_codes; + } + public Integer premiumSubscriptionMonthCount() { + return premium_subscription_month_count; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Giveaway that = (Giveaway) o; + return Objects.equals(chats, that.chats) + && Objects.equals(winners_selection_date, that.winners_selection_date) + && Objects.equals(winner_count, that.winner_count) + && Objects.equals(only_new_members, that.only_new_members) + && Objects.equals(has_public_winners, that.has_public_winners) + && Objects.equals(prize_description, that.prize_description) + && Objects.equals(country_codes, that.country_codes) + && Objects.equals(premium_subscription_month_count, that.premium_subscription_month_count); + } + + @Override + public int hashCode() { + return Objects.hash(chats, winners_selection_date, winner_count, only_new_members, has_public_winners, prize_description, country_codes, premium_subscription_month_count); + } + + @Override + public String toString() { + return "Giveaway{" + + "chats='" + chats + "'," + + "winners_selection_date='" + winners_selection_date + "'," + + "winner_count='" + winner_count + "'," + + "only_new_members='" + only_new_members + "'," + + "has_public_winners='" + has_public_winners + "'," + + "prize_description='" + prize_description + "'," + + "country_codes='" + country_codes + "'," + + "premium_subscription_month_count='" + premium_subscription_month_count + "'" + + '}'; + } + + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayCompleted.java b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayCompleted.java new file mode 100644 index 00000000..215dbed9 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayCompleted.java @@ -0,0 +1,54 @@ +package com.pengrad.telegrambot.model.giveaway; + +import com.pengrad.telegrambot.model.Message; + +import java.io.Serializable; +import java.util.Objects; + +public class GiveawayCompleted implements Serializable { + + private final static long serialVersionUID = 0L; + + private Integer winner_count; + private Integer unclaimed_prize_count; + private Message giveaway_message; + + + public Integer winnerCount() { + return winner_count; + } + + public Integer unclaimedPrizeCount() { + return unclaimed_prize_count; + } + + public Message giveawayMessage() { + return giveaway_message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GiveawayCompleted that = (GiveawayCompleted) o; + return Objects.equals(winner_count, that.winner_count) + && Objects.equals(unclaimed_prize_count, that.unclaimed_prize_count) + && Objects.equals(giveaway_message, that.giveaway_message); + } + + @Override + public int hashCode() { + return Objects.hash(winner_count, unclaimed_prize_count, giveaway_message); + } + + @Override + public String toString() { + return "GiveawayCompleted{" + + "winner_count='" + winner_count + "'," + + "unclaimed_prize_count='" + unclaimed_prize_count + "'," + + "giveaway_message='" + giveaway_message + "'" + + '}'; + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java new file mode 100644 index 00000000..f81b49bc --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java @@ -0,0 +1,99 @@ +package com.pengrad.telegrambot.model.giveaway; + +import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.User; + +import java.io.Serializable; +import java.util.Objects; + +public class GiveawayWinners implements Serializable { + + private final static long serialVersionUID = 0L; + + private Chat chat; + private Integer giveaway_message_id; + private Integer winners_selection_date; + private Integer winner_count; + private User[] winners; + private Integer additional_chat_count; + private Integer premium_subscription_month_count; + private Integer unclaimed_prize_count; + private Boolean only_new_members; + private Boolean was_refunded; + private String prize_description; + + + public Chat chat() { + return chat; + } + public Integer giveawayMessageId() { + return giveaway_message_id; + } + public Integer winnersSelectionDate() { + return winners_selection_date; + } + public Integer winnerCount() { + return winner_count; + } + public User[] winners() { + return winners; + } + public Integer additionalChatCount() { + return additional_chat_count; + } + public Integer premiumSubscriptionMonthCount() { + return premium_subscription_month_count; + } + public Integer unclaimedPrizeCount() { + return unclaimed_prize_count; + } + public Boolean onlyNewMembers() { + return only_new_members; + } + public Boolean wasRefunded() { + return was_refunded; + } + public String prizeDescription() { + return prize_description; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GiveawayWinners that = (GiveawayWinners) o; + return Objects.equals(chat, that.chat) + && Objects.equals(winners_selection_date, that.winners_selection_date) + && Objects.equals(winner_count, that.winner_count) + && Objects.equals(winners, that.winners) + && Objects.equals(additional_chat_count, that.additional_chat_count) + && Objects.equals(premium_subscription_month_count, that.premium_subscription_month_count) + && Objects.equals(unclaimed_prize_count, that.unclaimed_prize_count) + && Objects.equals(only_new_members, that.only_new_members) + && Objects.equals(was_refunded, that.was_refunded) + && Objects.equals(prize_description, that.prize_description); + } + + @Override + public int hashCode() { + return Objects.hash(chat, winners_selection_date, winner_count, winners, additional_chat_count, premium_subscription_month_count, unclaimed_prize_count, only_new_members, was_refunded, prize_description); + } + + @Override + public String toString() { + return "GiveawayWinners{" + + "chat='" + chat + "'," + + "winners_selection_date='" + winners_selection_date + "'," + + "winner_count='" + winner_count + "'," + + "winners='" + winners + "'," + + "additional_chat_count='" + additional_chat_count + "'," + + "premium_subscription_month_count='" + premium_subscription_month_count + "'," + + "unclaimed_prize_count='" + unclaimed_prize_count + "'," + + "only_new_members='" + only_new_members + "'," + + "was_refunded='" + was_refunded + "'," + + "prize_description='" + prize_description + "'" + + '}'; + } + + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOrigin.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOrigin.java new file mode 100644 index 00000000..003acd88 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOrigin.java @@ -0,0 +1,42 @@ +package com.pengrad.telegrambot.model.messageorigin; + +import java.io.Serializable; +import java.util.Objects; + +public class MessageOrigin implements Serializable { + private final static long serialVersionUID = 0L; + + protected String type; + protected Integer date; + + public String type() { + return type; + } + + public Integer date() { + return date; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessageOrigin that = (MessageOrigin) o; + return Objects.equals(type, that.type) + && Objects.equals(date, that.date); + } + + @Override + public int hashCode() { + return Objects.hash(type, date); + } + + @Override + public String toString() { + return "MessageOrigin{" + + "type='" + type + "'," + + "date='" + date + "'" + + '}'; + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java new file mode 100644 index 00000000..96b8689b --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java @@ -0,0 +1,54 @@ +package com.pengrad.telegrambot.model.messageorigin; + +import com.pengrad.telegrambot.model.Chat; + +import java.util.Objects; + +public class MessageOriginChannel extends MessageOrigin { + + private Chat chat; + private Integer message_id; + + private String author_signature; + + public Chat chat() { + return chat; + } + + public Integer messageId() { + return message_id; + } + + public String authorSignature() { + return author_signature; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessageOriginChannel that = (MessageOriginChannel) o; + return Objects.equals(type, that.type) + && Objects.equals(date, that.date) + && Objects.equals(chat, that.chat) + && Objects.equals(message_id, that.message_id) + && Objects.equals(author_signature, that.author_signature); + } + + @Override + public int hashCode() { + return Objects.hash(type, date, chat, message_id, author_signature); + } + + @Override + public String toString() { + return "MessageOriginChannel{" + + "type='" + type + "'," + + "date='" + date + "'," + + "chat='" + chat + "'," + + "message_id='" + message_id + "'," + + "author_signature='" + author_signature + "'" + + '}'; + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java new file mode 100644 index 00000000..5b00bcd4 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java @@ -0,0 +1,46 @@ +package com.pengrad.telegrambot.model.messageorigin; + +import com.pengrad.telegrambot.model.Chat; + +import java.util.Objects; + +public class MessageOriginChat extends MessageOrigin { + + private Chat sender_chat; + private String author_signature; + + public Chat senderChat() { + return sender_chat; + } + + public String authorSignature() { + return author_signature; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessageOriginChat that = (MessageOriginChat) o; + return Objects.equals(type, that.type) + && Objects.equals(date, that.date) + && Objects.equals(sender_chat, that.sender_chat) + && Objects.equals(author_signature, that.author_signature); + } + + @Override + public int hashCode() { + return Objects.hash(type, date, sender_chat, author_signature); + } + + @Override + public String toString() { + return "MessageOriginChat{" + + "type='" + type + "'," + + "date='" + date + "'," + + "sender_chat='" + sender_chat + "'," + + "author_signature='" + author_signature + "'" + + '}'; + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java new file mode 100644 index 00000000..820d5ec7 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java @@ -0,0 +1,37 @@ +package com.pengrad.telegrambot.model.messageorigin; + +import java.util.Objects; + +public class MessageOriginHiddenUser extends MessageOrigin { + + private String sender_user_name; + + public String senderUserName() { + return sender_user_name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessageOriginHiddenUser that = (MessageOriginHiddenUser) o; + return Objects.equals(type, that.type) + && Objects.equals(date, that.date) + && Objects.equals(sender_user_name, that.sender_user_name); + } + + @Override + public int hashCode() { + return Objects.hash(type, date, sender_user_name); + } + + @Override + public String toString() { + return "MessageOriginHiddenUser{" + + "type='" + type + "'," + + "date='" + date + "'," + + "sender_user_name='" + sender_user_name + "'" + + '}'; + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java new file mode 100644 index 00000000..81576a78 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java @@ -0,0 +1,39 @@ +package com.pengrad.telegrambot.model.messageorigin; + +import com.pengrad.telegrambot.model.User; + +import java.util.Objects; + +public class MessageOriginUser extends MessageOrigin { + + private User sender_user; + + public User senderUser() { + return sender_user; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessageOriginUser that = (MessageOriginUser) o; + return Objects.equals(type, that.type) + && Objects.equals(date, that.date) + && Objects.equals(sender_user, that.sender_user); + } + + @Override + public int hashCode() { + return Objects.hash(type, date, sender_user); + } + + @Override + public String toString() { + return "MessageOriginUser{" + + "type='" + type + "'," + + "date='" + date + "'," + + "sender_user='" + sender_user + "'" + + '}'; + } + +} From 8c15764204816b33cbe8c0171324536f33ee7385 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Wed, 10 Jan 2024 22:05:04 +0100 Subject: [PATCH 02/28] Added the class TextQuote and the field quote of type TextQuote to the class Message --- .../pengrad/telegrambot/model/Message.java | 6 ++ .../pengrad/telegrambot/model/TextQuote.java | 58 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java 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 78fe4dea..0688957b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -31,6 +31,7 @@ public class Message implements Serializable { private Boolean is_automatic_forward; private Message reply_to_message; private ExternalReplyInfo external_reply; + private TextQuote quote; private User via_bot; private Integer edit_date; private Boolean has_protected_content; @@ -152,6 +153,9 @@ public Message replyToMessage() { public ExternalReplyInfo externalReply() { return external_reply; } + public TextQuote quote() { + return quote; + } public User viaBot() { return via_bot; @@ -403,6 +407,7 @@ public boolean equals(Object o) { Objects.equals(is_automatic_forward, message.is_automatic_forward) && Objects.equals(reply_to_message, message.reply_to_message) && Objects.equals(external_reply, message.external_reply) && + Objects.equals(quote, message.quote) && Objects.equals(via_bot, message.via_bot) && Objects.equals(edit_date, message.edit_date) && Objects.equals(has_protected_content, message.has_protected_content) && @@ -486,6 +491,7 @@ public String toString() { ", is_automatic_forward=" + is_automatic_forward + ", reply_to_message=" + reply_to_message + ", external_reply=" + external_reply + + ", quote=" + quote + ", via_bot=" + via_bot + ", edit_date=" + edit_date + ", has_protected_content=" + has_protected_content+ diff --git a/library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java b/library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java new file mode 100644 index 00000000..6d2ed0f3 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java @@ -0,0 +1,58 @@ +package com.pengrad.telegrambot.model; + +import java.io.Serializable; +import java.util.Objects; + +public class TextQuote implements Serializable { + + private final static long serialVersionUID = 0L; + + private String text; + private MessageEntity[] entities; + private Integer position; + private Boolean is_manual; + + public String text() { + return text; + } + + public MessageEntity[] entities() { + return entities; + } + + public Integer position() { + return position; + } + + public Boolean isManual() { + return is_manual; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TextQuote that = (TextQuote) o; + return Objects.equals(text, that.text) && + Objects.equals(entities, that.entities) && + Objects.equals(position, that.position) && + Objects.equals(is_manual, that.is_manual); + } + + @Override + public int hashCode() { + return Objects.hash(text, entities, position, is_manual); + } + + @Override + public String toString() { + return "TextQuote{" + + "text='" + text + "'," + + "entities='" + entities + "'," + + "position='" + position + "'," + + "is_manual='" + is_manual + "'" + + '}'; + } + +} From a0940827112e7b435d63a8b4468a8529f9f29f56 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Wed, 10 Jan 2024 22:24:38 +0100 Subject: [PATCH 03/28] Added the class ReplyParameters and replaced parameters reply_to_message_id and allow_sending_without_reply in the methods copyMessage, sendMessage, sendPhoto, sendVideo, sendAnimation, sendAudio, sendDocument, sendSticker, sendVideoNote, sendVoice, sendLocation, sendVenue, sendContact, sendPoll, sendDice, sendInvoice, sendGame, and sendMediaGroup with the field reply_parameters of type ReplyParameters. --- .../telegrambot/model/ReplyParameters.java | 53 +++++++++++++++++++ .../request/AbstractSendRequest.java | 12 +++++ .../telegrambot/request/CopyMessage.java | 11 ++++ .../telegrambot/request/SendMediaGroup.java | 11 ++++ 4 files changed, 87 insertions(+) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/ReplyParameters.java diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ReplyParameters.java b/library/src/main/java/com/pengrad/telegrambot/model/ReplyParameters.java new file mode 100644 index 00000000..4b2d67df --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ReplyParameters.java @@ -0,0 +1,53 @@ +package com.pengrad.telegrambot.model; + +import com.pengrad.telegrambot.model.request.InlineQueryResultCachedVideo; +import com.pengrad.telegrambot.model.request.ParseMode; + +import java.io.Serializable; + +public class ReplyParameters implements Serializable { + + private final static long serialVersionUID = 0L; + + private Integer message_id; + private Object chat_id; + private Boolean allow_sending_without_reply; + private String quote; + private String quote_parse_mode; + private MessageEntity[] quote_entities; + private Integer quote_position; + + public ReplyParameters(Integer messageId) { + this.message_id = messageId; + } + + public ReplyParameters(Integer messageId, Object chatId) { + this.message_id = messageId; + this.chat_id = chatId; + } + + public ReplyParameters allowSendingWithoutReply(Boolean allowSendingWithoutReply) { + this.allow_sending_without_reply = allowSendingWithoutReply; + return this; + } + + public ReplyParameters quote(String quote) { + this.quote = quote; + return this; + } + + public ReplyParameters quoteParseMode(ParseMode parseMode) { + this.quote_parse_mode = parseMode.name(); + return this; + } + + public ReplyParameters quoteEntities(MessageEntity[] quoteEntities) { + this.quote_entities = quoteEntities; + return this; + } + + public ReplyParameters quotePosition(Integer quotePosition) { + this.quote_position = quotePosition; + return this; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java b/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java index 7cc01a97..735e7260 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.model.ReplyParameters; import com.pengrad.telegrambot.model.request.Keyboard; import com.pengrad.telegrambot.response.SendResponse; @@ -22,10 +23,20 @@ public T disableNotification(boolean disableNotification) { return add("disable_notification", disableNotification); } + public T replyParameters(ReplyParameters replyParameters) { + return add("reply_parameters", replyParameters); + } + + /* + @deprecated Use replyParameters instead + */ public T replyToMessageId(int replyToMessageId) { return add("reply_to_message_id", replyToMessageId); } + /* + @deprecated Use replyParameters instead + */ public T allowSendingWithoutReply(boolean allowSendingWithoutReply) { return add("allow_sending_without_reply", allowSendingWithoutReply); } @@ -37,4 +48,5 @@ public T replyMarkup(Keyboard replyMarkup) { public T protectContent(boolean protectContent) { return add("protect_content", protectContent); } + } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java index ba8a19a7..3f725548 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java @@ -1,6 +1,7 @@ package com.pengrad.telegrambot.request; import com.pengrad.telegrambot.model.MessageEntity; +import com.pengrad.telegrambot.model.ReplyParameters; import com.pengrad.telegrambot.model.request.Keyboard; import com.pengrad.telegrambot.model.request.ParseMode; import com.pengrad.telegrambot.response.MessageIdResponse; @@ -36,10 +37,20 @@ public CopyMessage disableNotification(boolean disableNotification) { return add("disable_notification", disableNotification); } + public CopyMessage replyParameters(ReplyParameters replyParameters) { + return add("reply_parameters", replyParameters); + } + + /* + @deprecated Use replyParameters instead + */ public CopyMessage allowSendingWithoutReply(boolean allowSendingWithoutReply) { return add("allow_sending_without_reply", allowSendingWithoutReply); } + /* + @deprecated Use replyParameters instead + */ public CopyMessage replyToMessageId(int replyToMessageId) { return add("reply_to_message_id", replyToMessageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java index 607dad76..a1b51404 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.model.ReplyParameters; import com.pengrad.telegrambot.model.request.InputMedia; import com.pengrad.telegrambot.response.MessagesResponse; @@ -38,10 +39,20 @@ public SendMediaGroup disableNotification(boolean disableNotification) { return add("disable_notification", disableNotification); } + public SendMediaGroup replyParameters(ReplyParameters replyParameters) { + return add("reply_parameters", replyParameters); + } + + /* + @deprecated Use replyParameters instead + */ public SendMediaGroup replyToMessageId(int replyToMessageId) { return add("reply_to_message_id", replyToMessageId); } + /* + @deprecated Use replyParameters instead + */ public SendMediaGroup allowSendingWithoutReply(boolean allowSendingWithoutReply) { return add("allow_sending_without_reply", allowSendingWithoutReply); } From a58cbfba05b0a58761b4c12acb4066ff8c60081a Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Wed, 10 Jan 2024 22:27:01 +0100 Subject: [PATCH 04/28] replaced the parameter disable_web_page_preview with link_preview_options in the methods sendMessage and editMessageText --- .../com/pengrad/telegrambot/request/EditMessageText.java | 8 ++++++++ .../java/com/pengrad/telegrambot/request/SendMessage.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java index a8461a13..977210b2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.model.LinkPreviewOptions; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.model.request.ParseMode; @@ -30,6 +31,13 @@ public EditMessageText entities(MessageEntity... entities) { return add("entities", entities); } + public EditMessageText linkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { + return add("link_preview_options", linkPreviewOptions); + } + + /* + @deprecated Use linkPreviewOptions instead + */ public EditMessageText disableWebPagePreview(boolean disableWebPagePreview) { return add("disable_web_page_preview", disableWebPagePreview); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java index 170126ec..02272972 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.model.LinkPreviewOptions; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -22,6 +23,13 @@ public SendMessage entities(MessageEntity... entities) { return add("entities", entities); } + public SendMessage linkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { + return add("link_preview_options", linkPreviewOptions); + } + + /* + @deprecated Use linkPreviewOptions instead + */ public SendMessage disableWebPagePreview(boolean disableWebPagePreview) { return add("disable_web_page_preview", disableWebPagePreview); } From eb08c9c1481e2e84aadfaeea4045d2ca75161c0d Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Wed, 10 Jan 2024 22:28:25 +0100 Subject: [PATCH 05/28] Replaced the field disable_web_page_preview with link_preview_options in the class InputTextMessageContent. --- .../model/request/InputTextMessageContent.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputTextMessageContent.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputTextMessageContent.java index b8c480af..0a6edd43 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputTextMessageContent.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputTextMessageContent.java @@ -1,6 +1,8 @@ package com.pengrad.telegrambot.model.request; +import com.pengrad.telegrambot.model.LinkPreviewOptions; import com.pengrad.telegrambot.model.MessageEntity; +import com.pengrad.telegrambot.request.EditMessageText; import java.io.Serializable; @@ -13,6 +15,7 @@ public class InputTextMessageContent extends InputMessageContent implements Seri private String message_text; private String parse_mode; + private LinkPreviewOptions link_preview_options; private Boolean disable_web_page_preview; private MessageEntity[] entities; @@ -30,6 +33,14 @@ public InputTextMessageContent entities(MessageEntity... entities) { return this; } + public InputTextMessageContent linkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { + this.link_preview_options = linkPreviewOptions; + return this; + } + + /* + @deprecated Use linkPreviewOptions instead + */ public InputTextMessageContent disableWebPagePreview(Boolean disableWebPagePreview) { this.disable_web_page_preview = disableWebPagePreview; return this; From 7ac1de296e8b7e0e3f1ccb3f280589eccbbee22c Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Wed, 10 Jan 2024 22:29:51 +0100 Subject: [PATCH 06/28] Added the field link_preview_options to the class Message --- .../main/java/com/pengrad/telegrambot/model/Message.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 0688957b..dfc4c7ed 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -41,6 +41,7 @@ public class Message implements Serializable { private String text; private MessageEntity[] entities; private MessageEntity[] caption_entities; + private LinkPreviewOptions link_preview_options; private Audio audio; private Document document; private Animation animation; @@ -194,6 +195,9 @@ public MessageEntity[] captionEntities() { return caption_entities; } + public LinkPreviewOptions linkPreviewOptions() { + return link_preview_options; + } public Audio audio() { return audio; } @@ -417,6 +421,7 @@ public boolean equals(Object o) { Objects.equals(text, message.text) && Arrays.equals(entities, message.entities) && Arrays.equals(caption_entities, message.caption_entities) && + Objects.equals(link_preview_options, message.link_preview_options) && Objects.equals(audio, message.audio) && Objects.equals(document, message.document) && Objects.equals(animation, message.animation) && @@ -501,6 +506,7 @@ public String toString() { ", text='" + text + '\'' + ", entities=" + Arrays.toString(entities) + ", caption_entities=" + Arrays.toString(caption_entities) + + ", link_preview_options=" + link_preview_options + ", audio=" + audio + ", document=" + document + ", animation=" + animation + From ca7d279a70a72270ea76107cc8e2f3e11a0f07ca Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Wed, 10 Jan 2024 22:31:26 +0100 Subject: [PATCH 07/28] =?UTF-8?q?Added=20support=20for=20=E2=80=9Cblockquo?= =?UTF-8?q?te=E2=80=9D=20entities=20in=20received=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/pengrad/telegrambot/model/MessageEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java b/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java index 473e91de..eeb2742c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java @@ -12,7 +12,7 @@ public class MessageEntity implements Serializable { public enum Type { mention, hashtag, cashtag, bot_command, url, email, phone_number, bold, italic, code, pre, text_link, - text_mention, underline, strikethrough, spoiler, custom_emoji + text_mention, underline, strikethrough, spoiler, custom_emoji, blockquote } private Type type; From f3fcd23c2386348e8d471c2cf72156c2023c2f5c Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Fri, 12 Jan 2024 15:57:03 +0100 Subject: [PATCH 08/28] Added deleteMessages, forwardMessages and copyMessages. Added missing fields. --- .../telegrambot/request/CopyMessage.java | 11 ++++--- .../telegrambot/request/CopyMessages.java | 33 +++++++++++++++++++ .../telegrambot/request/DeleteMessages.java | 11 +++++++ .../telegrambot/request/ForwardMessage.java | 4 +++ .../telegrambot/request/ForwardMessages.java | 22 +++++++++++++ .../telegrambot/request/PinChatMessage.java | 3 -- .../telegrambot/request/SendMediaGroup.java | 11 ++++--- .../response/MessageIdsResponse.java | 25 ++++++++++++++ 8 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/request/DeleteMessages.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/request/ForwardMessages.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/response/MessageIdsResponse.java diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java index 3f725548..740e2ea2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java @@ -33,10 +33,6 @@ public CopyMessage captionEntities(MessageEntity... entities) { return add("caption_entities", entities); } - public CopyMessage disableNotification(boolean disableNotification) { - return add("disable_notification", disableNotification); - } - public CopyMessage replyParameters(ReplyParameters replyParameters) { return add("reply_parameters", replyParameters); } @@ -59,4 +55,11 @@ public CopyMessage replyMarkup(Keyboard replyMarkup) { return add("reply_markup", replyMarkup); } + public CopyMessage disableNotification(boolean disableNotification) { + return add("disable_notification", disableNotification); + } + public CopyMessage protectContent(boolean protectContent) { + return add("protect_content", protectContent); + } + } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java new file mode 100644 index 00000000..51644922 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java @@ -0,0 +1,33 @@ +package com.pengrad.telegrambot.request; + +import com.pengrad.telegrambot.model.MessageEntity; +import com.pengrad.telegrambot.model.ReplyParameters; +import com.pengrad.telegrambot.model.request.Keyboard; +import com.pengrad.telegrambot.model.request.ParseMode; +import com.pengrad.telegrambot.response.MessageIdResponse; +import com.pengrad.telegrambot.response.MessageIdsResponse; + + +public class CopyMessages extends BaseRequest { + + public CopyMessages(Object chatId, Object fromChatId, int[] messageIds) { + super(MessageIdsResponse.class); + add("chat_id", chatId).add("from_chat_id", fromChatId).add("message_ids", messageIds); + } + + public CopyMessages messageThreadId(Integer messageThreadId) { + return add("message_thread_id", messageThreadId); + } + + public CopyMessages removeCaption(boolean removeCaption) { + return add("remove_caption", removeCaption); + } + + public CopyMessages disableNotification(boolean disableNotification) { + return add("disable_notification", disableNotification); + } + public CopyMessages protectContent(boolean protectContent) { + return add("protect_content", protectContent); + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/request/DeleteMessages.java b/library/src/main/java/com/pengrad/telegrambot/request/DeleteMessages.java new file mode 100644 index 00000000..4899817d --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteMessages.java @@ -0,0 +1,11 @@ +package com.pengrad.telegrambot.request; + +import com.pengrad.telegrambot.response.BaseResponse; + +public class DeleteMessages extends BaseRequest { + + public DeleteMessages(Object chatId, int[] messageIds) { + super(BaseResponse.class); + add("chat_id", chatId).add("message_ids", messageIds); + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java index 319ec817..671251e1 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java @@ -20,4 +20,8 @@ public ForwardMessage messageThreadId(Integer messageThreadId) { public ForwardMessage disableNotification(boolean disableNotification) { return add("disable_notification", disableNotification); } + public ForwardMessage protectContent(boolean protectContent) { + return add("protect_content", protectContent); + } + } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessages.java b/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessages.java new file mode 100644 index 00000000..3a348b39 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessages.java @@ -0,0 +1,22 @@ +package com.pengrad.telegrambot.request; + +import com.pengrad.telegrambot.response.MessageIdsResponse; + +public class ForwardMessages extends BaseRequest { + + public ForwardMessages(Object chatId, Object fromChatId, int[] messageIds) { + super(MessageIdsResponse.class); + add("chat_id", chatId).add("from_chat_id", fromChatId).add("message_ids", messageIds); + } + + public ForwardMessages messageThreadId(Integer messageThreadId) { + return add("message_thread_id", messageThreadId); + } + public ForwardMessages disableNotification(boolean disableNotification) { + return add("disable_notification", disableNotification); + } + public ForwardMessages protectContent(boolean protectContent) { + return add("protect_content", protectContent); + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java index 2857c95b..874b29d9 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java @@ -13,7 +13,4 @@ public PinChatMessage(Object chatId, int messageId) { add("chat_id", chatId).add("message_id", messageId); } - public PinChatMessage disableNotification(boolean disableNotification) { - return add("disable_notification", disableNotification); - } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java index a1b51404..96be38a6 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java @@ -35,10 +35,6 @@ public SendMediaGroup messageThreadId(Integer messageThreadId) { return add("message_thread_id", messageThreadId); } - public SendMediaGroup disableNotification(boolean disableNotification) { - return add("disable_notification", disableNotification); - } - public SendMediaGroup replyParameters(ReplyParameters replyParameters) { return add("reply_parameters", replyParameters); } @@ -57,6 +53,13 @@ public SendMediaGroup allowSendingWithoutReply(boolean allowSendingWithoutReply) return add("allow_sending_without_reply", allowSendingWithoutReply); } + public SendMediaGroup disableNotification(boolean disableNotification) { + return add("disable_notification", disableNotification); + } + public SendMediaGroup protectContent(boolean protectContent) { + return add("protect_content", protectContent); + } + @Override public boolean isMultipart() { return isMultipart; diff --git a/library/src/main/java/com/pengrad/telegrambot/response/MessageIdsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/MessageIdsResponse.java new file mode 100644 index 00000000..c10b50bf --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/response/MessageIdsResponse.java @@ -0,0 +1,25 @@ +package com.pengrad.telegrambot.response; + +import com.pengrad.telegrambot.model.MessageId; + +import java.util.Arrays; + +/** + * Stas Parshin + * 06 November 2020 + */ +public class MessageIdsResponse extends BaseResponse { + + private MessageId[] result; + + public MessageId[] result() { + return result; + } + + @Override + public String toString() { + return "MessageIdsResponse{" + + "result=" + Arrays.toString(result) + + '}'; + } +} From f717c01756f8fb60cccfd2a5c320bfb28876ab6c Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Fri, 12 Jan 2024 16:00:23 +0100 Subject: [PATCH 09/28] Renamed the class KeyboardButtonRequestUser to KeyboardButtonRequestUsers and added the field max_quantity --- .../request/KeyboardButtonRequestUser.java | 4 +++ .../request/KeyboardButtonRequestUsers.java | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUsers.java diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUser.java b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUser.java index 5e8d46fd..934d9e90 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUser.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUser.java @@ -2,6 +2,10 @@ import java.io.Serializable; +/** + * @deprecated Use KeyboardButtonRequestUsers instead + */ +@Deprecated public class KeyboardButtonRequestUser implements Serializable { private final static long serialVersionUID = 0L; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUsers.java b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUsers.java new file mode 100644 index 00000000..ffa418f5 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestUsers.java @@ -0,0 +1,32 @@ +package com.pengrad.telegrambot.model.request; + +import java.io.Serializable; + +public class KeyboardButtonRequestUsers implements Serializable { + private final static long serialVersionUID = 0L; + + private Integer request_id; + private Boolean user_is_bot; + private Boolean user_is_premium; + private Integer max_quantity; + + public KeyboardButtonRequestUsers(Integer requestId) { + this.request_id = requestId; + } + + public KeyboardButtonRequestUsers userIsBot(Boolean userIsBot) { + this.user_is_bot = userIsBot; + return this; + } + + public KeyboardButtonRequestUsers userIsPremium(Boolean userIsPremium) { + this.user_is_premium = userIsPremium; + return this; + } + + public KeyboardButtonRequestUsers maxQuantity(Integer maxQuantity) { + this.max_quantity = maxQuantity; + return this; + } + +} From e0c760a2f9ca18cc962d465f3b28b8e9c4767fb3 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Fri, 12 Jan 2024 16:02:09 +0100 Subject: [PATCH 10/28] Renamed the field request_user in the class KeyboardButton to request_users --- .../telegrambot/model/request/KeyboardButton.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButton.java b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButton.java index 4143c068..e51d1fa4 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButton.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButton.java @@ -15,7 +15,8 @@ public class KeyboardButton implements Serializable { private boolean request_contact; private boolean request_location; private KeyboardButtonPollType request_poll; - private KeyboardButtonRequestUser request_user; + private KeyboardButtonRequestUsers request_users; + private KeyboardButtonRequestUser request_user; // @deprecated private KeyboardButtonRequestChat request_chat; private WebAppInfo web_app; @@ -38,11 +39,20 @@ public KeyboardButton requestPoll(KeyboardButtonPollType poll) { return this; } + /** + * @deprecated Use reqyestUsers instead + */ + @Deprecated public KeyboardButton requestUser(KeyboardButtonRequestUser user) { this.request_user = user; return this; } + public KeyboardButton requestUsers(KeyboardButtonRequestUsers users) { + this.request_users = users; + return this; + } + public KeyboardButton requestChat(KeyboardButtonRequestChat chat) { this.request_chat = chat; return this; From fcd5b12aa45b07279217437805fd4a7376afd9b2 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Fri, 12 Jan 2024 16:07:27 +0100 Subject: [PATCH 11/28] Added the class UsersShared. Replaced the field user_shared in the class Message with the field users_shared. --- .../pengrad/telegrambot/model/Message.java | 15 +++++-- .../telegrambot/model/UsersShared.java | 43 +++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java 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 dfc4c7ed..9c5dea14 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -72,7 +72,8 @@ public class Message implements Serializable { private Invoice invoice; private SuccessfulPayment successful_payment; private Story story; - private UserShared user_shared; + private UserShared user_shared; //@deprectated + private UsersShared users_shared; private ChatShared chat_shared; private String connected_website; private PassportData passport_data; @@ -318,10 +319,18 @@ public Story story() { return story; } + /** + * @deprecated Use usersShared instead + */ + @Deprecated public UserShared userShared() { return user_shared; } + public UsersShared usersShared() { + return users_shared; + } + public ChatShared chatShared() { return chat_shared; } @@ -452,7 +461,7 @@ public boolean equals(Object o) { Objects.equals(invoice, message.invoice) && Objects.equals(successful_payment, message.successful_payment) && Objects.equals(story, message.story) && - Objects.equals(user_shared, message.user_shared) && + Objects.equals(users_shared, message.users_shared) && Objects.equals(chat_shared, message.chat_shared) && Objects.equals(connected_website, message.connected_website) && Objects.equals(passport_data, message.passport_data) && @@ -537,7 +546,7 @@ public String toString() { ", invoice=" + invoice + ", successful_payment=" + successful_payment + ", story=" + story + - ", user_shared=" + user_shared + + ", users_shared=" + users_shared + ", chat_shared=" + chat_shared + ", connected_website='" + connected_website + '\'' + ", passport_data=" + passport_data + diff --git a/library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java b/library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java new file mode 100644 index 00000000..6d6c8fc4 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java @@ -0,0 +1,43 @@ +package com.pengrad.telegrambot.model; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Objects; + +public class UsersShared implements Serializable { + private final static long serialVersionUID = 0L; + + private Integer request_id; + private Integer[] user_ids; + + public Integer requestId() { + return request_id; + } + public Integer[] userIds() { + return user_ids; + } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + UsersShared that = (UsersShared) o; + + return Objects.equals(request_id, that.request_id) && + Arrays.equals(user_ids, that.user_ids); + } + + @Override + public int hashCode() { + return Objects.hash(request_id, + user_ids); + } + + @Override + public String toString() { + return "UsersShared{" + + "request_id='" + request_id + '\'' + + ", user_ids='" + Arrays.toString(user_ids) + '\'' + + '}'; + } +} From 3b206b4ed1eeceb787165ab810c84b60f997ea4f Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Fri, 12 Jan 2024 16:25:21 +0100 Subject: [PATCH 12/28] MessageOriginTypeAdapter --- .../messageorigin/MessageOriginChannel.java | 4 ++- .../messageorigin/MessageOriginChat.java | 4 ++- .../MessageOriginHiddenUser.java | 4 ++- .../messageorigin/MessageOriginUser.java | 4 ++- .../gson/MessageOriginTypeAdapter.java | 27 +++++++++++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java index 96b8689b..e8b55655 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java @@ -5,7 +5,9 @@ import java.util.Objects; public class MessageOriginChannel extends MessageOrigin { - + + public static final String MESSAGE_ORIGIN_TYPE = "channel"; + private Chat chat; private Integer message_id; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java index 5b00bcd4..159dd377 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java @@ -5,7 +5,9 @@ import java.util.Objects; public class MessageOriginChat extends MessageOrigin { - + + public static final String MESSAGE_ORIGIN_TYPE = "chat"; + private Chat sender_chat; private String author_signature; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java index 820d5ec7..5605b839 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java @@ -3,7 +3,9 @@ import java.util.Objects; public class MessageOriginHiddenUser extends MessageOrigin { - + + public static final String MESSAGE_ORIGIN_TYPE = "hidden_user"; + private String sender_user_name; public String senderUserName() { diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java index 81576a78..40ce2aed 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java @@ -5,7 +5,9 @@ import java.util.Objects; public class MessageOriginUser extends MessageOrigin { - + + public static final String MESSAGE_ORIGIN_TYPE = "user"; + private User sender_user; public User senderUser() { diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java new file mode 100644 index 00000000..19215223 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java @@ -0,0 +1,27 @@ +package com.pengrad.telegrambot.utility.gson; + +import com.google.gson.*; +import com.pengrad.telegrambot.model.messageorigin.*; + +import java.lang.reflect.Type; + +public class MessageOriginTypeAdapter implements JsonDeserializer { + + @Override + public MessageOrigin deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException { + JsonObject object = element.getAsJsonObject(); + String discriminator = object.getAsJsonPrimitive("type").getAsString(); + + if (MessageOriginChannel.MESSAGE_ORIGIN_TYPE.equals(discriminator)) { + return context.deserialize(object, MessageOriginChannel.class); + } else if (MessageOriginChat.MESSAGE_ORIGIN_TYPE.equals(discriminator)) { + return context.deserialize(object, MessageOriginChat.class); + } else if (MessageOriginHiddenUser.MESSAGE_ORIGIN_TYPE.equals(discriminator)) { + return context.deserialize(object, MessageOriginHiddenUser.class); + } else if (MessageOriginUser.MESSAGE_ORIGIN_TYPE.equals(discriminator)) { + return context.deserialize(object, MessageOriginUser.class); + } + + throw new JsonParseException("Unknown MessageOrigin type: " + discriminator); + } +} From 872a9472e3e7d8490690372b1d86bcc4eb2af26a Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Fri, 12 Jan 2024 16:38:19 +0100 Subject: [PATCH 13/28] ChatBoostSource with TypeAdapter --- .../model/chatboost/ChatBoostSource.java | 37 +++++++++++++++++++ .../chatboost/ChatBoostSourceGiftCode.java | 25 +++++++++++++ .../chatboost/ChatBoostSourceGiveaway.java | 37 +++++++++++++++++++ .../chatboost/ChatBoostSourcePremium.java | 26 +++++++++++++ .../pengrad/telegrambot/utility/BotUtils.java | 7 +++- .../utility/gson/ChatBoostTypeAdapter.java | 28 ++++++++++++++ 6 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSource.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiftCode.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiveaway.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourcePremium.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSource.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSource.java new file mode 100644 index 00000000..606e2565 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSource.java @@ -0,0 +1,37 @@ +package com.pengrad.telegrambot.model.chatboost; + +import java.io.Serializable; +import java.util.Objects; + +import com.pengrad.telegrambot.model.User; + + +public class ChatBoostSource implements Serializable { + private final static long serialVersionUID = 0L; + + protected String source; + protected User user; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ChatBoostSource that = (ChatBoostSource) o; + return Objects.equals(source, that.source) + && Objects.equals(user, that.user); + } + + @Override + public int hashCode() { + return Objects.hash(source, user); + } + + @Override + public String toString() { + return "ChatBoostSource{" + + "source='" + source + "'," + + "user='" + user + "'" + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiftCode.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiftCode.java new file mode 100644 index 00000000..c9ff831b --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiftCode.java @@ -0,0 +1,25 @@ +package com.pengrad.telegrambot.model.chatboost; + +import java.io.Serializable; +import java.util.Objects; + + +public class ChatBoostSourceGiftCode extends ChatBoostSource implements Serializable { + private final static long serialVersionUID = 0L; + + public final static String CHAT_BOOST_TYPE = "gift_code"; + + @Override + public int hashCode() { + return Objects.hash(source, user); + } + + @Override + public String toString() { + return "ChatBoostSourceGiftCode{" + + "source='" + source + "'," + + "user='" + user + "'" + + '}'; + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiveaway.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiveaway.java new file mode 100644 index 00000000..13db3af0 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiveaway.java @@ -0,0 +1,37 @@ +package com.pengrad.telegrambot.model.chatboost; + +import java.io.Serializable; +import java.util.Objects; + + +public class ChatBoostSourceGiveaway extends ChatBoostSource implements Serializable { + private final static long serialVersionUID = 0L; + + public final static String CHAT_BOOST_TYPE = "giveaway"; + + private Integer giveaway_message_id; + private Boolean is_unclaimed; + + public Integer giveawayMessageId() { + return giveaway_message_id; + } + public Boolean isUnclaimed() { + return is_unclaimed != null && is_unclaimed; + } + + @Override + public int hashCode() { + return Objects.hash(source, user, giveaway_message_id, is_unclaimed); + } + + @Override + public String toString() { + return "ChatBoostSourceGiveaway{" + + "source='" + source + "'," + + "user='" + user + "'," + + "giveaway_message_id='" + giveaway_message_id + "'," + + "is_unclaimed='" + is_unclaimed + "'" + + '}'; + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourcePremium.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourcePremium.java new file mode 100644 index 00000000..9ac2a273 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourcePremium.java @@ -0,0 +1,26 @@ +package com.pengrad.telegrambot.model.chatboost; + +import com.pengrad.telegrambot.model.User; + +import java.io.Serializable; +import java.util.Objects; + + +public class ChatBoostSourcePremium extends ChatBoostSource implements Serializable { + private final static long serialVersionUID = 0L; + + public final static String CHAT_BOOST_TYPE = "premium"; + + @Override + public int hashCode() { + return Objects.hash(source, user); + } + + @Override + public String toString() { + return "ChatBoostSourcePremium{" + + "source='" + source + "'," + + "user='" + user + "'" + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java index a9698ea2..1c35282f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java @@ -3,7 +3,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.pengrad.telegrambot.model.Update; +import com.pengrad.telegrambot.model.messageorigin.MessageOrigin; import com.pengrad.telegrambot.model.reaction.ReactionType; +import com.pengrad.telegrambot.utility.gson.MessageOriginTypeAdapter; import com.pengrad.telegrambot.utility.gson.ReactionTypeAdapter; import java.io.ByteArrayOutputStream; @@ -20,8 +22,9 @@ public class BotUtils { private BotUtils() {} public static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(ReactionType.class, new ReactionTypeAdapter()) - .create(); + .registerTypeAdapter(ReactionType.class, new ReactionTypeAdapter()) + .registerTypeAdapter(MessageOrigin.class, new MessageOriginTypeAdapter()) + .create(); public static Update parseUpdate(String update) { return GSON.fromJson(update, Update.class); diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java new file mode 100644 index 00000000..62def3c5 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java @@ -0,0 +1,28 @@ +package com.pengrad.telegrambot.utility.gson; + +import com.google.gson.*; +import com.pengrad.telegrambot.model.chatboost.ChatBoostSourceGiftCode; +import com.pengrad.telegrambot.model.chatboost.ChatBoostSourceGiveaway; +import com.pengrad.telegrambot.model.chatboost.ChatBoostSourcePremium; +import com.pengrad.telegrambot.model.messageorigin.*; + +import java.lang.reflect.Type; + +public class ChatBoostTypeAdapter implements JsonDeserializer { + + @Override + public MessageOrigin deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException { + JsonObject object = element.getAsJsonObject(); + String discriminator = object.getAsJsonPrimitive("source").getAsString(); + + if (ChatBoostSourceGiftCode.CHAT_BOOST_TYPE.equals(discriminator)) { + return context.deserialize(object, ChatBoostSourceGiftCode.class); + } else if (ChatBoostSourceGiveaway.CHAT_BOOST_TYPE.equals(discriminator)) { + return context.deserialize(object, ChatBoostSourceGiveaway.class); + } else if (ChatBoostSourcePremium.CHAT_BOOST_TYPE.equals(discriminator)) { + return context.deserialize(object, ChatBoostSourcePremium.class); + } + + throw new JsonParseException("Unknown ChatBoost type: " + discriminator); + } +} From 507bbd328fa8823b8f3065c8eb5a8f87105a75ba Mon Sep 17 00:00:00 2001 From: Andrew Anfanik Date: Mon, 15 Jan 2024 12:41:39 +0300 Subject: [PATCH 14/28] Add ChatBoostUpdated and ChatBoostRemoved to Update --- .../com/pengrad/telegrambot/model/Update.java | 19 ++++++- .../model/chatboost/ChatBoost.java | 55 ++++++++++++++++++ .../model/chatboost/ChatBoostRemoved.java | 56 +++++++++++++++++++ .../model/chatboost/ChatBoostUpdated.java | 41 ++++++++++++++ .../{ => source}/ChatBoostSource.java | 2 +- .../{ => source}/ChatBoostSourceGiftCode.java | 2 +- .../{ => source}/ChatBoostSourceGiveaway.java | 2 +- .../{ => source}/ChatBoostSourcePremium.java | 4 +- .../utility/gson/ChatBoostTypeAdapter.java | 6 +- 9 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java rename library/src/main/java/com/pengrad/telegrambot/model/chatboost/{ => source}/ChatBoostSource.java (93%) rename library/src/main/java/com/pengrad/telegrambot/model/chatboost/{ => source}/ChatBoostSourceGiftCode.java (90%) rename library/src/main/java/com/pengrad/telegrambot/model/chatboost/{ => source}/ChatBoostSourceGiveaway.java (94%) rename library/src/main/java/com/pengrad/telegrambot/model/chatboost/{ => source}/ChatBoostSourcePremium.java (85%) 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 ff17a90d..049ce28f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Update.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Update.java @@ -1,5 +1,8 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.chatboost.ChatBoostRemoved; +import com.pengrad.telegrambot.model.chatboost.ChatBoostUpdated; + import java.io.Serializable; import java.util.Objects; @@ -27,6 +30,8 @@ public class Update implements Serializable { private ChatJoinRequest chat_join_request; private MessageReactionUpdated message_reaction; private MessageReactionCountUpdated message_reaction_count; + private ChatBoostUpdated chat_boost; + private ChatBoostRemoved removed_chat_boost; public Integer updateId() { return update_id; @@ -96,6 +101,14 @@ public MessageReactionCountUpdated messageReactionCount() { return message_reaction_count; } + public ChatBoostUpdated chatBoost() { + return chat_boost; + } + + public ChatBoostRemoved removedChatBoost() { + return removed_chat_boost; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -117,7 +130,9 @@ public boolean equals(Object o) { Objects.equals(chat_member, update.chat_member) && Objects.equals(chat_join_request, update.chat_join_request) && Objects.equals(message_reaction, update.message_reaction) && - Objects.equals(message_reaction_count, update.message_reaction_count); + Objects.equals(message_reaction_count, update.message_reaction_count) && + Objects.equals(chat_boost, update.chat_boost) && + Objects.equals(removed_chat_boost, update.removed_chat_boost); } @Override @@ -145,6 +160,8 @@ public String toString() { ", chat_join_request=" + chat_join_request + ", message_reaction=" + message_reaction + ", message_reaction_count=" + message_reaction_count + + ", chat_boost=" + chat_boost + + ", removed_chat_boost=" + removed_chat_boost + '}'; } } diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java new file mode 100644 index 00000000..97bb9c83 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java @@ -0,0 +1,55 @@ +package com.pengrad.telegrambot.model.chatboost; + +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; + +import java.util.Objects; + +public class ChatBoost { + + private String boost_id; + private Integer add_date; + private Integer expiration_date; + private ChatBoostSource source; + + public String boostId() { + return boost_id; + } + + public Integer addDate() { + return add_date; + } + + public Integer expirationDate() { + return expiration_date; + } + + public ChatBoostSource source() { + return source; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ChatBoost chatBoost = (ChatBoost) o; + return Objects.equals(boost_id, chatBoost.boost_id) + && Objects.equals(add_date, chatBoost.add_date) + && Objects.equals(expiration_date, chatBoost.expiration_date) + && Objects.equals(source, chatBoost.source); + } + + @Override + public int hashCode() { + return boost_id != null ? boost_id.hashCode() : 0; + } + + @Override + public String toString() { + return "ChatBoost{" + + "boost_id='" + boost_id + '\'' + + ", add_date=" + add_date + + ", expiration_date=" + expiration_date + + ", source=" + source + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java new file mode 100644 index 00000000..02f5bd0e --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java @@ -0,0 +1,56 @@ +package com.pengrad.telegrambot.model.chatboost; + +import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; + +import java.util.Objects; + +public class ChatBoostRemoved { + + private Chat chat; + private String boost_id; + private Integer remove_date; + private ChatBoostSource source; + + public Chat chat() { + return chat; + } + + public String boostId() { + return boost_id; + } + + public Integer removeDate() { + return remove_date; + } + + public ChatBoostSource source() { + return source; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ChatBoostRemoved that = (ChatBoostRemoved) o; + return Objects.equals(chat, that.chat) + && Objects.equals(boost_id, that.boost_id) + && Objects.equals(remove_date, that.remove_date) + && Objects.equals(source, that.source); + } + + @Override + public int hashCode() { + return boost_id != null ? boost_id.hashCode() : 0; + } + + @Override + public String toString() { + return "ChatBoostRemoved{" + + "chat=" + chat + + ", boost_id='" + boost_id + '\'' + + ", remove_date=" + remove_date + + ", source=" + source + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java new file mode 100644 index 00000000..4779ba1e --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java @@ -0,0 +1,41 @@ +package com.pengrad.telegrambot.model.chatboost; + +import com.pengrad.telegrambot.model.Chat; + +import java.util.Objects; + +public class ChatBoostUpdated { + + private Chat chat; + private ChatBoost boost; + + public Chat chat() { + return chat; + } + + public ChatBoost boost() { + return boost; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ChatBoostUpdated that = (ChatBoostUpdated) o; + return Objects.equals(chat, that.chat) + && Objects.equals(boost, that.boost); + } + + @Override + public int hashCode() { + return Objects.hash(chat, boost); + } + + @Override + public String toString() { + return "ChatBoostUpdated{" + + "chat=" + chat + + ", boost=" + boost + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSource.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java similarity index 93% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSource.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java index 606e2565..cf733082 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSource.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiftCode.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java similarity index 90% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiftCode.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java index c9ff831b..dbf2ea2a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiftCode.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiveaway.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java similarity index 94% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiveaway.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java index 13db3af0..4679d7c3 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourceGiveaway.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourcePremium.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java similarity index 85% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourcePremium.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java index 9ac2a273..dacba5ca 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostSourcePremium.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java @@ -1,6 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost; - -import com.pengrad.telegrambot.model.User; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java index 62def3c5..752d3891 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java @@ -1,9 +1,9 @@ package com.pengrad.telegrambot.utility.gson; import com.google.gson.*; -import com.pengrad.telegrambot.model.chatboost.ChatBoostSourceGiftCode; -import com.pengrad.telegrambot.model.chatboost.ChatBoostSourceGiveaway; -import com.pengrad.telegrambot.model.chatboost.ChatBoostSourcePremium; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiftCode; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiveaway; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourcePremium; import com.pengrad.telegrambot.model.messageorigin.*; import java.lang.reflect.Type; From 3919dfaef705ed5b61b44e595542795d16fd95fd Mon Sep 17 00:00:00 2001 From: Andrew Anfanik Date: Mon, 15 Jan 2024 19:38:21 +0300 Subject: [PATCH 15/28] Implement getUserChatBoosts method --- .../request/GetUserChatBoosts.java | 11 ++++++++++ .../response/UserChatBoostsResponse.java | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 library/src/main/java/com/pengrad/telegrambot/request/GetUserChatBoosts.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetUserChatBoosts.java b/library/src/main/java/com/pengrad/telegrambot/request/GetUserChatBoosts.java new file mode 100644 index 00000000..ef80de77 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetUserChatBoosts.java @@ -0,0 +1,11 @@ +package com.pengrad.telegrambot.request; + +import com.pengrad.telegrambot.response.UserChatBoostsResponse; + +public class GetUserChatBoosts extends BaseRequest { + + public GetUserChatBoosts(Object chatId, Integer userId) { + super(UserChatBoostsResponse.class); + add("chat_id", chatId).add("user_id", userId); + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java new file mode 100644 index 00000000..999fbc84 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java @@ -0,0 +1,21 @@ +package com.pengrad.telegrambot.response; + +import com.pengrad.telegrambot.model.chatboost.ChatBoost; + +import java.util.Arrays; + +public class UserChatBoostsResponse extends BaseResponse { + + private ChatBoost[] boosts; + + public ChatBoost[] boosts() { + return boosts; + } + + @Override + public String toString() { + return "UserChatBoostsResponse{" + + "boosts=" + Arrays.toString(boosts) + + '}'; + } +} From a802e3ca24adbe8e3813abe558c83613f2542b32 Mon Sep 17 00:00:00 2001 From: Andrew Anfanik Date: Mon, 15 Jan 2024 19:28:54 +0300 Subject: [PATCH 16/28] Fix ChatBoostSourceTypeAdapter and register it --- .../main/java/com/pengrad/telegrambot/utility/BotUtils.java | 4 +++- ...oostTypeAdapter.java => ChatBoostSourceTypeAdapter.java} | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) rename library/src/main/java/com/pengrad/telegrambot/utility/gson/{ChatBoostTypeAdapter.java => ChatBoostSourceTypeAdapter.java} (78%) diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java index 1c35282f..c34426ad 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java @@ -3,8 +3,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.pengrad.telegrambot.model.Update; -import com.pengrad.telegrambot.model.messageorigin.MessageOrigin; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; import com.pengrad.telegrambot.model.reaction.ReactionType; +import com.pengrad.telegrambot.utility.gson.ChatBoostSourceTypeAdapter; import com.pengrad.telegrambot.utility.gson.MessageOriginTypeAdapter; import com.pengrad.telegrambot.utility.gson.ReactionTypeAdapter; @@ -24,6 +25,7 @@ private BotUtils() {} public static final Gson GSON = new GsonBuilder() .registerTypeAdapter(ReactionType.class, new ReactionTypeAdapter()) .registerTypeAdapter(MessageOrigin.class, new MessageOriginTypeAdapter()) + .registerTypeAdapter(ChatBoostSource.class, new ChatBoostSourceTypeAdapter()) .create(); public static Update parseUpdate(String update) { diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java similarity index 78% rename from library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java rename to library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java index 752d3891..610dc97c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java @@ -1,17 +1,17 @@ package com.pengrad.telegrambot.utility.gson; import com.google.gson.*; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiftCode; import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiveaway; import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourcePremium; -import com.pengrad.telegrambot.model.messageorigin.*; import java.lang.reflect.Type; -public class ChatBoostTypeAdapter implements JsonDeserializer { +public class ChatBoostSourceTypeAdapter implements JsonDeserializer { @Override - public MessageOrigin deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException { + public ChatBoostSource deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject object = element.getAsJsonObject(); String discriminator = object.getAsJsonPrimitive("source").getAsString(); From 61cbf13feb07fbbb7fbddc98cb9688c8bd6dfff1 Mon Sep 17 00:00:00 2001 From: Andrew Anfanik Date: Mon, 15 Jan 2024 18:23:27 +0300 Subject: [PATCH 17/28] Add accent_color_id, background_custom_emoji_id, profile_accent_color_id and profile_background_custom_emoji_id and has_visible_history fields to Chat --- .../com/pengrad/telegrambot/model/Chat.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Chat.java b/library/src/main/java/com/pengrad/telegrambot/model/Chat.java index 330420d3..2508b267 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Chat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Chat.java @@ -36,6 +36,10 @@ public enum Type { private ChatPhoto photo; private String[] active_usernames; private ReactionType[] available_reactions; + private Integer accent_color_id; + private String background_custom_emoji_id; + private Integer profile_accent_color_id; + private String profile_background_custom_emoji_id; private String emoji_status_custom_emoji_id; private Integer emoji_status_expiration_date; private String bio; @@ -52,6 +56,7 @@ public enum Type { private Integer slow_mode_delay; private Integer message_auto_delete_time; private Boolean has_protected_content; + private Boolean has_visible_history; private String sticker_set_name; private Boolean can_set_sticker_set; private Long linked_chat_id; @@ -106,6 +111,22 @@ public ReactionType[] availableReactions() { return available_reactions; } + public Integer accentColorId() { + return accent_color_id; + } + + public String backgroundCustomEmojiId() { + return background_custom_emoji_id; + } + + public Integer profileAccentColorId() { + return profile_accent_color_id; + } + + public String profileBackgroundCustomEmojiId() { + return profile_background_custom_emoji_id; + } + /** * @deprecated Use emojiStatusCustomEmojiId() instead */ @@ -177,6 +198,10 @@ public Boolean hasProtectedContent() { return has_protected_content != null && has_protected_content; } + public Boolean hasVisibleHistory() { + return has_visible_history != null && has_visible_history; + } + public String stickerSetName() { return sticker_set_name; } @@ -208,6 +233,10 @@ public boolean equals(Object o) { Objects.equals(photo, chat.photo) && Arrays.equals(active_usernames, chat.active_usernames) && Arrays.equals(available_reactions, chat.available_reactions) && + Objects.equals(accent_color_id, chat.accent_color_id) && + Objects.equals(background_custom_emoji_id, chat.background_custom_emoji_id) && + Objects.equals(profile_accent_color_id, chat.profile_accent_color_id) && + Objects.equals(profile_background_custom_emoji_id, chat.profile_background_custom_emoji_id) && Objects.equals(emoji_status_custom_emoji_id, chat.emoji_status_custom_emoji_id) && Objects.equals(emoji_status_expiration_date, chat.emoji_status_expiration_date) && Objects.equals(bio, chat.bio) && @@ -224,6 +253,7 @@ public boolean equals(Object o) { Objects.equals(slow_mode_delay, chat.slow_mode_delay) && Objects.equals(message_auto_delete_time, chat.message_auto_delete_time) && Objects.equals(has_protected_content, chat.has_protected_content) && + Objects.equals(has_visible_history, chat.has_visible_history) && Objects.equals(sticker_set_name, chat.sticker_set_name) && Objects.equals(can_set_sticker_set, chat.can_set_sticker_set) && Objects.equals(linked_chat_id, chat.linked_chat_id) && @@ -248,6 +278,10 @@ public String toString() { ", photo=" + photo + ", active_usernames=" + Arrays.toString(active_usernames) + ", available_reactions=" + Arrays.toString(available_reactions) + + ", accent_color_id=" + accent_color_id + + ", background_custom_emoji_id='" + background_custom_emoji_id + '\'' + + ", profile_accent_color_id=" + profile_accent_color_id + + ", profile_background_custom_emoji_id='" + profile_background_custom_emoji_id + '\'' + ", emoji_status_custom_emoji_id='" + emoji_status_custom_emoji_id + '\'' + ", emoji_status_expiration_date='" + emoji_status_expiration_date + '\'' + ", bio='" + bio + '\'' + @@ -264,6 +298,7 @@ public String toString() { ", slow_mode_delay=" + slow_mode_delay + ", message_auto_delete_time=" + message_auto_delete_time + ", has_protected_content=" + has_protected_content + + ", has_visible_history=" + has_visible_history + ", sticker_set_name='" + sticker_set_name + '\'' + ", can_set_sticker_set=" + can_set_sticker_set + ", linked_chat_id=" + linked_chat_id + From 473e4191f35f3d87f3d8c03f21a9718f0938166e Mon Sep 17 00:00:00 2001 From: Andrew Anfanik Date: Mon, 15 Jan 2024 19:00:49 +0300 Subject: [PATCH 18/28] Add forward_origin to Message, remove deprecated fields, add backwards support --- .../pengrad/telegrambot/model/Message.java | 96 +++++++++++++------ 1 file changed, 68 insertions(+), 28 deletions(-) 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 9c5dea14..5a86c266 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -1,8 +1,8 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.messageorigin.*; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.passport.PassportData; -import jdk.javadoc.internal.doclets.toolkit.util.Extern; import java.io.Serializable; import java.util.Arrays; @@ -21,12 +21,7 @@ public class Message implements Serializable { private Chat sender_chat; private Integer date; private Chat chat; - private User forward_from; - private Chat forward_from_chat; - private Integer forward_from_message_id; - private String forward_signature; - private String forward_sender_name; - private Integer forward_date; + private MessageOrigin forward_origin; private Boolean is_topic_message; private Boolean is_automatic_forward; private Message reply_to_message; @@ -117,32 +112,87 @@ public Chat chat() { return chat; } + private MessageOrigin forwardOrigin() { + return forward_origin; + } + + /** + * @deprecated Use Message#forwardOrigin instead + */ + @Deprecated public User forwardFrom() { - return forward_from; + if (forward_origin instanceof MessageOriginUser) { + return ((MessageOriginUser) forward_origin).senderUser(); + } + return null; } + /** + * @deprecated Use Message#forwardOrigin instead + */ + @Deprecated public Chat forwardFromChat() { - return forward_from_chat; + if (forward_origin instanceof MessageOriginChat) { + return ((MessageOriginChat) forward_origin).senderChat(); + } + + if (forward_origin instanceof MessageOriginChannel) { + return ((MessageOriginChannel) forward_origin).chat(); + } + + return null; } + /** + * @deprecated Use Message#forwardOrigin instead + */ + @Deprecated public Integer forwardFromMessageId() { - return forward_from_message_id; + if (forward_origin instanceof MessageOriginChannel) { + return ((MessageOriginChannel) forward_origin).messageId(); + } + + return null; } + /** + * @deprecated Use Message#forwardOrigin instead + */ + @Deprecated public String forwardSignature() { - return forward_signature; + if (forward_origin instanceof MessageOriginChat) { + return ((MessageOriginChat) forward_origin).authorSignature(); + } + + if (forward_origin instanceof MessageOriginChannel) { + return ((MessageOriginChannel) forward_origin).authorSignature(); + } + + return null; } + /** + * @deprecated Use Message#forwardOrigin instead + */ + @Deprecated public String forwardSenderName() { - return forward_sender_name; - } + if (forward_origin instanceof MessageOriginHiddenUser) { + return ((MessageOriginHiddenUser) forward_origin).senderUserName(); + } - public Boolean isTopicMessage() { - return is_topic_message != null && is_topic_message; + return null; } + /** + * @deprecated Use Message#forwardOrigin instead + */ + @Deprecated public Integer forwardDate() { - return forward_date; + return forward_origin.date(); + } + + public Boolean isTopicMessage() { + return is_topic_message != null && is_topic_message; } public Boolean isAutomaticForward() { @@ -410,12 +460,7 @@ public boolean equals(Object o) { Objects.equals(sender_chat, message.sender_chat) && Objects.equals(date, message.date) && Objects.equals(chat, message.chat) && - Objects.equals(forward_from, message.forward_from) && - Objects.equals(forward_from_chat, message.forward_from_chat) && - Objects.equals(forward_from_message_id, message.forward_from_message_id) && - Objects.equals(forward_signature, message.forward_signature) && - Objects.equals(forward_sender_name, message.forward_sender_name) && - Objects.equals(forward_date, message.forward_date) && + Objects.equals(forward_origin, message.forward_origin) && Objects.equals(is_topic_message, message.is_topic_message) && Objects.equals(is_automatic_forward, message.is_automatic_forward) && Objects.equals(reply_to_message, message.reply_to_message) && @@ -495,12 +540,7 @@ public String toString() { ", sender_chat=" + sender_chat + ", date=" + date + ", chat=" + chat + - ", forward_from=" + forward_from + - ", forward_from_chat=" + forward_from_chat + - ", forward_from_message_id=" + forward_from_message_id + - ", forward_signature='" + forward_signature + '\'' + - ", forward_sender_name='" + forward_sender_name + '\'' + - ", forward_date=" + forward_date + + ", forward_origin=" + forward_origin + ", is_topic_message=" + is_topic_message + ", is_automatic_forward=" + is_automatic_forward + ", reply_to_message=" + reply_to_message + From af58ea5d7bd3181713dec29f06be1f01ed94afe1 Mon Sep 17 00:00:00 2001 From: Andrew Anfanik Date: Mon, 15 Jan 2024 19:31:09 +0300 Subject: [PATCH 19/28] Add MaybeInaccessibleMessage type and use it in CallbackQuery#message and Message#pinned_message --- .../telegrambot/model/CallbackQuery.java | 19 +++++- .../telegrambot/model/ExternalReplyInfo.java | 3 +- .../telegrambot/model/LinkPreviewOptions.java | 2 - .../pengrad/telegrambot/model/Message.java | 58 +++++++++++++------ .../model/message/InaccessibleMessage.java | 15 +++++ .../message/MaybeInaccessibleMessage.java | 48 +++++++++++++++ .../origin}/MessageOrigin.java | 2 +- .../origin}/MessageOriginChannel.java | 2 +- .../origin}/MessageOriginChat.java | 2 +- .../origin}/MessageOriginHiddenUser.java | 2 +- .../origin}/MessageOriginUser.java | 2 +- .../pengrad/telegrambot/utility/BotUtils.java | 4 ++ .../MaybeInaccessibleMessageTypeAdapter.java | 23 ++++++++ .../gson/MessageOriginTypeAdapter.java | 2 +- 14 files changed, 153 insertions(+), 31 deletions(-) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/message/InaccessibleMessage.java create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java rename library/src/main/java/com/pengrad/telegrambot/model/{messageorigin => message/origin}/MessageOrigin.java (94%) rename library/src/main/java/com/pengrad/telegrambot/model/{messageorigin => message/origin}/MessageOriginChannel.java (96%) rename library/src/main/java/com/pengrad/telegrambot/model/{messageorigin => message/origin}/MessageOriginChat.java (95%) rename library/src/main/java/com/pengrad/telegrambot/model/{messageorigin => message/origin}/MessageOriginHiddenUser.java (95%) rename library/src/main/java/com/pengrad/telegrambot/model/{messageorigin => message/origin}/MessageOriginUser.java (94%) create mode 100644 library/src/main/java/com/pengrad/telegrambot/utility/gson/MaybeInaccessibleMessageTypeAdapter.java diff --git a/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java b/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java index 9c96cd8e..90cd7a13 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java @@ -1,5 +1,7 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; + import java.io.Serializable; /** @@ -11,7 +13,7 @@ public class CallbackQuery implements Serializable { private String id; private User from; - private Message message; + private MaybeInaccessibleMessage message; private String inline_message_id; private String chat_instance; private String data; @@ -25,10 +27,23 @@ public User from() { return from; } - public Message message() { + private MaybeInaccessibleMessage maybeInaccessibleMessage() { return message; } + /** + * @deprecated Use CallbackQuery#maybeInaccessibleMessage instead + */ + @Deprecated + public Message message() { + Message result = new Message(); + result.setChat(message.chat()); + result.setMessageId(message.messageId()); + result.setDate(message.date()); + + return result; + } + public String inlineMessageId() { return inline_message_id; } 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 3b28caf2..b79912b9 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java @@ -1,9 +1,8 @@ package com.pengrad.telegrambot.model; import com.pengrad.telegrambot.model.giveaway.Giveaway; -import com.pengrad.telegrambot.model.giveaway.GiveawayCompleted; import com.pengrad.telegrambot.model.giveaway.GiveawayWinners; -import com.pengrad.telegrambot.model.messageorigin.MessageOrigin; +import com.pengrad.telegrambot.model.message.origin.MessageOrigin; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java b/library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java index 228b0d62..3eeae8c3 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/LinkPreviewOptions.java @@ -1,7 +1,5 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.messageorigin.MessageOriginChat; - import java.io.Serializable; import java.util.Objects; 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 5a86c266..23ca9a94 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -1,6 +1,7 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.messageorigin.*; +import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; +import com.pengrad.telegrambot.model.message.origin.*; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.passport.PassportData; @@ -12,15 +13,12 @@ * stas * 8/4/15. */ -public class Message implements Serializable { +public class Message extends MaybeInaccessibleMessage implements Serializable { private final static long serialVersionUID = 0L; - private Integer message_id; private Integer message_thread_id; private User from; private Chat sender_chat; - private Integer date; - private Chat chat; private MessageOrigin forward_origin; private Boolean is_topic_message; private Boolean is_automatic_forward; @@ -63,7 +61,7 @@ public class Message implements Serializable { private MessageAutoDeleteTimerChanged message_auto_delete_timer_changed; private Long migrate_to_chat_id; private Long migrate_from_chat_id; - private Message pinned_message; + private MaybeInaccessibleMessage pinned_message; private Invoice invoice; private SuccessfulPayment successful_payment; private Story story; @@ -88,10 +86,6 @@ public class Message implements Serializable { private InlineKeyboardMarkup reply_markup; private WebAppData web_app_data; - public Integer messageId() { - return message_id; - } - public Integer messageThreadId() { return message_thread_id; } @@ -104,14 +98,6 @@ public Chat senderChat() { return sender_chat; } - public Integer date() { - return date; - } - - public Chat chat() { - return chat; - } - private MessageOrigin forwardOrigin() { return forward_origin; } @@ -353,10 +339,23 @@ public Long migrateFromChatId() { return migrate_from_chat_id; } - public Message pinnedMessage() { + public MaybeInaccessibleMessage maybeInaccessiblePinnedMessage() { return pinned_message; } + /** + * @deprecated Use Message#maybeInaccessiblePinnedMessage instead + */ + @Deprecated + public Message pinnedMessage() { + Message result = new Message(); + result.setChat(pinned_message.chat()); + result.setMessageId(pinned_message.messageId()); + result.setDate(pinned_message.date()); + + return result; + } + public Invoice invoice() { return invoice; } @@ -449,6 +448,27 @@ public WebAppData webAppData() { return web_app_data; } + /** + * Only for backwards-compatibility with MaybeInaccessibleMessage + */ + void setChat(Chat chat) { + this.chat = chat; + } + + /** + * Only for backwards-compatibility with MaybeInaccessibleMessage + */ + void setMessageId(Integer messageId) { + this.message_id = messageId; + } + + /** + * Only for backwards-compatibility with MaybeInaccessibleMessage + */ + void setDate(Integer date) { + this.date = date; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/InaccessibleMessage.java b/library/src/main/java/com/pengrad/telegrambot/model/message/InaccessibleMessage.java new file mode 100644 index 00000000..c887d988 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/InaccessibleMessage.java @@ -0,0 +1,15 @@ +package com.pengrad.telegrambot.model.message; + +public class InaccessibleMessage extends MaybeInaccessibleMessage { + + public static final Integer INACCESSIBLE_MESSAGE_DATE = 0; + + @Override + public String toString() { + return "InaccessibleMessage{" + + "chat=" + chat + + ", message_id=" + message_id + + ", date=" + date + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java b/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java new file mode 100644 index 00000000..4dc9511c --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java @@ -0,0 +1,48 @@ +package com.pengrad.telegrambot.model.message; + +import com.pengrad.telegrambot.model.Chat; + +import java.util.Objects; + +public class MaybeInaccessibleMessage { + + protected Chat chat; + protected Integer message_id; + protected Integer date; + + public Chat chat() { + return chat; + } + + public Integer messageId() { + return message_id; + } + + public Integer date() { + return date; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MaybeInaccessibleMessage that = (MaybeInaccessibleMessage) o; + return Objects.equals(chat, that.chat) + && Objects.equals(message_id, that.message_id) + && Objects.equals(date, that.date); + } + + @Override + public int hashCode() { + return Objects.hash(chat, message_id); + } + + @Override + public String toString() { + return "MaybeInaccessibleMessage{" + + "chat=" + chat + + ", message_id=" + message_id + + ", date=" + date + + '}'; + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOrigin.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOrigin.java similarity index 94% rename from library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOrigin.java rename to library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOrigin.java index 003acd88..443aabaf 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOrigin.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOrigin.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.messageorigin; +package com.pengrad.telegrambot.model.message.origin; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java similarity index 96% rename from library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java rename to library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java index e8b55655..8a08b6b6 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChannel.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.messageorigin; +package com.pengrad.telegrambot.model.message.origin; import com.pengrad.telegrambot.model.Chat; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java similarity index 95% rename from library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java rename to library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java index 159dd377..63acfe6d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.messageorigin; +package com.pengrad.telegrambot.model.message.origin; import com.pengrad.telegrambot.model.Chat; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginHiddenUser.java similarity index 95% rename from library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java rename to library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginHiddenUser.java index 5605b839..3f205edb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginHiddenUser.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginHiddenUser.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.messageorigin; +package com.pengrad.telegrambot.model.message.origin; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginUser.java similarity index 94% rename from library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java rename to library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginUser.java index 40ce2aed..8f7f7462 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/messageorigin/MessageOriginUser.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginUser.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.messageorigin; +package com.pengrad.telegrambot.model.message.origin; import com.pengrad.telegrambot.model.User; diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java index c34426ad..68482d2c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java @@ -4,8 +4,11 @@ import com.google.gson.GsonBuilder; import com.pengrad.telegrambot.model.Update; import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; +import com.pengrad.telegrambot.model.message.origin.MessageOrigin; import com.pengrad.telegrambot.model.reaction.ReactionType; import com.pengrad.telegrambot.utility.gson.ChatBoostSourceTypeAdapter; +import com.pengrad.telegrambot.utility.gson.MaybeInaccessibleMessageTypeAdapter; import com.pengrad.telegrambot.utility.gson.MessageOriginTypeAdapter; import com.pengrad.telegrambot.utility.gson.ReactionTypeAdapter; @@ -26,6 +29,7 @@ private BotUtils() {} .registerTypeAdapter(ReactionType.class, new ReactionTypeAdapter()) .registerTypeAdapter(MessageOrigin.class, new MessageOriginTypeAdapter()) .registerTypeAdapter(ChatBoostSource.class, new ChatBoostSourceTypeAdapter()) + .registerTypeAdapter(MaybeInaccessibleMessage.class, new MaybeInaccessibleMessageTypeAdapter()) .create(); public static Update parseUpdate(String update) { diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/MaybeInaccessibleMessageTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MaybeInaccessibleMessageTypeAdapter.java new file mode 100644 index 00000000..f8d359f2 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MaybeInaccessibleMessageTypeAdapter.java @@ -0,0 +1,23 @@ +package com.pengrad.telegrambot.utility.gson; + +import com.google.gson.*; +import com.pengrad.telegrambot.model.Message; +import com.pengrad.telegrambot.model.message.InaccessibleMessage; +import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; + +import java.lang.reflect.Type; + +public class MaybeInaccessibleMessageTypeAdapter implements JsonDeserializer { + + @Override + public MaybeInaccessibleMessage deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException { + JsonObject object = element.getAsJsonObject(); + JsonPrimitive discriminator = object.getAsJsonPrimitive("date"); + + if (!discriminator.isJsonNull() && discriminator.getAsInt() != InaccessibleMessage.INACCESSIBLE_MESSAGE_DATE) { + return context.deserialize(object, Message.class); + } else { + return context.deserialize(object, InaccessibleMessage.class); + } + } +} diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java index 19215223..0c53ca4f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java @@ -1,7 +1,7 @@ package com.pengrad.telegrambot.utility.gson; import com.google.gson.*; -import com.pengrad.telegrambot.model.messageorigin.*; +import com.pengrad.telegrambot.model.message.origin.*; import java.lang.reflect.Type; From af42933e4d9e82672a84f32fcca1071b91139a06 Mon Sep 17 00:00:00 2001 From: Andrew Anfanik Date: Mon, 15 Jan 2024 19:48:11 +0300 Subject: [PATCH 20/28] Bump version: 7.0.1 --- README.md | 4 ++-- README_RU.md | 4 ++-- gradle.properties | 2 +- pom.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d06798f9..1f2ab8fd 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:7.0.0' +implementation 'com.github.pengrad:java-telegram-bot-api:7.0.1' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.0.0 + 7.0.1 ``` [JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases) diff --git a/README_RU.md b/README_RU.md index 177e71f9..ac2e28a1 100644 --- a/README_RU.md +++ b/README_RU.md @@ -13,14 +13,14 @@ Java библиотека, созданная для работы с [Telegram B Gradle: ```groovy -implementation 'com.github.pengrad:java-telegram-bot-api:7.0.0' +implementation 'com.github.pengrad:java-telegram-bot-api:7.0.1' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.0.0 + 7.0.1 ``` Также JAR со всеми зависимостями можно найти [в релизах](https://github.com/pengrad/java-telegram-bot-api/releases). diff --git a/gradle.properties b/gradle.properties index 49e2f173..44fdff4d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.github.pengrad -VERSION_NAME=7.0.0 +VERSION_NAME=7.0.1 POM_DESCRIPTION=Java API for Telegram Bot API POM_URL=https://github.com/pengrad/java-telegram-bot-api/ diff --git a/pom.xml b/pom.xml index 972c01d5..43fb919e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.pengrad java-telegram-bot-api - 7.0.0 + 7.0.1 JavaTelegramBotApi Java API for Telegram Bot API https://github.com/pengrad/java-telegram-bot-api/ From e708a6deefdde97746a83c3d23c50b6d9162f516 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 15 Jan 2024 19:14:16 +0100 Subject: [PATCH 21/28] Build fix --- .../java/com/pengrad/telegrambot/request/PinChatMessage.java | 4 ++++ .../main/java/com/pengrad/telegrambot/utility/BotUtils.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java index 874b29d9..1abe826d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java @@ -13,4 +13,8 @@ public PinChatMessage(Object chatId, int messageId) { add("chat_id", chatId).add("message_id", messageId); } + public PinChatMessage disableNotification(boolean disableNotification) { + return add("disable_notification", disableNotification); + } + } diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java index 68482d2c..f5a6555f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java @@ -40,7 +40,7 @@ public static Update parseUpdate(Reader reader) { return GSON.fromJson(reader, Update.class); } - static byte[] getBytesFromInputStream(InputStream is) throws IOException { + public static byte[] getBytesFromInputStream(InputStream is) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] buffer = new byte[0xFFFF]; for (int len = is.read(buffer); len != -1; len = is.read(buffer)) { From dde7226a07406bbbe0668032a23d225c249f97a9 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 15 Jan 2024 19:27:29 +0100 Subject: [PATCH 22/28] return the original message if it's instance is "Message" --- .../java/com/pengrad/telegrambot/model/CallbackQuery.java | 4 ++++ .../main/java/com/pengrad/telegrambot/model/Message.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java b/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java index 90cd7a13..71a3178e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java @@ -36,6 +36,10 @@ private MaybeInaccessibleMessage maybeInaccessibleMessage() { */ @Deprecated public Message message() { + if (message instanceof Message) { + return (Message)message; + } + Message result = new Message(); result.setChat(message.chat()); result.setMessageId(message.messageId()); 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 23ca9a94..ff27d455 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -1,5 +1,7 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.chat.ChatShared; import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; import com.pengrad.telegrambot.model.message.origin.*; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; @@ -348,6 +350,10 @@ public MaybeInaccessibleMessage maybeInaccessiblePinnedMessage() { */ @Deprecated public Message pinnedMessage() { + if (pinned_message instanceof Message) { + return (Message)pinned_message; + } + Message result = new Message(); result.setChat(pinned_message.chat()); result.setMessageId(pinned_message.messageId()); From 8275d2ad93025b80ec0d42053caaef422c236e14 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 15 Jan 2024 19:29:09 +0100 Subject: [PATCH 23/28] Moved Chat classes to com.pengrad.telegrambot.model.chat --- .../com/pengrad/telegrambot/model/ExternalReplyInfo.java | 1 + .../telegrambot/model/MessageReactionCountUpdated.java | 1 + .../pengrad/telegrambot/model/MessageReactionUpdated.java | 1 + .../java/com/pengrad/telegrambot/model/PollAnswer.java | 2 ++ .../main/java/com/pengrad/telegrambot/model/Update.java | 6 ++++-- .../com/pengrad/telegrambot/model/{ => chat}/Chat.java | 3 ++- .../model/{ => chat}/ChatAdministratorRights.java | 2 +- .../telegrambot/model/{ => chat}/ChatInviteLink.java | 4 +++- .../telegrambot/model/{ => chat}/ChatJoinRequest.java | 4 +++- .../telegrambot/model/{ => chat}/ChatLocation.java | 4 +++- .../pengrad/telegrambot/model/{ => chat}/ChatMember.java | 4 +++- .../telegrambot/model/{ => chat}/ChatMemberUpdated.java | 4 +++- .../telegrambot/model/{ => chat}/ChatPermissions.java | 2 +- .../pengrad/telegrambot/model/{ => chat}/ChatPhoto.java | 2 +- .../pengrad/telegrambot/model/{ => chat}/ChatShared.java | 2 +- .../model/{chatboost => chat/boost}/ChatBoost.java | 4 ++-- .../model/{chatboost => chat/boost}/ChatBoostRemoved.java | 6 +++--- .../model/{chatboost => chat/boost}/ChatBoostUpdated.java | 4 ++-- .../{chatboost => chat/boost}/source/ChatBoostSource.java | 2 +- .../boost}/source/ChatBoostSourceGiftCode.java | 2 +- .../boost}/source/ChatBoostSourceGiveaway.java | 2 +- .../boost}/source/ChatBoostSourcePremium.java | 2 +- .../com/pengrad/telegrambot/model/giveaway/Giveaway.java | 3 +-- .../telegrambot/model/giveaway/GiveawayWinners.java | 2 +- .../model/message/MaybeInaccessibleMessage.java | 2 +- .../model/message/origin/MessageOriginChannel.java | 2 +- .../model/message/origin/MessageOriginChat.java | 2 +- .../model/request/KeyboardButtonRequestChat.java | 2 +- .../pengrad/telegrambot/request/RestrictChatMember.java | 2 +- .../pengrad/telegrambot/request/SetChatPermissions.java | 2 +- .../request/SetMyDefaultAdministratorRights.java | 2 +- .../telegrambot/response/ChatInviteLinkResponse.java | 2 +- .../response/GetChatAdministratorsResponse.java | 2 +- .../telegrambot/response/GetChatMemberResponse.java | 2 +- .../com/pengrad/telegrambot/response/GetChatResponse.java | 2 +- .../response/GetMyDefaultAdministratorRightsResponse.java | 2 +- .../pengrad/telegrambot/response/MessageIdResponse.java | 1 - .../telegrambot/response/UserChatBoostsResponse.java | 2 +- .../java/com/pengrad/telegrambot/utility/BotUtils.java | 2 +- .../utility/gson/ChatBoostSourceTypeAdapter.java | 8 ++++---- .../src/test/java/com/pengrad/telegrambot/ModelTest.java | 1 + .../test/java/com/pengrad/telegrambot/PaymentsTest.java | 1 + .../java/com/pengrad/telegrambot/TelegramBotTest.java | 2 ++ .../com/pengrad/telegrambot/checks/ChatMemberTest.java | 2 +- .../com/pengrad/telegrambot/checks/ChatPhotoTest.java | 2 +- .../java/com/pengrad/telegrambot/checks/ChatTest.java | 2 +- 46 files changed, 68 insertions(+), 48 deletions(-) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/Chat.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatAdministratorRights.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatInviteLink.java (96%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatJoinRequest.java (95%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatLocation.java (91%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatMember.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatMemberUpdated.java (96%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatPermissions.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatPhoto.java (97%) rename library/src/main/java/com/pengrad/telegrambot/model/{ => chat}/ChatShared.java (95%) rename library/src/main/java/com/pengrad/telegrambot/model/{chatboost => chat/boost}/ChatBoost.java (91%) rename library/src/main/java/com/pengrad/telegrambot/model/{chatboost => chat/boost}/ChatBoostRemoved.java (88%) rename library/src/main/java/com/pengrad/telegrambot/model/{chatboost => chat/boost}/ChatBoostUpdated.java (89%) rename library/src/main/java/com/pengrad/telegrambot/model/{chatboost => chat/boost}/source/ChatBoostSource.java (93%) rename library/src/main/java/com/pengrad/telegrambot/model/{chatboost => chat/boost}/source/ChatBoostSourceGiftCode.java (90%) rename library/src/main/java/com/pengrad/telegrambot/model/{chatboost => chat/boost}/source/ChatBoostSourceGiveaway.java (94%) rename library/src/main/java/com/pengrad/telegrambot/model/{chatboost => chat/boost}/source/ChatBoostSourcePremium.java (90%) 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 b79912b9..45bf00eb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.chat.Chat; import com.pengrad.telegrambot.model.giveaway.Giveaway; import com.pengrad.telegrambot.model.giveaway.GiveawayWinners; import com.pengrad.telegrambot.model.message.origin.MessageOrigin; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java index 55a38694..62039aed 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.chat.Chat; import com.pengrad.telegrambot.model.reaction.ReactionCount; import java.util.Arrays; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java index 73e60f52..f095c0a4 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.chat.Chat; import com.pengrad.telegrambot.model.reaction.ReactionType; import java.util.Arrays; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java b/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java index a43058cf..e06a952f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java @@ -1,5 +1,7 @@ package com.pengrad.telegrambot.model; +import com.pengrad.telegrambot.model.chat.Chat; + import java.io.Serializable; import java.util.Arrays; import java.util.Objects; 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 049ce28f..eb8f8b1e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Update.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Update.java @@ -1,7 +1,9 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.chatboost.ChatBoostRemoved; -import com.pengrad.telegrambot.model.chatboost.ChatBoostUpdated; +import com.pengrad.telegrambot.model.chat.ChatJoinRequest; +import com.pengrad.telegrambot.model.chat.ChatMemberUpdated; +import com.pengrad.telegrambot.model.chat.boost.ChatBoostRemoved; +import com.pengrad.telegrambot.model.chat.boost.ChatBoostUpdated; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Chat.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/Chat.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/Chat.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/Chat.java index 2508b267..1e85157c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Chat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/Chat.java @@ -1,6 +1,7 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; import com.google.gson.annotations.SerializedName; +import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.reaction.ReactionType; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatAdministratorRights.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatAdministratorRights.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatAdministratorRights.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatAdministratorRights.java index 25fe017b..b7762135 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatAdministratorRights.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatAdministratorRights.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatInviteLink.java similarity index 96% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatInviteLink.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatInviteLink.java index f5c58458..3b2c8c7b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatInviteLink.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatInviteLink.java @@ -1,4 +1,6 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; + +import com.pengrad.telegrambot.model.User; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatJoinRequest.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatJoinRequest.java similarity index 95% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatJoinRequest.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatJoinRequest.java index b067670f..95dc8df8 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatJoinRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatJoinRequest.java @@ -1,4 +1,6 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; + +import com.pengrad.telegrambot.model.User; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatLocation.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatLocation.java similarity index 91% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatLocation.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatLocation.java index a001b596..734c27d7 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatLocation.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatLocation.java @@ -1,4 +1,6 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; + +import com.pengrad.telegrambot.model.Location; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMember.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMember.java index 64d22f49..01619913 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMember.java @@ -1,4 +1,6 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; + +import com.pengrad.telegrambot.model.User; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatMemberUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMemberUpdated.java similarity index 96% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatMemberUpdated.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMemberUpdated.java index 44d25e2a..4e5e8153 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatMemberUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMemberUpdated.java @@ -1,4 +1,6 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; + +import com.pengrad.telegrambot.model.User; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPermissions.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPermissions.java index ee560576..59b38f47 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPermissions.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPhoto.java similarity index 97% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPhoto.java index f97da1f0..dfc8e3eb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPhoto.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; import java.io.Serializable; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatShared.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatShared.java similarity index 95% rename from library/src/main/java/com/pengrad/telegrambot/model/ChatShared.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/ChatShared.java index 596c22fb..ebff6b02 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatShared.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatShared.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.chat; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoost.java similarity index 91% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoost.java index 97bb9c83..d1bdfaff 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoost.java @@ -1,6 +1,6 @@ -package com.pengrad.telegrambot.model.chatboost; +package com.pengrad.telegrambot.model.chat.boost; -import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostRemoved.java similarity index 88% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostRemoved.java index 02f5bd0e..ca7cd701 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostRemoved.java @@ -1,7 +1,7 @@ -package com.pengrad.telegrambot.model.chatboost; +package com.pengrad.telegrambot.model.chat.boost; -import com.pengrad.telegrambot.model.Chat; -import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostUpdated.java similarity index 89% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostUpdated.java index 4779ba1e..65c049a2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostUpdated.java @@ -1,6 +1,6 @@ -package com.pengrad.telegrambot.model.chatboost; +package com.pengrad.telegrambot.model.chat.boost; -import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chat.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSource.java similarity index 93% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSource.java index cf733082..63fd252e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSource.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost.source; +package com.pengrad.telegrambot.model.chat.boost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiftCode.java similarity index 90% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiftCode.java index dbf2ea2a..ced469f7 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiftCode.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost.source; +package com.pengrad.telegrambot.model.chat.boost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiveaway.java similarity index 94% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiveaway.java index 4679d7c3..89250382 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiveaway.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost.source; +package com.pengrad.telegrambot.model.chat.boost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourcePremium.java similarity index 90% rename from library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java rename to library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourcePremium.java index dacba5ca..3c12250a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourcePremium.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chatboost.source; +package com.pengrad.telegrambot.model.chat.boost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java index 7809bfee..56f51a9c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java @@ -1,7 +1,6 @@ package com.pengrad.telegrambot.model.giveaway; -import com.pengrad.telegrambot.model.Chat; -import com.pengrad.telegrambot.model.LinkPreviewOptions; +import com.pengrad.telegrambot.model.chat.Chat; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java index f81b49bc..e3033948 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.giveaway; -import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chat.Chat; import com.pengrad.telegrambot.model.User; import java.io.Serializable; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java b/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java index 4dc9511c..e02df7d8 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.message; -import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chat.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java index 8a08b6b6..12086401 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.message.origin; -import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chat.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java index 63acfe6d..9b93677f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.message.origin; -import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chat.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java index edc4581f..77ce2596 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import com.pengrad.telegrambot.model.ChatAdministratorRights; +import com.pengrad.telegrambot.model.chat.ChatAdministratorRights; public class KeyboardButtonRequestChat implements Serializable { private final static long serialVersionUID = 0L; diff --git a/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java b/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java index 1f44747f..773b8500 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.ChatPermissions; +import com.pengrad.telegrambot.model.chat.ChatPermissions; import com.pengrad.telegrambot.response.BaseResponse; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java index 88f9275d..885c43e4 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.ChatPermissions; +import com.pengrad.telegrambot.model.chat.ChatPermissions; import com.pengrad.telegrambot.response.BaseResponse; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java index 74d00283..55adf7fb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.ChatAdministratorRights; +import com.pengrad.telegrambot.model.chat.ChatAdministratorRights; import com.pengrad.telegrambot.response.BaseResponse; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java index 62d75895..c9a3e29f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.ChatInviteLink; +import com.pengrad.telegrambot.model.chat.ChatInviteLink; /** * Stas Parshin diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java index e5263d30..12b59571 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.ChatMember; +import com.pengrad.telegrambot.model.chat.ChatMember; import java.util.List; diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java index 5900cc62..849ac1bd 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.ChatMember; +import com.pengrad.telegrambot.model.chat.ChatMember; /** * Stas Parshin diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java index 00ba04c8..6010ef37 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chat.Chat; /** * Stas Parshin diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java index d3ec997d..de1cce7a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.ChatAdministratorRights; +import com.pengrad.telegrambot.model.chat.ChatAdministratorRights; /** * Mirco Ianese diff --git a/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java index a462925a..a6d4808e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java @@ -1,6 +1,5 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.MessageId; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java index 999fbc84..9de24bef 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.chatboost.ChatBoost; +import com.pengrad.telegrambot.model.chat.boost.ChatBoost; import java.util.Arrays; diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java index f5a6555f..44f588b2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java @@ -3,7 +3,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.pengrad.telegrambot.model.Update; -import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; import com.pengrad.telegrambot.model.message.origin.MessageOrigin; import com.pengrad.telegrambot.model.reaction.ReactionType; diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java index 610dc97c..020b9f12 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java @@ -1,10 +1,10 @@ package com.pengrad.telegrambot.utility.gson; import com.google.gson.*; -import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; -import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiftCode; -import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiveaway; -import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourcePremium; +import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSourceGiftCode; +import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSourceGiveaway; +import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSourcePremium; import java.lang.reflect.Type; diff --git a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java index a8463d4e..cc22f6ad 100644 --- a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java @@ -1,6 +1,7 @@ package com.pengrad.telegrambot; import com.pengrad.telegrambot.model.*; +import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.request.InlineKeyboardButton; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.passport.Credentials; diff --git a/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java b/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java index e097e13d..f504f81d 100644 --- a/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java @@ -2,6 +2,7 @@ import com.pengrad.telegrambot.checks.*; import com.pengrad.telegrambot.model.*; +import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.request.*; import com.pengrad.telegrambot.request.*; import com.pengrad.telegrambot.response.*; diff --git a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java index 085a5503..636bf8b5 100644 --- a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java @@ -4,6 +4,8 @@ import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.*; import com.pengrad.telegrambot.model.botcommandscope.BotCommandScopeAllChatAdministrators; +import com.pengrad.telegrambot.model.chat.*; +import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.request.*; import com.pengrad.telegrambot.passport.*; import com.pengrad.telegrambot.request.*; diff --git a/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java b/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java index 3c3f3a10..24526614 100644 --- a/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.checks; -import com.pengrad.telegrambot.model.ChatMember; +import com.pengrad.telegrambot.model.chat.ChatMember; import static org.junit.Assert.assertNotNull; diff --git a/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java b/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java index e9239327..23c335ce 100644 --- a/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.checks; -import com.pengrad.telegrambot.model.ChatPhoto; +import com.pengrad.telegrambot.model.chat.ChatPhoto; import static org.junit.Assert.assertNotNull; diff --git a/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java b/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java index 9d0d09f5..8875f70e 100644 --- a/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.checks; -import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chat.Chat; import static org.junit.Assert.assertNotNull; From 7f83a88c497ba8d6a2460f164b70fa2721179b66 Mon Sep 17 00:00:00 2001 From: Stas Parshin <2172170+pengrad@users.noreply.github.com> Date: Sun, 21 Jan 2024 12:25:56 +0700 Subject: [PATCH 24/28] Revert "Bump version: 7.0.1" This reverts commit af42933e4d9e82672a84f32fcca1071b91139a06. --- README.md | 4 ++-- README_RU.md | 4 ++-- gradle.properties | 2 +- pom.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1f2ab8fd..d06798f9 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:7.0.1' +implementation 'com.github.pengrad:java-telegram-bot-api:7.0.0' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.0.1 + 7.0.0 ``` [JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases) diff --git a/README_RU.md b/README_RU.md index ac2e28a1..177e71f9 100644 --- a/README_RU.md +++ b/README_RU.md @@ -13,14 +13,14 @@ Java библиотека, созданная для работы с [Telegram B Gradle: ```groovy -implementation 'com.github.pengrad:java-telegram-bot-api:7.0.1' +implementation 'com.github.pengrad:java-telegram-bot-api:7.0.0' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.0.1 + 7.0.0 ``` Также JAR со всеми зависимостями можно найти [в релизах](https://github.com/pengrad/java-telegram-bot-api/releases). diff --git a/gradle.properties b/gradle.properties index 44fdff4d..49e2f173 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.github.pengrad -VERSION_NAME=7.0.1 +VERSION_NAME=7.0.0 POM_DESCRIPTION=Java API for Telegram Bot API POM_URL=https://github.com/pengrad/java-telegram-bot-api/ diff --git a/pom.xml b/pom.xml index 88f37b8a..3ec96243 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.pengrad java-telegram-bot-api - 7.0.1 + 7.0.0 JavaTelegramBotApi Java API for Telegram Bot API https://github.com/pengrad/java-telegram-bot-api/ From 9f86e1045e689c20becafc768fcb954797c9c975 Mon Sep 17 00:00:00 2001 From: Stas Parshin <2172170+pengrad@users.noreply.github.com> Date: Sun, 21 Jan 2024 12:28:37 +0700 Subject: [PATCH 25/28] Revert "Bump version: 7.0.0" This reverts commit 42a3fe1dcc41a98a65671981f260bb7f2afa591f. --- README.md | 4 ++-- README_RU.md | 4 ++-- gradle.properties | 2 +- pom.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d06798f9..a8e64bd4 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:7.0.0' +implementation 'com.github.pengrad:java-telegram-bot-api:6.9.1' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.0.0 + 6.9.1 ``` [JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases) diff --git a/README_RU.md b/README_RU.md index 177e71f9..22a583f5 100644 --- a/README_RU.md +++ b/README_RU.md @@ -13,14 +13,14 @@ Java библиотека, созданная для работы с [Telegram B Gradle: ```groovy -implementation 'com.github.pengrad:java-telegram-bot-api:7.0.0' +implementation 'com.github.pengrad:java-telegram-bot-api:6.9.1' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.0.0 + 6.9.1 ``` Также JAR со всеми зависимостями можно найти [в релизах](https://github.com/pengrad/java-telegram-bot-api/releases). diff --git a/gradle.properties b/gradle.properties index 49e2f173..0931ed4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.github.pengrad -VERSION_NAME=7.0.0 +VERSION_NAME=6.9.1 POM_DESCRIPTION=Java API for Telegram Bot API POM_URL=https://github.com/pengrad/java-telegram-bot-api/ diff --git a/pom.xml b/pom.xml index 3ec96243..3e31d397 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.pengrad java-telegram-bot-api - 7.0.0 + 6.9.1 JavaTelegramBotApi Java API for Telegram Bot API https://github.com/pengrad/java-telegram-bot-api/ From 4b84d164dfbb4b2e178a415d7746d68bda243ccd Mon Sep 17 00:00:00 2001 From: Stas Parshin <2172170+pengrad@users.noreply.github.com> Date: Mon, 22 Jan 2024 13:53:17 +0700 Subject: [PATCH 26/28] Revert "Moved Chat classes to com.pengrad.telegrambot.model.chat" This reverts commit 8275d2ad93025b80ec0d42053caaef422c236e14. --- .../com/pengrad/telegrambot/model/{chat => }/Chat.java | 3 +-- .../model/{chat => }/ChatAdministratorRights.java | 2 +- .../telegrambot/model/{chat => }/ChatInviteLink.java | 4 +--- .../telegrambot/model/{chat => }/ChatJoinRequest.java | 4 +--- .../telegrambot/model/{chat => }/ChatLocation.java | 4 +--- .../pengrad/telegrambot/model/{chat => }/ChatMember.java | 4 +--- .../telegrambot/model/{chat => }/ChatMemberUpdated.java | 4 +--- .../telegrambot/model/{chat => }/ChatPermissions.java | 2 +- .../pengrad/telegrambot/model/{chat => }/ChatPhoto.java | 2 +- .../pengrad/telegrambot/model/{chat => }/ChatShared.java | 2 +- .../com/pengrad/telegrambot/model/ExternalReplyInfo.java | 1 - .../telegrambot/model/MessageReactionCountUpdated.java | 1 - .../pengrad/telegrambot/model/MessageReactionUpdated.java | 1 - .../java/com/pengrad/telegrambot/model/PollAnswer.java | 2 -- .../main/java/com/pengrad/telegrambot/model/Update.java | 6 ++---- .../model/{chat/boost => chatboost}/ChatBoost.java | 4 ++-- .../model/{chat/boost => chatboost}/ChatBoostRemoved.java | 6 +++--- .../model/{chat/boost => chatboost}/ChatBoostUpdated.java | 4 ++-- .../{chat/boost => chatboost}/source/ChatBoostSource.java | 2 +- .../source/ChatBoostSourceGiftCode.java | 2 +- .../source/ChatBoostSourceGiveaway.java | 2 +- .../source/ChatBoostSourcePremium.java | 2 +- .../com/pengrad/telegrambot/model/giveaway/Giveaway.java | 3 ++- .../telegrambot/model/giveaway/GiveawayWinners.java | 2 +- .../model/message/MaybeInaccessibleMessage.java | 2 +- .../model/message/origin/MessageOriginChannel.java | 2 +- .../model/message/origin/MessageOriginChat.java | 2 +- .../model/request/KeyboardButtonRequestChat.java | 2 +- .../pengrad/telegrambot/request/RestrictChatMember.java | 2 +- .../pengrad/telegrambot/request/SetChatPermissions.java | 2 +- .../request/SetMyDefaultAdministratorRights.java | 2 +- .../telegrambot/response/ChatInviteLinkResponse.java | 2 +- .../response/GetChatAdministratorsResponse.java | 2 +- .../telegrambot/response/GetChatMemberResponse.java | 2 +- .../com/pengrad/telegrambot/response/GetChatResponse.java | 2 +- .../response/GetMyDefaultAdministratorRightsResponse.java | 2 +- .../pengrad/telegrambot/response/MessageIdResponse.java | 1 + .../telegrambot/response/UserChatBoostsResponse.java | 2 +- .../java/com/pengrad/telegrambot/utility/BotUtils.java | 2 +- .../utility/gson/ChatBoostSourceTypeAdapter.java | 8 ++++---- .../src/test/java/com/pengrad/telegrambot/ModelTest.java | 1 - .../test/java/com/pengrad/telegrambot/PaymentsTest.java | 1 - .../java/com/pengrad/telegrambot/TelegramBotTest.java | 2 -- .../com/pengrad/telegrambot/checks/ChatMemberTest.java | 2 +- .../com/pengrad/telegrambot/checks/ChatPhotoTest.java | 2 +- .../java/com/pengrad/telegrambot/checks/ChatTest.java | 2 +- 46 files changed, 48 insertions(+), 68 deletions(-) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/Chat.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatAdministratorRights.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatInviteLink.java (96%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatJoinRequest.java (95%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatLocation.java (91%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatMember.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatMemberUpdated.java (96%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatPermissions.java (99%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatPhoto.java (97%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat => }/ChatShared.java (95%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat/boost => chatboost}/ChatBoost.java (91%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat/boost => chatboost}/ChatBoostRemoved.java (88%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat/boost => chatboost}/ChatBoostUpdated.java (89%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat/boost => chatboost}/source/ChatBoostSource.java (93%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat/boost => chatboost}/source/ChatBoostSourceGiftCode.java (90%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat/boost => chatboost}/source/ChatBoostSourceGiveaway.java (94%) rename library/src/main/java/com/pengrad/telegrambot/model/{chat/boost => chatboost}/source/ChatBoostSourcePremium.java (90%) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/Chat.java b/library/src/main/java/com/pengrad/telegrambot/model/Chat.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/Chat.java rename to library/src/main/java/com/pengrad/telegrambot/model/Chat.java index 1e85157c..2508b267 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/Chat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Chat.java @@ -1,7 +1,6 @@ -package com.pengrad.telegrambot.model.chat; +package com.pengrad.telegrambot.model; import com.google.gson.annotations.SerializedName; -import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.reaction.ReactionType; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatAdministratorRights.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatAdministratorRights.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatAdministratorRights.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatAdministratorRights.java index b7762135..25fe017b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatAdministratorRights.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatAdministratorRights.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatInviteLink.java similarity index 96% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatInviteLink.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatInviteLink.java index 3b2c8c7b..f5c58458 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatInviteLink.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatInviteLink.java @@ -1,6 +1,4 @@ -package com.pengrad.telegrambot.model.chat; - -import com.pengrad.telegrambot.model.User; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatJoinRequest.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatJoinRequest.java similarity index 95% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatJoinRequest.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatJoinRequest.java index 95dc8df8..b067670f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatJoinRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatJoinRequest.java @@ -1,6 +1,4 @@ -package com.pengrad.telegrambot.model.chat; - -import com.pengrad.telegrambot.model.User; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatLocation.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatLocation.java similarity index 91% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatLocation.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatLocation.java index 734c27d7..a001b596 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatLocation.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatLocation.java @@ -1,6 +1,4 @@ -package com.pengrad.telegrambot.model.chat; - -import com.pengrad.telegrambot.model.Location; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMember.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMember.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java index 01619913..64d22f49 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java @@ -1,6 +1,4 @@ -package com.pengrad.telegrambot.model.chat; - -import com.pengrad.telegrambot.model.User; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMemberUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatMemberUpdated.java similarity index 96% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMemberUpdated.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatMemberUpdated.java index 4e5e8153..44d25e2a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatMemberUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatMemberUpdated.java @@ -1,6 +1,4 @@ -package com.pengrad.telegrambot.model.chat; - -import com.pengrad.telegrambot.model.User; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPermissions.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java similarity index 99% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPermissions.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java index 59b38f47..ee560576 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPermissions.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPhoto.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java similarity index 97% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPhoto.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java index dfc8e3eb..f97da1f0 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatPhoto.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat; +package com.pengrad.telegrambot.model; import java.io.Serializable; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatShared.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatShared.java similarity index 95% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/ChatShared.java rename to library/src/main/java/com/pengrad/telegrambot/model/ChatShared.java index ebff6b02..596c22fb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/ChatShared.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatShared.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat; +package com.pengrad.telegrambot.model; import java.io.Serializable; import java.util.Objects; 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 45bf00eb..b79912b9 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java @@ -1,6 +1,5 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.chat.Chat; import com.pengrad.telegrambot.model.giveaway.Giveaway; import com.pengrad.telegrambot.model.giveaway.GiveawayWinners; import com.pengrad.telegrambot.model.message.origin.MessageOrigin; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java index 62039aed..55a38694 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionCountUpdated.java @@ -1,6 +1,5 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.chat.Chat; import com.pengrad.telegrambot.model.reaction.ReactionCount; import java.util.Arrays; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java index f095c0a4..73e60f52 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/MessageReactionUpdated.java @@ -1,6 +1,5 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.chat.Chat; import com.pengrad.telegrambot.model.reaction.ReactionType; import java.util.Arrays; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java b/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java index e06a952f..a43058cf 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java @@ -1,7 +1,5 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.chat.Chat; - import java.io.Serializable; import java.util.Arrays; import java.util.Objects; 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 eb8f8b1e..049ce28f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Update.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Update.java @@ -1,9 +1,7 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.chat.ChatJoinRequest; -import com.pengrad.telegrambot.model.chat.ChatMemberUpdated; -import com.pengrad.telegrambot.model.chat.boost.ChatBoostRemoved; -import com.pengrad.telegrambot.model.chat.boost.ChatBoostUpdated; +import com.pengrad.telegrambot.model.chatboost.ChatBoostRemoved; +import com.pengrad.telegrambot.model.chatboost.ChatBoostUpdated; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoost.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java similarity index 91% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoost.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java index d1bdfaff..97bb9c83 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoost.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoost.java @@ -1,6 +1,6 @@ -package com.pengrad.telegrambot.model.chat.boost; +package com.pengrad.telegrambot.model.chatboost; -import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostRemoved.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java similarity index 88% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostRemoved.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java index ca7cd701..02f5bd0e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostRemoved.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostRemoved.java @@ -1,7 +1,7 @@ -package com.pengrad.telegrambot.model.chat.boost; +package com.pengrad.telegrambot.model.chatboost; -import com.pengrad.telegrambot.model.chat.Chat; -import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostUpdated.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java similarity index 89% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostUpdated.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java index 65c049a2..4779ba1e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/ChatBoostUpdated.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/ChatBoostUpdated.java @@ -1,6 +1,6 @@ -package com.pengrad.telegrambot.model.chat.boost; +package com.pengrad.telegrambot.model.chatboost; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSource.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java similarity index 93% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSource.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java index 63fd252e..cf733082 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSource.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSource.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat.boost.source; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiftCode.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java similarity index 90% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiftCode.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java index ced469f7..dbf2ea2a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiftCode.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiftCode.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat.boost.source; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiveaway.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java similarity index 94% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiveaway.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java index 89250382..4679d7c3 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourceGiveaway.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourceGiveaway.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat.boost.source; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourcePremium.java b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java similarity index 90% rename from library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourcePremium.java rename to library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java index 3c12250a..dacba5ca 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chat/boost/source/ChatBoostSourcePremium.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatboost/source/ChatBoostSourcePremium.java @@ -1,4 +1,4 @@ -package com.pengrad.telegrambot.model.chat.boost.source; +package com.pengrad.telegrambot.model.chatboost.source; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java index 56f51a9c..7809bfee 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/Giveaway.java @@ -1,6 +1,7 @@ package com.pengrad.telegrambot.model.giveaway; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; +import com.pengrad.telegrambot.model.LinkPreviewOptions; import java.io.Serializable; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java index e3033948..f81b49bc 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/giveaway/GiveawayWinners.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.giveaway; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; import com.pengrad.telegrambot.model.User; import java.io.Serializable; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java b/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java index e02df7d8..4dc9511c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/MaybeInaccessibleMessage.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.message; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java index 12086401..8a08b6b6 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChannel.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.message.origin; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java index 9b93677f..63acfe6d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/message/origin/MessageOriginChat.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.model.message.origin; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; import java.util.Objects; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java index 77ce2596..edc4581f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/KeyboardButtonRequestChat.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import com.pengrad.telegrambot.model.chat.ChatAdministratorRights; +import com.pengrad.telegrambot.model.ChatAdministratorRights; public class KeyboardButtonRequestChat implements Serializable { private final static long serialVersionUID = 0L; diff --git a/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java b/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java index 773b8500..1f44747f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.chat.ChatPermissions; +import com.pengrad.telegrambot.model.ChatPermissions; import com.pengrad.telegrambot.response.BaseResponse; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java index 885c43e4..88f9275d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.chat.ChatPermissions; +import com.pengrad.telegrambot.model.ChatPermissions; import com.pengrad.telegrambot.response.BaseResponse; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java index 55adf7fb..74d00283 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.chat.ChatAdministratorRights; +import com.pengrad.telegrambot.model.ChatAdministratorRights; import com.pengrad.telegrambot.response.BaseResponse; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java index c9a3e29f..62d75895 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/ChatInviteLinkResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.chat.ChatInviteLink; +import com.pengrad.telegrambot.model.ChatInviteLink; /** * Stas Parshin diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java index 12b59571..e5263d30 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetChatAdministratorsResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.chat.ChatMember; +import com.pengrad.telegrambot.model.ChatMember; import java.util.List; diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java index 849ac1bd..5900cc62 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetChatMemberResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.chat.ChatMember; +import com.pengrad.telegrambot.model.ChatMember; /** * Stas Parshin diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java index 6010ef37..00ba04c8 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetChatResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; /** * Stas Parshin diff --git a/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java index de1cce7a..d3ec997d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/GetMyDefaultAdministratorRightsResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.chat.ChatAdministratorRights; +import com.pengrad.telegrambot.model.ChatAdministratorRights; /** * Mirco Ianese diff --git a/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java index a6d4808e..a462925a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/MessageIdResponse.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.response; +import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.MessageId; /** diff --git a/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java b/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java index 9de24bef..999fbc84 100644 --- a/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java +++ b/library/src/main/java/com/pengrad/telegrambot/response/UserChatBoostsResponse.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.response; -import com.pengrad.telegrambot.model.chat.boost.ChatBoost; +import com.pengrad.telegrambot.model.chatboost.ChatBoost; import java.util.Arrays; diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java index 44f588b2..f5a6555f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/BotUtils.java @@ -3,7 +3,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.pengrad.telegrambot.model.Update; -import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; import com.pengrad.telegrambot.model.message.origin.MessageOrigin; import com.pengrad.telegrambot.model.reaction.ReactionType; diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java index 020b9f12..610dc97c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java @@ -1,10 +1,10 @@ package com.pengrad.telegrambot.utility.gson; import com.google.gson.*; -import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSource; -import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSourceGiftCode; -import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSourceGiveaway; -import com.pengrad.telegrambot.model.chat.boost.source.ChatBoostSourcePremium; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSource; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiftCode; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourceGiveaway; +import com.pengrad.telegrambot.model.chatboost.source.ChatBoostSourcePremium; import java.lang.reflect.Type; diff --git a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java index cc22f6ad..a8463d4e 100644 --- a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java @@ -1,7 +1,6 @@ package com.pengrad.telegrambot; import com.pengrad.telegrambot.model.*; -import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.request.InlineKeyboardButton; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.passport.Credentials; diff --git a/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java b/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java index f504f81d..e097e13d 100644 --- a/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/PaymentsTest.java @@ -2,7 +2,6 @@ import com.pengrad.telegrambot.checks.*; import com.pengrad.telegrambot.model.*; -import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.request.*; import com.pengrad.telegrambot.request.*; import com.pengrad.telegrambot.response.*; diff --git a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java index 16c7b683..e7c3797c 100644 --- a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java @@ -4,8 +4,6 @@ import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.*; import com.pengrad.telegrambot.model.botcommandscope.BotCommandScopeAllChatAdministrators; -import com.pengrad.telegrambot.model.chat.*; -import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.request.*; import com.pengrad.telegrambot.passport.*; import com.pengrad.telegrambot.request.*; diff --git a/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java b/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java index 24526614..3c3f3a10 100644 --- a/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/checks/ChatMemberTest.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.checks; -import com.pengrad.telegrambot.model.chat.ChatMember; +import com.pengrad.telegrambot.model.ChatMember; import static org.junit.Assert.assertNotNull; diff --git a/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java b/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java index 23c335ce..e9239327 100644 --- a/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/checks/ChatPhotoTest.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.checks; -import com.pengrad.telegrambot.model.chat.ChatPhoto; +import com.pengrad.telegrambot.model.ChatPhoto; import static org.junit.Assert.assertNotNull; diff --git a/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java b/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java index 8875f70e..9d0d09f5 100644 --- a/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/checks/ChatTest.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.checks; -import com.pengrad.telegrambot.model.chat.Chat; +import com.pengrad.telegrambot.model.Chat; import static org.junit.Assert.assertNotNull; From c2df83d975b7f26f4899dcb14863b55fc0aea667 Mon Sep 17 00:00:00 2001 From: Stas Parshin <2172170+pengrad@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:06:37 +0700 Subject: [PATCH 27/28] Don't throw JsonParseException in type adapters --- .../telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java | 2 +- .../telegrambot/utility/gson/MessageOriginTypeAdapter.java | 2 +- .../pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java index 610dc97c..72a8cb4b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ChatBoostSourceTypeAdapter.java @@ -23,6 +23,6 @@ public ChatBoostSource deserialize(JsonElement element, Type type, JsonDeseriali return context.deserialize(object, ChatBoostSourcePremium.class); } - throw new JsonParseException("Unknown ChatBoost type: " + discriminator); + return context.deserialize(object, ChatBoostSource.class); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java index 0c53ca4f..41ea690e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/MessageOriginTypeAdapter.java @@ -22,6 +22,6 @@ public MessageOrigin deserialize(JsonElement element, Type type, JsonDeserializa return context.deserialize(object, MessageOriginUser.class); } - throw new JsonParseException("Unknown MessageOrigin type: " + discriminator); + return context.deserialize(object, MessageOrigin.class); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java index f96f2928..69aff521 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java @@ -20,6 +20,6 @@ public ReactionType deserialize(JsonElement element, Type type, JsonDeserializat return context.deserialize(object, ReactionTypeCustomEmoji.class); } - throw new JsonParseException("Unknown ReactionType type: " + discriminator); + return context.deserialize(object, ReactionType.class); } } From 0d478ddde2981ff1b08911dc0785551b15d79167 Mon Sep 17 00:00:00 2001 From: Stas Parshin <2172170+pengrad@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:07:38 +0700 Subject: [PATCH 28/28] Fix model tests --- .../telegrambot/model/ExternalReplyInfo.java | 96 ++++++++++--------- .../pengrad/telegrambot/model/Message.java | 23 +---- .../pengrad/telegrambot/model/TextQuote.java | 21 ++-- .../telegrambot/model/UsersShared.java | 12 +-- .../model/{ => request}/ReplyParameters.java | 5 +- .../request/AbstractSendRequest.java | 2 +- .../telegrambot/request/CopyMessage.java | 2 +- .../telegrambot/request/CopyMessages.java | 5 - .../telegrambot/request/SendMediaGroup.java | 2 +- .../com/pengrad/telegrambot/ModelTest.java | 7 +- .../telegrambot/checks/MessageTest.java | 1 - 11 files changed, 80 insertions(+), 96 deletions(-) rename library/src/main/java/com/pengrad/telegrambot/model/{ => request}/ReplyParameters.java (88%) 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 b79912b9..5ee55e7d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/ExternalReplyInfo.java @@ -5,6 +5,7 @@ import com.pengrad.telegrambot.model.message.origin.MessageOrigin; import java.io.Serializable; +import java.util.Arrays; import java.util.Objects; @@ -38,133 +39,136 @@ public class ExternalReplyInfo implements Serializable { public MessageOrigin origin() { return origin; } + public Chat chat() { return chat; } + public Integer messageId() { return message_id; } + public LinkPreviewOptions linkPreviewOptions() { return link_preview_options; } + public Animation animation() { return animation; } + public Audio audio() { return audio; } + public Document document() { return document; } + public PhotoSize[] photo() { return photo; } + public Sticker sticker() { return sticker; } + public Story story() { return story; } + public Video video() { return video; } + public VideoNote videoNote() { return video_note; } + public Voice voice() { return voice; } + public Boolean hasMediaSpoiler() { return has_media_spoiler; } + public Contact contact() { return contact; } + public Dice dice() { return dice; } + public Game game() { return game; } + public Giveaway giveaway() { return giveaway; } + public GiveawayWinners giveawayWinners() { return giveaway_winners; } + public Invoice invoice() { return invoice; } + public Location location() { return location; } + public Poll poll() { return poll; } + public Venue venue() { return venue; } - @Override 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(document, that.document) - && Objects.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(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(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(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() { - return Objects.hash(origin, chat, message_id, link_preview_options, animation, audio,document,photo,sticker,story,video,video_note,voice,has_media_spoiler,contact,dice,game,giveaway,giveaway_winners,invoice,location,poll,venue); + int result = Objects.hash(origin, chat, message_id, link_preview_options, animation, audio, document, sticker, story, video, video_note, voice, has_media_spoiler, contact, dice, game, giveaway, giveaway_winners, invoice, location, poll, venue); + result = 31 * result + Arrays.hashCode(photo); + return result; } @Override public String toString() { return "ExternalReplyInfo{" + - "origin='" + origin + "'," + - "chat='" + chat + "'," + - "message_id='" + message_id + "'," + - "link_preview_options='" + link_preview_options + "'," + - "animation='" + animation + "'," + - "document='" + document + "'," + - "photo='" + photo + "'," + - "story='" + story + "'," + - "video='" + video + "'," + - "video_note='" + video_note + "'," + - "voice='" + voice + "'," + - "has_media_spoiler='" + has_media_spoiler + "'," + - "contact='" + contact + "'," + - "dice='" + dice + "'," + - "game='" + game + "'," + - "giveaway='" + giveaway + "'," + - "giveaway_winners='" + giveaway_winners + "'," + - "invoice='" + invoice + "'," + - "location='" + location + "'," + - "poll='" + poll + "'," + - "venue='" + venue + "'" + + "origin=" + origin + + ", chat=" + chat + + ", message_id=" + message_id + + ", link_preview_options=" + link_preview_options + + ", animation=" + animation + + ", audio=" + audio + + ", document=" + document + + ", photo=" + Arrays.toString(photo) + + ", sticker=" + sticker + + ", story=" + story + + ", video=" + video + + ", video_note=" + video_note + + ", voice=" + voice + + ", has_media_spoiler=" + has_media_spoiler + + ", contact=" + contact + + ", dice=" + dice + + ", game=" + game + + ", giveaway=" + giveaway + + ", giveaway_winners=" + giveaway_winners + + ", invoice=" + invoice + + ", location=" + location + + ", poll=" + poll + + ", venue=" + venue + '}'; } } 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 ff27d455..8f3f7f2e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.java @@ -1,7 +1,5 @@ package com.pengrad.telegrambot.model; -import com.pengrad.telegrambot.model.chat.Chat; -import com.pengrad.telegrambot.model.chat.ChatShared; import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; import com.pengrad.telegrambot.model.message.origin.*; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; @@ -341,27 +339,10 @@ public Long migrateFromChatId() { return migrate_from_chat_id; } - public MaybeInaccessibleMessage maybeInaccessiblePinnedMessage() { + public MaybeInaccessibleMessage pinnedMessage() { return pinned_message; } - /** - * @deprecated Use Message#maybeInaccessiblePinnedMessage instead - */ - @Deprecated - public Message pinnedMessage() { - if (pinned_message instanceof Message) { - return (Message)pinned_message; - } - - Message result = new Message(); - result.setChat(pinned_message.chat()); - result.setMessageId(pinned_message.messageId()); - result.setDate(pinned_message.date()); - - return result; - } - public Invoice invoice() { return invoice; } @@ -532,6 +513,7 @@ public boolean equals(Object o) { Objects.equals(invoice, message.invoice) && Objects.equals(successful_payment, message.successful_payment) && Objects.equals(story, message.story) && + Objects.equals(user_shared, message.user_shared) && Objects.equals(users_shared, message.users_shared) && Objects.equals(chat_shared, message.chat_shared) && Objects.equals(connected_website, message.connected_website) && @@ -612,6 +594,7 @@ public String toString() { ", invoice=" + invoice + ", successful_payment=" + successful_payment + ", story=" + story + + ", user_shared=" + user_shared + ", users_shared=" + users_shared + ", chat_shared=" + chat_shared + ", connected_website='" + connected_website + '\'' + diff --git a/library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java b/library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java index 6d2ed0f3..15c410ec 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/TextQuote.java @@ -1,6 +1,7 @@ package com.pengrad.telegrambot.model; import java.io.Serializable; +import java.util.Arrays; import java.util.Objects; public class TextQuote implements Serializable { @@ -33,26 +34,24 @@ public Boolean isManual() { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - TextQuote that = (TextQuote) o; - return Objects.equals(text, that.text) && - Objects.equals(entities, that.entities) && - Objects.equals(position, that.position) && - Objects.equals(is_manual, that.is_manual); + TextQuote textQuote = (TextQuote) o; + return Objects.equals(text, textQuote.text) && Arrays.equals(entities, textQuote.entities) && Objects.equals(position, textQuote.position) && Objects.equals(is_manual, textQuote.is_manual); } @Override public int hashCode() { - return Objects.hash(text, entities, position, is_manual); + int result = Objects.hash(text, position, is_manual); + result = 31 * result + Arrays.hashCode(entities); + return result; } @Override public String toString() { return "TextQuote{" + - "text='" + text + "'," + - "entities='" + entities + "'," + - "position='" + position + "'," + - "is_manual='" + is_manual + "'" + + "text='" + text + '\'' + + ", entities=" + Arrays.toString(entities) + + ", position=" + position + + ", is_manual=" + is_manual + '}'; } - } diff --git a/library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java b/library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java index 6d6c8fc4..3e1d7853 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/UsersShared.java @@ -13,24 +13,24 @@ public class UsersShared implements Serializable { public Integer requestId() { return request_id; } + public Integer[] userIds() { return user_ids; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - UsersShared that = (UsersShared) o; - - return Objects.equals(request_id, that.request_id) && - Arrays.equals(user_ids, that.user_ids); + return Objects.equals(request_id, that.request_id) && Arrays.equals(user_ids, that.user_ids); } @Override public int hashCode() { - return Objects.hash(request_id, - user_ids); + int result = Objects.hash(request_id); + result = 31 * result + Arrays.hashCode(user_ids); + return result; } @Override diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ReplyParameters.java b/library/src/main/java/com/pengrad/telegrambot/model/request/ReplyParameters.java similarity index 88% rename from library/src/main/java/com/pengrad/telegrambot/model/ReplyParameters.java rename to library/src/main/java/com/pengrad/telegrambot/model/request/ReplyParameters.java index 4b2d67df..aa36fad0 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/ReplyParameters.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/ReplyParameters.java @@ -1,7 +1,6 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.model.request; -import com.pengrad.telegrambot.model.request.InlineQueryResultCachedVideo; -import com.pengrad.telegrambot.model.request.ParseMode; +import com.pengrad.telegrambot.model.MessageEntity; import java.io.Serializable; diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java b/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java index 735e7260..af7afd43 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AbstractSendRequest.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.ReplyParameters; +import com.pengrad.telegrambot.model.request.ReplyParameters; import com.pengrad.telegrambot.model.request.Keyboard; import com.pengrad.telegrambot.response.SendResponse; diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java index 740e2ea2..a4e74616 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java @@ -1,7 +1,7 @@ package com.pengrad.telegrambot.request; import com.pengrad.telegrambot.model.MessageEntity; -import com.pengrad.telegrambot.model.ReplyParameters; +import com.pengrad.telegrambot.model.request.ReplyParameters; import com.pengrad.telegrambot.model.request.Keyboard; import com.pengrad.telegrambot.model.request.ParseMode; import com.pengrad.telegrambot.response.MessageIdResponse; diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java index 51644922..7bdd2471 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessages.java @@ -1,10 +1,5 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.MessageEntity; -import com.pengrad.telegrambot.model.ReplyParameters; -import com.pengrad.telegrambot.model.request.Keyboard; -import com.pengrad.telegrambot.model.request.ParseMode; -import com.pengrad.telegrambot.response.MessageIdResponse; import com.pengrad.telegrambot.response.MessageIdsResponse; diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java index 96be38a6..e8a64c62 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java @@ -1,6 +1,6 @@ package com.pengrad.telegrambot.request; -import com.pengrad.telegrambot.model.ReplyParameters; +import com.pengrad.telegrambot.model.request.ReplyParameters; import com.pengrad.telegrambot.model.request.InputMedia; import com.pengrad.telegrambot.response.MessagesResponse; diff --git a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java index a8463d4e..f247e540 100644 --- a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java @@ -1,6 +1,8 @@ package com.pengrad.telegrambot; import com.pengrad.telegrambot.model.*; +import com.pengrad.telegrambot.model.Message; +import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage; import com.pengrad.telegrambot.model.request.InlineKeyboardButton; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.passport.Credentials; @@ -61,7 +63,7 @@ public void testEquals() throws ReflectiveOperationException { f.set(callbackQuery, "2"); Message message = Message.class.getDeclaredConstructor().newInstance(); - f = Message.class.getDeclaredField("message_id"); + f = MaybeInaccessibleMessage.class.getDeclaredField("message_id"); f.setAccessible(true); f.set(message, 11); @@ -87,6 +89,9 @@ public void testEquals() throws ReflectiveOperationException { verifierApi.withIgnoredFields("general_forum_topic_unhidden"); verifierApi.withIgnoredFields("story"); } + if (c == ExternalReplyInfo.class) { + verifierApi.withIgnoredFields("story"); + } verifierApi.verify(); } diff --git a/library/src/test/java/com/pengrad/telegrambot/checks/MessageTest.java b/library/src/test/java/com/pengrad/telegrambot/checks/MessageTest.java index bbf295f0..9d5390d0 100644 --- a/library/src/test/java/com/pengrad/telegrambot/checks/MessageTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/checks/MessageTest.java @@ -37,7 +37,6 @@ public static void checkTextMessage(Message message) { assertNull(message.isAutomaticForward()); assertNull(message.hasMediaSpoiler()); assertNull(message.messageAutoDeleteTimerChanged()); - assertNull(message.userShared()); assertNull(message.chatShared()); assertNull(message.proximityAlertTriggered()); assertNull(message.forumTopicCreated());