Skip to content

BOT API v9.0 #424

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

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
20722bf
Added the class BusinessBotRights and replaced the field can_reply wi…
mircoianese Jun 11, 2025
579dab7
Added the method readBusinessMessage, allowing bots to mark incoming …
mircoianese Jun 11, 2025
e9b87ff
Added the method deleteBusinessMessages, allowing bots to delete mess…
mircoianese Jun 11, 2025
d2c94b6
Added the method setBusinessAccountName, allowing bots to change the …
mircoianese Jun 11, 2025
68edc0f
Added the method setBusinessAccountUsername, allowing bots to change …
mircoianese Jun 11, 2025
4f816a0
Added the method setBusinessAccountBio, allowing bots to change the b…
mircoianese Jun 11, 2025
0f301c4
Added the class InputProfilePhoto, describing a profile photo to be set.
mircoianese Jun 11, 2025
8ca20cf
Added the methods setBusinessAccountProfilePhoto and removeBusinessAc…
mircoianese Jun 11, 2025
69378b0
Added the class AcceptedGiftTypes and the method setBusinessAccountGi…
mircoianese Jun 11, 2025
777986c
Added the class StarAmount and the method getBusinessAccountStarBalan…
mircoianese Jun 11, 2025
f8f0eb6
Added the method transferBusinessAccountStars, allowing bots to trans…
mircoianese Jun 11, 2025
cb7a69c
Added the classes OwnedGiftRegular, OwnedGiftUnique, OwnedGifts and t…
mircoianese Jun 11, 2025
54c86f2
Added the method convertGiftToStars, allowing bots to convert gifts r…
mircoianese Jun 11, 2025
e5697dc
Added the method upgradeGift, allowing bots to upgrade regular gifts …
mircoianese Jun 11, 2025
af685a6
Added the method transferGift, allowing bots to transfer unique gifts…
mircoianese Jun 11, 2025
b9097b4
Added the classes InputStoryContentPhoto and InputStoryContentVideo r…
mircoianese Jun 11, 2025
aa1d3a4
Added the classes StoryArea, StoryAreaPosition, LocationAddress, Stor…
mircoianese Jun 11, 2025
0d5df57
Added missing @get:JvmName
mircoianese Jun 11, 2025
f79724a
StoryArea.kt
mircoianese Jun 11, 2025
86f1b50
Added the method postStory, allowing bots to post a story on behalf o…
mircoianese Jun 11, 2025
aeb4fe5
Added the method editStory, allowing bots to edit stories they had pr…
mircoianese Jun 11, 2025
6efe3aa
Added the method deleteStory, allowing bots to delete stories they ha…
mircoianese Jun 11, 2025
6d23edc
Added the classes UniqueGiftModel, UniqueGiftSymbol, UniqueGiftBackdr…
mircoianese Jun 11, 2025
88669a9
Added the class UniqueGift describing a gift that was upgraded to a u…
mircoianese Jun 11, 2025
c29e22d
Replaced the field can_send_gift with the field accepted_gift_types o…
mircoianese Jun 11, 2025
b874222
Added the class GiftInfo and the field gift to the class Message, des…
mircoianese Jun 11, 2025
ded9f5f
Adding OwnedGift type adapter
mircoianese Jun 11, 2025
86c31a1
Added the class UniqueGiftInfo and the field unique_gift to the class…
mircoianese Jun 11, 2025
2c4f034
Added the method giftPremiumSubscription, allowing bots to gift a use…
mircoianese Jun 11, 2025
56ec945
Added the field premium_subscription_duration and transaction_type to…
mircoianese Jun 11, 2025
1471895
Added the class PaidMessagePriceChanged and the field paid_message_pr…
mircoianese Jun 11, 2025
ed57097
Added the field paid_star_count to the class Message, containing the …
mircoianese Jun 11, 2025
5f85dc7
Bump to 9.0.0
mircoianese Jun 11, 2025
7b9cfd1
Fix wrong type
mircoianese Jun 11, 2025
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![codecov](https://codecov.io/gh/pengrad/java-telegram-bot-api/branch/master/graph/badge.svg)](https://codecov.io/gh/pengrad/java-telegram-bot-api)

Java library for interacting with [Telegram Bot API](https://core.telegram.org/bots/api)
- Full support of all Bot API 8.3 methods
- Full support of all Bot API 9.0 methods
- Telegram [Passport](https://core.telegram.org/passport) and Decryption API
- Bot [Payments](https://core.telegram.org/bots/payments)
- [Gaming Platform](https://telegram.org/blog/games)
Expand All @@ -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:8.3.0'
implementation 'com.github.pengrad:java-telegram-bot-api:9.0.0'
```
Maven:
```xml
<dependency>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
<version>8.3.0</version>
<version>9.0.0</version>
</dependency>
```
[JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases)
Expand Down
6 changes: 3 additions & 3 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![codecov](https://codecov.io/gh/pengrad/java-telegram-bot-api/branch/master/graph/badge.svg)](https://codecov.io/gh/pengrad/java-telegram-bot-api)

Java библиотека, созданная для работы с [Telegram Bot API](https://core.telegram.org/bots/api)
- Полная поддержка всех методов BOT API 8.3
- Полная поддержка всех методов BOT API 9.0
- Поддержка Telegram [паспорта](https://core.telegram.org/passport) и дешифровки (Decryption API);
- Поддержка [платежей](https://core.telegram.org/bots/payments);
- [Игровая платформа](https://telegram.org/blog/games).
Expand All @@ -13,14 +13,14 @@ Java библиотека, созданная для работы с [Telegram B

Gradle:
```groovy
implementation 'com.github.pengrad:java-telegram-bot-api:8.3.0'
implementation 'com.github.pengrad:java-telegram-bot-api:9.0.0'
```
Maven:
```xml
<dependency>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
<version>8.3.0</version>
<version>9.0.0</version>
</dependency>
```
Также JAR со всеми зависимостями можно найти [в релизах](https://github.com/pengrad/java-telegram-bot-api/releases).
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.github.pengrad
VERSION_NAME=8.3.0
VERSION_NAME=9.0.0

POM_DESCRIPTION=Java API for Telegram Bot API
POM_URL=https://github.com/pengrad/java-telegram-bot-api/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.pengrad.telegrambot.model.business.BusinessIntro;
import com.pengrad.telegrambot.model.business.BusinessLocation;
import com.pengrad.telegrambot.model.business.BusinessOpeningHours;
import com.pengrad.telegrambot.model.gift.AcceptedGiftTypes;
import com.pengrad.telegrambot.model.reaction.ReactionType;


Expand Down Expand Up @@ -71,6 +72,7 @@ public enum Type {
private Long linked_chat_id;
private ChatLocation location;
private Boolean can_send_gift;
private AcceptedGiftTypes accepted_gift_types;

public Long id() {
return id;
Expand Down Expand Up @@ -247,10 +249,19 @@ public ChatLocation location() {
return location;
}

/**
*
* @deprecated Use 'acceptedGiftTypes' instead
*/
@Deprecated
public Boolean canSendGift() {
return can_send_gift;
}

public AcceptedGiftTypes acceptedGiftTypes() {
return accepted_gift_types;
}

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

@Override
Expand Down Expand Up @@ -355,7 +366,7 @@ public String toString() {
", custom_emoji_sticker_set_name=" + custom_emoji_sticker_set_name +
", linked_chat_id=" + linked_chat_id +
", location=" + location +
", can_send_gift=" + can_send_gift +
", accepted_gift_types=" + accepted_gift_types +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.pengrad.telegrambot.model

@Suppress("unused")
class LocationAddress private constructor(
@get:JvmName("countryCode") val countryCode: String,
@get:JvmName("state") var state: String?,
@get:JvmName("city") var city: String?,
@get:JvmName("street") var street: String?
) {

constructor(countryCode: String) : this(
countryCode = countryCode,
state = null,
city = null,
street = null
)

fun state(state: String) = apply {
this.state = state
}

fun city(city: String) = apply {
this.city = city
}

fun street(street: String) = apply {
this.street = street
}

}
32 changes: 31 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 @@ -2,6 +2,8 @@

import com.pengrad.telegrambot.model.chatbackground.ChatBackground;
import com.pengrad.telegrambot.model.chatboost.ChatBoostAdded;
import com.pengrad.telegrambot.model.gift.GiftInfo;
import com.pengrad.telegrambot.model.gift.unique.UniqueGiftInfo;
import com.pengrad.telegrambot.model.giveaway.Giveaway;
import com.pengrad.telegrambot.model.giveaway.GiveawayCompleted;
import com.pengrad.telegrambot.model.giveaway.GiveawayCreated;
Expand Down Expand Up @@ -105,6 +107,10 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private VideoChatScheduled video_chat_scheduled;
private InlineKeyboardMarkup reply_markup;
private WebAppData web_app_data;
private GiftInfo gift;
private UniqueGiftInfo unique_gift;
private PaidMessagePriceChanged paid_message_price_changed;
private Integer paid_star_count;

public Integer messageThreadId() {
return message_thread_id;
Expand Down Expand Up @@ -435,6 +441,22 @@ public WebAppData webAppData() {
return web_app_data;
}

public GiftInfo gift() {
return gift;
}

public UniqueGiftInfo uniqueGift() {
return unique_gift;
}

public PaidMessagePriceChanged paidMessagePriceChanged() {
return paid_message_price_changed;
}

public Integer paidStarCount() {
return paid_star_count;
}

/**
* Only for backwards-compatibility with MaybeInaccessibleMessage
*/
Expand Down Expand Up @@ -545,7 +567,11 @@ public boolean equals(Object o) {
Objects.equals(video_chat_participants_invited, message.video_chat_participants_invited) &&
Objects.equals(video_chat_scheduled, message.video_chat_scheduled) &&
Objects.equals(reply_markup, message.reply_markup) &&
Objects.equals(web_app_data, message.web_app_data);
Objects.equals(web_app_data, message.web_app_data) &&
Objects.equals(gift, message.gift) &&
Objects.equals(unique_gift, message.unique_gift) &&
Objects.equals(paid_message_price_changed, message.paid_message_price_changed) &&
Objects.equals(paid_star_count, message.paid_star_count);
}

@Override
Expand Down Expand Up @@ -641,6 +667,10 @@ public String toString() {
", video_chat_scheduled=" + video_chat_scheduled +
", reply_markup=" + reply_markup +
", web_app_data=" + web_app_data +
", gift=" + gift +
", unique_gift=" + unique_gift +
", paid_message_price_changed=" + paid_message_price_changed +
", paid_star_count=" + paid_star_count +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pengrad.telegrambot.model

data class PaidMessagePriceChanged(
@get:JvmName("prizeStarCount") val prizeStarCount: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.pengrad.telegrambot.model.business

data class BusinessBotRights(
@get:JvmName("canReply") val canReply: Boolean,
@get:JvmName("canReadMessages") val canReadMessages: Boolean,
@get:JvmName("canDeleteSentMessages") val canDeleteSentMessages: Boolean,
@get:JvmName("canDeleteAllMessages") val canDeleteAllMessages: Boolean,
@get:JvmName("canEditName") val canEditName: Boolean,
@get:JvmName("canEditBio") val canEditBio: Boolean,
@get:JvmName("canEditProfilePhoto") val canEditProfilePhoto: Boolean,
@get:JvmName("canEditUsername") val canEditUsername: Boolean,
@get:JvmName("canChangeGiftSettings") val canChangeGiftSettings: Boolean,
@get:JvmName("canViewGiftsAndStars") val canViewGiftsAndStars: Boolean,
@get:JvmName("canConvertGiftsToStars") val canConvertGiftsToStars: Boolean,
@get:JvmName("canTransferAndUpgradeGifts") val canTransferAndUpgradeGifts: Boolean,
@get:JvmName("canTransferStars") val canTransferStars: Boolean,
@get:JvmName("canManageStories") val canManageStories: Boolean,
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class BusinessConnection {
private User user;
private Long user_chat_id;
private Integer date;
private BusinessBotRights rights;
private Boolean can_reply;
private Boolean is_enabled;

Expand All @@ -29,10 +30,18 @@ public Integer date() {
return date;
}

/**
* @deprecated Use the 'rights' field instead.
*/
@Deprecated
public Boolean canReply() {
return can_reply;
}

public BusinessBotRights rights() {
return rights;
}

public Boolean isEnabled() {
return is_enabled;
}
Expand All @@ -42,12 +51,12 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BusinessConnection that = (BusinessConnection) o;
return Objects.equals(id, that.id) && Objects.equals(user, that.user) && Objects.equals(user_chat_id, that.user_chat_id) && Objects.equals(date, that.date) && Objects.equals(can_reply, that.can_reply) && Objects.equals(is_enabled, that.is_enabled);
return Objects.equals(id, that.id) && Objects.equals(user, that.user) && Objects.equals(user_chat_id, that.user_chat_id) && Objects.equals(date, that.date) && Objects.equals(rights, that.rights) && Objects.equals(is_enabled, that.is_enabled);
}

@Override
public int hashCode() {
return Objects.hash(id, user, user_chat_id, date, can_reply, is_enabled);
return Objects.hash(id, user, user_chat_id, date, rights, is_enabled);
}

@Override
Expand All @@ -57,7 +66,7 @@ public String toString() {
", user=" + user +
", user_chat_id=" + user_chat_id +
", date=" + date +
", can_reply=" + can_reply +
", rights=" + rights +
", is_enabled=" + is_enabled +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pengrad.telegrambot.model.gift

data class AcceptedGiftTypes(
@get:JvmName("unlimitedGifts") val unlimitedGifts: Boolean,
@get:JvmName("limitedGifts") val limitedGifts: Boolean,
@get:JvmName("uniqueGifts") val uniqueGifts: Boolean,
@get:JvmName("premiumSubscription") val premiumSubscription: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.pengrad.telegrambot.model.gift

import com.pengrad.telegrambot.model.MessageEntity

data class GiftInfo(
@get:JvmName("gift") val gift: Gift,
@get:JvmName("ownedGiftId") val ownedGiftId: String?,
@get:JvmName("convertStarCount") val convertStarCount: Int?,
@get:JvmName("prepaidUpgradeStarCount") val prepaidUpgradeStarCount: Int?,
@get:JvmName("canBeUpgraded") val canBeUpgraded: Boolean?,
@get:JvmName("text") val text: String?,
@get:JvmName("entities") val entities: Array<MessageEntity>?,
@get:JvmName("isPrivate") val isPrivate: Boolean?,
) {

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is GiftInfo) return false

return gift == other.gift &&
ownedGiftId == other.ownedGiftId &&
convertStarCount == other.convertStarCount &&
prepaidUpgradeStarCount == other.prepaidUpgradeStarCount &&
canBeUpgraded == other.canBeUpgraded &&
text == other.text &&
entities contentEquals other.entities &&
isPrivate == other.isPrivate
}

override fun hashCode(): Int {
var result = gift.hashCode()
result = 31 * result + (ownedGiftId?.hashCode() ?: 0)
result = 31 * result + (convertStarCount ?: 0)
result = 31 * result + (prepaidUpgradeStarCount ?: 0)
result = 31 * result + (canBeUpgraded?.hashCode() ?: 0)
result = 31 * result + (text?.hashCode() ?: 0)
result = 31 * result + (entities?.contentHashCode() ?: 0)
result = 31 * result + (isPrivate?.hashCode() ?: 0)
return result
}

override fun toString(): String {
return "GiftInfo(gift=$gift, ownedGiftId=$ownedGiftId, convertStarCount=$convertStarCount, " +
"prepaidUpgradeStarCount=$prepaidUpgradeStarCount, canBeUpgraded=$canBeUpgraded, " +
"text=$text, entities=${entities?.contentToString()}, isPrivate=$isPrivate)"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pengrad.telegrambot.model.gift.owned

open class OwnedGift(
@get:JvmName("type") val type: String
)
Loading
Loading