Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

BOT API v7.10 #402

Merged
merged 4 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import com.pengrad.telegrambot.model.business.BusinessConnection;
import com.pengrad.telegrambot.model.chatbackground.ChatBackground;
import com.pengrad.telegrambot.model.chatboost.ChatBoostAdded;
import com.pengrad.telegrambot.model.giveaway.Giveaway;
import com.pengrad.telegrambot.model.giveaway.GiveawayCompleted;
import com.pengrad.telegrambot.model.giveaway.GiveawayCreated;
import com.pengrad.telegrambot.model.giveaway.GiveawayWinners;
import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage;
import com.pengrad.telegrambot.model.message.origin.*;
import com.pengrad.telegrambot.model.paidmedia.PaidMedia;
Expand Down Expand Up @@ -93,8 +97,11 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private ForumTopicReopened forum_topic_reopened;
private GeneralForumTopicHidden general_forum_topic_hidden;
private GeneralForumTopicUnhidden general_forum_topic_unhidden;
private GiveawayCreated giveaway_created;
private Giveaway giveaway;
private GiveawayWinners giveaway_winners;
private GiveawayCompleted giveaway_completed;
private WriteAccessAllowed write_access_allowed;

private VideoChatStarted video_chat_started;
private VideoChatEnded video_chat_ended;
private VideoChatParticipantsInvited video_chat_participants_invited;
Expand Down Expand Up @@ -468,6 +475,22 @@ public GeneralForumTopicUnhidden generalForumTopicUnhidden() {
return general_forum_topic_unhidden;
}

public GiveawayCreated giveawayCreated() {
return giveaway_created;
}

public Giveaway giveaway() {
return giveaway;
}

public GiveawayWinners giveawayWinners() {
return giveaway_winners;
}

public GiveawayCompleted giveawayCompleted() {
return giveaway_completed;
}

