Skip to content
Open
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
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 10.3 methods
- Full support of all Bot API 10.4 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:10.3.0'
implementation 'com.github.pengrad:java-telegram-bot-api:10.4.0'
```
Maven:
```xml
<dependency>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
<version>10.3.0</version>
<version>10.4.0</version>
</dependency>
```
[JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.github.pengrad
VERSION_NAME=10.3.0
VERSION_NAME=10.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
@@ -1,10 +1,10 @@
package com.pengrad.telegrambot.model.story.area
package com.pengrad.telegrambot.model

data class StoryAreaPosition(
data class AreaPosition(
@get:JvmName("xPercentage") val xPercentage: Double,
@get:JvmName("yPercentage") val yPercentage: Double,
@get:JvmName("widthPercentage") val widthPercentage: Double,
@get:JvmName("heightPercentage") val heightPercentage: Double,
@get:JvmName("rotationAngle") val rotationAngle: Double,
@get:JvmName("cornerRadiusPercentage") val cornerRadiusPercentage: Double
)
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.pengrad.telegrambot.model;

import com.pengrad.telegrambot.model.chatsharetheme.ChatShareTheme;
import com.pengrad.telegrambot.model.ton.TonWalletCard;
import com.google.gson.annotations.SerializedName;
import com.pengrad.telegrambot.model.business.BusinessIntro;
import com.pengrad.telegrambot.model.business.BusinessLocation;
Expand Down Expand Up @@ -81,6 +83,8 @@ public enum Type {
private Audio first_profile_audio;
private User guard_bot;
private Community community;
private TonWalletCard ton_wallet_card;
private ChatShareTheme share_theme;

public Long id() {
return id;
Expand Down Expand Up @@ -293,6 +297,14 @@ public Community community() {
return community;
}

public TonWalletCard tonWalletCard() {
return ton_wallet_card;
}

public ChatShareTheme shareTheme() {
return share_theme;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -350,7 +362,9 @@ public boolean equals(Object o) {
Objects.equals(unique_gift_colors, chat.unique_gift_colors) &&
Objects.equals(first_profile_audio, chat.first_profile_audio) &&
Objects.equals(guard_bot, chat.guard_bot) &&
Objects.equals(community, chat.community);
Objects.equals(community, chat.community) &&
Objects.equals(ton_wallet_card, chat.ton_wallet_card) &&
Objects.equals(share_theme, chat.share_theme);
}

@Override
Expand Down Expand Up @@ -414,6 +428,8 @@ public String toString() {
", first_profile_audio=" + first_profile_audio +
", guard_bot=" + guard_bot +
", community=" + community +
", ton_wallet_card=" + ton_wallet_card +
", share_theme=" + share_theme +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pengrad.telegrambot.model;

import com.pengrad.telegrambot.model.widget.Widget;
import com.pengrad.telegrambot.model.checklist.Checklist;
import com.pengrad.telegrambot.model.giveaway.Giveaway;
import com.pengrad.telegrambot.model.giveaway.GiveawayWinners;
Expand All @@ -23,6 +24,7 @@ public class ExternalReplyInfo implements Serializable {
private PaidMediaInfo paid_media;
private Document document;
private LivePhoto live_photo;
private Widget widget;
private PhotoSize[] photo;
private Sticker sticker;
private Story story;
Expand Down Expand Up @@ -76,6 +78,10 @@ public LivePhoto livePhoto() {
return live_photo;
}

public Widget widget() {
return widget;
}

public PhotoSize[] photo() {
return photo;
}
Expand Down Expand Up @@ -149,12 +155,12 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ExternalReplyInfo that = (ExternalReplyInfo) o;
return Objects.equals(origin, that.origin) && Objects.equals(chat, that.chat) && Objects.equals(message_id, that.message_id) && Objects.equals(link_preview_options, that.link_preview_options) && Objects.equals(animation, that.animation) && Objects.equals(audio, that.audio) && Objects.equals(paid_media, that.paid_media) && Objects.equals(document, that.document) && Objects.equals(live_photo, that.live_photo) && Arrays.equals(photo, that.photo) && Objects.equals(sticker, that.sticker) && Objects.equals(story, that.story) && Objects.equals(video, that.video) && Objects.equals(video_note, that.video_note) && Objects.equals(voice, that.voice) && Objects.equals(has_media_spoiler, that.has_media_spoiler) && Objects.equals(checklist, that.checklist) && Objects.equals(contact, that.contact) && Objects.equals(dice, that.dice) && Objects.equals(game, that.game) && Objects.equals(giveaway, that.giveaway) && Objects.equals(giveaway_winners, that.giveaway_winners) && Objects.equals(invoice, that.invoice) && Objects.equals(location, that.location) && Objects.equals(poll, that.poll) && Objects.equals(venue, that.venue);
return Objects.equals(origin, that.origin) && Objects.equals(chat, that.chat) && Objects.equals(message_id, that.message_id) && Objects.equals(link_preview_options, that.link_preview_options) && Objects.equals(animation, that.animation) && Objects.equals(audio, that.audio) && Objects.equals(paid_media, that.paid_media) && Objects.equals(document, that.document) && Objects.equals(live_photo, that.live_photo) && Objects.equals(widget, that.widget) && Arrays.equals(photo, that.photo) && Objects.equals(sticker, that.sticker) && Objects.equals(story, that.story) && Objects.equals(video, that.video) && Objects.equals(video_note, that.video_note) && Objects.equals(voice, that.voice) && Objects.equals(has_media_spoiler, that.has_media_spoiler) && Objects.equals(checklist, that.checklist) && Objects.equals(contact, that.contact) && Objects.equals(dice, that.dice) && Objects.equals(game, that.game) && Objects.equals(giveaway, that.giveaway) && Objects.equals(giveaway_winners, that.giveaway_winners) && Objects.equals(invoice, that.invoice) && Objects.equals(location, that.location) && Objects.equals(poll, that.poll) && Objects.equals(venue, that.venue);
}

@Override
public int hashCode() {
int result = Objects.hash(origin, chat, message_id, link_preview_options, animation, audio, paid_media, document, live_photo, sticker, story, video, video_note, voice, has_media_spoiler, checklist, contact, dice, game, giveaway, giveaway_winners, invoice, location, poll, venue);
int result = Objects.hash(origin, chat, message_id, link_preview_options, animation, audio, paid_media, document, live_photo, widget, sticker, story, video, video_note, voice, has_media_spoiler, checklist, contact, dice, game, giveaway, giveaway_winners, invoice, location, poll, venue);
result = 31 * result + Arrays.hashCode(photo);
return result;
}
Expand All @@ -171,6 +177,7 @@ public String toString() {
", paid_media=" + paid_media +
", document=" + document +
", live_photo=" + live_photo +
", widget=" + widget +
", photo=" + Arrays.toString(photo) +
", sticker=" + sticker +
", story=" + story +
Expand Down
25 changes: 24 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Message.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.pengrad.telegrambot.model;

import com.pengrad.telegrambot.model.ton.TonWalletTransfer;
import com.pengrad.telegrambot.model.widget.Widget;
import com.pengrad.telegrambot.model.chatbackground.ChatBackground;
import com.pengrad.telegrambot.model.chatboost.ChatBoostAdded;
import com.pengrad.telegrambot.model.chatowner.ChatOwnerChanged;
Expand Down Expand Up @@ -151,6 +153,9 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private CommunityChatAdded community_chat_added;
private CommunityChatJoined community_chat_joined;
private CommunityChatRemoved community_chat_removed;
private Widget widget;
private TonWalletTransfer ton_wallet_transfer;
private PaidMessagesWaived paid_messages_waived;

public Long messageThreadId() {
return message_thread_id;
Expand Down Expand Up @@ -609,6 +614,18 @@ public CommunityChatRemoved communityChatRemoved() {
return community_chat_removed;
}

public Widget widget() {
return widget;
}

public TonWalletTransfer tonWalletTransfer() {
return ton_wallet_transfer;
}

public PaidMessagesWaived paidMessagesWaived() {
return paid_messages_waived;
}

public User guestBotCallerUser() {
return guest_bot_caller_user;
}
Expand Down Expand Up @@ -766,7 +783,10 @@ public boolean equals(Object o) {
Objects.equals(guest_query_id, message.guest_query_id) &&
Objects.equals(community_chat_added, message.community_chat_added) &&
Objects.equals(community_chat_joined, message.community_chat_joined) &&
Objects.equals(community_chat_removed, message.community_chat_removed);
Objects.equals(community_chat_removed, message.community_chat_removed) &&
Objects.equals(widget, message.widget) &&
Objects.equals(ton_wallet_transfer, message.ton_wallet_transfer) &&
Objects.equals(paid_messages_waived, message.paid_messages_waived);
}

@Override
Expand Down Expand Up @@ -897,6 +917,9 @@ public String toString() {
", community_chat_added=" + community_chat_added +
", community_chat_joined=" + community_chat_joined +
", community_chat_removed=" + community_chat_removed +
", widget=" + widget +
", ton_wallet_transfer=" + ton_wallet_transfer +
", paid_messages_waived=" + paid_messages_waived +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ 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, blockquote, expandable_blockquote, date_time
text_mention, underline, strikethrough, spoiler, custom_emoji, blockquote, expandable_blockquote, date_time,
ton_address, bank_card_number
}

private Type type;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.pengrad.telegrambot.model

import java.io.Serializable

class PaidMessagesWaived : Serializable {

override fun equals(other: Any?): Boolean {
if (this === other) return true
return other != null && javaClass == other.javaClass
}

override fun hashCode(): Int = 1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pengrad.telegrambot.model;

import com.pengrad.telegrambot.model.richmessages.richtext.RichText;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
Expand All @@ -10,6 +11,7 @@ public class TextQuote implements Serializable {

private String text;
private MessageEntity[] entities;
private RichText[] rich_texts;
private Integer position;
private Boolean is_manual;

Expand All @@ -21,6 +23,10 @@ public MessageEntity[] entities() {
return entities;
}

public RichText[] richTexts() {
return rich_texts;
}

public Integer position() {
return position;
}
Expand All @@ -35,13 +41,14 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
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);
return Objects.equals(text, textQuote.text) && Arrays.equals(entities, textQuote.entities) && Arrays.equals(rich_texts, textQuote.rich_texts) && Objects.equals(position, textQuote.position) && Objects.equals(is_manual, textQuote.is_manual);
}

@Override
public int hashCode() {
int result = Objects.hash(text, position, is_manual);
result = 31 * result + Arrays.hashCode(entities);
result = 31 * result + Arrays.hashCode(rich_texts);
return result;
}

Expand All @@ -50,6 +57,7 @@ public String toString() {
return "TextQuote{" +
"text='" + text + '\'' +
", entities=" + Arrays.toString(entities) +
", rich_texts=" + Arrays.toString(rich_texts) +
", position=" + position +
", is_manual=" + is_manual +
'}';
Expand Down
18 changes: 17 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Update.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.pengrad.telegrambot.model;

import com.pengrad.telegrambot.model.widget.SharedWidgetQuery;
import com.pengrad.telegrambot.model.widget.WidgetQuery;
import com.pengrad.telegrambot.model.business.BusinessConnection;
import com.pengrad.telegrambot.model.business.BusinessMessageDeleted;
import com.pengrad.telegrambot.model.chatboost.ChatBoostRemoved;
Expand Down Expand Up @@ -44,6 +46,8 @@ public class Update implements Serializable {
private Message guest_message;
private BotSubscriptionUpdated subscription;
private MessageGenerationStopped stopped_message_generation;
private WidgetQuery widget_query;
private SharedWidgetQuery shared_widget_query;

public Integer updateId() {
return update_id;
Expand Down Expand Up @@ -157,6 +161,14 @@ public MessageGenerationStopped stoppedMessageGeneration() {
return stopped_message_generation;
}

public WidgetQuery widgetQuery() {
return widget_query;
}

public SharedWidgetQuery sharedWidgetQuery() {
return shared_widget_query;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -189,7 +201,9 @@ public boolean equals(Object o) {
Objects.equals(managed_bot, update.managed_bot) &&
Objects.equals(guest_message, update.guest_message) &&
Objects.equals(subscription, update.subscription) &&
Objects.equals(stopped_message_generation, update.stopped_message_generation);
Objects.equals(stopped_message_generation, update.stopped_message_generation) &&
Objects.equals(widget_query, update.widget_query) &&
Objects.equals(shared_widget_query, update.shared_widget_query);
}

@Override
Expand Down Expand Up @@ -228,6 +242,8 @@ public String toString() {
", guest_message=" + guest_message +
", subscription=" + subscription +
", stopped_message_generation=" + stopped_message_generation +
", widget_query=" + widget_query +
", shared_widget_query=" + shared_widget_query +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.pengrad.telegrambot.model.chatsharetheme

import java.io.Serializable

interface ChatShareTheme : Serializable {
val type: String

companion object {
const val EMOJI = "emoji"
const val UNIQUE_GIFT = "unique_gift"
const val UNKNOWN = "unknown"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.pengrad.telegrambot.model.chatsharetheme

import com.pengrad.telegrambot.model.gift.unique.UniqueGiftBackdropColors
import java.io.Serializable

data class ChatShareThemeBackdrop(
@get:JvmName("id") val id: Long,
@get:JvmName("name") val name: String,
@get:JvmName("colors") val colors: UniqueGiftBackdropColors,
) : Serializable
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.pengrad.telegrambot.model.chatsharetheme

import java.io.Serializable

data class ChatShareThemeBackdrops(
@get:JvmName("backdrops") val backdrops: Array<ChatShareThemeBackdrop>,
) : Serializable {

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is ChatShareThemeBackdrops) return false
return backdrops contentEquals other.backdrops
}

override fun hashCode(): Int = backdrops.contentHashCode()

override fun toString(): String = "ChatShareThemeBackdrops(backdrops=${backdrops.contentToString()})"
}
Loading