Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Java library for interacting with [Telegram Bot API](https://core.telegram.org/b

Gradle:
```groovy
implementation 'com.github.pengrad:java-telegram-bot-api:9.3.0'
implementation 'com.github.pengrad:java-telegram-bot-api:9.4.0'
```
Maven:
```xml
<dependency>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
<version>9.3.0</version>
<version>9.4.0</version>
</dependency>
```
[JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases)
Expand Down
4 changes: 2 additions & 2 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Java библиотека, созданная для работы с [Telegram B

Gradle:
```groovy
implementation 'com.github.pengrad:java-telegram-bot-api:9.3.0'
implementation 'com.github.pengrad:java-telegram-bot-api:9.4.0'
```
Maven:
```xml
<dependency>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
<version>9.3.0</version>
<version>9.4.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=9.3.0
VERSION_NAME=9.4.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 @@ -78,6 +78,7 @@ public enum Type {
private UserRating rating;
private Integer paid_message_star_count;
private UniqueGiftColors unique_gift_colors;
private Audio first_profile_audio;

public Long id() {
return id;
Expand Down Expand Up @@ -278,6 +279,10 @@ public UniqueGiftColors uniqueGiftColors() {
return unique_gift_colors;
}

public Audio firstProfileAudio() {
return first_profile_audio;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -332,7 +337,8 @@ public boolean equals(Object o) {
Objects.equals(accepted_gift_types, chat.accepted_gift_types) &&
Objects.equals(rating, chat.rating) &&
Objects.equals(paid_message_star_count, chat.paid_message_star_count) &&
Objects.equals(unique_gift_colors, chat.unique_gift_colors);
Objects.equals(unique_gift_colors, chat.unique_gift_colors) &&
Objects.equals(first_profile_audio, chat.first_profile_audio);
}

@Override
Expand Down Expand Up @@ -393,6 +399,7 @@ public String toString() {
", rating=" + rating +
", paid_message_star_count=" + paid_message_star_count +
", unique_gift_colors=" + unique_gift_colors +
", first_profile_audio=" + first_profile_audio +
'}';
}
}
18 changes: 17 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.chatowner.ChatOwnerChanged;
import com.pengrad.telegrambot.model.chatowner.ChatOwnerLeft;
import com.pengrad.telegrambot.model.checklist.Checklist;
import com.pengrad.telegrambot.model.checklist.ChecklistTasksAdded;
import com.pengrad.telegrambot.model.checklist.ChecklistTasksDone;
Expand Down Expand Up @@ -131,6 +133,8 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private SuggestedPostRefunded suggested_post_refunded;
private DirectMessagePriceChanged direct_message_price_changed;
private Integer paid_star_count;
private ChatOwnerLeft chat_owner_left;
private ChatOwnerChanged chat_owner_changed;

public Long messageThreadId() {
return message_thread_id;
Expand Down Expand Up @@ -533,6 +537,14 @@ public Integer paidStarCount() {
return paid_star_count;
}

public ChatOwnerLeft chatOwnerLeft() {
return chat_owner_left;
}

public ChatOwnerChanged chatOwnerChanged() {
return chat_owner_changed;
}

/**
* Only for backwards-compatibility with MaybeInaccessibleMessage
*/
Expand Down Expand Up @@ -661,7 +673,9 @@ public boolean equals(Object o) {
Objects.equals(suggested_post_paid, message.suggested_post_paid) &&
Objects.equals(suggested_post_refunded, message.suggested_post_refunded) &&
Objects.equals(direct_message_price_changed, message.direct_message_price_changed) &&
Objects.equals(paid_star_count, message.paid_star_count);
Objects.equals(paid_star_count, message.paid_star_count) &&
Objects.equals(chat_owner_left, message.chat_owner_left) &&
Objects.equals(chat_owner_changed, message.chat_owner_changed);
}

@Override
Expand Down Expand Up @@ -775,6 +789,8 @@ public String toString() {
", suggested_post_refunded=" + suggested_post_refunded +
", direct_message_price_changed=" + direct_message_price_changed +
", paid_star_count=" + paid_star_count +
", chat_owner_left=" + chat_owner_left +
", chat_owner_changed=" + chat_owner_changed +
'}';
}
}
14 changes: 13 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class User implements Serializable {
private Boolean can_connect_to_business;
private Boolean has_main_web_app;
private Boolean has_topics_enabled;
private Boolean allows_users_to_create_topics;

private User() {
}
Expand Down Expand Up @@ -88,12 +89,22 @@ public Boolean hasTopicsEnabled() {
return has_topics_enabled;
}

public Boolean allowsUsersToCreateTopics() {
return allows_users_to_create_topics;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return Objects.equals(id, user.id) && Objects.equals(is_bot, user.is_bot) && Objects.equals(first_name, user.first_name) && Objects.equals(last_name, user.last_name) && Objects.equals(username, user.username) && Objects.equals(language_code, user.language_code) && Objects.equals(is_premium, user.is_premium) && Objects.equals(added_to_attachment_menu, user.added_to_attachment_menu) && Objects.equals(can_join_groups, user.can_join_groups) && Objects.equals(can_read_all_group_messages, user.can_read_all_group_messages) && Objects.equals(supports_inline_queries, user.supports_inline_queries) && Objects.equals(can_connect_to_business, user.can_connect_to_business) && Objects.equals(has_main_web_app, user.has_main_web_app) && Objects.equals(has_topics_enabled, user.has_topics_enabled);
return Objects.equals(id, user.id) && Objects.equals(is_bot, user.is_bot) && Objects.equals(first_name, user.first_name)
&& Objects.equals(last_name, user.last_name) && Objects.equals(username, user.username) && Objects.equals(language_code, user.language_code)
&& Objects.equals(is_premium, user.is_premium) && Objects.equals(added_to_attachment_menu, user.added_to_attachment_menu)
&& Objects.equals(can_join_groups, user.can_join_groups) && Objects.equals(can_read_all_group_messages, user.can_read_all_group_messages)
&& Objects.equals(supports_inline_queries, user.supports_inline_queries) && Objects.equals(can_connect_to_business, user.can_connect_to_business)
&& Objects.equals(has_main_web_app, user.has_main_web_app) && Objects.equals(has_topics_enabled, user.has_topics_enabled)
&& Objects.equals(allows_users_to_create_topics, user.allows_users_to_create_topics);
}

@Override
Expand All @@ -118,6 +129,7 @@ public String toString() {
", can_connect_to_business=" + can_connect_to_business +
", has_main_web_app=" + has_main_web_app +
", has_topics_enabled=" + has_topics_enabled +
", allows_users_to_create_topics=" + allows_users_to_create_topics +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.pengrad.telegrambot.model

data class UserProfileAudios(
@get:JvmName("totalCount") val totalCount: Int,
@get:JvmName("audios") val audios: Array<Audio>
) {

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

return totalCount == other.totalCount &&
audios contentEquals other.audios
}

override fun hashCode(): Int {
var result = totalCount.hashCode()
result = 31 * result + audios.contentHashCode()
return result
}

}
38 changes: 37 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Video.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ data class Video(

@get:JvmName("fileName") val fileName: String? = null,
@get:JvmName("mimeType") val mimeType: String? = null,
@get:JvmName("fileSize") val fileSize: Long? = null
@get:JvmName("fileSize") val fileSize: Long? = null,

@get:JvmName("qualities") val qualities: Array<VideoQuality>? = null
) {

/**
Expand All @@ -35,4 +37,38 @@ data class Video(
*/
fun duration() = duration as JavaInteger

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

return fileId == other.fileId &&
fileUniqueId == other.fileUniqueId &&
width == other.width &&
height == other.height &&
duration == other.duration &&
thumbnail == other.thumbnail &&
cover == other.cover &&
startTimestamp == other.startTimestamp &&
fileName == other.fileName &&
mimeType == other.mimeType &&
fileSize == other.fileSize &&
qualities contentEquals other.qualities
}

override fun hashCode(): Int {
var result = fileId.hashCode()
result = 31 * result + fileUniqueId.hashCode()
result = 31 * result + width.hashCode()
result = 31 * result + height.hashCode()
result = 31 * result + duration.hashCode()
result = 31 * result + (thumbnail?.hashCode() ?: 0)
result = 31 * result + (cover?.hashCode() ?: 0)
result = 31 * result + (startTimestamp?.hashCode() ?: 0)
result = 31 * result + (fileName?.hashCode() ?: 0)
result = 31 * result + (mimeType?.hashCode() ?: 0)
result = 31 * result + (fileSize?.hashCode() ?: 0)
result = 31 * result + (qualities?.contentHashCode() ?: 0)
return result
}

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

data class VideoQuality(
@get:JvmName("fileId") val fileId: String,
@get:JvmName("fileUniqueId") val fileUniqueId: String,
@get:JvmName("width") val width: Int,
@get:JvmName("height") val height: Int,
@get:JvmName("codec") val codec: String,
@get:JvmName("fileSize") val fileSize: Long? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pengrad.telegrambot.model.chatowner

import com.pengrad.telegrambot.model.User

data class ChatOwnerChanged(
@get:JvmName("newOwner") val newOwner: User
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pengrad.telegrambot.model.chatowner

import com.pengrad.telegrambot.model.User

data class ChatOwnerLeft(
@get:JvmName("newOwner") val newOwner: User
) {
}
Comment on lines +7 to +8
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

This data class has an empty body block ({ }). It can be removed to reduce noise and match the style used in other simple model data classes.

Suggested change
) {
}
)

Copilot uses AI. Check for mistakes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ data class UniqueGift(
@get:JvmName("giftId") val giftId: String? = null,
@get:JvmName("isFromBlockchain") val isFromBlockchain: Boolean? = null,
@get:JvmName("isPremium") val isPremium: Boolean? = null,
@get:JvmName("isBurned") val isBurned: Boolean? = null,
@get:JvmName("colors") val colors: UniqueGiftColors? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import com.pengrad.telegrambot.model.Sticker
data class UniqueGiftModel(
@get:JvmName("name") val name: String,
@get:JvmName("sticker") val sticker: Sticker,
@get:JvmName("rarityPerMille") val rarityPerMille: Int
@get:JvmName("rarityPerMille") val rarityPerMille: Int,
@get:JvmName("rarity") val rarity: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ data class InlineKeyboardButton @JvmOverloads constructor(
var pay: Boolean? = null,
@get:JvmName("webApp") var webApp: WebAppInfo? = null,
@get:JvmName("copyText") var copyText: CopyTextButton? = null,
@get:JvmName("iconCustomEmojiId") var iconCustomEmojiId: String? = null,
@get:JvmName("style") var style: String? = null
) {

fun url(url: String): InlineKeyboardButton {
Expand Down Expand Up @@ -78,4 +80,14 @@ data class InlineKeyboardButton @JvmOverloads constructor(
fun isPay(): Boolean {
return pay ?: false
}

fun iconCustomEmojiId(iconCustomEmojiId: String): InlineKeyboardButton {
this.iconCustomEmojiId = iconCustomEmojiId
return this
}

fun style(style: String): InlineKeyboardButton {
this.style = style
return this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class KeyboardButton implements Serializable {
private KeyboardButtonRequestUsers request_users;
private KeyboardButtonRequestChat request_chat;
private WebAppInfo web_app;
private String icon_custom_emoji_id;
private String style;

public KeyboardButton(String text) {
this.text = text;
Expand Down Expand Up @@ -52,4 +54,14 @@ public KeyboardButton webAppInfo(WebAppInfo webApp) {
this.web_app = webApp;
return this;
}

public KeyboardButton iconCustomEmojiId(String iconCustomEmojiId) {
this.icon_custom_emoji_id = iconCustomEmojiId;
return this;
}

public KeyboardButton style(String style) {
this.style = style;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.pengrad.telegrambot.request

import com.pengrad.telegrambot.response.GetUserProfileAudiosResponse
import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
import com.pengrad.telegrambot.utility.kotlin.requestParameter

class GetUserProfileAudios(
userId: Long
) : KBaseRequest<GetUserProfileAudios, GetUserProfileAudiosResponse>(GetUserProfileAudiosResponse::class) {

val userId: Long by requestParameter(userId)

var offset: Int? by optionalRequestParameter()
var limit: Int? by optionalRequestParameter()

fun offset(offset: Int) = applySelf { this.offset = offset }

fun limit(limit: Int) = applySelf { this.limit = limit }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pengrad.telegrambot.request

import com.pengrad.telegrambot.response.BaseResponse

class RemoveMyProfilePhoto (

) : KBaseRequest<RemoveMyProfilePhoto, BaseResponse>(BaseResponse::class)
Comment on lines +5 to +7
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

RemoveMyProfilePhoto is declared with an empty primary constructor and extra whitespace/newlines. For consistency with other parameterless requests (e.g., GetAvailableGifts), consider removing the empty constructor parentheses and formatting it as a single-line class extending KBaseRequest.

Copilot uses AI. Check for mistakes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pengrad.telegrambot.request

import com.pengrad.telegrambot.model.inputprofilephoto.InputProfilePhoto
import com.pengrad.telegrambot.response.BaseResponse
import com.pengrad.telegrambot.utility.kotlin.requestParameter

class SetMyProfilePhoto(
photo: InputProfilePhoto

) : KBaseRequest<SetMyProfilePhoto, BaseResponse>(BaseResponse::class) {

val photo: InputProfilePhoto by requestParameter(photo)

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

import com.pengrad.telegrambot.model.UserProfileAudios

data class GetUserProfileAudiosResponse(val result: UserProfileAudios) : BaseResponse()
Loading
Loading