public WriteAccessAllowed writeAccessAllowed() {
return write_access_allowed;
}
Expand Down Expand Up @@ -597,6 +620,10 @@ public boolean equals(Object o) {
Objects.equals(forum_topic_reopened, message.forum_topic_reopened) &&
Objects.equals(general_forum_topic_hidden, message.general_forum_topic_hidden) &&
Objects.equals(general_forum_topic_unhidden, message.general_forum_topic_unhidden) &&
Objects.equals(giveaway_created, message.giveaway_created) &&
Objects.equals(giveaway, message.giveaway) &&
Objects.equals(giveaway_winners, message.giveaway_winners) &&
Objects.equals(giveaway_completed, message.giveaway_completed) &&
Objects.equals(write_access_allowed, message.write_access_allowed) &&
Objects.equals(video_chat_started, message.video_chat_started) &&
Objects.equals(video_chat_ended, message.video_chat_ended) &&
Expand Down Expand Up @@ -689,6 +716,10 @@ public String toString() {
", forum_topic_reopened=" + forum_topic_reopened +
", general_forum_topic_hidden=" + general_forum_topic_hidden +
", general_forum_topic_unhidden=" + general_forum_topic_unhidden +
", giveaway_created=" + giveaway_created +
", giveaway=" + giveaway +
", giveaway_winners=" + giveaway_winners +
", giveaway_completed=" + giveaway_completed +
", write_access_allowed=" + write_access_allowed +
", video_chat_started=" + video_chat_started +
", video_chat_ended=" + video_chat_ended +
Expand Down
10 changes: 9 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.pengrad.telegrambot.model.business.BusinessMessageDeleted;
import com.pengrad.telegrambot.model.chatboost.ChatBoostRemoved;
import com.pengrad.telegrambot.model.chatboost.ChatBoostUpdated;
import com.pengrad.telegrambot.model.paidmedia.PaidMediaPurchased;

import java.io.Serializable;
import java.util.Objects;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class Update implements Serializable {
private MessageReactionCountUpdated message_reaction_count;
private ChatBoostUpdated chat_boost;
private ChatBoostRemoved removed_chat_boost;
private PaidMediaPurchased paid_media_purchased;

public Integer updateId() {
return update_id;
Expand Down Expand Up @@ -131,6 +133,10 @@ public ChatBoostRemoved removedChatBoost() {
return removed_chat_boost;
}

public PaidMediaPurchased paidMediaPurchased() {
return paid_media_purchased;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -158,7 +164,8 @@ public boolean equals(Object o) {
Objects.equals(message_reaction, update.message_reaction) &&
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);
Objects.equals(removed_chat_boost, update.removed_chat_boost) &&
Objects.equals(paid_media_purchased, update.paid_media_purchased);
}

@Override
Expand Down Expand Up @@ -192,6 +199,7 @@ public String toString() {
", message_reaction_count=" + message_reaction_count +
", chat_boost=" + chat_boost +
", removed_chat_boost=" + removed_chat_boost +
", paid_media_purchased=" + paid_media_purchased +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ChatBoostSourceGiveaway extends ChatBoostSource implements Serializ

private Integer giveaway_message_id;
private Boolean is_unclaimed;
private Integer prize_star_count;

public Integer giveawayMessageId() {
return giveaway_message_id;
Expand All @@ -20,18 +21,28 @@ public Boolean isUnclaimed() {
return is_unclaimed != null && is_unclaimed;
}

public Integer prizeStarCount() {
return prize_star_count;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
ChatBoostSourceGiveaway that = (ChatBoostSourceGiveaway) o;
return Objects.equals(giveaway_message_id, that.giveaway_message_id) && Objects.equals(is_unclaimed, that.is_unclaimed);
return Objects.equals(giveaway_message_id, that.giveaway_message_id)
&& Objects.equals(is_unclaimed, that.is_unclaimed)
&& Objects.equals(prize_star_count, that.prize_star_count);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), giveaway_message_id, is_unclaimed);
return Objects.hash(
super.hashCode(),
giveaway_message_id,
is_unclaimed,
prize_star_count);
}

@Override
Expand All @@ -40,7 +51,8 @@ public String toString() {
"source='" + source + "'," +
"user='" + user + "'," +
"giveaway_message_id='" + giveaway_message_id + "'," +
"is_unclaimed='" + is_unclaimed + "'" +
"is_unclaimed='" + is_unclaimed + "'," +
"prize_star_count='" + prize_star_count + "'" +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Giveaway implements Serializable {
private String prize_description;
private String[] country_codes;
private Integer premium_subscription_month_count;

private Integer prize_star_count;

public Chat[] chats() {
return chats;
Expand All @@ -45,18 +45,38 @@ public String[] countryCodes() {
public Integer premiumSubscriptionMonthCount() {
return premium_subscription_month_count;
}
public Integer prizeStarCount() {
return prize_star_count;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Giveaway giveaway = (Giveaway) o;
return Objects.deepEquals(chats, giveaway.chats) && Objects.equals(winners_selection_date, giveaway.winners_selection_date) && Objects.equals(winner_count, giveaway.winner_count) && Objects.equals(only_new_members, giveaway.only_new_members) && Objects.equals(has_public_winners, giveaway.has_public_winners) && Objects.equals(prize_description, giveaway.prize_description) && Objects.deepEquals(country_codes, giveaway.country_codes) && Objects.equals(premium_subscription_month_count, giveaway.premium_subscription_month_count);
return Objects.deepEquals(chats, giveaway.chats)
&& Objects.equals(winners_selection_date, giveaway.winners_selection_date)
&& Objects.equals(winner_count, giveaway.winner_count)
&& Objects.equals(only_new_members, giveaway.only_new_members)
&& Objects.equals(has_public_winners, giveaway.has_public_winners)
&& Objects.equals(prize_description, giveaway.prize_description)
&& Objects.deepEquals(country_codes, giveaway.country_codes)
&& Objects.equals(premium_subscription_month_count, giveaway.premium_subscription_month_count)
&& Objects.equals(prize_star_count, giveaway.prize_star_count);
}

@Override
public int hashCode() {
return Objects.hash(Arrays.hashCode(chats), winners_selection_date, winner_count, only_new_members, has_public_winners, prize_description, Arrays.hashCode(country_codes), premium_subscription_month_count);
return Objects.hash(
Arrays.hashCode(chats),
winners_selection_date,
winner_count,
only_new_members,
has_public_winners,
prize_description,
Arrays.hashCode(country_codes),
premium_subscription_month_count,
prize_star_count);
}

@Override
Expand All @@ -70,6 +90,7 @@ public String toString() {
", prize_description='" + prize_description + '\'' +
", country_codes=" + Arrays.toString(country_codes) +
", premium_subscription_month_count=" + premium_subscription_month_count +
", prize_star_count=" + prize_star_count +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GiveawayCompleted implements Serializable {
private Integer winner_count;
private Integer unclaimed_prize_count;
private Message giveaway_message;

private Boolean is_star_giveaway;

public Integer winnerCount() {
return winner_count;
Expand All @@ -26,6 +26,9 @@ public Message giveawayMessage() {
return giveaway_message;
}

public Boolean isStarGiveaway() {
return is_star_giveaway;
}

@Override
public boolean equals(Object o) {
Expand All @@ -34,12 +37,17 @@ public boolean equals(Object o) {
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);
&& Objects.equals(giveaway_message, that.giveaway_message)
&& Objects.equals(is_star_giveaway, that.is_star_giveaway);
}

@Override
public int hashCode() {
return Objects.hash(winner_count, unclaimed_prize_count, giveaway_message);
return Objects.hash(
winner_count,
unclaimed_prize_count,
giveaway_message,
is_star_giveaway);
}

@Override
Expand All @@ -48,6 +56,7 @@ public String toString() {
"winner_count='" + winner_count + "'," +
"unclaimed_prize_count='" + unclaimed_prize_count + "'," +
"giveaway_message='" + giveaway_message + "'" +
"is_star_giveaway='" + is_star_giveaway + "'" +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pengrad.telegrambot.model.giveaway

data class GiveawayCreated(
@get:JvmName("prizeStarCount") val prizeStarCount: Int
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says "Optional", perhaps should be Int? = null or Int = 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it should be Int = 0

)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class GiveawayWinners implements Serializable {
private Boolean only_new_members;
private Boolean was_refunded;
private String prize_description;

private Integer prize_star_count;

public Chat chat() {
return chat;
Expand Down Expand Up @@ -68,17 +68,44 @@ public String prizeDescription() {
return prize_description;
}

public Integer prizeStarCount() {
return prize_star_count;
}

@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(giveaway_message_id, that.giveaway_message_id) && Objects.equals(winners_selection_date, that.winners_selection_date) && Objects.equals(winner_count, that.winner_count) && Objects.deepEquals(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);
return Objects.equals(chat, that.chat)
&& Objects.equals(giveaway_message_id, that.giveaway_message_id)
&& Objects.equals(winners_selection_date, that.winners_selection_date)
&& Objects.equals(winner_count, that.winner_count)
&& Objects.deepEquals(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)
&& Objects.equals(prize_star_count, that.prize_star_count);
}

@Override
public int hashCode() {
return Objects.hash(chat, giveaway_message_id, winners_selection_date, winner_count, Arrays.hashCode(winners), additional_chat_count, premium_subscription_month_count, unclaimed_prize_count, only_new_members, was_refunded, prize_description);
return Objects.hash(
chat,
giveaway_message_id,
winners_selection_date,
winner_count,
Arrays.hashCode(winners),
additional_chat_count,
premium_subscription_month_count,
unclaimed_prize_count,
only_new_members,
was_refunded,
prize_description,
prize_star_count);
}

@Override
Expand All @@ -95,6 +122,7 @@ public String toString() {
", only_new_members=" + only_new_members +
", was_refunded=" + was_refunded +
", prize_description='" + prize_description + '\'' +
", prize_star_count=" + prize_star_count +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pengrad.telegrambot.model.paidmedia

import com.pengrad.telegrambot.model.User

data class PaidMediaPurchased(
@get:JvmName("user") val from: User,
@get:JvmName("paidMediaPayload") val paidMediaPayload: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TransactionPartnerUser extends TransactionPartner {
private User user;
private String invoice_payload;
private PaidMedia[] paid_media;
private String paid_media_payload;

public TransactionPartnerUser() {
super(TYPE);
Expand All @@ -31,13 +32,20 @@ public PaidMedia[] paidMedia() {
return paid_media;
}

public String paidMediaPayload() {
return paid_media_payload;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
TransactionPartnerUser that = (TransactionPartnerUser) o;
return Objects.equals(user, that.user) && Objects.equals(invoice_payload, that.invoice_payload) && Objects.deepEquals(paid_media, that.paid_media);
return Objects.equals(user, that.user)
&& Objects.equals(invoice_payload, that.invoice_payload)
&& Objects.deepEquals(paid_media, that.paid_media)
&& Objects.equals(paid_media_payload, that.paid_media_payload);
}

@Override
Expand All @@ -51,6 +59,7 @@ public String toString() {
"user=" + user +
", invoice_payload='" + invoice_payload + '\'' +
", paid_media=" + Arrays.toString(paid_media) +
", paid_media_payload='" + paid_media_payload + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ public SendPaidMedia replyMarkup(ForceReply replyMarkup) {
return add("reply_markup", replyMarkup);
}

public SendPaidMedia payload(String payload) {
return add("payload", payload);
}

}