Merge pull request #1145 from rubenlagus/dev

Dev
This commit is contained in:
Ruben Bermudez 2022-11-08 18:45:48 +00:00 committed by GitHub
commit 888e0deac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
107 changed files with 2583 additions and 477 deletions

View File

@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambots:6.1.0'
implementation 'org.telegram:telegrambots:6.3.0'
```
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.1.0)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.1.0)
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.3.0)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.3.0)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -1,3 +1,7 @@
### <a id="6.3.0"></a>6.3.0 ###
1. Update Api version [6.3](https://core.telegram.org/bots/api-changelog#November-5-2022)
2. Bug fixing: #1116
### <a id="6.1.0"></a>6.1.0 ###
1. Update Api version [6.1](https://core.telegram.org/bots/api-changelog#june-20-2022)
2. Add support for Long when setting the chatId: #1065

View File

@ -1,7 +1,7 @@
So, you just wanna program your own Telegram bot with TelegramBots? Let's see the fast version.
So, youd like to create your own Telegram bot with TelegramBots? Then Let's get You started quickly.
## Grab the library
First you need ot get the library and add it to your project. There are few possibilities for this:
First you need to acquire the library and add it to your project. There are several ways to do this:
1. If you use [Maven](https://maven.apache.org/), [Gradle](https://gradle.org/), etc; you should be able to import the dependency directly from [Maven Central Repository](http://mvnrepository.com/artifact/org.telegram/telegrambots). For example:
@ -11,23 +11,23 @@ First you need ot get the library and add it to your project. There are few poss
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
```
* With **Gradle**:
```gradle
implementation 'org.telegram:telegrambots:6.1.0'
implementation 'org.telegram:telegrambots:6.3.0'
```
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
3. Import the library *.jar* direclty to your project. You can find it [here](https://github.com/rubenlagus/TelegramBots/releases), don't forget to take last version, it usually is a good idea. Depending on the IDE you are using, the process to add a library is different, here is a video that may help with [Intellij](https://www.youtube.com/watch?v=NZaH4tjwMYg) or [Eclipse](https://www.youtube.com/watch?v=VWnfHkBgO1I)
2. Don't like the **Maven Central Repository**? It can also be grabbed from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
3. Import the library *.jar* direclty to your project. You can find it [here](https://github.com/rubenlagus/TelegramBots/releases), don't forget to fetch the latest version, it usually is a good idea. Depending on the IDE you are using, the process to add a library is different, here is a video that may help with [Intellij](https://www.youtube.com/watch?v=NZaH4tjwMYg) or [Eclipse](https://www.youtube.com/watch?v=VWnfHkBgO1I)
## Build our first bot
Now that we have the library, we can start coding. There are few steps to follow, in this tutorial (for the sake of simplicity), we are going to build a [Long Polling Bot](http://en.wikipedia.org/wiki/Push_technology#Long_polling):
## Building your first bot
Now that you have the library, you can start coding. There are few steps to follow, in this tutorial (for the sake of simplicity), we are going to build a [Long Polling Bot](http://en.wikipedia.org/wiki/Push_technology#Long_polling):
1. **Create your actual bot:**
1. **Creating your actual bot:**
The class must extends `TelegramLongPollingBot` and implement necessary methods:
```java
@ -99,7 +99,7 @@ Now that we have the library, we can start coding. There are few steps to follow
```
2. **Instantiate `TelegramBotsApi` and register our new bot:**
For this part, we need to actually perform 2 steps: _Instantiate Telegram Api_ and _Register our Bot_. In this tutorial, we are going to make it in our `main` method:
For this part, we need to actually perform 2 steps: _Instantiate Telegram Api_ and _Register our Bot_. In this tutorial, we are going to do it in our `main` method:
```java

View File

@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
```
* **Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:6.1.0'
implementation 'org.telegram:telegrambots-abilities:6.3.0'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)

16
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>6.1.0</version>
<version>6.3.0</version>
<modules>
<module>telegrambots</module>
@ -67,13 +67,13 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit.version>5.8.2</junit.version>
<mockito.version>4.6.1</mockito.version>
<mockitojupiter.version>4.6.1</mockitojupiter.version>
<jacksonanotation.version>2.13.2</jacksonanotation.version>
<jackson.version>2.13.2.2</jackson.version>
<json.version>20220320</json.version>
<slf4j.version>1.7.36</slf4j.version>
<junit.version>5.9.1</junit.version>
<mockito.version>4.8.1</mockito.version>
<mockitojupiter.version>4.8.1</mockitojupiter.version>
<jacksonanotation.version>2.14.0</jacksonanotation.version>
<jackson.version>2.14.0</jackson.version>
<json.version>20220924</json.version>
<slf4j.version>2.0.3</slf4j.version>
<jakarta.annotation.version>2.1.1</jakarta.annotation.version>
<lombok.version>1.18.24</lombok.version>
<guava.version>31.1-jre</guava.version>

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:6.1.0'
implementation 'org.telegram:telegrambots-abilities:6.3.0'
```
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</parent>
<artifactId>telegrambots-abilities</artifactId>
@ -84,7 +84,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

View File

@ -15,14 +15,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-chat-session-bot</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-chat-session-bot:6.1.0'
implementation 'org.telegram:telegrambots-chat-session-bot:6.3.0'
```
Motivation

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</parent>
<artifactId>telegrambots-chat-session-bot</artifactId>
@ -76,7 +76,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<shiro.version>1.9.0</shiro.version>
<shiro.version>1.10.0</shiro.version>
</properties>
<dependencies>
@ -84,7 +84,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->

View File

@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambotsextensions</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambotsextensions:6.1.0'
implementation 'org.telegram:telegrambotsextensions:6.3.0'
```

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</parent>
<artifactId>telegrambotsextensions</artifactId>
@ -75,7 +75,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
</dependencies>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</parent>
<artifactId>telegrambots-meta</artifactId>

View File

@ -25,7 +25,7 @@ import java.util.List;
* @version 1.0
* Use this method to copy messages of any kind.
* Service messages and invoice messages can't be copied.
*
* A quiz poll can be copied only if the value of the field correct_option_id is known to the bot.
* The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message.
* Returns the MessageId of the sent message on success.
*/
@ -42,6 +42,7 @@ public class CopyMessage extends BotApiMethod<MessageId> {
public static final String PATH = "copyMessage";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String FROMCHATID_FIELD = "from_chat_id";
private static final String MESSAGEID_FIELD = "message_id";
private static final String CAPTION_FIELD = "caption";
@ -56,6 +57,12 @@ public class CopyMessage extends BotApiMethod<MessageId> {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(FROMCHATID_FIELD)
@NonNull
private String fromChatId; ///< Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)

View File

@ -34,6 +34,7 @@ public class ForwardMessage extends BotApiMethodMessage {
public static final String PATH = "forwardmessage";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String FROMCHATID_FIELD = "from_chat_id";
private static final String MESSAGEID_FIELD = "message_id";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
@ -42,6 +43,12 @@ public class ForwardMessage extends BotApiMethodMessage {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(FROMCHATID_FIELD)
@NonNull
private String fromChatId; ///< Unique identifier for the chat where the original message was sent User or GroupChat id

View File

@ -0,0 +1,80 @@
package org.telegram.telegrambots.meta.api.methods.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 6.3
* Use this method to close an open topic in a forum supergroup chat.
* The bot must be an administrator in the chat for this to work and must have
* the can_manage_topics administrator rights, unless it is the creator of the topic.
*
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CloseForumTopic extends BotApiMethodBoolean {
public static final String PATH = "closeForumTopic";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
/**
* Unique identifier for the target chat or username
* of the target supergroup (in the format @supergroupusername)
*/
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId;
/**
* Unique identifier for the target message thread of the forum topic
*/
@JsonProperty(MESSAGETHREADID_FIELD)
@NonNull
private Integer messageThreadId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (messageThreadId <= 0) {
throw new TelegramApiValidationException("Message Thread Id can't be empty", this);
}
}
@Override
public String getMethod() {
return PATH;
}
public static class CloseForumTopicBuilder {
@Tolerate
public CloseForumTopicBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -0,0 +1,103 @@
package org.telegram.telegrambots.meta.api.methods.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.forum.ForumTopic;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 6.3
* Use this method to create a topic in a forum supergroup chat.
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
* Returns information about the created topic as a ForumTopic object.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@RequiredArgsConstructor
@AllArgsConstructor
@Builder
public class CreateForumTopic extends BotApiMethod<ForumTopic> {
public static final String PATH = "createForumTopic";
private static final String CHATID_FIELD = "chat_id";
private static final String NAME_FIELD = "name";
private static final String ICONCOLOR_FIELD = "icon_color";
private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id";
/**
* Unique identifier for the target chat or username
* of the target supergroup (in the format @supergroupusername)
*/
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId;
/**
* Topic name, 1-128 characters
*/
@JsonProperty(NAME_FIELD)
@NonNull
private String name;
/**
* Optional.
* Color of the topic icon in RGB format. Currently,
* must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F
*/
@JsonProperty(ICONCOLOR_FIELD)
private Integer iconColor;
/**
* Optional.
* Unique identifier of the custom emoji shown as the topic icon.
* Use getForumTopicIconStickers to get all allowed custom emoji identifiers
*/
@JsonProperty(ICONCUSTOMEMOJIID_FIELD)
private String iconCustomEmojiId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (name.isEmpty() || name.length() > 128) {
throw new TelegramApiValidationException("Name must be between 1 and 128 characters", this);
}
}
@Override
public String getMethod() {
return PATH;
}
@Override
public ForumTopic deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponse(answer, ForumTopic.class);
}
public static class CreateForumTopicBuilder {
@Tolerate
public CreateForumTopicBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -0,0 +1,80 @@
package org.telegram.telegrambots.meta.api.methods.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 6.3
* Use this method to delete a forum topic along with all its messages in a
* forum supergroup chat. The bot must be an administrator in the chat
* for this to work and must have the can_delete_messages administrator rights.
*
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DeleteForumTopic extends BotApiMethodBoolean {
public static final String PATH = "deleteForumTopic";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
/**
* Unique identifier for the target chat or username
* of the target supergroup (in the format @supergroupusername)
*/
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId;
/**
* Unique identifier for the target message thread of the forum topic
*/
@JsonProperty(MESSAGETHREADID_FIELD)
@NonNull
private Integer messageThreadId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (messageThreadId <= 0) {
throw new TelegramApiValidationException("Message Thread Id can't be empty", this);
}
}
@Override
public String getMethod() {
return PATH;
}
public static class DeleteForumTopicBuilder {
@Tolerate
public DeleteForumTopicBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -0,0 +1,102 @@
package org.telegram.telegrambots.meta.api.methods.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 6.3
* Use this method to edit name and icon of a topic in a forum supergroup chat.
* The bot must be an administrator in the chat for this to work and must have
* can_manage_topics administrator rights, unless it is the creator of the topic.
*
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class EditForumTopic extends BotApiMethodBoolean {
public static final String PATH = "editForumTopic";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String NAME_FIELD = "name";
private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id";
/**
* Unique identifier for the target chat or username
* of the target supergroup (in the format @supergroupusername)
*/
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId;
/**
* Unique identifier for the target message thread of the forum topic
*/
@JsonProperty(MESSAGETHREADID_FIELD)
@NonNull
private Integer messageThreadId;
/**
* Topic name, 1-128 characters
*/
@JsonProperty(NAME_FIELD)
@NonNull
private String name;
/**
* Optional.
* Unique identifier of the custom emoji shown as the topic icon.
* Use getForumTopicIconStickers to get all allowed custom emoji identifiers
*/
@JsonProperty(ICONCUSTOMEMOJIID_FIELD)
@NonNull
private String iconCustomEmojiId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (name.isEmpty() || name.length() > 128) {
throw new TelegramApiValidationException("Name must be between 1 and 128 characters", this);
}
if (messageThreadId <= 0) {
throw new TelegramApiValidationException("Message Thread Id can't be empty", this);
}
if (iconCustomEmojiId.isEmpty()) {
throw new TelegramApiValidationException("Icon Custom Emoji Id can't be empty", this);
}
}
@Override
public String getMethod() {
return PATH;
}
public static class EditForumTopicBuilder {
@Tolerate
public EditForumTopicBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -0,0 +1,45 @@
package org.telegram.telegrambots.meta.api.methods.forum;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.stickers.Sticker;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.ArrayList;
/**
* @author Ruben Bermudez
* @version 6.3
* Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters.
* Returns an Array of Sticker objects.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@Builder
public class GetForumTopicIconStickers extends BotApiMethod<ArrayList<Sticker>> {
private static final String PATH = "getForumTopicIconStickers";
@Override
public void validate() throws TelegramApiValidationException {
}
@Override
public String getMethod() {
return PATH;
}
@Override
public ArrayList<Sticker> deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponseArray(answer, Sticker.class);
}
}

View File

@ -0,0 +1,81 @@
package org.telegram.telegrambots.meta.api.methods.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 6.3
* Use this method to reopen a closed topic in a forum supergroup chat.
* The bot must be an administrator in the chat for this to work and must
* have the can_manage_topics administrator rights,
* unless it is the creator of the topic.
*
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ReopenForumTopic extends BotApiMethodBoolean {
public static final String PATH = "reopenForumTopic";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
/**
* Unique identifier for the target chat or username
* of the target supergroup (in the format @supergroupusername)
*/
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId;
/**
* Unique identifier for the target message thread of the forum topic
*/
@JsonProperty(MESSAGETHREADID_FIELD)
@NonNull
private Integer messageThreadId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (messageThreadId <= 0) {
throw new TelegramApiValidationException("Message Thread Id can't be empty", this);
}
}
@Override
public String getMethod() {
return PATH;
}
public static class ReopenForumTopicBuilder {
@Tolerate
public ReopenForumTopicBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -0,0 +1,80 @@
package org.telegram.telegrambots.meta.api.methods.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 6.3
* Use this method to clear the list of pinned messages in a forum topic.
* The bot must be an administrator in the chat for this to work and must
* have the can_pin_messages administrator right in the supergroup.
*
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class UnpinAllForumTopicMessages extends BotApiMethodBoolean {
public static final String PATH = "unpinAllForumTopicMessages";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
/**
* Unique identifier for the target chat or username
* of the target supergroup (in the format @supergroupusername)
*/
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId;
/**
* Unique identifier for the target message thread of the forum topic
*/
@JsonProperty(MESSAGETHREADID_FIELD)
@NonNull
private Integer messageThreadId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (messageThreadId <= 0) {
throw new TelegramApiValidationException("Message Thread Id can't be empty", this);
}
}
@Override
public String getMethod() {
return PATH;
}
public static class UnpinAllForumTopicMessagesBuilder {
@Tolerate
public UnpinAllForumTopicMessagesBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -64,11 +64,11 @@ public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
private static final String USER_ID_FIELD = "user_id";
@JsonProperty(CHATID_FIELD)
private String chatId; ///< Optional Required if inline_message_id is not specified. Unique identifier for the target chat (or username of the target channel in the format @channelusername)
private String chatId; ///< Optional. Required if inline_message_id is not specified. Unique identifier for the target chat (or username of the target channel in the format @channelusername)
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Optional Required if inline_message_id is not specified. Unique identifier of the sent message
private Integer messageId; ///< Optional. Required if inline_message_id is not specified. Unique identifier of the sent message
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
private String inlineMessageId; ///< Optional Required if chat_id and message_id are not specified. Identifier of the inline message
private String inlineMessageId; ///< Optional. Required if chat_id and message_id are not specified. Identifier of the inline message
@JsonProperty(USER_ID_FIELD)
@NonNull
private Long userId; ///<Target user id

View File

@ -46,6 +46,7 @@ public class PromoteChatMember extends BotApiMethodBoolean {
private static final String ISANONYMOUS_FIELD = "is_anonymous";
private static final String CANMANAGECHAT_FIELD = "can_manage_chat";
private static final String CANMANAGEVIDEOCHATS_FIELD = "can_manage_video_chats";
private static final String CANMANAGETOPICS_FIELD = "can_manage_topics";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -87,6 +88,12 @@ public class PromoteChatMember extends BotApiMethodBoolean {
*/
@JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
private Boolean canManageVideoChats;
/**
* Optional.
* True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
*/
@JsonProperty(CANMANAGETOPICS_FIELD)
private Boolean canManageTopics;
@Tolerate
public void setChatId(@NonNull Long chatId) {

View File

@ -40,7 +40,7 @@ public class SetChatTitle extends BotApiMethodBoolean {
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(TITLE_FIELD)
@NonNull
private String title; ///< Required. New chat title, 1-255 characters
private String title; ///< Required. New chat title, 1-128 characters
@Tolerate
public void setChatId(@NonNull Long chatId) {

View File

@ -1,7 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.invoices;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.Strings;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -14,19 +13,17 @@ import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.List;
/**
* @author Ruben Bermudez
* @version 6.1
* Use this method to create a link for an invoice. On success, the created link is returned.
* Use this method to create a link for an invoice.
* Retruns the created invoice link as String on success
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -36,7 +33,7 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CreateInvoiceLink extends BotApiMethod<Message> {
public class CreateInvoiceLink extends BotApiMethod<String> {
public static final String PATH = "createInvoiceLink";
public static final String TITLE_FIELD = "title";
@ -135,21 +132,6 @@ public class CreateInvoiceLink extends BotApiMethod<Message> {
return PATH;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Message> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Message>>(){});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error sending invoice", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
@Override
public void validate() throws TelegramApiValidationException {
if (Strings.isNullOrEmpty(title) || title.length() > 32) {
@ -178,4 +160,9 @@ public class CreateInvoiceLink extends BotApiMethod<Message> {
throw new TelegramApiValidationException("No more that 4 suggested tips allowed", this);
}
}
@Override
public String deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponse(answer, String.class);
}
}

View File

@ -1,7 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.invoices;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.Strings;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -14,15 +13,11 @@ import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodMessage;
import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.List;
/**
@ -38,10 +33,11 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SendInvoice extends BotApiMethod<Message> {
public class SendInvoice extends BotApiMethodMessage {
public static final String PATH = "sendinvoice";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String PAYLOAD_FIELD = "payload";
@ -72,6 +68,12 @@ public class SendInvoice extends BotApiMethod<Message> {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(TITLE_FIELD)
@NonNull
private String title; ///< Product name
@ -176,21 +178,6 @@ public class SendInvoice extends BotApiMethod<Message> {
return PATH;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Message> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Message>>(){});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error sending invoice", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
@Override
public void validate() throws TelegramApiValidationException {
if (Strings.isNullOrEmpty(chatId)) {

View File

@ -40,6 +40,7 @@ public class SendPoll extends BotApiMethodMessage {
public static final String PATH = "sendPoll";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String QUESTION_FIELD = "question";
private static final String OPTIONS_FIELD = "options";
private static final String ISANONYMOUS_FIELD = "is_anonymous";
@ -65,6 +66,12 @@ public class SendPoll extends BotApiMethodMessage {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(QUESTION_FIELD)
@NonNull
private String question; ///< Poll question, 1-300 characters

View File

@ -41,6 +41,7 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
public static final String PATH = "sendAnimation";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String ANIMATION_FIELD = "animation";
public static final String DURATION_FIELD = "duration";
public static final String WIDTH_FIELD = "width";
@ -62,6 +63,11 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
* Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation
* from the Internet, or upload a new animation using multipart/form-data.
*/
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile animation;
private Integer duration; ///< Optional. Duration of sent animation in seconds

View File

@ -43,6 +43,7 @@ public class SendAudio extends PartialBotApiMethod<Message> {
public static final String DURATION_FIELD = "duration";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String AUDIO_FIELD = "audio";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
@ -58,6 +59,11 @@ public class SendAudio extends PartialBotApiMethod<Message> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers or Url to upload it
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message

View File

@ -33,6 +33,7 @@ public class SendContact extends BotApiMethodMessage {
public static final String PATH = "sendContact";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String PHONE_NUMBER_FIELD = "phone_number";
private static final String FIRST_NAME_FIELD = "first_name";
private static final String LAST_NAME_FIELD = "last_name";
@ -46,6 +47,12 @@ public class SendContact extends BotApiMethodMessage {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(PHONE_NUMBER_FIELD)
@NonNull
private String phoneNumber; ///< User's phone number

View File

@ -38,6 +38,7 @@ public class SendDice extends BotApiMethodMessage {
public static final String PATH = "sendDice";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String EMOJI_FIELD = "emoji";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
@ -45,9 +46,18 @@ public class SendDice extends BotApiMethodMessage {
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String PROTECTCONTENT_FIELD = "protect_content";
/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
private String chatId;
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
/**
* Optional.
*

View File

@ -38,6 +38,7 @@ public class SendDocument extends PartialBotApiMethod<Message> {
public static final String PATH = "senddocument";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String DOCUMENT_FIELD = "document";
public static final String CAPTION_FIELD = "caption";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
@ -52,6 +53,11 @@ public class SendDocument extends PartialBotApiMethod<Message> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers or Url to upload it
private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters

View File

@ -49,6 +49,8 @@ public class SendGame extends BotApiMethodMessage {
public static final String PATH = "sendGame";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String GAMESHORTNAME_FIELD = "game_short_name";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
@ -59,6 +61,12 @@ public class SendGame extends BotApiMethodMessage {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(GAMESHORTNAME_FIELD)
@NonNull
private String gameShortName; ///< Short name of the game

View File

@ -32,6 +32,8 @@ public class SendLocation extends BotApiMethodMessage {
public static final String PATH = "sendlocation";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
@ -47,6 +49,12 @@ public class SendLocation extends BotApiMethodMessage {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(LATITUDE_FIELD)
@NonNull
private Double latitude; ///< Latitude of location

View File

@ -1,6 +1,5 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@ -44,23 +43,24 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
public static final String PATH = "sendMediaGroup";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String MEDIA_FIELD = "media";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(MEDIA_FIELD)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private List<InputMedia> medias; ///< A JSON-serialized array describing photos and videos to be sent, must include 210 items
@JsonProperty(REPLYTOMESSAGEID_FIELD)
private Integer replyToMessageId; ///< Optional. If the messages are a reply, ID of the original message
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification; ///< Optional. Sends the messages silently. Users will receive a notification with no sound.
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving

View File

@ -38,6 +38,7 @@ public class SendMessage extends BotApiMethodMessage {
public static final String PATH = "sendmessage";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String TEXT_FIELD = "text";
private static final String PARSEMODE_FIELD = "parse_mode";
private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@ -51,6 +52,12 @@ public class SendMessage extends BotApiMethodMessage {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(TEXT_FIELD)
@NonNull
private String text; ///< Text of the message to be sent

View File

@ -39,6 +39,7 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
public static final String PATH = "sendphoto";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String PHOTO_FIELD = "photo";
public static final String CAPTION_FIELD = "caption";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
@ -51,6 +52,11 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers or URL to upload it
private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).

View File

@ -35,6 +35,7 @@ public class SendSticker extends PartialBotApiMethod<Message> {
public static final String PATH = "sendsticker";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String STICKER_FIELD = "sticker";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
@ -44,6 +45,11 @@ public class SendSticker extends PartialBotApiMethod<Message> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers or URL to upload it
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.

View File

@ -33,6 +33,7 @@ public class SendVenue extends BotApiMethodMessage {
public static final String PATH = "sendVenue";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
private static final String TITLE_FIELD = "title";
@ -50,6 +51,12 @@ public class SendVenue extends BotApiMethodMessage {
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
@JsonProperty(LATITUDE_FIELD)
@NonNull
private Double latitude; ///< Latitude of venue location

View File

@ -39,6 +39,7 @@ public class SendVideo extends PartialBotApiMethod<Message> {
public static final String PATH = "sendvideo";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String VIDEO_FIELD = "video";
public static final String DURATION_FIELD = "duration";
public static final String CAPTION_FIELD = "caption";
@ -56,6 +57,11 @@ public class SendVideo extends PartialBotApiMethod<Message> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers or URL to upload it
private Integer duration; ///< Optional. Duration of sent video in seconds

View File

@ -36,6 +36,7 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
public static final String PATH = "sendvideonote";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String VIDEONOTE_FIELD = "video_note";
public static final String DURATION_FIELD = "duration";
public static final String LENGTH_FIELD = "length";
@ -48,6 +49,11 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile videoNote; ///< Videonote to send. file_id as String to resend a video that is already on the Telegram servers.
private Integer duration; ///< Optional. Duration of sent video in seconds

View File

@ -40,6 +40,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
public static final String PATH = "sendvoice";
public static final String CHATID_FIELD = "chat_id";
public static final String MESSAGETHREADID_FIELD = "message_thread_id";
public static final String VOICE_FIELD = "voice";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
@ -53,6 +54,11 @@ public class SendVoice extends PartialBotApiMethod<Message> {
@NonNull
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
/**
* Unique identifier for the target message thread (topic) of the forum;
* for forum supergroups only
*/
private Integer messageThreadId;
@NonNull
private InputFile voice; ///< Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.

View File

@ -9,12 +9,17 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.CopyMessage;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.stickers.MaskPosition;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.Arrays;
import java.util.List;
/**
* @author Ruben Bermudez
* @version 1.0
@ -36,6 +41,8 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
public static final String USERID_FIELD = "user_id";
public static final String NAME_FIELD = "name";
public static final String STICKERTYPE_FIELD = "sticker_type";
public static final String TITLE_FIELD = "title";
public static final String PNGSTICKER_FIELD = "png_sticker";
public static final String TGSSTICKER_FIELD = "tgs_sticker";
@ -46,6 +53,13 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
@NonNull
private Long userId; ///< User identifier of created sticker set owner
/**
* Type of stickers in the set, pass regular or mask.
* Custom emoji sticker sets can't be created via the Bot API at the moment.
* By default, a regular sticker set is created.
*/
@Builder.Default
private String stickerType = "regular";
/**
* Name of sticker set, to be used in t.me/addstickers/<name> URLs.
* Can contain only english letters, digits and underscores.
@ -58,7 +72,6 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
private String title; ///< User identifier of created sticker set owner
@NonNull
private String emojis; ///< One or more emoji corresponding to the sticker
private Boolean containsMasks; ///< Optional. Pass True, if a set of mask stickers should be created
private MaskPosition maskPosition; ///< Optional. Position where the mask should be placed on faces
/**
* Optional.
@ -84,6 +97,33 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
*/
private InputFile webmSticker;
/**
* @deprecated Use {@link #setStickerType(String)}
*/
@Deprecated
public void setContainsMasks(boolean containsMasks) {
if (containsMasks) {
this.stickerType = "mask";
} else {
this.stickerType = "regular";
}
}
/**
* @deprecated Use {@link #getStickerType()} or {@link #isMask()}
*/
@Deprecated
public Boolean getContainsMasks() {
return isMask();
}
public boolean isRegularSticker() {
return "regular".equals(stickerType);
}
public boolean isMask() {
return "mask".equals(stickerType);
}
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponse(answer, Boolean.class);
@ -94,6 +134,9 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
if (userId <= 0) {
throw new TelegramApiValidationException("userId can't be empty", this);
}
if (!Arrays.asList("regular", "mask").contains(stickerType)) {
throw new TelegramApiValidationException("Stickertype must be 'regular' or 'mask'", this);
}
if (name.isEmpty()) {
throw new TelegramApiValidationException("name can't be empty", this);
}
@ -129,4 +172,20 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
maskPosition.validate();
}
}
public static class CreateNewStickerSetBuilder {
/**
* @deprecated Use {@link #stickerType(String)} or {@link #setStickerType(String)}
*/
@Tolerate
@Deprecated
public CreateNewStickerSet.CreateNewStickerSetBuilder containsMasks(@NonNull Boolean containsMasks) {
if (containsMasks) {
this.stickerType("mask");
} else {
this.stickerType("regular");
}
return this;
}
}
}

View File

@ -0,0 +1,57 @@
package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
import org.telegram.telegrambots.meta.api.objects.games.GameHighScore;
import org.telegram.telegrambots.meta.api.objects.stickers.Sticker;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.ArrayList;
import java.util.List;
/**
* @author Ruben Bermudez
* @version 6.2
* Use this method to get information about emoji stickers by their identifiers.
* Returns an Array of Sticker on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GetCustomEmojiStickers extends BotApiMethod<ArrayList<Sticker>> {
private static final String PATH = "getCustomEmojiStickers";
private static final String CUSTOMEMOJIID_FIELD = "custom_emoji_ids";
/**
* List of custom emoji identifiers.
* At most 200 custom emoji identifiers can be specified.
*/
@Singular
@JsonProperty(CUSTOMEMOJIID_FIELD)
private List<String> customEmojiIds;
@Override
public void validate() throws TelegramApiValidationException {
if (customEmojiIds == null || customEmojiIds.isEmpty() || customEmojiIds.size() > 200) {
throw new TelegramApiValidationException("CustomEmojiIds must be between 1 and 200", this);
}
}
@Override
public String getMethod() {
return PATH;
}
@Override
public ArrayList<Sticker> deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponseArray(answer, Sticker.class);
}
}

View File

@ -24,6 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
* - Bots granted can_post_messages permissions can delete outgoing messages in channels.
* - If the bot is an administrator of a group, it can delete any message there.
* - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
* - Service messages about a supergroup, channel, or forum topic creation can't be deleted
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents an audio file
* @author Ruben Bermudez
* @version 1.0
* This object represents an audio file
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -32,18 +32,28 @@ public class Audio implements BotApiObject {
private static final String THUMB_FIELD = "thumb";
private static final String FILENAME_FIELD = "file_name";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
*/
@JsonProperty(FILEUNIQUEID_FIELD)
private String fileUniqueId;
/**
* Integer Duration of the audio in seconds as defined by sender
*/
@JsonProperty(DURATION_FIELD)
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
private Integer duration;
/**
* Optional.
* MIME type of the file as defined by sender
*/
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Optional. MIME type of the file as defined by sender
private String mimeType;
/**
* Optional.
* File size in bytes.
@ -52,12 +62,28 @@ public class Audio implements BotApiObject {
*/
@JsonProperty(FILESIZE_FIELD)
private Long fileSize;
/**
* Optional.
* Title of the audio as defined by sender or by audio tags
*/
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title of the audio as defined by sender or by audio tags
private String title;
/**
* Optional.
* Performer of the audio as defined by sender or by audio tags
*/
@JsonProperty(PERFORMER_FIELD)
private String performer; ///< Optional. Performer of the audio as defined by sender or by audio tags
private String performer;
/**
* Optional.
* Thumbnail of the album cover to which the music file belongs
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb; ///< Optional. Thumbnail of the album cover to which the music file belongs
private PhotoSize thumb;
/**
* Optional.
* Original filename as defined by sender
*/
@JsonProperty(FILENAME_FIELD)
private String fileName; ///< Optional. Original filename as defined by sender
private String fileName;
}

View File

@ -10,8 +10,6 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 1.0
* This object represents an incoming callback query from a
* callback button in an inline keyboard.
* If the button that originated the query was attached to a message sent by the bot,
@ -22,6 +20,8 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
* until you call answerCallbackQuery. It is, therefore, necessary to react by
* calling answerCallbackQuery even if no notification to the user is needed
* (e.g., without specifying any of the optional parameters).
* @author Ruben Bermudez
* @version 1.0
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -39,10 +39,16 @@ public class CallbackQuery implements BotApiObject {
private static final String GAMESHORTNAME_FIELD = "game_short_name";
private static final String CHAT_INSTANCE_FIELD = "chat_instance";
/**
* Unique identifier for this query
*/
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier for this query
private String id;
/**
* Sender
*/
@JsonProperty(FROM_FIELD)
private User from; ///< Sender
private User from;
/**
* Optional.
* Message with the callback button that originated the query.
@ -51,8 +57,12 @@ public class CallbackQuery implements BotApiObject {
*/
@JsonProperty(MESSAGE_FIELD)
private Message message;
/**
* Optional.
* Identifier of the message sent via the bot in inline mode, that originated the query
*/
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
private String inlineMessageId; ///< Optional. Identifier of the message sent via the bot in inline mode, that originated the query
private String inlineMessageId;
/**
*
* Optional. Data associated with the callback button.

View File

@ -12,10 +12,12 @@ import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import java.util.List;
/**
* This object represents a Telegram chat with an user or a group
* @author Ruben Bermudez
* @version 6.1
* This object represents a Telegram chat with an user or a group
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@ -49,6 +51,10 @@ public class Chat implements BotApiObject {
private static final String HASPROTECTEDCONTENT_FIELD = "has_protected_content";
private static final String JOINTOSENDMESSAGES_FIELD = "join_to_send_messages";
private static final String JOINBYREQUEST_FIELD = "join_by_request";
private static final String HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD = "has_restricted_voice_and_video_messages";
private static final String ISFORUM_FIELD = "is_forum";
private static final String ACTIVEUSERNAMES_FIELD = "active_usernames";
private static final String EMOJISTATUSCUSTOMEMOJIID_FIELD = "emoji_status_custom_emoji_id";
private static final String USERCHATTYPE = "private";
private static final String GROUPCHATTYPE = "group";
@ -63,32 +69,79 @@ public class Chat implements BotApiObject {
*/
@JsonProperty(ID_FIELD)
@NonNull
private Long id; ///< Unique identifier for this chat, not exceeding 1e13 by absolute value
private Long id;
/**
* Type of the chat, one of private, group or channel or "supergroup"
*/
@JsonProperty(TYPE_FIELD)
@NonNull
private String type; ///< Type of the chat, one of private, group or channel or "supergroup"
private String type;
/**
* Optional.
* Title of the chat, only for channels and group chat
*/
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title of the chat, only for channels and group chat
private String title;
/**
* Optional
* Username of the chat, only for private chats and channels if available
*/
@JsonProperty(FIRSTNAME_FIELD)
private String firstName; ///< Optional. Username of the chat, only for private chats and channels if available
private String firstName;
/**
* Optional.
* Interlocutor's first name for private chats
*/
@JsonProperty(LASTNAME_FIELD)
private String lastName; ///< Optional. Interlocutor's first name for private chats
private String lastName;
/**
* Optional.
* Interlocutor's last name for private chats
*/
@JsonProperty(USERNAME_FIELD)
private String userName; ///< Optional. Interlocutor's last name for private chats
private String userName;
/**
* Optional.
* Chat photo. Returned only in getChat.
*/
@JsonProperty(PHOTO_FIELD)
private ChatPhoto photo; ///< Optional. Chat photo. Returned only in getChat.
private ChatPhoto photo;
/**
* Optional.
* Description, for groups, supergroups and channel chats. Returned only in getChat.
*/
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Description, for groups, supergroups and channel chats. Returned only in getChat.
private String description;
/**
* Optional.
* Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.
*/
@JsonProperty(INVITELINK_FIELD)
private String inviteLink; ///< Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.
private String inviteLink;
/**
* Optional.
* The most recent pinned message (by sending date). Returned only in getChat.
*/
@JsonProperty(PINNEDMESSAGE_FIELD)
private Message pinnedMessage; ///< Optional. The most recent pinned message (by sending date). Returned only in getChat.
private Message pinnedMessage;
/**
* Optional.
* For supergroups, name of Group sticker set. Returned only in getChat.
*/
@JsonProperty(STICKERSETNAME_FIELD)
private String stickerSetName; ///< Optional. For supergroups, name of Group sticker set. Returned only in getChat.
private String stickerSetName;
/**
* Optional.
* True, if the bot can change group the sticker set. Returned only in getChat.
*/
@JsonProperty(CANSETSTICKERSET_FIELD)
private Boolean canSetStickerSet; ///< Optional. True, if the bot can change group the sticker set. Returned only in getChat.
private Boolean canSetStickerSet;
/**
* Optional.
* Default chat member permissions, for groups and supergroups. Returned only in getChat.
*/
@JsonProperty(PERMISSIONS_FIELD)
private ChatPermissions permissions; ///< Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
private ChatPermissions permissions;
/**
* Optional.
* For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user.
@ -96,8 +149,12 @@ public class Chat implements BotApiObject {
*/
@JsonProperty(SLOWMODEDELAY_FIELD)
private Integer slowModeDelay;
/**
* Optional.
* Bio of the other party in a private chat. Returned only in getChat.
*/
@JsonProperty(BIO_FIELD)
private String bio; ///< Optional. Bio of the other party in a private chat. Returned only in getChat.
private String bio;
/**
* Optional.
* Unique identifier for the linked chat,
@ -110,10 +167,16 @@ public class Chat implements BotApiObject {
*/
@JsonProperty(LINKEDCHATID_FIELD)
private Long linkedChatId;
/**
* Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
*/
@JsonProperty(LOCATION_FIELD)
private ChatLocation location; ///< Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
private ChatLocation location;
/**
* Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.
*/
@JsonProperty(MESSAGEAUTODELETETIME_FIELD)
private Integer messageAutoDeleteTime; ///< Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.
private Integer messageAutoDeleteTime;
/**
* Optional.
* True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user.
@ -142,6 +205,36 @@ public class Chat implements BotApiObject {
*/
@JsonProperty(JOINBYREQUEST_FIELD)
private Boolean joinByRequest;
/**
* Optional.
* True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat.
* Returned only in getChat.
*/
@JsonProperty(HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD)
private Boolean hasRestrictedVoiceAndVideoMessages;
/**
* Optional.
* True, if the supergroup chat is a forum (has topics enabled)
*/
@JsonProperty(ISFORUM_FIELD)
private Boolean isForum;
/**
* Optional.
* If non-empty, the list of all active chat usernames; for private chats, supergroups and channels.
* Returned only in getChat.
*/
@JsonProperty(ACTIVEUSERNAMES_FIELD)
private List<String> activeUsernames;
/**
* Optional.
* Custom emoji identifier of emoji status of the other party in a private chat.
* Returned only in getChat.
*/
@JsonProperty(EMOJISTATUSCUSTOMEMOJIID_FIELD)
private String emojiStatusCustomEmojiId;
@JsonIgnore
public Boolean isGroupChat() {

View File

@ -10,10 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* Represents an invite link for a chat.
* @author Ruben Bermudez
* @version 5.1
*
* Represents an invite link for a chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -38,25 +37,45 @@ public class ChatInviteLink implements BotApiObject {
*/
@JsonProperty(INVITELINK_FIELD)
private String inviteLink;
/**
* Creator of the link
*/
@JsonProperty(CREATOR_FIELD)
private User creator; ///< Creator of the link
private User creator;
/**
* True, if the link is primary
*/
@JsonProperty(ISPRIMARY_FIELD)
private Boolean isPrimary; ///< True, if the link is primary
private Boolean isPrimary;
/**
* True, if the link is revoked
*/
@JsonProperty(ISREVOKED_FIELD)
private Boolean isRevoked; ///< True, if the link is revoked
@JsonProperty(EXPIREDATE_FIELD)
private Integer expireDate; ///< Optional. Point in time (Unix timestamp) when the link will expire or has been expired
private Boolean isRevoked;
/**
* Optional.
* Point in time (Unix timestamp) when the link will expire or has been expired
*/
@JsonProperty(EXPIREDATE_FIELD)
private Integer expireDate;
/**
* Optional.
*
* Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
*/
@JsonProperty(MEMBERLIMIT_FIELD)
private Integer memberLimit;
/**
* Optional.
* Invite link name
*/
@JsonProperty(NAME_FIELD)
private String name; ///< Optional. Invite link name
private String name;
/**
* Optional.
* Number of pending join requests created using this link
*/
@JsonProperty(PENDINGJOINREQUESTCOUNT_FIELD)
private Integer pendingJoinRequestCount; ///< Optional. Number of pending join requests created using this link
private Integer pendingJoinRequestCount;
/**
* True, if users joining the chat via the link need to be approved by chat administrators
*/

View File

@ -5,10 +5,9 @@ import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* Represents a join request sent to a chat.
* @author Ruben Bermudez
* @version 5.4
*
* Represents a join request sent to a chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -23,15 +22,31 @@ public class ChatJoinRequest implements BotApiObject {
private static final String BIO_FIELD = "bio";
private static final String INVITELINK_FIELD = "invite_link";
/**
* Chat to which the request was sent
*/
@JsonProperty(CHAT_FIELD)
private Chat chat; ///< Chat to which the request was sent
private Chat chat;
/**
* User that sent the join request
*/
@JsonProperty(FROM_FIELD)
private User user; ///< User that sent the join request
private User user;
/**
* Date the request was sent in Unix time
*/
@JsonProperty(DATE_FIELD)
private Integer date; ///< Date the request was sent in Unix time
private Integer date;
/**
* Optional.
* Bio of the user.
*/
@JsonProperty(BIO_FIELD)
private String bio; ///< Optional. Bio of the user.
private String bio;
/**
* Optional.
* Chat invite link that was used by the user to send the join request
*/
@JsonProperty(INVITELINK_FIELD)
private ChatInviteLink inviteLink; ///< Optional. Chat invite link that was used by the user to send the join request
private ChatInviteLink inviteLink;
}

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* Represents a location to which a chat is connected.
* @author Ruben Bermudez
* @version 5.0
* Represents a location to which a chat is connected.
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@ -26,8 +26,14 @@ public class ChatLocation implements BotApiObject {
private static final String LOCATION_FIELD = "location";
private static final String ADDRESS_FIELD = "address";
/**
* The location to which the supergroup is connected
*/
@JsonProperty(LOCATION_FIELD)
private Location location; ///< The location to which the supergroup is connected
private Location location;
/**
* Location address; 1-64 characters, as defined by the chat owner
*/
@JsonProperty(ADDRESS_FIELD)
private String address; ///< Location address; 1-64 characters, as defined by the chat owner
private String address;
}

View File

@ -29,17 +29,36 @@ public class ChatMemberUpdated implements BotApiObject {
private static final String NEWCHATMEMBER_FIELD = "new_chat_member";
private static final String INVITELINK_FIELD = "invite_link";
/**
* Chat the user belongs to
*/
@JsonProperty(CHAT_FIELD)
private Chat chat; ///< Chat the user belongs to
private Chat chat;
/**
* Performer of the action, which resulted in the change
*/
@JsonProperty(FROM_FIELD)
private User from; ///< Performer of the action, which resulted in the change
private User from;
/**
* Date the change was done in Unix time
*/
@JsonProperty(DATE_FIELD)
private Integer date; ///< Date the change was done in Unix time
private Integer date;
/**
* Previous information about the chat member
*/
@JsonProperty(OLDCHATMEMBER_FIELD)
private ChatMember oldChatMember; ///< Previous information about the chat member
private ChatMember oldChatMember;
/**
* New information about the chat member
*/
@JsonProperty(NEWCHATMEMBER_FIELD)
private ChatMember newChatMember; ///< New information about the chat member
private ChatMember newChatMember;
/**
* Optional.
* Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
*/
@JsonProperty(INVITELINK_FIELD)
private ChatInviteLink inviteLink; ///< Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
private ChatInviteLink inviteLink;
}

View File

@ -11,11 +11,11 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 4.4
* Use this method to change the description of a group, supergroup or channel.
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* Returns True on success.
* @author Ruben Bermudez
* @version 4.4
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -34,20 +34,52 @@ public class ChatPermissions implements BotApiObject {
private static final String CAN_INVITE_USERS_FIELD = "can_invite_users";
private static final String CAN_PIN_MESSAGES_FIELD = "can_pin_messages";
/**
* Optional.
* True, if the user is allowed to send text messages, contacts, locations and venues
*/
@JsonProperty(CAN_SEND_MESSAGES_FIELD)
private Boolean canSendMessages; ///< Optional. True, if the user is allowed to send text messages, contacts, locations and venues
private Boolean canSendMessages;
/**
* Optional.
* True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
*/
@JsonProperty(CAN_SEND_MEDIA_MESSAGES_FIELD)
private Boolean canSendMediaMessages; ///< Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
private Boolean canSendMediaMessages;
/**
* Optional.
* True, if the user is allowed to send polls, implies can_send_messages
*/
@JsonProperty(CAN_SEND_POLLS_FIELD)
private Boolean canSendPolls; ///< Optional. True, if the user is allowed to send polls, implies can_send_messages
private Boolean canSendPolls;
/**
* Optional.
* True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages
*/
@JsonProperty(CAN_SEND_OTHER_MESSAGES_FIELD)
private Boolean canSendOtherMessages; ///< Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages
private Boolean canSendOtherMessages;
/**
* Optional.
* True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages
*/
@JsonProperty(CAN_ADD_WEB_PAGE_PREVIEWS_FIELD)
private Boolean canAddWebPagePreviews; ///< Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages
private Boolean canAddWebPagePreviews;
/**
* Optional.
* True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups
*/
@JsonProperty(CAN_CHANGE_INFO_FIELD)
private Boolean canChangeInfo; ///< Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups
private Boolean canChangeInfo;
/**
* Optional.
* True, if the user is allowed to invite new users to the chat
*/
@JsonProperty(CAN_INVITE_USERS_FIELD)
private Boolean canInviteUsers; ///< Optional. True, if the user is allowed to invite new users to the chat
private Boolean canInviteUsers;
/**
* Optional.
* True, if the user is allowed to pin messages. Ignored in public supergroups
*/
@JsonProperty(CAN_PIN_MESSAGES_FIELD)
private Boolean canPinMessages; ///< Optional. True, if the user is allowed to pin messages. Ignored in public supergroups
private Boolean canPinMessages;
}

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a phone contact.
* @author Ruben Bermudez
* @version 1.0
* This object represents a phone contact.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -28,12 +28,22 @@ public class Contact implements BotApiObject {
private static final String USERID_FIELD = "user_id";
private static final String VCARD_FIELD = "vcard";
/**
* Contact's phone number
*/
@JsonProperty(PHONENUMBER_FIELD)
private String phoneNumber; ///< Contact's phone number
private String phoneNumber;
/**
* Contact's first name
*/
@JsonProperty(FIRSTNAME_FIELD)
private String firstName; ///< Contact's first name
private String firstName;
/**
* Optional.
* Contact's last name
*/
@JsonProperty(LASTNAME_FIELD)
private String lastName; ///< Optional. Contact's last name
private String lastName;
/**
* Optional.
* Contact's user identifier in Telegram.
@ -41,8 +51,16 @@ public class Contact implements BotApiObject {
* @apiNote This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
* But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
*/
/**
* Optional.
* Contact's user identifier in Telegram
*/
@JsonProperty(USERID_FIELD)
private Long userId; ///< Optional. Contact's user identifier in Telegram
private Long userId;
/**
* Optional.
* Additional data about the contact in the form of a vCard
*/
@JsonProperty(VCARD_FIELD)
private String vCard; ///< Optional. Additional data about the contact in the form of a vCard
private String vCard;
}

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents an animated emoji that displays a random value.
* @author Ruben Bermudez
* @version 4.7
* This object represents an animated emoji that displays a random value.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -32,6 +32,9 @@ public class Dice implements BotApiObject {
*/
@JsonProperty(VALUE_FIELD)
private Integer value;
/**
* Emoji on which the dice throw animation is based
*/
@JsonProperty(EMOJI_FIELD)
private String emoji; ///< Emoji on which the dice throw animation is based
private String emoji;
}

View File

@ -10,10 +10,10 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 1.0
* This object represents a general file (as opposed to photos and audio files).
* Telegram users can send files of any type of up to 1.5 GB in size.
* @author Ruben Bermudez
* @version 1.0
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -30,20 +30,34 @@ public class Document implements BotApiObject {
private static final String MIMETYPE_FIELD = "mime_type";
private static final String FILESIZE_FIELD = "file_size";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
*/
@JsonProperty(FILEUNIQUEID_FIELD)
private String fileUniqueId;
/**
* Document thumbnail as defined by sender
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb; ///< Document thumbnail as defined by sender
private PhotoSize thumb;
/**
* Optional.
* Original filename as defined by sender
*/
@JsonProperty(FILENAME_FIELD)
private String fileName; ///< Optional. Original filename as defined by sender
private String fileName;
/**
* Optional.
* Mime type of a file as defined by sender
*/
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Optional. Mime type of a file as defined by sender
private String mimeType;
/**
* Optional.
* File size in bytes.

View File

@ -1,26 +1,68 @@
package org.telegram.telegrambots.meta.api.objects;
/**
* Types of messages entities
* @author Ruben Bermudez
* @version 1.0
* Types of messages entities
*/
@SuppressWarnings("WeakerAccess")
public class EntityType {
public static final String MENTION = "mention"; ///< @username
public static final String HASHTAG = "hashtag"; ///< #hashtag
public static final String CASHTAG = "cashtag"; ///< $USD
public static final String BOTCOMMAND = "bot_command"; ///< /botcommand
public static final String URL = "url"; ///< http://url.url
public static final String EMAIL = "email"; ///< email@email.com
public static final String PHONENUMBER = "phone_number"; ///< +4299999999
public static final String BOLD = "bold"; ///< Bold text
public static final String ITALIC = "italic"; ///< Italic text
public static final String CODE = "code"; ///< Monowidth string
public static final String PRE = "pre"; ///< Monowidth block
public static final String TEXTLINK = "text_link"; ///< Clickable urls
public static final String TEXTMENTION = "text_mention"; ///< for users without usernames
public static final String SPOILER = "spoiler"; ///< spoiler message
/**
* @username
*/
public static final String MENTION = "mention";
/**
* #hashtag
*/
public static final String HASHTAG = "hashtag";
/**
* $USD
*/
public static final String CASHTAG = "cashtag";
/**
* /botcommand
*/
public static final String BOTCOMMAND = "bot_command";
/**
* http://url.url
*/
public static final String URL = "url";
/**
* email@email.com
*/
public static final String EMAIL = "email";
/**
* +4299999999
*/
public static final String PHONENUMBER = "phone_number";
/**
* Bold text
*/
public static final String BOLD = "bold";
/**
* Italic text
*/
public static final String ITALIC = "italic";
/**
* Monowidth string
*/
public static final String CODE = "code";
/**
* Monowidth block
*/
public static final String PRE = "pre";
/**
* Clickable urls
*/
public static final String TEXTLINK = "text_link";
/**
* for users without usernames
*/
public static final String TEXTMENTION = "text_mention";
/**
* spoiler message
*/
public static final String SPOILER = "spoiler";
private EntityType() {
}

View File

@ -13,9 +13,9 @@ import java.security.InvalidParameterException;
import java.text.MessageFormat;
/**
* This object represents a file ready to be downloaded
* @author Ruben Bermudez
* @version 1.0
* This object represents a file ready to be downloaded
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -29,8 +29,11 @@ public class File implements BotApiObject {
private static final String FILE_SIZE_FIELD = "file_size";
private static final String FILE_PATH_FIELD = "file_path";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
@ -45,8 +48,11 @@ public class File implements BotApiObject {
*/
@JsonProperty(FILE_SIZE_FIELD)
private Long fileSize;
/**
* Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
*/
@JsonProperty(FILE_PATH_FIELD)
private String filePath; ///< Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
private String filePath;
public String getFileUrl(String botToken) {
return getFileUrl(botToken, filePath);

View File

@ -14,10 +14,9 @@ import java.io.File;
import java.io.InputStream;
/**
* Input file used to upload a file to Telegram server and use it afterwards
* @author Ruben Bermudez
* @version 4.0.0
*
* Input file used to upload a file to Telegram server and use it afterwards
*/
@SuppressWarnings({"WeakerAccess", "UnusedReturnValue"})
@JsonSerialize(using = InputFileSerializer.class, as = String.class)
@ -29,14 +28,26 @@ public class InputFile implements Validable, BotApiObject {
private String attachName;
/**
* Name of the media to upload
*/
@JsonIgnore
private String mediaName; ///< Name of the media to upload
private String mediaName;
/**
* New media file
*/
@JsonIgnore
private File newMediaFile; ///< New media file
private File newMediaFile;
/**
* New media stream
*/
@JsonIgnore
private InputStream newMediaStream; ///< New media stream
private InputStream newMediaStream;
/**
* True if the file is new, false if it is a file_id
*/
@JsonIgnore
private boolean isNew; ///< True if the file is new, false if it is a file_id
private boolean isNew;
public InputFile(String attachName) {
this();

View File

@ -11,9 +11,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a point on the map.
* @author Ruben Bermudez
* @version 1.0
* This object represents a point on the map.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -30,12 +30,18 @@ public class Location implements BotApiObject {
private static final String HEADING_FIELD = "heading";
private static final String PROXMITYALERTRADIUS_FIELD = "proximity_alert_radius";
/**
* Longitude as defined by sender
*/
@JsonProperty(LONGITUDE_FIELD)
@NonNull
private Double longitude; ///< Longitude as defined by sender
private Double longitude;
/**
* Latitude as defined by sender
*/
@JsonProperty(LATITUDE_FIELD)
@NonNull
private Double latitude; ///< Latitude as defined by sender
private Double latitude;
/**
* Optional.
* The radius of uncertainty for the location, measured in meters; 0-1500

View File

@ -9,6 +9,9 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.forum.ForumTopicClosed;
import org.telegram.telegrambots.meta.api.objects.forum.ForumTopicCreated;
import org.telegram.telegrambots.meta.api.objects.forum.ForumTopicReopened;
import org.telegram.telegrambots.meta.api.objects.games.Animation;
import org.telegram.telegrambots.meta.api.objects.games.Game;
import org.telegram.telegrambots.meta.api.objects.passport.PassportData;
@ -27,9 +30,9 @@ import java.util.ArrayList;
import java.util.List;
/**
* This object represents a message.
* @author Ruben Bermudez
* @version 1.0
* This object represents a message.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -39,6 +42,7 @@ import java.util.List;
@AllArgsConstructor
public class Message implements BotApiObject {
private static final String MESSAGEID_FIELD = "message_id";
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String FROM_FIELD = "from";
private static final String DATE_FIELD = "date";
private static final String CHAT_FIELD = "chat";
@ -97,81 +101,188 @@ public class Message implements BotApiObject {
private static final String VIDEOCHATSTARTED_FIELD = "video_chat_started";
private static final String VIDEOCHATENDED_FIELD = "video_chat_ended";
private static final String VIDEOCHATPARTICIPANTSINVITED_FIELD = "video_chat_participants_invited";
private static final String ISTOPICMESSAGE_FIELD = "is_topic_message";
private static final String FORUMTOPICCREATED_FIELD = "forum_topic_created";
private static final String FORUMTOPICCLOSED_FIELD = "forum_topic_closed";
private static final String FORUMTOPICREOPENED_FIELD = "forum_topic_reopened";
/**
* Integer Unique message identifier
*/
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier
private Integer messageId;
/**
* Optional.
* Unique identifier of a message thread or a forum topic to which the message belongs;
* for supergroups only
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
/**
* Optional.
* Sender, can be empty for messages sent to channels
*/
@JsonProperty(FROM_FIELD)
private User from; ///< Optional. Sender, can be empty for messages sent to channels
private User from;
/**
* Date the message was sent in Unix time
*/
@JsonProperty(DATE_FIELD)
private Integer date; ///< Date the message was sent in Unix time
private Integer date;
/**
* Conversation the message belongs to
*/
@JsonProperty(CHAT_FIELD)
private Chat chat; ///< Conversation the message belongs to
private Chat chat;
/**
* Optional.
* For forwarded messages, sender of the original message
*/
@JsonProperty(FORWARDFROM_FIELD)
private User forwardFrom; ///< Optional. For forwarded messages, sender of the original message
private User forwardFrom;
/**
* Optional.
* For messages forwarded from channels or from anonymous administrators, information about the original sender chat
*/
@JsonProperty(FORWARDFROMCHAT_FIELD)
private Chat forwardFromChat;
@JsonProperty(FORWARDDATE_FIELD)
private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent
@JsonProperty(TEXT_FIELD)
private String text; ///< Optional. For text messages, the actual UTF-8 text of the message
/**
* Optional. For text messages, special entities like usernames, URLs,
* Optional.
* For forwarded messages, date the original message was sent
*/
@JsonProperty(FORWARDDATE_FIELD)
private Integer forwardDate;
/**
* Optional.
* For text messages, the actual UTF-8 text of the message
*/
@JsonProperty(TEXT_FIELD)
private String text;
/**
* Optional.
* For text messages, special entities like usernames, URLs,
* bot commands, etc. that appear in the text
*/
@JsonProperty(ENTITIES_FIELD)
private List<MessageEntity> entities;
/**
* Optional. For messages with a caption, special entities like usernames,
* Optional.
* For messages with a caption, special entities like usernames,
* URLs, bot commands, etc. that appear in the caption
*/
@JsonProperty(CAPTIONENTITIES_FIELD)
private List<MessageEntity> captionEntities;
@JsonProperty(AUDIO_FIELD)
private Audio audio; ///< Optional. Message is an audio file, information about the file
@JsonProperty(DOCUMENT_FIELD)
private Document document; ///< Optional. Message is a general file, information about the file
@JsonProperty(PHOTO_FIELD)
private List<PhotoSize> photo; ///< Optional. Message is a photo, available sizes of the photo
@JsonProperty(STICKER_FIELD)
private Sticker sticker; ///< Optional. Message is a sticker, information about the sticker
@JsonProperty(VIDEO_FIELD)
private Video video; ///< Optional. Message is a video, information about the video
@JsonProperty(CONTACT_FIELD)
private Contact contact; ///< Optional. Message is a shared contact, information about the contact
@JsonProperty(LOCATION_FIELD)
private Location location; ///< Optional. Message is a shared location, information about the location
@JsonProperty(VENUE_FIELD)
private Venue venue; ///< Optional. Message is a venue, information about the venue
/**
* Optional. Message is an animation, information about the animation.
* Optional.
* Message is an audio file, information about the file
*/
@JsonProperty(AUDIO_FIELD)
private Audio audio;
/**
* Optional.
* Message is a general file, information about the file
*/
@JsonProperty(DOCUMENT_FIELD)
private Document document;
/**
* Optional.
* Message is a photo, available sizes of the photo
*/
@JsonProperty(PHOTO_FIELD)
private List<PhotoSize> photo;
/**
* Optional.
* Message is a sticker, information about the sticker
*/
@JsonProperty(STICKER_FIELD)
private Sticker sticker;
/**
* Optional.
* Message is a video, information about the video
*/
@JsonProperty(VIDEO_FIELD)
private Video video;
/**
* Optional.
* Message is a shared contact, information about the contact
*/
@JsonProperty(CONTACT_FIELD)
private Contact contact;
/**
* Optional.
* Message is a shared location, information about the location
*/
@JsonProperty(LOCATION_FIELD)
private Location location;
/**
* Optional.
* Message is a venue, information about the venue
*/
@JsonProperty(VENUE_FIELD)
private Venue venue;
/**
* Optional.
* Message is an animation, information about the animation.
* For backward compatibility, when this field is set, the document field will be also set
*/
@JsonProperty(ANIMATION_FIELD)
private Animation animation;
/**
* Optional.
* Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
*/
@JsonProperty(PINNED_MESSAGE_FIELD)
private Message pinnedMessage; ///< Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
private Message pinnedMessage;
/**
* Optional.
* New members were added to the group or supergroup, information about them (the bot itself may be one of these members)
*/
@JsonProperty(NEWCHATMEMBERS_FIELD)
private List<User> newChatMembers; ///< Optional. New members were added to the group or supergroup, information about them (the bot itself may be one of these members)
private List<User> newChatMembers;
/**
* Optional.
* A member was removed from the group, information about them (this member may be bot itself)
*/
@JsonProperty(LEFTCHATMEMBER_FIELD)
private User leftChatMember; ///< Optional. A member was removed from the group, information about them (this member may be bot itself)
private User leftChatMember;
/**
* Optional.
* A chat title was changed to this value
*/
@JsonProperty(NEWCHATTITLE_FIELD)
private String newChatTitle; ///< Optional. A chat title was changed to this value
private String newChatTitle;
/**
* Optional.
* A chat photo was change to this value
*/
@JsonProperty(NEWCHATPHOTO_FIELD)
private List<PhotoSize> newChatPhoto; ///< Optional. A chat photo was change to this value
private List<PhotoSize> newChatPhoto;
/**
* Optional.
* Informs that the chat photo was deleted
*/
@JsonProperty(DELETECHATPHOTO_FIELD)
private Boolean deleteChatPhoto; ///< Optional. Informs that the chat photo was deleted
private Boolean deleteChatPhoto;
/**
* Optional.
* Informs that the group has been created
*/
@JsonProperty(GROUPCHATCREATED_FIELD)
private Boolean groupchatCreated; ///< Optional. Informs that the group has been created
private Boolean groupchatCreated;
@JsonProperty(REPLYTOMESSAGE_FIELD)
private Message replyToMessage;
/**
* Optional.
* Message is a voice message, information about the file
*/
@JsonProperty(VOICE_FIELD)
private Voice voice; ///< Optional. Message is a voice message, information about the file
private Voice voice;
/**
* Optional.
* Caption for the document, photo or video, 0-200 characters
*/
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption for the document, photo or video, 0-200 characters
private String caption;
/**
* Optional. Service message: the supergroup has been created.
* This field cant be received in a message coming through updates,
@ -198,7 +309,7 @@ public class Message implements BotApiObject {
* float type are safe for storing this identifier.
*/
@JsonProperty(MIGRATETOCHAT_FIELD)
private Long migrateToChatId; ///< Optional. The chat has been migrated to a chat with specified identifier, not exceeding 1e13 by absolute value
private Long migrateToChatId;
/**
* Optional. The supergroup has been migrated from a group with the specified identifier.
* This number may be greater than 32 bits and some programming languages
@ -207,37 +318,85 @@ public class Message implements BotApiObject {
* float type are safe for storing this identifier.
*/
@JsonProperty(MIGRATEFROMCHAT_FIELD)
private Long migrateFromChatId; ///< Optional. The chat has been migrated from a chat with specified identifier, not exceeding 1e13 by absolute value
private Long migrateFromChatId;
/**
* Optional.
* Date the message was last edited in Unix time
*/
@JsonProperty(EDITDATE_FIELD)
private Integer editDate; ///< Optional. Date the message was last edited in Unix time
private Integer editDate;
/**
* Optional.
* Message is a game, information about the game
*/
@JsonProperty(GAME_FIELD)
private Game game; ///< Optional. Message is a game, information about the game
private Game game;
/**
* Optional.
* For forwarded channel posts, identifier of the original message in the channel
*/
@JsonProperty(FORWARDFROMMESSAGEID_FIELD)
private Integer forwardFromMessageId; ///< Optional. For forwarded channel posts, identifier of the original message in the channel
private Integer forwardFromMessageId;
/**
* Optional.
* Message is an invoice for a payment, information about the invoice.
*/
@JsonProperty(INVOICE_FIELD)
private Invoice invoice; ///< Optional. Message is an invoice for a payment, information about the invoice.
private Invoice invoice;
/**
* Optional.
* Message is a service message about a successful payment, information about the payment.
*/
@JsonProperty(SUCCESSFUL_PAYMENT_FIELD)
private SuccessfulPayment successfulPayment; ///< Optional. Message is a service message about a successful payment, information about the payment.
private SuccessfulPayment successfulPayment;
/**
* Optional.
* Message is a video note, information about the video message
*/
@JsonProperty(VIDEO_NOTE_FIELD)
private VideoNote videoNote; ///< Optional. Message is a video note, information about the video message
private VideoNote videoNote;
/**
* Optional.
* Signature of the post author for messages in channels, or the custom title of an anonymous group administrator
*/
@JsonProperty(AUTHORSIGNATURE_FIELD)
private String authorSignature;
/**
* Optional.
* Post author signature for messages forwarded from channel chats
*/
@JsonProperty(FORWARDSIGNATURE_FIELD)
private String forwardSignature; ///< Optional. Post author signature for messages forwarded from channel chats
private String forwardSignature;
/**
* Optional.
* The unique identifier of a media message group this message belongs to
*/
@JsonProperty(MEDIAGROUPID_FIELD)
private String mediaGroupId; ///< Optional. The unique identifier of a media message group this message belongs to
private String mediaGroupId;
/**
* Optional.
* The domain name of the website on which the user has logged in
*/
@JsonProperty(CONNECTEDWEBSITE_FIELD)
private String connectedWebsite; ///< Optional. The domain name of the website on which the user has logged in
private String connectedWebsite;
/**
* Optional.
* Telegram Passport data
*/
@JsonProperty(PASSPORTDATA_FIELD)
private PassportData passportData; ///< Optional. Telegram Passport data
private PassportData passportData;
/**
* Optional.
* Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
*/
@JsonProperty(FORWARDSENDERNAME_FIELD)
private String forwardSenderName; ///< Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
private String forwardSenderName;
/**
* Optional.
* Message is a native poll, information about the poll
*/
@JsonProperty(POLL_FIELD)
private Poll poll; ///< Optional. Message is a native poll, information about the poll
private Poll poll;
/**
* Inline keyboard attached to the message.
*
@ -245,10 +404,18 @@ public class Message implements BotApiObject {
*/
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup;
/**
* Optional.
* Message is a dice with random value from 1 to 6
*/
@JsonProperty(DICE_FIELD)
private Dice dice; // Optional. Message is a dice with random value from 1 to 6
private Dice dice;
/**
* Optional.
* Bot through which the message was sent
*/
@JsonProperty(VIABOT_FIELD)
private User viaBot; // Optional. Bot through which the message was sent
private User viaBot;
/**
* Optional.
* Sender of the message, sent on behalf of a chat. The channel itself for channel messages.
@ -264,26 +431,78 @@ public class Message implements BotApiObject {
*/
@JsonProperty(PROXIMITYALERTTRIGGERED_FIELD)
private ProximityAlertTriggered proximityAlertTriggered;
/**
* Optional.
* Service message: auto-delete timer settings changed in the chat
*/
@JsonProperty(MESSAGEAUTODELETETIMERCHANGED_FIELD)
private MessageAutoDeleteTimerChanged messageAutoDeleteTimerChanged; ///< Optional. Service message: auto-delete timer settings changed in the chat
@JsonProperty(ISAUTOMATICFORWARD_FIELD)
private MessageAutoDeleteTimerChanged messageAutoDeleteTimerChanged;
/**
* Optional.
* True, if the message is a channel post that was automatically forwarded to the connected discussion group
*/
@JsonProperty(ISAUTOMATICFORWARD_FIELD)
private Boolean isAutomaticForward;
/**
* Optional.
* True, if the message can't be forwarded
*/
@JsonProperty(HASPROTECTEDCONTENT_FIELD)
private Boolean hasProtectedContent; ///< Optional. True, if the message can't be forwarded
private Boolean hasProtectedContent;
/**
* Optional.
* Service message: data sent by a web app
*/
@JsonProperty(WEBAPPDATA_FIELD)
private WebAppData webAppData; ///< Optional. Service message: data sent by a web app
private WebAppData webAppData;
/**
* Optional.
* Service message: video chat started
*/
@JsonProperty(VIDEOCHATSTARTED_FIELD)
private VideoChatStarted videoChatStarted; ///< Optional. Service message: video chat started
private VideoChatStarted videoChatStarted;
/**
* Optional.
* Service message: video chat ended
*/
@JsonProperty(VIDEOCHATENDED_FIELD)
private VideoChatEnded videoChatEnded; ///< Optional. Service message: video chat ended
private VideoChatEnded videoChatEnded;
/**
* Optional.
* Service message: new participants invited to a video chat
*/
@JsonProperty(VIDEOCHATPARTICIPANTSINVITED_FIELD)
private VideoChatParticipantsInvited videoChatParticipantsInvited; ///< Optional. Service message: new participants invited to a video chat
private VideoChatParticipantsInvited videoChatParticipantsInvited;
/**
* Optional.
* Service message: video chat scheduled
*/
@JsonProperty(VIDEOCHATSCHEDULED_FIELD)
private VideoChatScheduled videoChatScheduled; ///< Optional. Service message: video chat scheduled
private VideoChatScheduled videoChatScheduled;
/**
* Optional.
* True, if the message is sent to a forum topic
*/
@JsonProperty(ISTOPICMESSAGE_FIELD)
private Boolean isTopicMessage;
/**
* Optional.
* Service message: forum topic created
*/
@JsonProperty(FORUMTOPICCREATED_FIELD)
private ForumTopicCreated forumTopicCreated;
/**
* Optional.
* Service message: forum topic closed
*/
@JsonProperty(FORUMTOPICCLOSED_FIELD)
private ForumTopicClosed forumTopicClosed;
/**
* Optional.
* Service message: forum topic reopened
*/
@JsonProperty(FORUMTOPICREOPENED_FIELD)
private ForumTopicReopened forumTopicReopened;
public List<MessageEntity> getEntities() {
if (entities != null) {
@ -309,6 +528,11 @@ public class Message implements BotApiObject {
return sticker != null;
}
@JsonIgnore
public boolean isTopicMessage() {
return isTopicMessage != null && isTopicMessage;
}
@JsonIgnore
public boolean isGroupMessage() {
return chat.isGroupChat();
@ -476,4 +700,19 @@ public class Message implements BotApiObject {
private boolean hasVideoChatParticipantsInvited() {
return videoChatParticipantsInvited != null;
}
@JsonIgnore
private boolean hasForumTopicCreated() {
return forumTopicCreated != null;
}
@JsonIgnore
private boolean hasForumTopicClosed() {
return forumTopicClosed != null;
}
@JsonIgnore
private boolean hasForumTopicReopened() {
return forumTopicReopened != null;
}
}

View File

@ -10,10 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a service message about a change in auto-delete timer settings.
* @author Ruben Bermudez
* @version 5.1
*
* This object represents a service message about a change in auto-delete timer settings.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -24,6 +23,9 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
public class MessageAutoDeleteTimerChanged implements BotApiObject {
private static final String MESSAGEAUTODELETETIME_FIELD = "message_auto_delete_time";
/**
* New auto-delete time for messages in the chat
*/
@JsonProperty(MESSAGEAUTODELETETIME_FIELD)
private Integer messageAutoDeleteTime; ///< New auto-delete time for messages in the chat
private Integer messageAutoDeleteTime;
}

View File

@ -14,10 +14,10 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 1.0
* This object represents one special entity in a text message. For example, hashtags,
* usernames, URL.
* @author Ruben Bermudez
* @version 1.0
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@ -35,6 +35,7 @@ public class MessageEntity implements BotApiObject {
private static final String URL_FIELD = "url";
private static final String USER_FIELD = "user";
private static final String LANGUAGE_FIELD = "language";
private static final String CUSTOMEMOJI_FIELD = "custom_emoji_id";
/**
* Type of the entity.
* Currently, can be:
@ -54,24 +55,53 @@ public class MessageEntity implements BotApiObject {
* - pre (monowidth block)
* - text_link (for clickable text URLs)
* - text_mention (for users without usernames)
* - "custom_emoji" (for inline custom emoji stickers)
*/
@JsonProperty(TYPE_FIELD)
@NonNull
private String type;
/**
* Offset in UTF-16 code units to the start of the entity
*/
@JsonProperty(OFFSET_FIELD)
@NonNull
private Integer offset; ///< Offset in UTF-16 code units to the start of the entity
private Integer offset;
/**
* Length of the entity in UTF-16 code units
*/
@JsonProperty(LENGTH_FIELD)
@NonNull
private Integer length; ///< Length of the entity in UTF-16 code units
private Integer length;
/**
* Optional.
* For text_link only, url that will be opened after user taps on the text
*/
@JsonProperty(URL_FIELD)
private String url; ///< Optional. For text_link only, url that will be opened after user taps on the text
private String url;
/**
* Optional.
* For text_mention only, the mentioned user
*/
@JsonProperty(USER_FIELD)
private User user; ///< Optional. For text_mention only, the mentioned user
private User user;
/**
* Optional.
* For pre only, the programming language of the entity text
*/
@JsonProperty(LANGUAGE_FIELD)
private String language; ///< Optional. For pre only, the programming language of the entity text
private String language;
/**
* Optional.
* For custom_emoji only, unique identifier of the custom emoji.
* Use getCustomEmojiStickers to get full information about the sticker
*/
@JsonProperty(CUSTOMEMOJI_FIELD)
private String customEmojiId;
/**
* Text present in the entity. Computed from offset and length
*/
@JsonIgnore
private String text; ///< Text present in the entity. Computed from offset and length
private String text;
protected void computeText(String message) {
if (message != null) {

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a unique message identifier.
* @author Ruben Bermudez
* @version 5.0
* This object represents a unique message identifier.
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@ -25,7 +25,10 @@ public class MessageId implements BotApiObject {
private static final String MESSAGEID_FIELD = "message_id";
/**
* Unique message identifier
*/
@JsonProperty(MESSAGEID_FIELD)
private Long messageId; ///< Unique message identifier
private Long messageId;
}

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents one size of a photo or a file / sticker thumbnail.
* @author Ruben Bermudez
* @version 1.0
* This object represents one size of a photo or a file / sticker thumbnail.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -29,20 +29,36 @@ public class PhotoSize implements BotApiObject {
private static final String FILESIZE_FIELD = "file_size";
private static final String FILEPATH_FIELD = "file_path";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
*/
@JsonProperty(FILEUNIQUEID_FIELD)
private String fileUniqueId;
/**
* Photo width
*/
@JsonProperty(WIDTH_FIELD)
private Integer width; ///< Photo width
private Integer width;
/**
* Photo height
*/
@JsonProperty(HEIGHT_FIELD)
private Integer height; ///< Photo height
private Integer height;
/**
* Optional.
* File size
*/
@JsonProperty(FILESIZE_FIELD)
private Integer fileSize; ///< Optional. File size
private Integer fileSize;
/**
* Undocumented field. Optional. Can contain the path to download the file directly without calling to getFile
*/
@JsonProperty(FILEPATH_FIELD)
private String filePath; ///< Undocumented field. Optional. Can contain the path to download the file directly without calling to getFile
private String filePath;
}

View File

@ -10,10 +10,10 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 5.0
* This object represents the content of a service message,
* sent whenever a user in the chat triggers a proximity alert set by another user.
* @author Ruben Bermudez
* @version 5.0
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@ -28,10 +28,19 @@ public class ProximityAlertTriggered implements BotApiObject {
private static final String WATCHER_FIELD = "watcher";
private static final String DISTANCE_FIELD = "distance";
/**
* User that triggered the alert
*/
@JsonProperty(TRAVELER_FIELD)
private User traveler; ///< User that triggered the alert
private User traveler;
/**
* User that set the alert
*/
@JsonProperty(WATCHER_FIELD)
private User watcher; ///< User that set the alert
private User watcher;
/**
* The distance between the users
*/
@JsonProperty(DISTANCE_FIELD)
private Integer distance; ///< The distance between the users
private Integer distance;
}

View File

@ -28,9 +28,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* Contains information about why a request was unsuccessfull.
* @author Ruben Bermudez
* @version 1.0
* Contains information about why a request was unsuccessfull.
*/
@EqualsAndHashCode(callSuper = false)
@Getter

View File

@ -16,12 +16,10 @@ import org.telegram.telegrambots.meta.api.objects.polls.Poll;
import org.telegram.telegrambots.meta.api.objects.polls.PollAnswer;
/**
* This object represents an incoming update.
* @apiNote Only one of the optional parameters can be present in any given update.
* @author Ruben Bermudez
* @version 1.0
*
* This object represents an incoming update.
*
* @apiNote Only one of the optional parameters can be present in any given update.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -48,26 +46,66 @@ public class Update implements BotApiObject {
@JsonProperty(UPDATEID_FIELD)
private Integer updateId;
/**
* Optional.
* New incoming message of any kind text, photo, sticker, etc.
*/
@JsonProperty(MESSAGE_FIELD)
private Message message; ///< Optional. New incoming message of any kind text, photo, sticker, etc.
private Message message;
/**
* Optional.
* New incoming inline query
*/
@JsonProperty(INLINEQUERY_FIELD)
private InlineQuery inlineQuery; ///< Optional. New incoming inline query
private InlineQuery inlineQuery;
/**
* Optional.
* The result of an inline query that was chosen by a user and sent to their chat partner
*/
@JsonProperty(CHOSENINLINEQUERY_FIELD)
private ChosenInlineQuery chosenInlineQuery; ///< Optional. The result of a inline query that was chosen by a user and sent to their chat partner
private ChosenInlineQuery chosenInlineQuery;
/**
* Optional.
* New incoming callback query
*/
@JsonProperty(CALLBACKQUERY_FIELD)
private CallbackQuery callbackQuery; ///< Optional. New incoming callback query
private CallbackQuery callbackQuery;
/**
* Optional.
* New version of a message that is known to the bot and was edited
*/
@JsonProperty(EDITEDMESSAGE_FIELD)
private Message editedMessage; ///< Optional. New version of a message that is known to the bot and was edited
private Message editedMessage;
/**
* Optional.
* New incoming channel post of any kind text, photo, sticker, etc.
*/
@JsonProperty(CHANNELPOST_FIELD)
private Message channelPost; ///< Optional. New incoming channel post of any kind text, photo, sticker, etc.
private Message channelPost;
/**
* Optional.
* New version of a channel post that is known to the bot and was edited
*/
@JsonProperty(EDITEDCHANNELPOST_FIELD)
private Message editedChannelPost; ///< Optional. New version of a channel post that is known to the bot and was edited
private Message editedChannelPost;
/**
* Optional.
* New incoming shipping query. Only for invoices with flexible price
*/
@JsonProperty(SHIPPING_QUERY_FIELD)
private ShippingQuery shippingQuery; ///< Optional. New incoming shipping query. Only for invoices with flexible price
private ShippingQuery shippingQuery;
/**
* Optional.
* New incoming pre-checkout query. Contains full information about checkout
*/
@JsonProperty(PRE_CHECKOUT_QUERY_FIELD)
private PreCheckoutQuery preCheckoutQuery; ///< Optional. New incoming pre-checkout query. Contains full information about checkout
private PreCheckoutQuery preCheckoutQuery;
/**
* Optional.
* New poll state. Bots receive only updates about polls, which are sent by the bot.
*/
@JsonProperty(POLL_FIELD)
private Poll poll; ///< Optional. New poll state. Bots receive only updates about polls, which are sent by the bot.
private Poll poll;
/**
* Optional.
* A user changed their answer in a non-anonymous poll.
@ -78,7 +116,6 @@ public class Update implements BotApiObject {
private PollAnswer pollAnswer;
/**
* Optional.
*
* The bot's chat member status was updated in a chat.
* For private chats, this update is received only when the bot is blocked or unblocked by the user.
*/
@ -86,7 +123,6 @@ public class Update implements BotApiObject {
private ChatMemberUpdated myChatMember;
/**
* Optional.
*
* A chat member's status was updated in a chat.
* The bot must be an administrator in the chat and must explicitly specify chat_member in the list of allowed_updates to receive these updates.
*/

View File

@ -12,9 +12,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a Telegram user or bot.
* @author Ruben Bermudez
* @version 6.1
* This object represents a Telegram user or bot.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -44,27 +44,57 @@ public class User implements BotApiObject {
*/
@JsonProperty(ID_FIELD)
@NonNull
private Long id; ///< Unique identifier for this user or bot
private Long id;
/**
* Users or bots first name
*/
@JsonProperty(FIRSTNAME_FIELD)
@NonNull
private String firstName; ///< Users or bots first name
private String firstName;
/**
* True, if this user is a bot
*/
@JsonProperty(ISBOT_FIELD)
@NonNull
private Boolean isBot; ///< True, if this user is a bot
private Boolean isBot;
/**
* Optional. Users or bots last name
*/
@JsonProperty(LASTNAME_FIELD)
private String lastName; ///< Optional. Users or bots last name
private String lastName;
/**
* Optional. Users or bots username
*/
@JsonProperty(USERNAME_FIELD)
private String userName; ///< Optional. Users or bots username
private String userName;
/**
* Optional. IETF language tag of the user's language
*/
@JsonProperty(LANGUAGECODE_FIELD)
private String languageCode; ///< Optional. IETF language tag of the user's language
private String languageCode;
/**
* Optional. True, if the bot can be invited to groups. Returned only in getMe.
*/
@JsonProperty(CANJOINGROUPS_FIELD)
private Boolean canJoinGroups; ///< Optional. True, if the bot can be invited to groups. Returned only in getMe.
private Boolean canJoinGroups;
/**
* Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
*/
@JsonProperty(CANREADALLGROUPMESSAGES_FIELD)
private Boolean canReadAllGroupMessages; ///< Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
private Boolean canReadAllGroupMessages;
/**
* Optional. True, if the bot supports inline queries. Returned only in getMe.
*/
@JsonProperty(SUPPORTINLINEQUERIES_FIELD)
private Boolean supportInlineQueries; ///< Optional. True, if the bot supports inline queries. Returned only in getMe.
private Boolean supportInlineQueries;
/**
* Optional. True, if this user is a Telegram Premium user
*/
@JsonProperty(ISPREMIUM_FIELD)
private Boolean isPremium; ///< Optional. True, if this user is a Telegram Premium user
private Boolean isPremium;
/**
* Optional. True, if this user added the bot to the attachment menu
*/
@JsonProperty(ADDEDTOATTACHMENTMENU_FIELD)
private Boolean addedToAttachmentMenu; ///< Optional. True, if this user added the bot to the attachment menu
private Boolean addedToAttachmentMenu;
}

View File

@ -13,9 +13,9 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import java.util.List;
/**
* This object represent a user's profile pictures.
* @author Ruben Bermudez
* @version 1.0
* This object represent a user's profile pictures.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -28,8 +28,14 @@ public class UserProfilePhotos implements BotApiObject {
private static final String TOTALCOUNT_FIELD = "total_count";
private static final String PHOTOS_FIELD = "photos";
/**
* Total number of profile pictures the target user has
*/
@JsonProperty(TOTALCOUNT_FIELD)
private Integer totalCount; ///< Total number of profile pictures the target user has
private Integer totalCount;
/**
* Requested profile pictures (in up to 4 sizes each)
*/
@JsonProperty(PHOTOS_FIELD)
private List<List<PhotoSize>> photos; ///< Requested profile pictures (in up to 4 sizes each)
private List<List<PhotoSize>> photos;
}

View File

@ -11,9 +11,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a venue.
* @author Ruben Bermudez
* @version 1.0
* This object represents a venue.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -30,18 +30,43 @@ public class Venue implements BotApiObject {
private static final String GOOGLEPLACEID_FIELD = "google_place_id";
private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
/**
* Venue location
*/
@JsonProperty(LOCATION_FIELD)
private Location location; ///< Venue location
private Location location;
/**
* Name of the venue
*/
@JsonProperty(TITLE_FIELD)
private String title; ///< Name of the venue
private String title;
/**
* Address of the venue
*/
@JsonProperty(ADDRESS_FIELD)
private String address; ///< Address of the venue
private String address;
/**
* Optional.
* Foursquare identifier of the venue
*/
@JsonProperty(FOURSQUAREID_FIELD)
private String foursquareId; ///< Optional. Foursquare identifier of the venue
private String foursquareId;
/**
* Optional.
* Foursquare type of the venue.
*/
@JsonProperty(FOURSQUARETYPE_FIELD)
private String foursquareType; ///< Optional. Foursquare type of the venue.
private String foursquareType;
/**
* Optional.
* Google Places identifier of the venue
*/
@JsonProperty(GOOGLEPLACEID_FIELD)
private String googlePlaceId; ///< Optional. Google Places identifier of the venue
private String googlePlaceId;
/**
* Optional.
* Google Places type of the venue. (See supported types.)
*/
@JsonProperty(GOOGLEPLACETYPE_FIELD)
private String googlePlaceType; ///< Optional. Google Places type of the venue. (See supported types.)
private String googlePlaceType;
}

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a video file.
* @author Ruben Bermudez
* @version 1.0
* This object represents a video file.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -32,24 +32,43 @@ public class Video implements BotApiObject {
private static final String FILESIZE_FIELD = "file_size";
private static final String FILENAME_FIELD = "file_name";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
*/
@JsonProperty(FILEUNIQUEID_FIELD)
private String fileUniqueId;
/**
* Video width as defined by sender
*/
@JsonProperty(WIDTH_FIELD)
private Integer width; ///< Video width as defined by sender
private Integer width;
/**
* Video height as defined by sender
*/
@JsonProperty(HEIGHT_FIELD)
private Integer height; ///< Video height as defined by sender
private Integer height;
/**
* Duration of the video in seconds as defined by sender
*/
@JsonProperty(DURATION_FIELD)
private Integer duration; ///< Duration of the video in seconds as defined by sender
private Integer duration;
/**
* Video thumbnail
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb; ///< Video thumbnail
private PhotoSize thumb;
/**
* Optional.
* Mime type of file as defined by sender
*/
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Optional. Mime type of a file as defined by sender
private String mimeType;
/**
* Optional.
* File size in bytes.
@ -58,6 +77,10 @@ public class Video implements BotApiObject {
*/
@JsonProperty(FILESIZE_FIELD)
private Long fileSize;
/**
* Optional.
* Original filename as defined by sender
*/
@JsonProperty(FILENAME_FIELD)
private String fileName; ///< Optional. Original filename as defined by sender
private String fileName;
}

View File

@ -10,10 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a video message (available in Telegram apps as of v.4.0).
* @author Ruben Bermudez
* @version 1.0
*
* This object represents a video message (available in Telegram apps as of v.4.0).
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -29,20 +28,37 @@ public class VideoNote implements BotApiObject {
private static final String THUMB_FIELD = "thumb";
private static final String FILESIZE_FIELD = "file_size";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
*/
@JsonProperty(FILEUNIQUEID_FIELD)
private String fileUniqueId;
/**
* Video width and height as defined by sender
*/
@JsonProperty(LENGTH_FIELD)
private Integer length; ///< Video width and height as defined by sender
private Integer length;
/**
* Duration of the video in seconds as defined by sender
*/
@JsonProperty(DURATION_FIELD)
private Integer duration; ///< Duration of the video in seconds as defined by sender
private Integer duration;
/**
* Optional.
* Video thumbnail
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb; ///< Optional. Video thumbnail
private PhotoSize thumb;
/**
* Optional.
* File size
*/
@JsonProperty(FILESIZE_FIELD)
private Integer fileSize; ///< Optional. File size
private Integer fileSize;
}

View File

@ -10,9 +10,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a voice note
* @author Ruben Bermudez
* @version 1.0
* This object represents a voice note
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -27,18 +27,28 @@ public class Voice implements BotApiObject {
private static final String MIMETYPE_FIELD = "mime_type";
private static final String FILESIZE_FIELD = "file_size";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
*/
@JsonProperty(FILEUNIQUEID_FIELD)
private String fileUniqueId;
/**
* Integer Duration of the audio in seconds as defined by sender
*/
@JsonProperty(DURATION_FIELD)
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
private Integer duration;
/**
* Optional.
* MIME type of the file as defined by sender
*/
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Optional. MIME type of the file as defined by sender
private String mimeType;
/**
* Optional.
* File size in bytes.

View File

@ -12,9 +12,9 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import java.util.List;
/**
* Contains information about the current status of a webhook.
* @author Ruben Bermudez
* @version 2.4
* Contains information about the current status of a webhook.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -34,22 +34,51 @@ public class WebhookInfo implements BotApiObject {
private static final String IPADDRESS_FIELD = "ip_address";
private static final String LASTSYNCHRONIZATIONERRORDATE_FIELD = "last_synchronization_error_date";
/**
* Webhook URL, may be empty if webhook is not set up
*/
@JsonProperty(URL_FIELD)
private String url; ///< Webhook URL, may be empty if webhook is not set up
private String url;
/**
* True, if a custom certificate was provided for webhook certificate checks
*/
@JsonProperty(HASCUSTOMCERTIFICATE_FIELD)
private Boolean hasCustomCertificate; ///< True, if a custom certificate was provided for webhook certificate checks
private Boolean hasCustomCertificate;
/**
* Number updates awaiting delivery
*/
@JsonProperty(PENDINGUPDATECOUNT_FIELD)
private Integer pendingUpdatesCount; ///< Number updates awaiting delivery
private Integer pendingUpdatesCount;
/**
* Optional.
* Unix time for the most recent error that happened when trying to deliver an update via webhook
*/
@JsonProperty(LASTERRORDATE_FIELD)
private Integer lastErrorDate; ///< Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook
private Integer lastErrorDate;
/**
* Optional.
* Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
*/
@JsonProperty(LASTERRORMESSAGE_FIELD)
private String lastErrorMessage; ///< Optional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
private String lastErrorMessage;
/**
* Optional.
* Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
*/
@JsonProperty(MAXCONNECTIONS_FIELD)
private Integer maxConnections; ///< Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
private Integer maxConnections;
/**
* Optional.
* A list of update types the bot is subscribed to. Defaults to all update types
*/
@JsonProperty(ALLOWEDUPDATES_FIELD)
private List<String> allowedUpdates; ///< Optional. A list of update types the bot is subscribed to. Defaults to all update types
private List<String> allowedUpdates;
/**
* Optional.
* Currently used webhook IP address
*/
@JsonProperty(IPADDRESS_FIELD)
private String ipAddress; ///< Optional. Currently used webhook IP address
private String ipAddress;
/**
* Optional.
* Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters

View File

@ -5,10 +5,9 @@ import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* Represents rights of an administrator in a chat.
* @author Ruben Bermudez
* @version 6.0
*
* Represents rights of an administrator in a chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -30,9 +29,13 @@ public class ChatAdministratorRights implements BotApiObject {
private static final String CANPOSTMESSAGES_FIELD = "can_post_messages";
private static final String CANEDITMESSAGES_FIELD = "can_edit_messages";
private static final String CANPINMESSAGES_FIELD = "can_pin_messages";
private static final String CANMANAGETOPICS_FIELD = "can_manage_topics";
/**
* True, if the user's presence in the chat is hidden
*/
@JsonProperty(ISANONYMOUS_FIELD)
private Boolean isAnonymous; ///< True, if the user's presence in the chat is hidden
private Boolean isAnonymous;
/**
* True, if the administrator can access the chat event log, chat statistics,
* message statistics in channels, see channel members, see anonymous administrators
@ -41,12 +44,21 @@ public class ChatAdministratorRights implements BotApiObject {
*/
@JsonProperty(CANMANAGECHAT_FIELD)
private Boolean canManageChat;
/**
* True, if the administrator can delete messages of other users
*/
@JsonProperty(CANDELETEMESSAGES_FIELD)
private Boolean canDeleteMessages; ///< True, if the administrator can delete messages of other users
private Boolean canDeleteMessages;
/**
* True, if the administrator can manage video chats
*/
@JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
private Boolean canManageVideoChats; ///< True, if the administrator can manage video chats
private Boolean canManageVideoChats;
/**
* True, if the administrator can restrict, ban or unban chat members
*/
@JsonProperty(CANRESTRICTMEMBERS_FIELD)
private Boolean canRestrictMembers; ///< True, if the administrator can restrict, ban or unban chat members
private Boolean canRestrictMembers;
/**
* True, if the administrator can add new administrators with a subset of
* their own privileges or demote administrators that he has promoted,
@ -54,15 +66,38 @@ public class ChatAdministratorRights implements BotApiObject {
*/
@JsonProperty(CANPROMOTEMEMBERS_FIELD)
private Boolean canPromoteMembers;
/**
* True, if the user is allowed to change the chat title, photo and other settings
*/
@JsonProperty(CANCHANGEINFO_FIELD)
private Boolean canChangeInfo; ///< True, if the user is allowed to change the chat title, photo and other settings
private Boolean canChangeInfo;
/**
* True, if the user is allowed to invite new users to the chat
*/
@JsonProperty(CANINVITEUSERS_FIELD)
private Boolean canInviteUsers; ///< True, if the user is allowed to invite new users to the chat
private Boolean canInviteUsers;
/**
* Optional.
* True, if the administrator can post in the channel; channels only
*/
@JsonProperty(CANPOSTMESSAGES_FIELD)
private Boolean canPostMessages; ///< Optional. True, if the administrator can post in the channel; channels only
private Boolean canPostMessages;
/**
* Optional.
* True, if the administrator can edit messages of other users and can pin messages; channels only
*/
@JsonProperty(CANEDITMESSAGES_FIELD)
private Boolean canEditMessages; ///< Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
private Boolean canEditMessages;
/**
* Optional.
* True, if the user is allowed to pin messages; groups and supergroups only
*/
@JsonProperty(CANPINMESSAGES_FIELD)
private Boolean canPinMessages; ///< Optional. True, if the user is allowed to pin messages; groups and supergroups only
private Boolean canPinMessages;
/**
* Optional.
* True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
*/
@JsonProperty(CANMANAGETOPICS_FIELD)
private Boolean canManageTopics;
}

View File

@ -43,6 +43,7 @@ public class ChatMemberAdministrator implements ChatMember {
private static final String CANINVITEUSERS_FIELD = "can_invite_users";
private static final String CANPINMESSAGES_FIELD = "can_pin_messages";
private static final String CANMANAGEVIDEOCHATS_FIELD = "can_manage_video_chats";
private static final String CANMANAGETOPICS_FIELD = "can_manage_topics";
/**
* The member's status in the chat, always administrator
@ -124,4 +125,10 @@ public class ChatMemberAdministrator implements ChatMember {
*/
@JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
private Boolean canManageVideoChats;
/**
* Optional.
* True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
*/
@JsonProperty(CANMANAGETOPICS_FIELD)
private Boolean canManageTopics;
}

View File

@ -40,6 +40,7 @@ public class ChatMemberRestricted implements ChatMember {
private static final String CANSENDOTHERMESSAGES_FIELD = "can_send_other_messages";
private static final String CANADDWEBPAGEPREVIEWS_FIELD = "can_add_web_page_previews";
private static final String UNTILDATE_FIELD = "until_date";
private static final String CANMANAGETOPICS_FIELD = "can_manage_topics";
/**
* The member's status in the chat, always restricted
@ -101,4 +102,9 @@ public class ChatMemberRestricted implements ChatMember {
*/
@JsonProperty(UNTILDATE_FIELD)
private Integer untilDate;
/**
* True, if the user is allowed to create forum topics
*/
@JsonProperty(CANMANAGETOPICS_FIELD)
private Boolean canManageTopics;
}

View File

@ -14,9 +14,9 @@ import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* This object represents a bot command.
* @author Ruben Bermudez
* @version 4.7
* This object represents a bot command.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -34,10 +34,13 @@ public class BotCommand implements BotApiObject, Validable {
*/
@JsonProperty(COMMAND_FIELD)
@NonNull
private String command; ///< Value of the dice, 1-6
private String command;
/**
* Description of the command, 3-256 characters.
*/
@JsonProperty(DESCRIPTION_FIELD)
@NonNull
private String description; ///< Description of the command, 3-256 characters.
private String description;
@Override
public void validate() throws TelegramApiValidationException {

View File

@ -0,0 +1,51 @@
package org.telegram.telegrambots.meta.api.objects.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a forum topic.
* @author Ruben Bermudez
* @version 6.3
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class ForumTopic implements BotApiObject {
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
private static final String NAME_FIELD = "name";
private static final String ICONCOLOR_FIELD = "icon_color";
private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id";
/**
* Unique identifier of the forum topic
*/
@JsonProperty(MESSAGETHREADID_FIELD)
private Integer messageThreadId;
/**
* Name of the topic
*/
@JsonProperty(NAME_FIELD)
private String name;
/**
* Color of the topic icon in RGB format
*/
@JsonProperty(ICONCOLOR_FIELD)
private Integer iconColor;
/**
* Optional.
* Unique identifier of the custom emoji shown as the topic icon
*/
@JsonProperty(ICONCUSTOMEMOJIID_FIELD)
private String iconCustomEmojiId;
}

View File

@ -0,0 +1,24 @@
package org.telegram.telegrambots.meta.api.objects.forum;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a service message about a forum topic closed in the chat.
* Currently holds no information.
* @author Ruben Bermudez
* @version 6.3
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
public class ForumTopicClosed implements BotApiObject {
}

View File

@ -0,0 +1,47 @@
package org.telegram.telegrambots.meta.api.objects.forum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a service message about a new forum topic created in the chat.
* @author Ruben Bermudez
* @version 6.1
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class ForumTopicCreated implements BotApiObject {
private static final String NAME_FIELD = "name";
private static final String ICONCOLOR_FIELD = "icon_color";
private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id";
/**
* Name of the topic
*/
@JsonProperty(NAME_FIELD)
private String name;
/**
* Color of the topic icon in RGB format
*/
@JsonProperty(ICONCOLOR_FIELD)
private Integer iconColor;
/**
* Optional.
* Unique identifier of the custom emoji shown as the topic icon
*/
@JsonProperty(ICONCUSTOMEMOJIID_FIELD)
private String iconCustomEmojiId;
}

View File

@ -0,0 +1,24 @@
package org.telegram.telegrambots.meta.api.objects.forum;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a service message about a forum topic reopened in the chat.
* Currently holds no information.
* @author Ruben Bermudez
* @version 6.3
*/
@SuppressWarnings("WeakerAccess")
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
public class ForumTopicReopened implements BotApiObject {
}

View File

@ -29,9 +29,9 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.PhotoSize;
/**
* This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
* @author Ruben Bermudez
* @version 2.4
* This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -51,9 +51,12 @@ public class Animation implements BotApiObject {
private static final String MIMETYPE_FIELD = "mime_type";
private static final String FILESIZE_FIELD = "file_size";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
@NonNull
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
@ -61,21 +64,42 @@ public class Animation implements BotApiObject {
@JsonProperty(FILEUNIQUEID_FIELD)
@NonNull
private String fileUniqueId;
/**
* Video width as defined by sender
*/
@JsonProperty(WIDTH_FIELD)
@NonNull
private Integer width; ///< Video width as defined by sender
private Integer width;
/**
* Video height as defined by sender
*/
@JsonProperty(HEIGHT_FIELD)
@NonNull
private Integer height; ///< Video height as defined by sender
private Integer height;
/**
* Duration of the video in seconds as defined by sender
*/
@JsonProperty(DURATION_FIELD)
@NonNull
private Integer duration; ///< Duration of the video in seconds as defined by sender
private Integer duration;
/**
* Optional.
* Animation thumbnail as defined by sender
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb; ///< Optional. Animation thumbnail as defined by sender
private PhotoSize thumb;
/**
* Optional.
* Original animation filename as defined by sender
*/
@JsonProperty(FILENAME_FIELD)
private String fileName; ///< Optional. Original animation filename as defined by sender
private String fileName;
/**
* Optional.
* MIME type of the file as defined by sender
*/
@JsonProperty(MIMETYPE_FIELD)
private String mimetype; ///< Optional. MIME type of the file as defined by sender
private String mimetype;
/**
* Optional.
* File size in bytes.

View File

@ -32,9 +32,9 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize;
import java.util.List;
/**
* This object represents a game.
* @author Ruben Bermudez
* @version 2.4
* This object represents a game.
* @apiNote Use BotFather to create and edit games, their short names will act as unique identifiers.
*/
@EqualsAndHashCode(callSuper = false)
@ -53,15 +53,24 @@ public class Game implements BotApiObject {
private static final String TEXT_FIELD = "text";
private static final String TEXTENTITIES_FIELD = "text_entities";
/**
* Title of the game
*/
@JsonProperty(TITLE_FIELD)
@NonNull
private String title; ///< Title of the game
private String title;
/**
* Description of the game
*/
@JsonProperty(DESCRIPTION_FIELD)
@NonNull
private String description; ///< Description of the game
private String description;
/**
* Photo
*/
@JsonProperty(PHOTO_FIELD)
@NonNull
private List<PhotoSize> photo; ///< Photo
private List<PhotoSize> photo;
/**
* Optional. Brief description of the game or high scores included in the game message.
* Can be automatically edited to include current high scores for the game
@ -76,8 +85,12 @@ public class Game implements BotApiObject {
*/
@JsonProperty(TEXTENTITIES_FIELD)
private List<MessageEntity> entities;
/**
* Optional.
* Animation
*/
@JsonProperty(ANIMATION_FIELD)
private Animation animation; ///< Optional. Animation
private Animation animation;
public boolean hasEntities() {
return entities != null && !entities.isEmpty();

View File

@ -29,9 +29,9 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.User;
/**
* This object represents one row of a game high scores table
* @author Ruben Bermudez
* @version 1.0
* This object represents one row of a game high scores table
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -44,13 +44,22 @@ public class GameHighScore implements BotApiObject {
private static final String USER_FIELD = "user";
private static final String SCORE_FIELD = "score";
/**
* Position in the game high score table
*/
@JsonProperty(POSITION_FIELD)
@NonNull
private Integer position; ///< Position in the game high score table
private Integer position;
/**
* User
*/
@JsonProperty(USER_FIELD)
@NonNull
private User user; ///< User
private User user;
/**
* Score
*/
@JsonProperty(SCORE_FIELD)
@NonNull
private Integer score; ///< Score
private Integer score;
}

View File

@ -19,9 +19,9 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.List;
/**
* Represents the content of a text message to be sent as the result of an inline query.
* @author Ruben Bermudez
* @version 1.0
* Represents the content of a text message to be sent as the result of an inline query.
*/
@JsonDeserialize
@EqualsAndHashCode(callSuper = false)
@ -55,12 +55,18 @@ public class InputInvoiceMessageContent implements InputMessageContent {
private static final String SENDEMAILTOPROVIDER_FIELD = "send_email_to_provider";
private static final String ISFLEXIBLE_FIELD = "is_flexible";
/**
* Product name, 1-32 characters
*/
@JsonProperty(TITLE_FIELD)
@NonNull
private String title; ///< Product name, 1-32 characters
private String title;
/**
* Product description, 1-255 characters
*/
@JsonProperty(DESCRIPTION_FIELD)
@NonNull
private String description; ///< Product description, 1-255 characters
private String description;
/**
* Bot-defined invoice payload, 1-128 bytes.
* This will not be displayed to the user, use for your internal processes.
@ -68,12 +74,18 @@ public class InputInvoiceMessageContent implements InputMessageContent {
@JsonProperty(PAYLOAD_FIELD)
@NonNull
private String payload;
/**
* Payment provider token, obtained via Botfather
*/
@JsonProperty(PROVIDERTOKEN_FIELD)
@NonNull
private String providerToken; ///< Payment provider token, obtained via Botfather
private String providerToken;
/**
* Three-letter ISO 4217 currency code, see more on currencies
*/
@JsonProperty(CURRENCY_FIELD)
@NonNull
private String currency; ///< Three-letter ISO 4217 currency code, see more on currencies
private String currency;
/**
* Price breakdown, a JSON-serialized list of components
* (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
@ -114,26 +126,66 @@ public class InputInvoiceMessageContent implements InputMessageContent {
*/
@JsonProperty(PHOTOURL_FIELD)
private String photoUrl;
/**
* Optional.
* Photo size
*/
@JsonProperty(PHOTOSIZE_FIELD)
private Integer photoSize; ///< Optional. Photo size
private Integer photoSize;
/**
* Optional.
* Photo width
*/
@JsonProperty(PHOTOWIDTH_FIELD)
private Integer photoWidth; ///< Optional. Photo width
private Integer photoWidth;
/**
* Optional.
* Photo height
*/
@JsonProperty(PHOTOHEIGHT_FIELD)
private Integer photoHeight; ///< Optional. Photo height
private Integer photoHeight;
/**
* Optional.
* Pass True, if you require the user's full name to complete the order
*/
@JsonProperty(NEEDNAME_FIELD)
private Boolean needName; ///< Optional. Pass True, if you require the user's full name to complete the order
private Boolean needName;
/**
* Optional.
* Pass True, if you require the user's phone number to complete the order
*/
@JsonProperty(NEEDPHONENUMBER_FIELD)
private Boolean needPhoneNumber; ///< Optional. Pass True, if you require the user's phone number to complete the order
private Boolean needPhoneNumber;
/**
* Optional.
* Pass True, if you require the user's email address to complete the order
*/
@JsonProperty(NEEDEMAIL_FIELD)
private Boolean needEmail; ///< Optional. Pass True, if you require the user's email address to complete the order
private Boolean needEmail;
/**
* Optional.
* Pass True, if you require the user's shipping address to complete the order
*/
@JsonProperty(NEEDSHIPPINGADDRESS_FIELD)
private Boolean needShippingAddress; ///< Optional. Pass True, if you require the user's shipping address to complete the order
private Boolean needShippingAddress;
/**
* Optional.
* Pass True, if user's phone number should be sent to provider
*/
@JsonProperty(SENDPHONENUMBERTOPROVIDER_FIELD)
private Boolean sendPhoneNumberToProvider; ///< Optional. Pass True, if user's phone number should be sent to provider
private Boolean sendPhoneNumberToProvider;
/**
* Optional.
* Pass True, if user's email address should be sent to provider
*/
@JsonProperty(SENDEMAILTOPROVIDER_FIELD)
private Boolean sendEmailToProvider; ///< Optional. Pass True, if user's email address should be sent to provider
private Boolean sendEmailToProvider;
/**
* Optional.
* Pass True, if the final price depends on the shipping method
*/
@JsonProperty(ISFLEXIBLE_FIELD)
private Boolean isFlexible; ///< Optional. Pass True, if the final price depends on the shipping method
private Boolean isFlexible;
@Override
public void validate() throws TelegramApiValidationException {

View File

@ -14,9 +14,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* Represents the content of a location message to be sent as the result of an inline query.
* @author Ruben Bermudez
* @version 1.0
* Represents the content of a location message to be sent as the result of an inline query.
* @apiNote This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
*/
@ -38,14 +38,24 @@ public class InputLocationMessageContent implements InputMessageContent {
private static final String HEADING_FIELD = "heading";
private static final String PROXIMITYALERTRADIUS_FIELD = "proximity_alert_radius";
/**
* Latitude of the location in degrees
*/
@JsonProperty(LATITUDE_FIELD)
@NonNull
private Double latitude; ///< Latitude of the location in degrees
private Double latitude;
/**
* Longitude of the location in degrees
*/
@JsonProperty(LONGITUDE_FIELD)
@NonNull
private Double longitude; ///< Longitude of the location in degrees
private Double longitude;
/**
* Optional.
* Period in seconds for which the location can be updated, should be between 60 and 86400.
*/
@JsonProperty(LIVEPERIOD_FIELD)
private Integer livePeriod; ///< Optional. Period in seconds for which the location can be updated, should be between 60 and 86400.
private Integer livePeriod;
/**
* Optional.
* The radius of uncertainty for the location, measured in meters; 0-1500

View File

@ -37,15 +37,30 @@ public class InputTextMessageContent implements InputMessageContent {
private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
private static final String ENTITIES_FIELD = "entities";
/**
* Text of a message to be sent, 1-4096 characters
*/
@JsonProperty(MESSAGETEXT_FIELD)
@NonNull
private String messageText; ///< Text of a message to be sent, 1-4096 characters
private String messageText;
/**
* Optional.
* Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
*/
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
private String parseMode;
/**
* Optional.
* Disables link previews for links in the sent message
*/
@JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
private Boolean disableWebPagePreview;
/**
* Optional.
* List of special entities that appear in message text, which can be specified instead of parse_mode
*/
@JsonProperty(ENTITIES_FIELD)
private List<MessageEntity> entities; ///< Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
private List<MessageEntity> entities;
@Override
public void validate() throws TelegramApiValidationException {

View File

@ -14,9 +14,9 @@ import lombok.ToString;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* Represents the content of a venue message to be sent as the result of an inline query.
* @author Ruben Bermudez
* @version 1.0
* Represents the content of a venue message to be sent as the result of an inline query.
* @apiNote This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
*/
@ -40,26 +40,50 @@ public class InputVenueMessageContent implements InputMessageContent {
private static final String GOOGLEPLACEID_FIELD = "google_place_id";
private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
/**
* Latitude of the venue in degrees
*/
@JsonProperty(LATITUDE_FIELD)
@NonNull
private Float latitude; ///< Latitude of the venue in degrees
private Float latitude;
/**
* Longitude of the venue in degrees
*/
@JsonProperty(LONGITUDE_FIELD)
@NonNull
private Float longitude; ///< Longitude of the venue in degrees
private Float longitude;
/**
* Name of the venue
*/
@JsonProperty(TITLE_FIELD)
@NonNull
private String title; ///< Name of the venue
private String title;
/**
* Address of the venue
*/
@JsonProperty(ADDRESS_FIELD)
@NonNull
private String address; ///< Address of the venue
private String address;
/**
* Optional. Foursquare identifier of the venue, if known
*/
@JsonProperty(FOURSQUAREID_FIELD)
private String foursquareId; ///< Optional. Foursquare identifier of the venue, if known
private String foursquareId;
/**
* Optional. Foursquare type of the venue, if known.
*/
@JsonProperty(FOURSQUARETYPE_FIELD)
private String foursquareType; ///< Optional. Foursquare type of the venue, if known.
private String foursquareType;
/**
* Optional. Google Places identifier of the venue
*/
@JsonProperty(GOOGLEPLACEID_FIELD)
private String googlePlaceId; ///< Optional. Google Places identifier of the venue
private String googlePlaceId;
/**
* Optional. Google Places type of the venue. (See supported types.)
*/
@JsonProperty(GOOGLEPLACETYPE_FIELD)
private String googlePlaceType; ///< Optional. Google Places type of the venue. (See supported types.)
private String googlePlaceType;
@Override
public void validate() throws TelegramApiValidationException {

View File

@ -15,9 +15,9 @@ import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* This object describes the position on faces where a mask should be placed by default.
* @author Ruben Bermudez
* @version 3.2
* This object describes the position on faces where a mask should be placed by default.
*/
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
@EqualsAndHashCode(callSuper = false)
@ -33,18 +33,30 @@ public class MaskPosition implements Validable, BotApiObject {
private static final String YSHIFT_FIELD = "y_shift";
private static final String SCALE_FIELD = "scale";
/**
* The part of the face relative to which the mask should be placed. One of forehead, eyes, mouth, or chin.
*/
@JsonProperty(POINT_FIELD)
@NonNull
private String point; ///< The part of the face relative to which the mask should be placed. One of forehead, eyes, mouth, or chin.
private String point;
/**
* Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position.
*/
@JsonProperty(XSHIFT_FIELD)
@NonNull
private Float xShift; ///< Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position.
private Float xShift;
/**
* Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position.
*/
@JsonProperty(YSHIFT_FIELD)
@NonNull
private Float yShift; ///< Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position.
private Float yShift;
/**
* Mask scaling coefficient. For example, 2.0 means double size.
*/
@JsonProperty(SCALE_FIELD)
@NonNull
private Float scale; ///< Mask scaling coefficient. For example, 2.0 means double size.
private Float scale;
@Override
public void validate() throws TelegramApiValidationException {

View File

@ -12,9 +12,9 @@ import org.telegram.telegrambots.meta.api.objects.File;
import org.telegram.telegrambots.meta.api.objects.PhotoSize;
/**
* This object represents a sticker.
* @author Ruben Bermudez
* @version 6.1
* This object represents a sticker.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -26,6 +26,7 @@ public class Sticker implements BotApiObject {
private static final String FILEID_FIELD = "file_id";
private static final String FILEUNIQUEID_FIELD = "file_unique_id";
private static final String TYPE_FIELD = "type";
private static final String WIDTH_FIELD = "width";
private static final String HEIGHT_FIELD = "height";
private static final String THUMB_FIELD = "thumb";
@ -36,33 +37,86 @@ public class Sticker implements BotApiObject {
private static final String ISANIMATED_FIELD = "is_animated";
private static final String ISVIDEO_FIELD = "is_video";
private static final String PREMIUMANIMATION_FIELD = "premium_animation";
private static final String CUSTOMEMOJIID_FIELD = "custom_emoji_id";
/**
* Identifier for this file, which can be used to download or reuse the file
*/
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
private String fileId;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
* Can't be used to download or reuse the file.
*/
@JsonProperty(FILEUNIQUEID_FIELD)
private String fileUniqueId;
/**
* Type of the sticker, currently one of regular, mask, custom_emoji.
* The type of the sticker is independent of its format, which is determined by the fields is_animated and is_video.
*/
@JsonProperty(TYPE_FIELD)
private String type;
/**
* Sticker width
*/
@JsonProperty(WIDTH_FIELD)
private Integer width; ///< Sticker width
private Integer width;
/**
* Sticker height
*/
@JsonProperty(HEIGHT_FIELD)
private Integer height; ///< Sticker height
private Integer height;
/**
* Optional.
* Sticker thumbnail in .webp or .jpg format
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb; ///< Optional. Sticker thumbnail in .webp or .jpg format
private PhotoSize thumb;
/**
* Optional.
* File size
*/
@JsonProperty(FILESIZE_FIELD)
private Integer fileSize; ///< Optional. File size
private Integer fileSize;
/**
* Optional.
* Emoji associated with the sticker
*/
@JsonProperty(EMOJI_FIELD)
private String emoji; ///< Optional. Emoji associated with the sticker
private String emoji;
/**
* Optional.
* Name of the sticker set to which the sticker belongs
*/
@JsonProperty(SETNAME_FIELD)
private String setName; ///< Optional. Name of the sticker set to which the sticker belongs
private String setName;
/**
* Optional.
* For mask stickers, the position where the mask should be placed
*/
@JsonProperty(MASKPOSITON_FIELD)
private MaskPosition maskPosition; ///< Optional. For mask stickers, the position where the mask should be placed
private MaskPosition maskPosition;
/**
* True, if the sticker is animated
*/
@JsonProperty(ISANIMATED_FIELD)
private Boolean isAnimated; ///< True, if the sticker is animated
private Boolean isAnimated;
/**
* True, if the sticker is a video sticker
*/
@JsonProperty(ISVIDEO_FIELD)
private Boolean isVideo; ///< True, if the sticker is a video sticker
private Boolean isVideo;
/**
* Optional.
* Premium animation for the sticker, if the sticker is premium
*/
@JsonProperty(PREMIUMANIMATION_FIELD)
private File premiumAnimation; ///< Optional. Premium animation for the sticker, if the sticker is premium
private File premiumAnimation;
/**
* Optional.
* For custom emoji stickers, unique identifier of the custom emoji
*/
@JsonProperty(CUSTOMEMOJIID_FIELD)
private String customEmojiId;
}

View File

@ -13,9 +13,9 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize;
import java.util.List;
/**
* This object represents a sticker set.
* @author Ruben Bermudez
* @version 1.0
* This object represents a sticker set.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -24,6 +24,7 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
public class StickerSet implements BotApiObject {
private static final String STICKERTYPE_FIELD = "sticker_type";
private static final String NAME_FIELD = "name";
private static final String TITLE_FIELD = "title";
private static final String CONTAINSMASKS_FIELD = "contains_masks";
@ -32,18 +33,59 @@ public class StickerSet implements BotApiObject {
private static final String ISVIDEO_FIELD = "is_video";
private static final String THUMB_FIELD = "thumb";
@JsonProperty(NAME_FIELD)
private String name; ///< Sticker set name
@JsonProperty(TITLE_FIELD)
private String title; ///< Sticker set title
@JsonProperty(CONTAINSMASKS_FIELD)
private Boolean containsMasks; ///< True, if the sticker set contains animated stickers
/**
* Type of stickers in the set, currently one of regular, mask, custom_emoji
*/
@JsonProperty(STICKERS_FIELD)
private List<Sticker> stickers; ///< True, if the sticker set contains masks
private String stickerType;
/**
* Sticker set name
*/
@JsonProperty(NAME_FIELD)
private String name;
/**
* Sticker set title
*/
@JsonProperty(TITLE_FIELD)
private String title;
/**
* True, if the sticker set contains animated stickers
*
* @deprecated Use {@link #getStickerType()} or {@link #isMask()}
*/
@JsonProperty(CONTAINSMASKS_FIELD)
@Deprecated
private Boolean containsMasks;
/**
* True, if the sticker set contains masks
*/
@JsonProperty(STICKERS_FIELD)
private List<Sticker> stickers;
/**
* List of all set stickers
*/
@JsonProperty(ISANIMATED_FIELD)
private Boolean isAnimated; ///< List of all set stickers
private Boolean isAnimated;
/**
* True, if the sticker set contains video stickers
*/
@JsonProperty(ISVIDEO_FIELD)
private Boolean isVideo; ///< True, if the sticker set contains video stickers
private Boolean isVideo;
/**
* Optional.
* Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb; ///< Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format
private PhotoSize thumb;
public boolean isRegularSticker() {
return "regular".equals(stickerType);
}
public boolean isMask() {
return "mask".equals(stickerType);
}
public boolean isCustomEmoji() {
return "custom_emoji".equals(stickerType);
}
}

View File

@ -5,10 +5,9 @@ import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a service message about a video chat ended in the chat.
* @author Ruben Bermudez
* @version 6.0
*
* This object represents a service message about a video chat ended in the chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -19,6 +18,9 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
public class VideoChatEnded implements BotApiObject {
private static final String DURATION_FIELD = "duration";
/**
* Voice chat duration; in seconds
*/
@JsonProperty(DURATION_FIELD)
private Integer duration; ///< Voice chat duration; in seconds
private Integer duration;
}

View File

@ -8,11 +8,9 @@ import org.telegram.telegrambots.meta.api.objects.User;
import java.util.List;
/**
* This object represents a service message about new members invited to a video chat.
* @author Ruben Bermudez
* @version 6.0
*
* This object represents a service message about new members invited to a video chat.
*
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -23,6 +21,10 @@ import java.util.List;
public class VideoChatParticipantsInvited implements BotApiObject {
private static final String USERS_FIELD = "users";
/**
* Optional.
* New members that were invited to the voice chat
*/
@JsonProperty(USERS_FIELD)
private List<User> users; ///< Optional. New members that were invited to the voice chat
private List<User> users;
}

View File

@ -5,10 +5,9 @@ import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* This object represents a service message about a video chat scheduled in the chat.
* @author Ruben Bermudez
* @version 6.0
*
* This object represents a service message about a video chat scheduled in the chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -19,7 +18,10 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
public class VideoChatScheduled implements BotApiObject {
private static final String STARTDATE_FIELD = "start_date";
/**
* Point in time (Unix timestamp) when the voice chat is supposed to be started by a chat administrator
*/
@JsonProperty(STARTDATE_FIELD)
@NonNull
private Integer startDate; ///< Point in time (Unix timestamp) when the voice chat is supposed to be started by a chat administrator
private Integer startDate;
}

View File

@ -7,10 +7,9 @@ import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* Contains data sent from a web app to the bot.
* @author Ruben Bermudez
* @version 6.0
*
* Contains data sent from a web app to the bot.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@ -22,11 +21,17 @@ public class WebAppData implements BotApiObject {
private static final String DATA_FIELD = "data";
private static final String BUTTONTEXT_FIELD = "button_text";
/**
* The data
*/
@JsonProperty(DATA_FIELD)
@NonNull
private String data; ///< The data
private String data;
/**
* Text of the web_app keyboard button, from which the web app was opened
*/
@JsonProperty(BUTTONTEXT_FIELD)
@NonNull
private String buttonText; ///< Text of the web_app keyboard button, from which the web app was opened
private String buttonText;
}

View File

@ -2,6 +2,7 @@ package org.telegram.telegrambots.meta.api.methods.invoices;
import org.junit.jupiter.api.Test;
import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.ArrayList;
@ -11,6 +12,7 @@ import java.util.Collections;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Ruben Bermudez
@ -111,6 +113,23 @@ public class CreateInvoiceLinkTest {
assertEquals("No more that 4 suggested tips allowed", thrown.getMessage());
}
@Test
public void testCreateInvoiceLinkDeserializeValidResponse(){
String responseText = "{\n" +
" \"ok\": true,\n" +
" \"result\": \"https://t.me/testlink\" \n" +
"}";
CreateInvoiceLink createInvoiceLink = createSendInvoiceObject();
try {
String link = createInvoiceLink.deserializeResponse(responseText);
assertEquals("https://t.me/testlink",link);
} catch (TelegramApiRequestException e) {
fail(e.getMessage());
}
}
private CreateInvoiceLink createSendInvoiceObject() {
return CreateInvoiceLink.builder()
.title("Title")

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-spring-boot-starter</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-spring-boot-starter:6.1.0'
implementation 'org.telegram:telegrambots-spring-boot-starter:6.3.0'
```
Motivation

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>6.1.0</version>
<version>6.3.0</version>
</parent>
<artifactId>telegrambots-spring-boot-starter</artifactId>
@ -70,8 +70,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<telegrambots.version>6.1.0</telegrambots.version>
<spring-boot.version>2.7.0</spring-boot.version>
<telegrambots.version>6.3.0</telegrambots.version>
<spring-boot.version>2.7.5</spring-boot.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
@ -110,6 +110,17 @@
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>

Some files were not shown because too many files have changed in this diff Show More