Update 5.0 and lombok
This commit is contained in:
parent
3275c10913
commit
447c9d3f92
@ -27,16 +27,16 @@ Just import add the library to your project with one of these options:
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
```gradle
|
||||
compile "org.telegram:telegrambots:4.9.2"
|
||||
compile "org.telegram:telegrambots:5.0.0"
|
||||
```
|
||||
|
||||
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.9.2)
|
||||
3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.9.2)
|
||||
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.0.0)
|
||||
3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.0.0)
|
||||
|
||||
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
### <a id="5.0.0"></a>5.0.0 ###
|
||||
1. Update Api version [5.0](https://core.telegram.org/bots/api-changelog#june-4-2020)
|
||||
2. Added Builders for many of the API methods and objects
|
||||
3. Some setters/getters may have change name. They no longer return a refence to itself, use Builder for that.
|
||||
4. Simplified methods to set files in methods. Only InputFile is available now (this class contains constructors for all the cases)
|
||||
5. Locations now use Double instead of Float to avoid rounding.
|
||||
6. When registering a Webhook Bot, a SetWebhook object must be provided.
|
||||
7. When using Webhook with Spring, extends class SpringWebhookBot instead of WebhookBot
|
||||
|
||||
### <a id="4.9.2"></a>4.9.2 ###
|
||||
1. Bug fixing: #792, #801, #804, #810, #812, #813, #820 and #814
|
||||
|
||||
|
@ -11,13 +11,13 @@ 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>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
* With **Gradle**:
|
||||
|
||||
```groovy
|
||||
compile group: 'org.telegram', name: 'telegrambots', version: '4.9.2'
|
||||
compile group: 'org.telegram', name: 'telegrambots', version: '5.0.0'
|
||||
```
|
||||
|
||||
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
|
||||
|
@ -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>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
* **Gradle**
|
||||
```groovy
|
||||
implementation group: 'org.telegram', name: 'telegrambots-abilities', version: '4.9.2'
|
||||
implementation group: 'org.telegram', name: 'telegrambots-abilities', version: '5.0.0'
|
||||
```
|
||||
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
||||
|
||||
|
14
pom.xml
14
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
|
||||
<modules>
|
||||
<module>telegrambots</module>
|
||||
@ -67,12 +67,12 @@
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
|
||||
<junit.version>5.6.2</junit.version>
|
||||
<mockito.version>3.1.0</mockito.version>
|
||||
<mockitojupiter.version>3.1.0</mockitojupiter.version>
|
||||
<jacksonbase.version>2.10.1</jacksonbase.version>
|
||||
<jackson.version>2.10.1</jackson.version>
|
||||
<slf4j.version>1.7.29</slf4j.version>
|
||||
<junit.version>5.7.0</junit.version>
|
||||
<mockito.version>3.6.0</mockito.version>
|
||||
<mockitojupiter.version>3.6.0</mockitojupiter.version>
|
||||
<jacksonbase.version>2.11.3</jacksonbase.version>
|
||||
<jackson.version>2.11.3</jackson.version>
|
||||
<slf4j.version>1.7.30</slf4j.version>
|
||||
<jakarta.annotation.version>1.3.5</jakarta.annotation.version>
|
||||
<lombok.version>1.18.16</lombok.version>
|
||||
</properties>
|
||||
|
@ -18,19 +18,19 @@ Usage
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-abilities</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
**Gradle**
|
||||
|
||||
```gradle
|
||||
compile "org.telegram:telegrambots-abilities:4.9.2"
|
||||
compile "org.telegram:telegrambots-abilities:5.0.0"
|
||||
```
|
||||
|
||||
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.9.2)
|
||||
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.0)
|
||||
|
||||
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.9.2)
|
||||
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v5.0.0)
|
||||
|
||||
Motivation
|
||||
----------
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambots-abilities</artifactId>
|
||||
@ -76,15 +76,15 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<commonslang.version>3.9</commonslang.version>
|
||||
<mapdb.version>3.0.7</mapdb.version>
|
||||
<commonslang.version>3.11</commonslang.version>
|
||||
<mapdb.version>3.0.8</mapdb.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
@ -3,11 +3,12 @@ package org.telegram.abilitybots.api.bot;
|
||||
import org.telegram.abilitybots.api.db.DBContext;
|
||||
import org.telegram.abilitybots.api.toggle.AbilityToggle;
|
||||
import org.telegram.abilitybots.api.toggle.DefaultToggle;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||
import org.telegram.telegrambots.bots.TelegramWebhookBot;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.meta.generics.WebhookBot;
|
||||
import org.telegram.telegrambots.util.WebhookUtils;
|
||||
|
||||
@ -63,8 +64,8 @@ public abstract class AbilityWebhookBot extends BaseAbilityBot implements Webhoo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWebhook(String url, String publicCertificatePath) throws TelegramApiRequestException {
|
||||
WebhookUtils.setWebhook(this, url, publicCertificatePath);
|
||||
public void setWebhook(SetWebhook setWebhook) throws TelegramApiException {
|
||||
WebhookUtils.setWebhook(this, setWebhook);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -258,7 +258,7 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability
|
||||
}
|
||||
|
||||
public boolean isGroupAdmin(long chatId, int id) {
|
||||
GetChatAdministrators admins = new GetChatAdministrators().setChatId(chatId);
|
||||
GetChatAdministrators admins = GetChatAdministrators.builder().chatId(Long.toString(chatId)).build();
|
||||
return silent.execute(admins)
|
||||
.orElse(new ArrayList<>()).stream()
|
||||
.anyMatch(member -> member.getUser().getId() == id);
|
||||
|
@ -14,6 +14,7 @@ import org.telegram.abilitybots.api.util.AbilityUtils;
|
||||
import org.telegram.abilitybots.api.util.Pair;
|
||||
import org.telegram.telegrambots.meta.api.methods.GetFile;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendDocument;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
@ -221,9 +222,10 @@ public final class DefaultAbilities implements AbilityExtension {
|
||||
|
||||
try (PrintStream printStream = new PrintStream(backup)) {
|
||||
printStream.print(bot.db.backup());
|
||||
bot.sender.sendDocument(new SendDocument()
|
||||
.setDocument(backup)
|
||||
.setChatId(ctx.chatId())
|
||||
bot.sender.sendDocument(SendDocument.builder()
|
||||
.document(new InputFile(backup))
|
||||
.chatId(ctx.chatId().toString())
|
||||
.build()
|
||||
);
|
||||
} catch (FileNotFoundException e) {
|
||||
log.error("Error while fetching backup", e);
|
||||
@ -472,6 +474,6 @@ public final class DefaultAbilities implements AbilityExtension {
|
||||
}
|
||||
|
||||
protected File downloadFileWithId(String fileId) throws TelegramApiException {
|
||||
return bot.sender.downloadFile(bot.sender.execute(new GetFile().setFileId(fileId)));
|
||||
return bot.sender.downloadFile(bot.sender.execute(GetFile.builder().fileId(fileId).build()));
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class SilentSender {
|
||||
public Optional<Message> forceReply(String message, long id) {
|
||||
SendMessage msg = new SendMessage();
|
||||
msg.setText(message);
|
||||
msg.setChatId(id);
|
||||
msg.setChatId(Long.toString(id));
|
||||
msg.setReplyMarkup(new ForceReplyKeyboard());
|
||||
|
||||
return execute(msg);
|
||||
@ -64,7 +64,7 @@ public class SilentSender {
|
||||
|
||||
private Optional<Message> doSendMessage(String txt, long groupId, boolean format) {
|
||||
SendMessage smsg = new SendMessage();
|
||||
smsg.setChatId(groupId);
|
||||
smsg.setChatId(Long.toString(groupId));
|
||||
smsg.setText(txt);
|
||||
smsg.enableMarkdown(format);
|
||||
|
||||
|
@ -702,6 +702,7 @@ public class AbilityBotTest {
|
||||
Message botMessage = mock(Message.class);
|
||||
Document document = mock(Document.class);
|
||||
|
||||
when(document.getFileId()).thenReturn("FAKEFILEID");
|
||||
when(message.getFrom()).thenReturn(CREATOR);
|
||||
when(update.getMessage()).thenReturn(message);
|
||||
when(message.getDocument()).thenReturn(document);
|
||||
|
@ -15,7 +15,7 @@ Usage
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.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.4.2</shiro.version>
|
||||
<shiro.version>1.7.0</shiro.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -84,7 +84,7 @@
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
|
||||
|
@ -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>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
2. Using Gradle:
|
||||
|
||||
```gradle
|
||||
compile "org.telegram:telegrambotsextensions:4.9.2"
|
||||
compile "org.telegram:telegrambotsextensions:5.0.0"
|
||||
```
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambotsextensions</artifactId>
|
||||
@ -75,7 +75,7 @@
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -98,14 +98,14 @@ public class HelpCommand extends ManCommand {
|
||||
IBotCommand command = registry.getRegisteredCommand(arguments[0]);
|
||||
String reply = getManText(command);
|
||||
try {
|
||||
absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML"));
|
||||
absSender.execute(SendMessage.builder().chatId(chat.getId().toString()).text(reply).parseMode("HTML").build());
|
||||
} catch (TelegramApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
String reply = getHelpText(registry);
|
||||
try {
|
||||
absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML"));
|
||||
absSender.execute(SendMessage.builder().chatId(chat.getId().toString()).text(reply).parseMode("HTML").build());
|
||||
} catch (TelegramApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>4.9.2</version>
|
||||
<version>5.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambots-meta</artifactId>
|
||||
@ -70,8 +70,8 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<guice.version>4.2.3</guice.version>
|
||||
<jackson.version>2.10.1</jackson.version>
|
||||
<jacksonanotation.version>2.10.1</jacksonanotation.version>
|
||||
<jackson.version>2.11.3</jackson.version>
|
||||
<jacksonanotation.version>2.11.3</jacksonanotation.version>
|
||||
<json.version>20180813</json.version>
|
||||
<guava.version>30.0-jre</guava.version>
|
||||
</properties>
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.telegram.telegrambots.meta;
|
||||
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.generics.BotSession;
|
||||
import org.telegram.telegrambots.meta.generics.LongPollingBot;
|
||||
@ -11,8 +13,7 @@ import java.text.MessageFormat;
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* @brief Bots manager
|
||||
* @date 14 of January of 2016
|
||||
* Bots manager
|
||||
*/
|
||||
public class TelegramBotsApi {
|
||||
private static final String webhookUrlFormat = "{0}callback/";
|
||||
@ -130,12 +131,13 @@ public class TelegramBotsApi {
|
||||
/**
|
||||
* Register a bot in the api that will receive updates using webhook method
|
||||
* @param bot Bot to register
|
||||
* @param setWebhook Set webhook request to initialize the bot
|
||||
*/
|
||||
public void registerBot(WebhookBot bot) throws TelegramApiRequestException {
|
||||
public void registerBot(WebhookBot bot, SetWebhook setWebhook) throws TelegramApiException {
|
||||
if (useWebhook) {
|
||||
bot.onRegister();
|
||||
webhook.registerWebhook(bot);
|
||||
bot.setWebhook(externalUrl + bot.getBotPath(), pathToCertificate);
|
||||
bot.setWebhook(setWebhook);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,15 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
@ -16,10 +24,18 @@ import java.io.IOException;
|
||||
* will be displayed to the user as a notification at the top of the chat screen or as an alert. On
|
||||
* success, True is returned.
|
||||
*
|
||||
* @note Alternatively, the user can be redirected to the specified URL. For this option to work,
|
||||
* @apiNote Alternatively, the user can be redirected to the specified URL. For this option to work,
|
||||
* you must enable /setcustomurls for your bot via BotFather and accept the terms.
|
||||
*
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "answercallbackquery";
|
||||
|
||||
@ -30,6 +46,7 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
private static final String CACHETIME_FIELD = "cache_time";
|
||||
|
||||
@JsonProperty(CALLBACKQUERYID_FIELD)
|
||||
@NonNull
|
||||
private String callbackQueryId; ///< Unique identifier for the query to be answered
|
||||
@JsonProperty(TEXT_FIELD)
|
||||
private String text; ///< Optional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
|
||||
@ -47,60 +64,11 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
* Optional The maximum amount of time in seconds that the result of the callback query
|
||||
* may be cached client-side.
|
||||
*
|
||||
* @note Telegram apps will support caching starting in version 3.14. Defaults to 0.
|
||||
* @apiNote Telegram apps will support caching starting in version 3.14. Defaults to 0.
|
||||
*/
|
||||
@JsonProperty(CACHETIME_FIELD)
|
||||
private Integer cacheTime;
|
||||
|
||||
public AnswerCallbackQuery() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getCallbackQueryId() {
|
||||
return this.callbackQueryId;
|
||||
}
|
||||
|
||||
public AnswerCallbackQuery setCallbackQueryId(String callbackQueryId) {
|
||||
this.callbackQueryId = callbackQueryId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public AnswerCallbackQuery setText(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getShowAlert() {
|
||||
return this.showAlert;
|
||||
}
|
||||
|
||||
public AnswerCallbackQuery setShowAlert(Boolean showAlert) {
|
||||
this.showAlert = showAlert;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public AnswerCallbackQuery setUrl(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCacheTime() {
|
||||
return cacheTime;
|
||||
}
|
||||
|
||||
public AnswerCallbackQuery setCacheTime(Integer cacheTime) {
|
||||
this.cacheTime = cacheTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -127,15 +95,4 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("CallbackQueryId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AnswerCallbackQuery{" +
|
||||
"callbackQueryId='" + callbackQueryId + '\'' +
|
||||
", text='" + text + '\'' +
|
||||
", showAlert=" + showAlert +
|
||||
", url='" + url + '\'' +
|
||||
", cacheTime=" + cacheTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,23 @@
|
||||
package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult;
|
||||
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.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -19,6 +26,14 @@ import java.util.regex.Pattern;
|
||||
* @version 1.0
|
||||
* Use this method to send answers to an inline query. On success, True is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AnswerInlineQuery extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "answerInlineQuery";
|
||||
|
||||
@ -31,8 +46,11 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
|
||||
private static final String SWITCH_PM_PARAMETER_FIELD = "switch_pm_parameter";
|
||||
|
||||
@JsonProperty(INLINEQUERYID_FIELD)
|
||||
@NonNull
|
||||
private String inlineQueryId; ///< Unique identifier for answered query
|
||||
@JsonProperty(RESULTS_FIELD)
|
||||
@Singular
|
||||
@NonNull
|
||||
private List<InlineQueryResult> results; ///< A JSON-serialized array of results for the inline query
|
||||
@JsonProperty(CACHETIME_FIELD)
|
||||
private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server
|
||||
@ -45,79 +63,6 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
|
||||
@JsonProperty(SWITCH_PM_PARAMETER_FIELD)
|
||||
private String switchPmParameter; ///< Optional. Parameter for the start message sent to the bot when user presses the switch button
|
||||
|
||||
public AnswerInlineQuery() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getInlineQueryId() {
|
||||
return inlineQueryId;
|
||||
}
|
||||
|
||||
public AnswerInlineQuery setInlineQueryId(String inlineQueryId) {
|
||||
this.inlineQueryId = inlineQueryId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<InlineQueryResult> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public AnswerInlineQuery setResults(List<InlineQueryResult> results) {
|
||||
this.results = results;
|
||||
return this;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public AnswerInlineQuery setResults(InlineQueryResult... results) {
|
||||
this.results = Arrays.asList(results);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCacheTime() {
|
||||
return cacheTime;
|
||||
}
|
||||
|
||||
public AnswerInlineQuery setCacheTime(Integer cacheTime) {
|
||||
this.cacheTime = cacheTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean isPersonal() {
|
||||
return isPersonal;
|
||||
}
|
||||
|
||||
public AnswerInlineQuery setPersonal(Boolean personal) {
|
||||
isPersonal = personal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNextOffset() {
|
||||
return nextOffset;
|
||||
}
|
||||
|
||||
public AnswerInlineQuery setNextOffset(String nextOffset) {
|
||||
this.nextOffset = nextOffset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSwitchPmText() {
|
||||
return switchPmText;
|
||||
}
|
||||
|
||||
public AnswerInlineQuery setSwitchPmText(String switchPmText) {
|
||||
this.switchPmText = switchPmText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSwitchPmParameter() {
|
||||
return switchPmParameter;
|
||||
}
|
||||
|
||||
public AnswerInlineQuery setSwitchPmParameter(String switchPmParameter) {
|
||||
this.switchPmParameter = switchPmParameter;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (inlineQueryId == null || inlineQueryId.isEmpty()) {
|
||||
@ -164,17 +109,4 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AnswerInlineQuery{" +
|
||||
"inlineQueryId='" + inlineQueryId + '\'' +
|
||||
", results=" + results +
|
||||
", cacheTime=" + cacheTime +
|
||||
", isPersonal=" + isPersonal +
|
||||
", switchPmText=" + switchPmText +
|
||||
", switchPmParameter=" + switchPmParameter +
|
||||
", nextOffset='" + nextOffset + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,21 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
@ -21,6 +28,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
* @apiNote The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AnswerPreCheckoutQuery extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "answerPreCheckoutQuery";
|
||||
|
||||
@ -29,56 +44,14 @@ public class AnswerPreCheckoutQuery extends BotApiMethod<Boolean> {
|
||||
private static final String ERROR_MESSAGE_FIELD = "error_message";
|
||||
|
||||
@JsonProperty(PRE_CHECKOUT_QUERY_ID_FIELD)
|
||||
@NonNull
|
||||
private String preCheckoutQueryId; ///< Unique identifier for the query to be answered
|
||||
@JsonProperty(OK_FIELD)
|
||||
@NonNull
|
||||
private Boolean ok; ///< Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
|
||||
@JsonProperty(ERROR_MESSAGE_FIELD)
|
||||
private String errorMessage; ///< Optional. Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout
|
||||
|
||||
/**
|
||||
* Creates an empty answer pre-checkout query
|
||||
*/
|
||||
public AnswerPreCheckoutQuery() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an answer pre-checkout query with mandatory parameters
|
||||
* @param preCheckoutQueryId Unique identifier for the query to be answered
|
||||
* @param ok Specify True if delivery to the specified address is possible and False if there are any problems
|
||||
*/
|
||||
public AnswerPreCheckoutQuery(String preCheckoutQueryId, Boolean ok) {
|
||||
this.preCheckoutQueryId = checkNotNull(preCheckoutQueryId);
|
||||
this.ok = checkNotNull(ok);
|
||||
}
|
||||
|
||||
public String getPreCheckoutQueryId() {
|
||||
return preCheckoutQueryId;
|
||||
}
|
||||
|
||||
public AnswerPreCheckoutQuery setPreCheckoutQueryId(String preCheckoutQueryId) {
|
||||
this.preCheckoutQueryId = checkNotNull(preCheckoutQueryId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getOk() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
public AnswerPreCheckoutQuery setOk(Boolean ok) {
|
||||
this.ok = checkNotNull(ok);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public AnswerPreCheckoutQuery setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (preCheckoutQueryId == null || preCheckoutQueryId.isEmpty()) {
|
||||
@ -113,13 +86,4 @@ public class AnswerPreCheckoutQuery extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AnswerPreCheckoutQuery{" +
|
||||
"preCheckoutQueryId='" + preCheckoutQueryId + '\'' +
|
||||
", ok=" + ok +
|
||||
", errorMessage='" + errorMessage + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,23 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.telegram.telegrambots.meta.api.objects.payments.ShippingOption;
|
||||
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 org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.payments.ShippingOption;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
@ -22,6 +29,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
* On success, True is returned
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AnswerShippingQuery extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "answerShippingQuery";
|
||||
|
||||
@ -31,67 +46,16 @@ public class AnswerShippingQuery extends BotApiMethod<Boolean> {
|
||||
private static final String ERROR_MESSAGE_FIELD = "error_message";
|
||||
|
||||
@JsonProperty(SHIPPING_QUERY_ID_FIELD)
|
||||
@NonNull
|
||||
private String shippingQueryId; ///< Unique identifier for the query to be answered
|
||||
@JsonProperty(OK_FIELD)
|
||||
@NonNull
|
||||
private Boolean ok; ///< Specify True if delivery to the specified address is possible and False if there are any problems
|
||||
@JsonProperty(SHIPPING_OPTIONS_FIELD)
|
||||
private List<ShippingOption> shippingOptions; ///< Optional. Required if ok is True. A JSON-serialized array of available shipping options.
|
||||
@JsonProperty(ERROR_MESSAGE_FIELD)
|
||||
private String errorMessage; ///< Optional. Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable').
|
||||
|
||||
/**
|
||||
* Creates an empty answer shipping query
|
||||
*/
|
||||
public AnswerShippingQuery() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an answer shipping query with mandatory parameters
|
||||
* @param shippingQueryId Unique identifier for the query to be answered
|
||||
* @param ok Specify True if delivery to the specified address is possible and False if there are any problems
|
||||
*/
|
||||
public AnswerShippingQuery(String shippingQueryId, Boolean ok) {
|
||||
this.shippingQueryId = checkNotNull(shippingQueryId);
|
||||
this.ok = checkNotNull(ok);
|
||||
}
|
||||
|
||||
public String getShippingQueryId() {
|
||||
return shippingQueryId;
|
||||
}
|
||||
|
||||
public AnswerShippingQuery setShippingQueryId(String shippingQueryId) {
|
||||
this.shippingQueryId = checkNotNull(shippingQueryId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getOk() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
public AnswerShippingQuery setOk(Boolean ok) {
|
||||
this.ok = checkNotNull(ok);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ShippingOption> getShippingOptions() {
|
||||
return shippingOptions;
|
||||
}
|
||||
|
||||
public AnswerShippingQuery setShippingOptions(List<ShippingOption> shippingOptions) {
|
||||
this.shippingOptions = shippingOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public AnswerShippingQuery setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (shippingQueryId == null || shippingQueryId.isEmpty()) {
|
||||
@ -133,14 +97,4 @@ public class AnswerShippingQuery extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AnswerShippingQuery{" +
|
||||
"shippingQueryId='" + shippingQueryId + '\'' +
|
||||
", ok=" + ok +
|
||||
", shippingOptions=" + shippingOptions +
|
||||
", errorMessage='" + errorMessage + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,158 @@
|
||||
package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
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 org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageId;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
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 1.0
|
||||
* Use this method to copy messages of any kind. The method is analogous to the method forwardMessages,
|
||||
* but the copied message doesn't have a link to the original message.
|
||||
* Returns the MessageId of the sent message on success.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class CopyMessage extends BotApiMethod<MessageId> {
|
||||
public static final String PATH = "copyMessage";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_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";
|
||||
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||
private static final String CAPTIONENTITIES_FIELD = "caption_entities";
|
||||
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
@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)
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
@NonNull
|
||||
private Integer messageId; ///< Message identifier in the chat specified in from_chat_id
|
||||
@JsonProperty(CAPTION_FIELD)
|
||||
private String caption; ///< Optional. New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Optional. Mode for parsing entities in the new caption. See formatting options for more details.
|
||||
@JsonProperty(CAPTIONENTITIES_FIELD)
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the new caption, which can be specified instead of parse_mode
|
||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
@JsonProperty(REPLYTOMESSAGEID_FIELD)
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
@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
|
||||
/**
|
||||
* Optional.
|
||||
*
|
||||
* Additional interface options.
|
||||
* A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or
|
||||
* to force a reply from the user.
|
||||
*/
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
@JsonDeserialize()
|
||||
private ReplyKeyboard replyMarkup;
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = null;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public void enableMarkdown(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.MARKDOWN;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void enableHtml(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.HTML;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void enableMarkdownV2(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.MARKDOWNV2;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageId deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
ApiResponse<MessageId> result = OBJECT_MAPPER.readValue(answer,
|
||||
new TypeReference<ApiResponse<MessageId>>(){});
|
||||
if (result.getOk()) {
|
||||
return result.getResult();
|
||||
} else {
|
||||
throw new TelegramApiRequestException("Error copying message", result);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (fromChatId == null) {
|
||||
throw new TelegramApiValidationException("FromChatId parameter can't be empty", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
throw new TelegramApiValidationException("MessageId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
}
|
@ -2,20 +2,35 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
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 org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send text messages. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ForwardMessage extends BotApiMethod<Message> {
|
||||
public static final String PATH = "forwardmessage";
|
||||
|
||||
@ -25,10 +40,13 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (or username for channels)
|
||||
@JsonProperty(FROMCHATID_FIELD)
|
||||
@NonNull
|
||||
private String fromChatId; ///< Unique identifier for the chat where the original message was sent — User or GroupChat id
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
@NonNull
|
||||
private Integer messageId; ///< Unique message identifier
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
@ -39,99 +57,6 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||
private Boolean disableNotification;
|
||||
|
||||
public ForwardMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ForwardMessage(String chatId, String fromChatId, Integer messageId) {
|
||||
this();
|
||||
Objects.requireNonNull(chatId);
|
||||
Objects.requireNonNull(fromChatId);
|
||||
this.chatId = chatId;
|
||||
this.fromChatId = fromChatId;
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public ForwardMessage(String chatId, Long fromChatId, Integer messageId) {
|
||||
this();
|
||||
Objects.requireNonNull(chatId);
|
||||
Objects.requireNonNull(fromChatId);
|
||||
this.chatId = chatId;
|
||||
this.fromChatId = fromChatId.toString();
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public ForwardMessage(Long chatId, String fromChatId, Integer messageId) {
|
||||
this();
|
||||
Objects.requireNonNull(chatId);
|
||||
Objects.requireNonNull(fromChatId);
|
||||
this.chatId = chatId.toString();
|
||||
this.fromChatId = fromChatId;
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public ForwardMessage(Long chatId, Long fromChatId, Integer messageId) {
|
||||
this();
|
||||
Objects.requireNonNull(chatId);
|
||||
Objects.requireNonNull(fromChatId);
|
||||
this.chatId = chatId.toString();
|
||||
this.fromChatId = fromChatId.toString();
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public ForwardMessage setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ForwardMessage setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFromChatId() {
|
||||
return fromChatId;
|
||||
}
|
||||
|
||||
public ForwardMessage setFromChatId(String fromChatId) {
|
||||
this.fromChatId = fromChatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ForwardMessage setFromChatId(Long fromChatId) {
|
||||
Objects.requireNonNull(fromChatId);
|
||||
this.fromChatId = fromChatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public ForwardMessage setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public ForwardMessage enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ForwardMessage disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
@ -164,14 +89,4 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForwardMessage{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", fromChatId='" + fromChatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", disableNotification=" + disableNotification +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,16 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import org.telegram.telegrambots.meta.api.objects.File;
|
||||
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 org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.File;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
@ -21,27 +28,22 @@ import java.io.IOException;
|
||||
* It is guaranteed that the link will be valid for at least 1 hour.
|
||||
* When the link expires, a new one can be requested by calling getFile again.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetFile extends BotApiMethod<File> {
|
||||
public static final String PATH = "getFile";
|
||||
|
||||
private static final String FILEID_FIELD = "file_id";
|
||||
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
@NonNull
|
||||
private String fileId; ///< File identifier to get info about
|
||||
|
||||
public GetFile() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public GetFile setFileId(String fileId) {
|
||||
this.fileId = fileId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (fileId == null) {
|
||||
@ -68,11 +70,4 @@ public class GetFile extends BotApiMethod<File> {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetFile{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
@ -15,13 +20,15 @@ import java.io.IOException;
|
||||
* A simple method for testing your bot's auth token. Requires no parameters.
|
||||
* Returns basic information about the bot in form of a User object
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetMe extends BotApiMethod<User> {
|
||||
public static final String PATH = "getme";
|
||||
|
||||
public GetMe() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
|
@ -3,6 +3,15 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.objects.UserProfilePhotos;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
@ -15,6 +24,14 @@ import java.io.IOException;
|
||||
* @version 1.0
|
||||
* Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> {
|
||||
public static final String PATH = "getuserprofilephotos";
|
||||
|
||||
@ -23,9 +40,10 @@ public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> {
|
||||
private static final String LIMIT_FIELD = "limit";
|
||||
|
||||
@JsonProperty(USERID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< Unique identifier of the target user
|
||||
/**
|
||||
* Sequential number of the first photo to be returned. By default, all photos are returned.
|
||||
* Optional. Sequential number of the first photo to be returned. By default, all photos are returned.
|
||||
*/
|
||||
@JsonProperty(OFFSET_FIELD)
|
||||
private Integer offset;
|
||||
@ -35,37 +53,6 @@ public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> {
|
||||
@JsonProperty(LIMIT_FIELD)
|
||||
private Integer limit;
|
||||
|
||||
public GetUserProfilePhotos() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public GetUserProfilePhotos setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public GetUserProfilePhotos setOffset(Integer offset) {
|
||||
this.offset = offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public GetUserProfilePhotos setLimit(Integer limit) {
|
||||
this.limit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -92,13 +79,4 @@ public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> {
|
||||
throw new TelegramApiValidationException("UserId parameter can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetUserProfilePhotos{" +
|
||||
"userId=" + userId +
|
||||
", offset=" + offset +
|
||||
", limit=" + limit +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,23 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.telegram.telegrambots.meta.api.objects.passport.dataerror.PassportElementError;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import lombok.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.passport.dataerror.PassportElementError;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 4.0.0
|
||||
@ -20,6 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Informs a user that some Telegram Passport data contains errors.
|
||||
* The user will not be able to resend data, until the errors are fixed
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetPassportDataErrors extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setPassportDataErrors";
|
||||
|
||||
@ -27,47 +40,13 @@ public class SetPassportDataErrors extends BotApiMethod<Boolean> {
|
||||
private static final String ERRORS_FIELD = "errors";
|
||||
|
||||
@JsonProperty(USERID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< User identifier
|
||||
@JsonProperty(ERRORS_FIELD)
|
||||
@NonNull
|
||||
@Singular
|
||||
private List<PassportElementError> errors; ///< A JSON-serialized array describing the errors
|
||||
|
||||
public SetPassportDataErrors(Integer userId, List<PassportElementError> errors) {
|
||||
super();
|
||||
this.userId = checkNotNull(userId);
|
||||
this.errors = checkNotNull(errors);
|
||||
}
|
||||
|
||||
public SetPassportDataErrors() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public SetPassportDataErrors setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<PassportElementError> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public SetPassportDataErrors setErrors(List<PassportElementError> errors) {
|
||||
this.errors = errors;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetPassportDataErrors addError(PassportElementError error) {
|
||||
error = checkNotNull(error);
|
||||
if (this.errors == null) {
|
||||
this.errors = new ArrayList<>();
|
||||
}
|
||||
this.errors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
|
@ -2,8 +2,15 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
@ -18,6 +25,13 @@ import java.io.Serializable;
|
||||
* before live_period expires. On success, if the message was sent by the bot, the sent Message is returned,
|
||||
* otherwise True is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class StopMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
public static final String PATH = "stopMessageLiveLocation";
|
||||
|
||||
@ -45,51 +59,6 @@ public class StopMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
||||
|
||||
public StopMessageLiveLocation() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public StopMessageLiveLocation setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StopMessageLiveLocation setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public StopMessageLiveLocation setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public StopMessageLiveLocation setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public StopMessageLiveLocation setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -142,14 +111,4 @@ public class StopMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StopMessageLiveLocation{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.commands;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.commands.BotCommand;
|
||||
@ -17,13 +23,15 @@ import java.util.ArrayList;
|
||||
* Requires no parameters.
|
||||
* Returns Array of BotCommand on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class GetMyCommands extends BotApiMethod<ArrayList<BotCommand>> {
|
||||
public static final String PATH = "getMyCommands";
|
||||
|
||||
public GetMyCommands() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -47,9 +55,4 @@ public class GetMyCommands extends BotApiMethod<ArrayList<BotCommand>> {
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetMyCommands{}";
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.commands;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
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.commands.BotCommand;
|
||||
@ -11,13 +20,18 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 4.7
|
||||
* Use this method to change the list of the bot's commands. Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetMyCommands extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setMyCommands";
|
||||
|
||||
@ -28,25 +42,10 @@ public class SetMyCommands extends BotApiMethod<Boolean> {
|
||||
* At most 100 commands can be specified.
|
||||
*/
|
||||
@JsonProperty(COMMANDS_FIELD)
|
||||
@Singular
|
||||
@NonNull
|
||||
private List<BotCommand> commands;
|
||||
|
||||
public SetMyCommands() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetMyCommands(List<BotCommand> commands) {
|
||||
this.commands = checkNotNull(commands);
|
||||
}
|
||||
|
||||
public List<BotCommand> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public SetMyCommands setCommands(List<BotCommand> commands) {
|
||||
this.commands = checkNotNull(commands);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -79,11 +78,4 @@ public class SetMyCommands extends BotApiMethod<Boolean> {
|
||||
command.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetMyCommands{" +
|
||||
"commands=" + commands +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,15 @@ package org.telegram.telegrambots.meta.api.methods.games;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.games.GameHighScore;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
@ -35,12 +44,20 @@ import java.util.ArrayList;
|
||||
* Will return the score of the specified user and several of his neighbors in a game.
|
||||
* On success, returns an Array of GameHighScore objects.
|
||||
*
|
||||
* @note This method will currently return scores for the target user,
|
||||
* @apiNote This method will currently return scores for the target user,
|
||||
* plus two of his closest neighbors on each side. Will also return the top three users
|
||||
* if the user and his neighbors are not among them.
|
||||
* Please note that this behavior is subject to change.
|
||||
*
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
|
||||
public static final String PATH = "getGameHighScores";
|
||||
|
||||
@ -56,53 +73,9 @@ public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
|
||||
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
|
||||
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 Integer userId; ///<Target user id
|
||||
|
||||
public GetGameHighScores() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public GetGameHighScores setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetGameHighScores setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetGameHighScores setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetGameHighScores setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetGameHighScores setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -144,14 +117,4 @@ public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetGameHighScores{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", userId=" + userId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,15 @@ package org.telegram.telegrambots.meta.api.methods.games;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
@ -39,6 +48,14 @@ import java.io.Serializable;
|
||||
* Returns an error, if the new score is not greater than the user's current score in
|
||||
* the chat and force is False.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
public static final String PATH = "setGameScore";
|
||||
|
||||
@ -59,84 +76,14 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
@JsonProperty(DISABLEEDITMESSAGE_FIELD)
|
||||
private Boolean disableEditMessage; ///< Optional Pass True, if the game message should not be automatically edited to include the current scoreboard. Defaults to False
|
||||
@JsonProperty(USER_ID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< User identifier
|
||||
@JsonProperty(SCORE_FIELD)
|
||||
@NonNull
|
||||
private Integer score; ///< New score, must be positive
|
||||
@JsonProperty(FORCE_FIELD)
|
||||
private Boolean force; ///< Optional. Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters
|
||||
|
||||
public SetGameScore() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public Boolean getDisableEditMessage() {
|
||||
return disableEditMessage;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public Integer getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public Boolean getForce() {
|
||||
return force;
|
||||
}
|
||||
|
||||
public SetGameScore setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setDisableEditMessage(Boolean disableEditMessage) {
|
||||
this.disableEditMessage = disableEditMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setScore(Integer score) {
|
||||
this.score = score;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetGameScore setForce(Boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -192,17 +139,4 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetGameScore{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", disableEditMessage=" + disableEditMessage +
|
||||
", userId=" + userId +
|
||||
", score=" + score +
|
||||
", force=" + force +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -21,43 +26,22 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
* @apiNote In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class DeleteChatPhoto extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "deleteChatPhoto";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
|
||||
public DeleteChatPhoto() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DeleteChatPhoto(String chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
}
|
||||
|
||||
public DeleteChatPhoto(Long chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public DeleteChatPhoto setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeleteChatPhoto setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -84,11 +68,4 @@ public class DeleteChatPhoto extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("ChatId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeleteChatPhoto{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -20,43 +25,22 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class DeleteChatStickerSet extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "deleteChatStickerSet";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public DeleteChatStickerSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet(String chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet(Long chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeleteChatStickerSet setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -83,11 +67,4 @@ public class DeleteChatStickerSet extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeleteChatStickerSet{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -18,43 +23,22 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the
|
||||
* chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ExportChatInviteLink extends BotApiMethod<String> {
|
||||
public static final String PATH = "exportChatInviteLink";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public ExportChatInviteLink() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ExportChatInviteLink(String chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
}
|
||||
|
||||
public ExportChatInviteLink(Long chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public ExportChatInviteLink setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExportChatInviteLink setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -81,11 +65,4 @@ public class ExportChatInviteLink extends BotApiMethod<String> {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExportChatInviteLink{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,60 +2,43 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Chat;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Chat;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to get information about the chat. Returns Chat object on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetChat extends BotApiMethod<Chat> {
|
||||
public static final String PATH = "getChat";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public GetChat() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GetChat(String chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
}
|
||||
|
||||
public GetChat(Long chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public GetChat setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetChat setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -82,11 +65,4 @@ public class GetChat extends BotApiMethod<Chat> {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetChat{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,22 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatMember;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatMember;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -22,33 +28,22 @@ import java.util.Objects;
|
||||
* If the chat is a group or a supergroup and no administrators were appointed,
|
||||
* only the creator will be returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetChatAdministrators extends BotApiMethod<ArrayList<ChatMember>> {
|
||||
public static final String PATH = "getChatAdministrators";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public GetChatAdministrators() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public GetChatAdministrators setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetChatAdministrators setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -75,11 +70,4 @@ public class GetChatAdministrators extends BotApiMethod<ArrayList<ChatMember>> {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetChatAdministrators{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatMember;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatMember;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -18,6 +24,13 @@ import java.util.Objects;
|
||||
* Use this method to get information about a member of a chat.
|
||||
* Returns a ChatMember object on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetChatMember extends BotApiMethod<ChatMember> {
|
||||
public static final String PATH = "getChatMember";
|
||||
|
||||
@ -25,38 +38,12 @@ public class GetChatMember extends BotApiMethod<ChatMember> {
|
||||
private static final String USERID_FIELD = "user_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(USERID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< Unique identifier of the target user
|
||||
|
||||
public GetChatMember() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public GetChatMember setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetChatMember setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public GetChatMember setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -86,12 +73,4 @@ public class GetChatMember extends BotApiMethod<ChatMember> {
|
||||
throw new TelegramApiValidationException("UserId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetChatMember{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", userId='" + userId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,46 +2,42 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to get the number of members in a chat. Returns Int on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetChatMembersCount extends BotApiMethod<Integer> {
|
||||
public static final String PATH = "getChatMembersCount";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public GetChatMembersCount() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public GetChatMembersCount setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetChatMembersCount setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -68,11 +64,4 @@ public class GetChatMembersCount extends BotApiMethod<Integer> {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetChatMembersCount{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,15 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
@ -13,9 +21,6 @@ import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -28,6 +33,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* group. Otherwise members may only be removed by the group's creator or by the member that added
|
||||
* them.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class KickChatMember extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "kickchatmember";
|
||||
|
||||
@ -36,72 +49,27 @@ public class KickChatMember extends BotApiMethod<Boolean> {
|
||||
private static final String UNTILDATE_FIELD = "until_date";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(USER_ID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< Required. Unique identifier of the target user
|
||||
@JsonProperty(UNTILDATE_FIELD)
|
||||
private Integer untilDate; ///< Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
|
||||
private Integer untilDate; ///< Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
|
||||
|
||||
public KickChatMember() {
|
||||
super();
|
||||
}
|
||||
|
||||
public KickChatMember(String chatId, Integer userId) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
public KickChatMember(Long chatId, Integer userId) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public KickChatMember setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public KickChatMember setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public KickChatMember setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUntilDate() {
|
||||
return untilDate;
|
||||
}
|
||||
|
||||
public KickChatMember setUntilDate(Integer untilDateInSeconds) {
|
||||
this.untilDate = untilDateInSeconds;
|
||||
return this;
|
||||
@JsonIgnore
|
||||
public void setUntilDateInstant(Instant instant) {
|
||||
setUntilDate((int) instant.getEpochSecond());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public KickChatMember setUntilDate(Instant instant) {
|
||||
return setUntilDate((int) instant.getEpochSecond());
|
||||
public void setUntilDateDateTime(ZonedDateTime date) {
|
||||
setUntilDateInstant(date.toInstant());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public KickChatMember setUntilDate(ZonedDateTime date) {
|
||||
return setUntilDate(date.toInstant());
|
||||
}
|
||||
|
||||
public KickChatMember forTimePeriod(Duration duration) {
|
||||
return setUntilDate(Instant.now().plusMillis(duration.toMillis()));
|
||||
public void forTimePeriodDuration(Duration duration) {
|
||||
setUntilDateInstant(Instant.now().plusMillis(duration.toMillis()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -133,13 +101,4 @@ public class KickChatMember extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("UserId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KickChatMember{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", userId=" + userId +
|
||||
", untilDate=" + untilDate +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,47 +2,42 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class LeaveChat extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "leaveChat";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
|
||||
public LeaveChat() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public LeaveChat setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaveChat setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -69,11 +64,4 @@ public class LeaveChat extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("ChatId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LeaveChat{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -20,6 +26,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Pass False for all boolean parameters to demote a user. Returns True on success.
|
||||
*
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class PromoteChatMember extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "promoteChatMember";
|
||||
|
||||
@ -33,137 +47,32 @@ public class PromoteChatMember extends BotApiMethod<Boolean> {
|
||||
private static final String CANRESTRICTMEMBERS_FIELD = "can_restrict_members";
|
||||
private static final String CANPINMESSAGES_FIELD = "can_pin_messages";
|
||||
private static final String CANPROMOTEMEMBERS_FIELD = "can_promote_members";
|
||||
private static final String ISANONYMOUS_FIELD = "is_anonymous";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(USER_ID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< Required. Unique identifier of the target user
|
||||
@JsonProperty(CANCHANGEINFORMATION_FIELD)
|
||||
private Boolean canChangeInformation; ///< Pass True, if the administrator can change chat title, photo and other settings
|
||||
private Boolean canChangeInformation; ///< Optional. Pass True, if the administrator can change chat title, photo and other settings
|
||||
@JsonProperty(CANPOSTMESSAGES_FIELD)
|
||||
private Boolean canPostMessages; ///< Pass True, if the administrator can create channel posts, channels only
|
||||
private Boolean canPostMessages; ///< Optional. Pass True, if the administrator can create channel posts, channels only
|
||||
@JsonProperty(CANEDITMESSAGES_FIELD)
|
||||
private Boolean canEditMessages; ///< Pass True, if the administrator can edit messages of other users, channels only
|
||||
private Boolean canEditMessages; ///< Optional. Pass True, if the administrator can edit messages of other users, channels only
|
||||
@JsonProperty(CANDELETEMESSAGES_FIELD)
|
||||
private Boolean canDeleteMessages; ///< Pass True, if the administrator can delete messages of other users
|
||||
private Boolean canDeleteMessages; ///< Optional. Pass True, if the administrator can delete messages of other users
|
||||
@JsonProperty(CANINVITEUSERS_FIELD)
|
||||
private Boolean canInviteUsers; ///< Pass True, if the administrator can invite new users to the chat
|
||||
private Boolean canInviteUsers; ///< Optional. Pass True, if the administrator can invite new users to the chat
|
||||
@JsonProperty(CANRESTRICTMEMBERS_FIELD)
|
||||
private Boolean canRestrictMembers; ///< Pass True, if the administrator can restrict, ban or unban chat members
|
||||
private Boolean canRestrictMembers; ///< Optional. Pass True, if the administrator can restrict, ban or unban chat members
|
||||
@JsonProperty(CANPINMESSAGES_FIELD)
|
||||
private Boolean canPinMessages; ///< Pass True, if the administrator can pin messages
|
||||
private Boolean canPinMessages; ///< Optional. Pass True, if the administrator can pin messages
|
||||
@JsonProperty(CANPROMOTEMEMBERS_FIELD)
|
||||
private Boolean canPromoteMembers; ///< Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administators that were appointed by the him)
|
||||
|
||||
public PromoteChatMember() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PromoteChatMember(String chatId, Integer userId) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
public PromoteChatMember(Long chatId, Integer userId) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public PromoteChatMember setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PromoteChatMember setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public PromoteChatMember setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanChangeInformation() {
|
||||
return canChangeInformation;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanChangeInformation(Boolean canChangeInformation) {
|
||||
this.canChangeInformation = canChangeInformation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanPostMessages() {
|
||||
return canPostMessages;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanPostMessages(Boolean canPostMessages) {
|
||||
this.canPostMessages = canPostMessages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanEditMessages() {
|
||||
return canEditMessages;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanEditMessages(Boolean canEditMessages) {
|
||||
this.canEditMessages = canEditMessages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanDeleteMessages() {
|
||||
return canDeleteMessages;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanDeleteMessages(Boolean canDeleteMessages) {
|
||||
this.canDeleteMessages = canDeleteMessages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanInviteUsers() {
|
||||
return canInviteUsers;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanInviteUsers(Boolean canInviteUsers) {
|
||||
this.canInviteUsers = canInviteUsers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanRestrictMembers() {
|
||||
return canRestrictMembers;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanRestrictMembers(Boolean canRestrictMembers) {
|
||||
this.canRestrictMembers = canRestrictMembers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanPinMessages() {
|
||||
return canPinMessages;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanPinMessages(Boolean canPinMessages) {
|
||||
this.canPinMessages = canPinMessages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getCanPromoteMembers() {
|
||||
return canPromoteMembers;
|
||||
}
|
||||
|
||||
public PromoteChatMember setCanPromoteMembers(Boolean canPromoteMembers) {
|
||||
this.canPromoteMembers = canPromoteMembers;
|
||||
return this;
|
||||
}
|
||||
private Boolean canPromoteMembers; ///< Optional. Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administators that were appointed by the him)
|
||||
@JsonProperty(ISANONYMOUS_FIELD)
|
||||
private Boolean isAnonymous; ///< Optional. Pass True, if the administrator's presence in the chat is hidden
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -195,20 +104,4 @@ public class PromoteChatMember extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("UserId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PromoteChatMember{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", userId=" + userId +
|
||||
", canChangeInformation=" + canChangeInformation +
|
||||
", canPostMessages=" + canPostMessages +
|
||||
", canEditMessages=" + canEditMessages +
|
||||
", canDeleteMessages=" + canDeleteMessages +
|
||||
", canInviteUsers=" + canInviteUsers +
|
||||
", canRestrictMembers=" + canRestrictMembers +
|
||||
", canPinMessages=" + canPinMessages +
|
||||
", canPromoteMembers=" + canPromoteMembers +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,15 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatPermissions;
|
||||
@ -13,9 +22,6 @@ import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -26,6 +32,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class RestrictChatMember extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "restrictchatmember";
|
||||
|
||||
@ -39,19 +53,11 @@ public class RestrictChatMember extends BotApiMethod<Boolean> {
|
||||
private static final String PERMISSIONS_FIELD = "permissions";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(USER_ID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< Required. Unique identifier of the target user
|
||||
@JsonProperty(UNTILDATE_FIELD)
|
||||
private Integer untilDate; ///< Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be banned forever
|
||||
@JsonProperty(CANSENDMESSAGES_FIELD)
|
||||
private Boolean canSendMessages; ///< Pass True, if the user can send text messages, contacts, locations and venues
|
||||
@JsonProperty(CANSENDMEDIAMESSAGES_FIELD)
|
||||
private Boolean canSendMediaMessages; ///< Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
|
||||
@JsonProperty(CANSENDOTHERMESSAGES_FIELD)
|
||||
private Boolean canSendOtherMessages; ///< Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
|
||||
@JsonProperty(CANADDWEBPAGEPREVIEWS_FIELD)
|
||||
private Boolean canAddWebPagePreviews; ///< Pass True, if the user may add web page previews to their messages, implies can_send_messages
|
||||
/**
|
||||
* Optional
|
||||
* Date when restrictions will be lifted for the user, unix time.
|
||||
@ -59,76 +65,24 @@ public class RestrictChatMember extends BotApiMethod<Boolean> {
|
||||
* from the current time, they are considered to be restricted forever
|
||||
*/
|
||||
@JsonProperty(PERMISSIONS_FIELD)
|
||||
@NonNull
|
||||
private ChatPermissions permissions;
|
||||
@JsonProperty(UNTILDATE_FIELD)
|
||||
private Integer untilDate; ///< Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be banned forever
|
||||
|
||||
public RestrictChatMember() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RestrictChatMember(String chatId, Integer userId) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
public RestrictChatMember(Long chatId, Integer userId) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public RestrictChatMember setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestrictChatMember setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public RestrictChatMember setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUntilDate() {
|
||||
return untilDate;
|
||||
}
|
||||
|
||||
public RestrictChatMember setUntilDate(Integer untilDateInSeconds) {
|
||||
this.untilDate = untilDateInSeconds;
|
||||
return this;
|
||||
@JsonIgnore
|
||||
public void setUntilDateInstant(Instant instant) {
|
||||
setUntilDate((int) instant.getEpochSecond());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public RestrictChatMember setUntilDate(Instant instant) {
|
||||
return setUntilDate((int) instant.getEpochSecond());
|
||||
public void setUntilDateDateTime(ZonedDateTime date) {
|
||||
setUntilDateInstant(date.toInstant());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public RestrictChatMember setUntilDate(ZonedDateTime date) {
|
||||
return setUntilDate(date.toInstant());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public RestrictChatMember forTimePeriod(Duration duration) {
|
||||
return setUntilDate(Instant.now().plusMillis(duration.toMillis()));
|
||||
}
|
||||
|
||||
public ChatPermissions getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(ChatPermissions permissions) {
|
||||
this.permissions = permissions;
|
||||
public void forTimePeriodDuration(Duration duration) {
|
||||
setUntilDateInstant(Instant.now().plusMillis(duration.toMillis()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,18 +117,4 @@ public class RestrictChatMember extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("Permissions can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RestrictChatMember{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", userId=" + userId +
|
||||
", untilDate=" + untilDate +
|
||||
", canSendMessages=" + canSendMessages +
|
||||
", canSendMediaMessages=" + canSendMediaMessages +
|
||||
", canSendOtherMessages=" + canSendOtherMessages +
|
||||
", canAddWebPagePreviews=" + canAddWebPagePreviews +
|
||||
", permissions=" + permissions +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -18,6 +23,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetChatAdministratorCustomTitle extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setChatAdministratorCustomTitle";
|
||||
|
||||
@ -26,65 +38,15 @@ public class SetChatAdministratorCustomTitle extends BotApiMethod<Boolean> {
|
||||
private static final String CUSTOMTITLE_FIELD = "custom_title";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
@JsonProperty(USERID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< Unique identifier of the target user
|
||||
@JsonProperty(CUSTOMTITLE_FIELD)
|
||||
@NonNull
|
||||
private String customTitle; ///< New custom title for the administrator; 0-16 characters, emoji are not allowed
|
||||
|
||||
public SetChatAdministratorCustomTitle() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetChatAdministratorCustomTitle(String chatId, Integer userId, String customTitle) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.userId = checkNotNull(userId);
|
||||
this.customTitle = checkNotNull(customTitle);
|
||||
}
|
||||
|
||||
public SetChatAdministratorCustomTitle(Long chatId, Integer userId, String customTitle) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.userId = checkNotNull(userId);
|
||||
this.customTitle = checkNotNull(customTitle);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SetChatAdministratorCustomTitle setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatAdministratorCustomTitle setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public SetChatAdministratorCustomTitle setUserId(Integer userId) {
|
||||
checkNotNull(userId);
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCustomTitle() {
|
||||
return customTitle;
|
||||
}
|
||||
|
||||
public SetChatAdministratorCustomTitle setCustomTitle(String customTitle) {
|
||||
checkNotNull(customTitle);
|
||||
this.customTitle = customTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -117,13 +79,4 @@ public class SetChatAdministratorCustomTitle extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("CustomTitle can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetChatDescription{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
"userId='" + userId + '\'' +
|
||||
", customTitle='" + customTitle + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -19,6 +25,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetChatDescription extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setChatDescription";
|
||||
|
||||
@ -26,50 +40,10 @@ public class SetChatDescription extends BotApiMethod<Boolean> {
|
||||
private static final String DESCRIPTION_FIELD = "description";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
@JsonProperty(DESCRIPTION_FIELD)
|
||||
private String description; ///< New chat description, 0-255 characters
|
||||
|
||||
public SetChatDescription() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetChatDescription(String chatId, String description) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.description = checkNotNull(description);
|
||||
}
|
||||
|
||||
public SetChatDescription(Long chatId, String description) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.description = checkNotNull(description);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SetChatDescription setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatDescription setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public SetChatDescription setDescription(String description) {
|
||||
Objects.requireNonNull(description);
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
private String description; ///< Optional. New chat description, 0-255 characters
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -100,12 +74,4 @@ public class SetChatDescription extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("Description can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetChatDescription{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatPermissions;
|
||||
@ -9,9 +17,6 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -20,6 +25,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* The bot must be an administrator in the group or a supergroup
|
||||
* for this to work and must have the can_restrict_members admin rights.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetChatPermissions extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setChatPermissions";
|
||||
|
||||
@ -27,51 +39,12 @@ public class SetChatPermissions extends BotApiMethod<Boolean> {
|
||||
private static final String PERMISSIONS_FIELD = "permissions";
|
||||
|
||||
@JsonProperty(CHAT_ID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
||||
@JsonProperty(PERMISSIONS_FIELD)
|
||||
@NonNull
|
||||
private ChatPermissions permissions; ///< New default chat permissions
|
||||
|
||||
public SetChatPermissions() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetChatPermissions(String chatId, ChatPermissions permissions) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.permissions = checkNotNull(permissions);
|
||||
}
|
||||
|
||||
public SetChatPermissions(Long chatId, ChatPermissions permissions) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.permissions = checkNotNull(permissions);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SetChatPermissions setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatPermissions setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChatPermissions getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public SetChatPermissions setPermissions(ChatPermissions permissions) {
|
||||
Objects.requireNonNull(permissions);
|
||||
this.permissions = permissions;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -101,12 +74,4 @@ public class SetChatPermissions extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("Permissions can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetChatPermissions{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", permissions=" + permissions +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,21 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -22,87 +26,23 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
* @apiNote In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetChatPhoto extends PartialBotApiMethod<Boolean> {
|
||||
public static final String PATH = "setChatPhoto";
|
||||
|
||||
public static final String CHATID_FIELD = "chat_id";
|
||||
public static final String PHOTO_FIELD = "photo";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
private String photoName; ///< Name of new chat photo
|
||||
private InputStream photoStream; ///< New chat photo as InputStream, uploaded using multipart/form-data
|
||||
private File photo; ///< New chat photo as File, uploaded using multipart/form-data
|
||||
|
||||
public SetChatPhoto() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetChatPhoto(String chatId, File photo) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.photo = checkNotNull(photo);
|
||||
}
|
||||
|
||||
public SetChatPhoto(String chatId, InputStream photoStream, String photoName) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.photoStream = checkNotNull(photoStream);
|
||||
this.photoName = checkNotNull(photoName);
|
||||
}
|
||||
|
||||
|
||||
public SetChatPhoto(Long chatId, File photo) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.photo = checkNotNull(photo);
|
||||
}
|
||||
|
||||
public SetChatPhoto(Long chatId, InputStream photoStream, String photoName) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.photoStream = checkNotNull(photoStream);
|
||||
this.photoName = checkNotNull(photoName);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SetChatPhoto setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatPhoto setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatPhoto setPhoto(File file) {
|
||||
this.photo = file;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatPhoto setNewPhoto(String photoName, InputStream inputStream) {
|
||||
Objects.requireNonNull(photoName, "photoName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.photoName = photoName;
|
||||
this.photoStream = inputStream;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPhotoName() {
|
||||
return photoName;
|
||||
}
|
||||
|
||||
public InputStream getPhotoStream() {
|
||||
return photoStream;
|
||||
}
|
||||
|
||||
public File getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
@NonNull
|
||||
private InputFile photo; ///< New chat photo as InputStream, uploaded using multipart/form-data
|
||||
|
||||
@Override
|
||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
@ -124,22 +64,8 @@ public class SetChatPhoto extends PartialBotApiMethod<Boolean> {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId can't be empty", this);
|
||||
}
|
||||
if (photo == null) {
|
||||
if (photoStream == null) {
|
||||
throw new TelegramApiValidationException("Photo parameter is required", this);
|
||||
} else if (photoName == null || photoName.isEmpty()){
|
||||
throw new TelegramApiValidationException("Photo name can't be empty", this);
|
||||
}
|
||||
if (photo == null || !photo.isNew()) {
|
||||
throw new TelegramApiValidationException("Photo parameter is required and must be a new file to upload", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetChatPhoto{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", photoName='" + photoName + '\'' +
|
||||
", photoStream=" + photoStream +
|
||||
", photo=" + photo +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -20,6 +25,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetChatStickerSet extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setChatStickerSet";
|
||||
|
||||
@ -27,50 +39,12 @@ public class SetChatStickerSet extends BotApiMethod<Boolean> {
|
||||
private static final String STICKERSETNAME_FIELD = "sticker_set_name";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(STICKERSETNAME_FIELD)
|
||||
@NonNull
|
||||
private String stickerSetName; ///< Name of the sticker set to be set as the group sticker set
|
||||
|
||||
public SetChatStickerSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetChatStickerSet(String chatId, String stickerSetName) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.stickerSetName = checkNotNull(stickerSetName);
|
||||
}
|
||||
|
||||
public SetChatStickerSet(Long chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SetChatStickerSet setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatStickerSet setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStickerSetName() {
|
||||
return stickerSetName;
|
||||
}
|
||||
|
||||
public SetChatStickerSet setStickerSetName(String stickerSetName) {
|
||||
Objects.requireNonNull(stickerSetName);
|
||||
this.stickerSetName = stickerSetName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -100,12 +74,4 @@ public class SetChatStickerSet extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("StickerSetName can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetChatStickerSet{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", stickerSetName='" + stickerSetName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -21,6 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
* @apiNote In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetChatTitle extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setChatTitle";
|
||||
|
||||
@ -28,51 +40,12 @@ public class SetChatTitle extends BotApiMethod<Boolean> {
|
||||
private static final String TITLE_FIELD = "title";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
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
|
||||
|
||||
public SetChatTitle() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetChatTitle(String chatId, String title) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.title = checkNotNull(title);
|
||||
}
|
||||
|
||||
public SetChatTitle(Long chatId, String title) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.title = checkNotNull(title);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SetChatTitle setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetChatTitle setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public SetChatTitle setTitle(String title) {
|
||||
Objects.requireNonNull(title);
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -102,12 +75,4 @@ public class SetChatTitle extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("Title can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetChatTitle{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,74 +2,58 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to unban a previously kicked user in a supergroup. The user will not
|
||||
* return to the group automatically, but will be able to join via link, etc. The bot must be an
|
||||
* administrator in the group for this to work. Returns True on success.
|
||||
* Use this method to unban a previously kicked user in a supergroup or channel.
|
||||
* Returns True on success.
|
||||
*
|
||||
* @apiNote The user will not return to the group or channel automatically, but will be able to join via link, etc.
|
||||
* @apiNote The bot must be an administrator for this to work.
|
||||
* @apiNote By default, this method guarantees that after the call the user is not a member of the chat,
|
||||
* but will be able to join it.
|
||||
* @apiNote So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class UnbanChatMember extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "unbanchatmember";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
private static final String USER_ID_FIELD = "user_id";
|
||||
private static final String USERID_FIELD = "user_id";
|
||||
private static final String ONLYISBANNED_FIELD = "only_if_banned";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(USER_ID_FIELD)
|
||||
@JsonProperty(USERID_FIELD)
|
||||
@NonNull
|
||||
private Integer userId; ///< Required. Unique identifier of the target user
|
||||
@JsonProperty(ONLYISBANNED_FIELD)
|
||||
private Boolean onlyIfBanned; ///< Optional. Do nothing if the user is not banned
|
||||
|
||||
public UnbanChatMember() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UnbanChatMember(String chatId, Integer userId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
public UnbanChatMember(Long chatId, Integer userId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public UnbanChatMember setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UnbanChatMember setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public UnbanChatMember setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -100,12 +84,4 @@ public class UnbanChatMember extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("UserId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UnbanChatMember{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", userId='" + userId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,39 @@ package org.telegram.telegrambots.meta.api.methods.pinnedmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 3.1
|
||||
* Use this method to pin a message in a group, a supergroup or a channel.
|
||||
* The bot must be an administrator in the chat for this to work and must
|
||||
* have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’
|
||||
* admin right in the channel. Returns True on success.
|
||||
* Use this method to add a message to the list of pinned messages in a chat.
|
||||
* Returns True on success.
|
||||
*
|
||||
* @apiNote If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must
|
||||
* have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class PinChatMessage extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "pinChatMessage";
|
||||
|
||||
@ -28,8 +43,10 @@ public class PinChatMessage extends BotApiMethod<Boolean> {
|
||||
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
@NonNull
|
||||
private Integer messageId; ///< Required. Identifier of a message to pin
|
||||
/**
|
||||
* Pass True, if it is not necessary to send a notification to all chat members about the new pinned message.
|
||||
@ -38,56 +55,6 @@ public class PinChatMessage extends BotApiMethod<Boolean> {
|
||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||
private Boolean disableNotification;
|
||||
|
||||
public PinChatMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PinChatMessage(String chatId, Integer messageId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.messageId = checkNotNull(messageId);
|
||||
}
|
||||
|
||||
public PinChatMessage(Long chatId, Integer messageId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.messageId = checkNotNull(messageId);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public PinChatMessage setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PinChatMessage setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public PinChatMessage setMessageId(Integer messageId) {
|
||||
Objects.requireNonNull(messageId);
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public PinChatMessage setDisableNotification(Boolean disableNotification) {
|
||||
this.disableNotification = disableNotification;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -117,13 +84,4 @@ public class PinChatMessage extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("MessageId parameter can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PinChatMessage{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", disableNotification=" + disableNotification +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.pinnedmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 3.1
|
||||
* Use this method to clear the list of pinned messages in a chat.
|
||||
* Returns True on success.
|
||||
*
|
||||
* @apiNote If the chat is not a private chat, the bot must be an administrator in the chat for this to
|
||||
* work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin
|
||||
* right in a channel.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class UnpinAllChatMessages extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "unpinAllChatMessages";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
|
||||
new TypeReference<ApiResponse<Boolean>>(){});
|
||||
if (result.getOk()) {
|
||||
return result.getResult();
|
||||
} else {
|
||||
throw new TelegramApiRequestException("Error unpinning chat message", result);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,60 +2,57 @@ package org.telegram.telegrambots.meta.api.methods.pinnedmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 3.1
|
||||
* Use this method to unpin a message in a group, a supergroup or a channel.
|
||||
* The bot must be an administrator in the chat for this to work and must have
|
||||
* the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’
|
||||
* admin right in the channel. Returns True on success.
|
||||
* Use this method to remove a message from the list of pinned messages in a chat.
|
||||
* Returns True on success.
|
||||
*
|
||||
* @apiNote If the chat is not a private chat, the bot must be an administrator in the chat for this to work
|
||||
* and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages'
|
||||
* admin right in a channel.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class UnpinChatMessage extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "unpinChatMessage";
|
||||
|
||||
private static final String CHATID_FIELD = "chat_id";
|
||||
private static final String MESSAGEID_FIELD = "message_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
|
||||
public UnpinChatMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UnpinChatMessage(String chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
}
|
||||
|
||||
public UnpinChatMessage(Long chatId) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public UnpinChatMessage setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UnpinChatMessage setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Optional.
|
||||
* Identifier of a message to unpin.
|
||||
*
|
||||
* @apiNote If not specified, the most recent pinned message (by send date) will be unpinned.
|
||||
*/
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
private Integer messageId;
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -83,11 +80,4 @@ public class UnpinChatMessage extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UnpinChatMessage{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,26 @@ package org.telegram.telegrambots.meta.api.methods.polls;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
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.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.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -25,6 +32,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
* On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendPoll extends BotApiMethod<Message> {
|
||||
public static final String PATH = "sendPoll";
|
||||
|
||||
@ -43,17 +58,23 @@ public class SendPoll extends BotApiMethod<Message> {
|
||||
private static final String CLOSEDATE_FIELD = "close_date";
|
||||
private static final String EXPLANATION_FIELD = "explanation";
|
||||
private static final String EXPLANATIONPARSEMODE_FIELD = "explanation_parse_mode";
|
||||
private static final String EXPLANATION_ENTITIES_FIELD = "explanation_entities";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
/**
|
||||
* Unique identifier for the target chat or username of the target channel (in the format @channelusername).
|
||||
* A native poll can't be sent to a private chat.
|
||||
*/
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
@JsonProperty(QUESTION_FIELD)
|
||||
private String question; ///< Poll question, 1-255 characters
|
||||
@NonNull
|
||||
private String question; ///< Poll question, 1-300 characters
|
||||
@JsonProperty(OPTIONS_FIELD)
|
||||
private List<String> options = new ArrayList<>(); ///< List of answer options, 2-10 strings 1-100 characters each
|
||||
@Singular
|
||||
@NonNull
|
||||
private List<String> options; ///< List of answer options, 2-10 strings 1-100 characters each
|
||||
@JsonProperty(ISANONYMOUS_FIELD)
|
||||
private Boolean isAnonymous; ///< Optional True, if the poll needs to be anonymous, defaults to True
|
||||
@JsonProperty(TYPE_FIELD)
|
||||
@ -79,168 +100,18 @@ public class SendPoll extends BotApiMethod<Message> {
|
||||
private String explanation; ///< Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
|
||||
@JsonProperty(EXPLANATIONPARSEMODE_FIELD)
|
||||
private String explanationParseMode; ///< Optional. Mode for parsing entities in the explanation. See formatting options for more details.
|
||||
@JsonProperty(EXPLANATION_ENTITIES_FIELD)
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the poll explanation, which can be specified instead of parse_mode
|
||||
@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
|
||||
|
||||
public SendPoll() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SendPoll(String chatId, String question, List<String> options) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.question = checkNotNull(question);
|
||||
this.options = checkNotNull(options);
|
||||
}
|
||||
|
||||
public SendPoll(Long chatId, String question, List<String> options) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.question = checkNotNull(question);
|
||||
this.options = checkNotNull(options);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendPoll setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendPoll setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public SendPoll setQuestion(String question) {
|
||||
this.question = question;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public SendPoll setOptions(List<String> options) {
|
||||
this.options = options;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendPoll setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendPoll setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendPoll enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendPoll disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getAnonymous() {
|
||||
return isAnonymous;
|
||||
}
|
||||
|
||||
public SendPoll setAnonymous(Boolean anonymous) {
|
||||
isAnonymous = anonymous;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public SendPoll setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getAllowMultipleAnswers() {
|
||||
return allowMultipleAnswers;
|
||||
}
|
||||
|
||||
public SendPoll setAllowMultipleAnswers(Boolean allowMultipleAnswers) {
|
||||
this.allowMultipleAnswers = allowMultipleAnswers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCorrectOptionId() {
|
||||
return correctOptionId;
|
||||
}
|
||||
|
||||
public SendPoll setCorrectOptionId(Integer correctOptionId) {
|
||||
this.correctOptionId = correctOptionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getClosed() {
|
||||
return isClosed;
|
||||
}
|
||||
|
||||
public SendPoll setClosed(Boolean closed) {
|
||||
isClosed = closed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getOpenPeriod() {
|
||||
return openPeriod;
|
||||
}
|
||||
|
||||
public SendPoll setOpenPeriod(Integer openPeriod) {
|
||||
this.openPeriod = openPeriod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCloseDate() {
|
||||
return closeDate;
|
||||
}
|
||||
|
||||
public SendPoll setCloseDate(Integer closeDate) {
|
||||
this.closeDate = closeDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getExplanation() {
|
||||
return explanation;
|
||||
}
|
||||
|
||||
public SendPoll setExplanation(String explanation) {
|
||||
this.explanation = explanation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getExplanationParseMode() {
|
||||
return explanationParseMode;
|
||||
}
|
||||
|
||||
public SendPoll setExplanationParseMode(String explanationParseMode) {
|
||||
this.explanationParseMode = explanationParseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -287,57 +158,11 @@ public class SendPoll extends BotApiMethod<Message> {
|
||||
if (options.parallelStream().anyMatch(x -> x.isEmpty() || x.length() > 100)) {
|
||||
throw new TelegramApiValidationException("Options parameter values must be between 1 and 100 chars length", this);
|
||||
}
|
||||
if (explanationParseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof SendPoll)) return false;
|
||||
SendPoll sendPoll = (SendPoll) o;
|
||||
return Objects.equals(chatId, sendPoll.chatId) &&
|
||||
Objects.equals(question, sendPoll.question) &&
|
||||
Objects.equals(options, sendPoll.options) &&
|
||||
Objects.equals(isAnonymous, sendPoll.isAnonymous) &&
|
||||
Objects.equals(type, sendPoll.type) &&
|
||||
Objects.equals(allowMultipleAnswers, sendPoll.allowMultipleAnswers) &&
|
||||
Objects.equals(correctOptionId, sendPoll.correctOptionId) &&
|
||||
Objects.equals(isClosed, sendPoll.isClosed) &&
|
||||
Objects.equals(disableNotification, sendPoll.disableNotification) &&
|
||||
Objects.equals(replyToMessageId, sendPoll.replyToMessageId) &&
|
||||
Objects.equals(replyMarkup, sendPoll.replyMarkup) &&
|
||||
Objects.equals(openPeriod, sendPoll.openPeriod) &&
|
||||
Objects.equals(closeDate, sendPoll.closeDate) &&
|
||||
Objects.equals(explanation, sendPoll.explanation) &&
|
||||
Objects.equals(explanationParseMode, sendPoll.explanationParseMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(chatId, question, options, isAnonymous, type, allowMultipleAnswers, correctOptionId, isClosed,
|
||||
disableNotification, replyToMessageId, replyMarkup, openPeriod, closeDate, explanation, explanationParseMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendPoll{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", question='" + question + '\'' +
|
||||
", options=" + options +
|
||||
", isAnonymous=" + isAnonymous +
|
||||
", type='" + type + '\'' +
|
||||
", allowMultipleAnswers=" + allowMultipleAnswers +
|
||||
", correctOptionId=" + correctOptionId +
|
||||
", isClosed=" + isClosed +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", openPeriod=" + openPeriod +
|
||||
", closeDate=" + closeDate +
|
||||
", explanation='" + explanation + '\'' +
|
||||
", explanationParseMode='" + explanationParseMode + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.polls;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -20,6 +25,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*
|
||||
* On success, the stopped Poll with the final results is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class StopPoll extends BotApiMethod<Poll> {
|
||||
public static final String PATH = "stopPoll";
|
||||
|
||||
@ -27,48 +39,12 @@ public class StopPoll extends BotApiMethod<Poll> {
|
||||
private static final String MESSAGEID_FIELD = "message_id";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
@NonNull
|
||||
private Integer messageId; ///< Identifier of the original message with the poll
|
||||
|
||||
public StopPoll() {
|
||||
super();
|
||||
}
|
||||
|
||||
public StopPoll(String chatId, Integer messageId) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.messageId = checkNotNull(messageId);
|
||||
}
|
||||
|
||||
public StopPoll(Long chatId, Integer messageId) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.messageId = checkNotNull(messageId);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public StopPoll setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StopPoll setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public StopPoll setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -98,31 +74,4 @@ public class StopPoll extends BotApiMethod<Poll> {
|
||||
throw new TelegramApiValidationException("Message Id parameter can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof StopPoll)) {
|
||||
return false;
|
||||
}
|
||||
StopPoll sendMessage = (StopPoll) o;
|
||||
return Objects.equals(chatId, sendMessage.chatId)
|
||||
&& Objects.equals(messageId, sendMessage.messageId)
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
chatId,
|
||||
messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StopPoll{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,27 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -22,6 +31,14 @@ import java.util.Objects;
|
||||
*
|
||||
* Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendAnimation extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "sendAnimation";
|
||||
|
||||
@ -36,14 +53,17 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
/**
|
||||
* Animation to send. Pass a file_id as String to send an animation that exists on the
|
||||
* 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.
|
||||
*/
|
||||
@NonNull
|
||||
private InputFile animation;
|
||||
private Integer duration; ///< Optional. Duration of sent animation in seconds
|
||||
private String caption; ///< Optional. Animation caption (may also be used when resending videos by file_id).
|
||||
@ -54,6 +74,7 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
/**
|
||||
* Optional.
|
||||
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||
* A thumbnail’s width and height should not exceed 320.
|
||||
* Ignored if the file is not uploaded using multipart/form-data.
|
||||
@ -61,137 +82,16 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
|
||||
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
|
||||
*/
|
||||
private InputFile thumb;
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public SendAnimation() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendAnimation setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getAnimation() {
|
||||
return animation;
|
||||
}
|
||||
|
||||
public SendAnimation setAnimation(String animation) {
|
||||
this.animation = new InputFile(animation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAnimation setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public SendAnimation setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public SendAnimation setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendAnimation setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendAnimation setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendAnimation enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAnimation disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public SendAnimation setWidth(Integer width) {
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public SendAnimation setHeight(Integer height) {
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAnimation setAnimation(File file) {
|
||||
this.animation = new InputFile(file, file.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAnimation setAnimation(String animationName, InputStream inputStream) {
|
||||
Objects.requireNonNull(animationName, "animationName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.animation = new InputFile(inputStream, animationName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAnimation setAnimation(InputFile animation) {
|
||||
Objects.requireNonNull(animation, "animation cannot be null!");
|
||||
this.animation = animation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public SendAnimation setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public SendAnimation setThumb(InputFile thumb) {
|
||||
this.thumb = thumb;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -219,6 +119,10 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("Animation parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
|
||||
animation.validate();
|
||||
|
||||
if (replyMarkup != null) {
|
||||
@ -228,20 +132,4 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
|
||||
thumb.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendAnimation{" + "chatId='" + chatId + '\'' +
|
||||
", animation=" + animation +
|
||||
", duration=" + duration +
|
||||
", caption='" + caption + '\'' +
|
||||
", width=" + width +
|
||||
", height=" + height +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", thumb=" + thumb +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,27 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -21,8 +30,16 @@ import java.util.Objects;
|
||||
* Telegram clients to display them in the music player. Your audio must be in an .mp3 format. On
|
||||
* success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in
|
||||
* size, this limit may be changed in the future.
|
||||
* @note For sending voice notes, use sendVoice method instead.
|
||||
* @apiNote For sending voice notes, use sendVoice method instead.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendAudio extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "sendaudio";
|
||||
|
||||
@ -37,9 +54,14 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
||||
public static final String CAPTION_FIELD = "caption";
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@NonNull
|
||||
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
|
||||
@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
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
@ -47,8 +69,9 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
||||
private String performer; ///< Optional. Performer of sent audio
|
||||
private String title; ///< Optional. Title of sent audio
|
||||
private String caption; ///< Optional. Audio caption (may also be used when resending documents by file_id), 0-200 characters
|
||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
/**
|
||||
* Optional.
|
||||
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||
* A thumbnail’s width and height should not exceed 320.
|
||||
* Ignored if the file is not uploaded using multipart/form-data.
|
||||
@ -56,149 +79,16 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
||||
* “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
|
||||
*/
|
||||
private InputFile thumb;
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public SendAudio() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public SendAudio setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendAudio setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAudio setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getAudio() {
|
||||
return audio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the audio to an audio existing in Telegram system
|
||||
*
|
||||
* @param audio File_id of the audio to send
|
||||
* @note The file_id must have already been received or sent by your bot
|
||||
*/
|
||||
public SendAudio setAudio(String audio) {
|
||||
this.audio = new InputFile(audio);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the audio to a new file
|
||||
*
|
||||
* @param file New audio file
|
||||
*/
|
||||
public SendAudio setAudio(File file) {
|
||||
Objects.requireNonNull(file, "file cannot be null!");
|
||||
this.audio = new InputFile(file, file.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAudio setAudio(String audioName, InputStream inputStream) {
|
||||
Objects.requireNonNull(audioName, "audioName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.audio = new InputFile(inputStream, audioName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAudio setAudio(InputFile audio) {
|
||||
Objects.requireNonNull(audio, "audio cannot be null!");
|
||||
this.audio = audio;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendAudio setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendAudio setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPerformer() {
|
||||
return performer;
|
||||
}
|
||||
|
||||
public SendAudio setPerformer(String performer) {
|
||||
this.performer = performer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public SendAudio setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendAudio enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAudio disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public SendAudio setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public SendAudio setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public SendAudio setThumb(InputFile thumb) {
|
||||
this.thumb = thumb;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -226,6 +116,10 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("Audio parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
|
||||
audio.validate();
|
||||
|
||||
if (thumb != null) {
|
||||
@ -236,21 +130,4 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendAudio{" +
|
||||
"duration=" + duration +
|
||||
", chatId='" + chatId + '\'' +
|
||||
", audio=" + audio +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", performer='" + performer + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", caption='" + caption + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", thumb=" + thumb +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,14 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.ActionType;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
@ -11,9 +18,6 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -22,6 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram
|
||||
* clients clear its typing status).
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendChatAction extends BotApiMethod<Boolean> {
|
||||
|
||||
public static final String PATH = "sendChatAction";
|
||||
@ -30,6 +41,7 @@ public class SendChatAction extends BotApiMethod<Boolean> {
|
||||
private static final String ACTION_FIELD = "action";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
/**
|
||||
* Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages,
|
||||
@ -38,46 +50,17 @@ public class SendChatAction extends BotApiMethod<Boolean> {
|
||||
* record_video_note or upload_video_note for video notes.
|
||||
*/
|
||||
@JsonProperty(ACTION_FIELD)
|
||||
@NonNull
|
||||
private String action;
|
||||
|
||||
public SendChatAction() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SendChatAction(String chatId, String action) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.action = checkNotNull(action);
|
||||
}
|
||||
|
||||
public SendChatAction(Long chatId, String action) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.action = checkNotNull(action);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ActionType getAction() {
|
||||
public ActionType getActionType() {
|
||||
return ActionType.get(action);
|
||||
}
|
||||
|
||||
public SendChatAction setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendChatAction setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public SendChatAction setAction(ActionType action) {
|
||||
public void setAction(ActionType action) {
|
||||
this.action = action.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,12 +92,4 @@ public class SendChatAction extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("Action parameter can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendChatAction{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", action='" + action + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,23 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -19,6 +26,14 @@ import java.util.Objects;
|
||||
* Use this method to send information about user contact. On success, the sent Message is
|
||||
* returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendContact extends BotApiMethod<Message> {
|
||||
public static final String PATH = "sendContact";
|
||||
|
||||
@ -30,12 +45,16 @@ public class SendContact extends BotApiMethod<Message> {
|
||||
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String VCARD_FIELD = "vcard";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(PHONE_NUMBER_FIELD)
|
||||
@NonNull
|
||||
private String phoneNumber; ///< User's phone number
|
||||
@JsonProperty(FIRST_NAME_FIELD)
|
||||
@NonNull
|
||||
private String firstName; ///< User's first name
|
||||
@JsonProperty(LAST_NAME_FIELD)
|
||||
private String lastName; ///< Optional. User's last name
|
||||
@ -47,91 +66,15 @@ public class SendContact extends BotApiMethod<Message> {
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
@JsonProperty(VCARD_FIELD)
|
||||
private String vCard; ///< Optional. Additional data about the contact in the form of a vCard
|
||||
@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
|
||||
|
||||
public SendContact() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendContact setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendContact setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendContact setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendContact setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendContact enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendContact disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public SendContact setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public SendContact setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public SendContact setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getvCard() {
|
||||
return vCard;
|
||||
}
|
||||
|
||||
public void setvCard(String vCard) {
|
||||
this.vCard = vCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,18 +112,4 @@ public class SendContact extends BotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendContact{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", phoneNumber='" + phoneNumber + '\'' +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", vCard='" + vCard + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
@ -19,8 +28,16 @@ import java.util.List;
|
||||
* @version 4.7
|
||||
* Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendDice extends BotApiMethod<Message> {
|
||||
private static final List<String> VALIDEMOJIS = Collections.unmodifiableList(Arrays.asList("\uD83C\uDFB2", "\uD83C\uDFAF", "\uD83C\uDFC0"));
|
||||
private static final List<String> VALIDEMOJIS = Collections.unmodifiableList(Arrays.asList("🎲", "🎯", "🏀", "⚽", "🎰"));
|
||||
|
||||
public static final String PATH = "sendDice";
|
||||
|
||||
@ -29,14 +46,19 @@ public class SendDice extends BotApiMethod<Message> {
|
||||
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
/**
|
||||
* Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, or “🏀”.
|
||||
* Dice can have values 1-6 for “🎲” and “🎯”, and values 1-5 for “🏀”. Defauts to “🎲”
|
||||
* Emoji on which the dice throw animation is based.
|
||||
* Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, or “🎰”.
|
||||
* Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”.
|
||||
* Defaults to “🎲”
|
||||
*/
|
||||
@JsonProperty(EMOJI_FIELD)
|
||||
@NonNull
|
||||
private String emoji;
|
||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
@ -44,64 +66,15 @@ public class SendDice extends BotApiMethod<Message> {
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
@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
|
||||
|
||||
public SendDice() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendDice setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendDice setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendDice setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendDice setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendDice enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendDice disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEmoji() {
|
||||
return emoji;
|
||||
}
|
||||
|
||||
public SendDice setEmoji(String emoji) {
|
||||
this.emoji = emoji;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,21 +103,10 @@ public class SendDice extends BotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (emoji != null && !VALIDEMOJIS.contains(emoji)) {
|
||||
throw new TelegramApiValidationException("Only \uD83C\uDFB2, \uD83C\uDFAF or \uD83C\uDFC0 are allowed in Emoji field ", this);
|
||||
throw new TelegramApiValidationException("Only \"\uD83C\uDFB2\", \"\uD83C\uDFAF\", \"\uD83C\uDFC0\", \"⚽\", \"\uD83C\uDFB0\" are allowed in Emoji field ", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendDice{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", emoji='" + emoji + '\'' +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,41 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send general files. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "senddocument";
|
||||
|
||||
@ -30,15 +47,20 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
|
||||
@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
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
/**
|
||||
* Optional.
|
||||
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||
* A thumbnail’s width and height should not exceed 320.
|
||||
* Ignored if the file is not uploaded using multipart/form-data.
|
||||
@ -46,122 +68,16 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
|
||||
*/
|
||||
private InputFile thumb;
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public SendDocument() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendDocument setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendDocument setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the document to an document existing in Telegram system
|
||||
*
|
||||
* @param document File_id of the document to send
|
||||
* @note The file_id must have already been received or sent by your bot
|
||||
*/
|
||||
public SendDocument setDocument(String document) {
|
||||
this.document = new InputFile(document);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the document to a new file
|
||||
*
|
||||
* @param file New document file
|
||||
*/
|
||||
public SendDocument setDocument(File file) {
|
||||
Objects.requireNonNull(file, "documentName cannot be null!");
|
||||
this.document = new InputFile(file, file.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendDocument setDocument(InputFile document) {
|
||||
Objects.requireNonNull(document, "document cannot be null!");
|
||||
this.document = document;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendDocument setDocument(String documentName, InputStream inputStream) {
|
||||
Objects.requireNonNull(documentName, "documentName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.document = new InputFile(inputStream, documentName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendDocument setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendDocument enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendDocument disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public SendDocument setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendDocument setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public SendDocument setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public SendDocument setThumb(InputFile thumb) {
|
||||
this.thumb = thumb;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -189,6 +105,10 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("Document parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
|
||||
document.validate();
|
||||
|
||||
if (thumb != null) {
|
||||
@ -199,18 +119,4 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendDocument{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", document=" + document +
|
||||
", caption='" + caption + '\'' +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", thumb=" + thumb +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -19,22 +19,37 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send a game. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendGame extends BotApiMethod<Message> {
|
||||
public static final String PATH = "sendGame";
|
||||
|
||||
@ -43,10 +58,13 @@ public class SendGame extends BotApiMethod<Message> {
|
||||
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(GAMESHORTNAME_FIELD)
|
||||
@NonNull
|
||||
private String gameShortName; ///< Short name of the game
|
||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
@ -54,65 +72,15 @@ public class SendGame extends BotApiMethod<Message> {
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
@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
|
||||
|
||||
public SendGame() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendGame setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendGame setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendGame setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendGame setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendGame enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendGame disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGameShortName() {
|
||||
return gameShortName;
|
||||
}
|
||||
|
||||
public SendGame setGameShortName(String gameShortName) {
|
||||
this.gameShortName = gameShortName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,15 +115,4 @@ public class SendGame extends BotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendGame{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", gameShortName='" + gameShortName + '\'' +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,19 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 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.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
@ -13,13 +22,19 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send an invoice. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendInvoice extends BotApiMethod<Message> {
|
||||
public static final String PATH = "sendinvoice";
|
||||
|
||||
@ -46,22 +61,31 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
private static final String REPLY_TO_MESSAGE_ID_FIELD = "reply_to_message_id";
|
||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||
private static final String PROVIDER_DATA_FIELD = "provider_data";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private Integer chatId; ///< Unique identifier for the target private chat
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
@NonNull
|
||||
private String title; ///< Product name
|
||||
@JsonProperty(DESCRIPTION_FIELD)
|
||||
@NonNull
|
||||
private String description; ///< Product description
|
||||
@JsonProperty(PAYLOAD_FIELD)
|
||||
@NonNull
|
||||
private String payload; ///< Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
|
||||
@JsonProperty(PROVIDER_TOKEN_FIELD)
|
||||
@NonNull
|
||||
private String providerToken; ///< Payments provider token, obtained via Botfather
|
||||
@JsonProperty(START_PARAMETER_FIELD)
|
||||
@NonNull
|
||||
private String startParameter; ///< Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter.
|
||||
@JsonProperty(CURRENCY_FIELD)
|
||||
@NonNull
|
||||
private String currency; ///< 3-letter ISO 4217 currency code
|
||||
@JsonProperty(PRICES_FIELD)
|
||||
@NonNull
|
||||
private List<LabeledPrice> prices; ///< Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
|
||||
/**
|
||||
* Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
|
||||
@ -97,250 +121,19 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
/**
|
||||
* Optional. A JSON-serialized object for an inline keyboard.
|
||||
*
|
||||
* @note If empty, one 'Buy title' button will be shown. If not empty, the first button must be a Pay button.
|
||||
* @apiNote If empty, one 'Buy title' button will be shown. If not empty, the first button must be a Pay button.
|
||||
*/
|
||||
@JsonProperty(REPLY_MARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup;
|
||||
/**
|
||||
* Optional JSON-encoded data about the invoice, which will be shared with the payment provider.
|
||||
*
|
||||
* @note A detailed description of required fields should be provided by the payment provider.
|
||||
* @apiNote A detailed description of required fields should be provided by the payment provider.
|
||||
*/
|
||||
@JsonProperty(PROVIDER_DATA_FIELD)
|
||||
private String providerData;
|
||||
|
||||
/**
|
||||
* Build an empty SendInvoice object
|
||||
*/
|
||||
public SendInvoice() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a SendInvoice object with empty parameters
|
||||
* @param chatId Unique identifier for the target private chat
|
||||
* @param title Product name
|
||||
* @param description Product description
|
||||
* @param payload Bot defined invoice payload, 1-128 bytes.
|
||||
* @param providerToken Payments provider token
|
||||
* @param startParameter Unique deep-linking parameter.
|
||||
* @param currency 3-letter ISO 4217 currency code
|
||||
* @param prices Price breakdown, a list of components
|
||||
*/
|
||||
public SendInvoice(Integer chatId, String title, String description, String payload, String providerToken,
|
||||
String startParameter, String currency, List<LabeledPrice> prices) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.title = checkNotNull(title);
|
||||
this.description = checkNotNull(description);
|
||||
this.payload = checkNotNull(payload);
|
||||
this.providerToken = checkNotNull(providerToken);
|
||||
this.startParameter = checkNotNull(startParameter);
|
||||
this.currency = checkNotNull(currency);
|
||||
this.prices = checkNotNull(prices);
|
||||
}
|
||||
|
||||
public Integer getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendInvoice setChatId(Integer chatId) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public SendInvoice setTitle(String title) {
|
||||
this.title = checkNotNull(title);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public SendInvoice setDescription(String description) {
|
||||
this.description = checkNotNull(description);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public SendInvoice setPayload(String payload) {
|
||||
this.payload = checkNotNull(payload);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProviderToken() {
|
||||
return providerToken;
|
||||
}
|
||||
|
||||
public SendInvoice setProviderToken(String providerToken) {
|
||||
this.providerToken = checkNotNull(providerToken);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStartParameter() {
|
||||
return startParameter;
|
||||
}
|
||||
|
||||
public SendInvoice setStartParameter(String startParameter) {
|
||||
this.startParameter = checkNotNull(startParameter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public SendInvoice setCurrency(String currency) {
|
||||
this.currency = checkNotNull(currency);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<LabeledPrice> getPrices() {
|
||||
return prices;
|
||||
}
|
||||
|
||||
public SendInvoice setPrices(List<LabeledPrice> prices) {
|
||||
this.prices = checkNotNull(prices);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPhotoUrl() {
|
||||
return photoUrl;
|
||||
}
|
||||
|
||||
public SendInvoice setPhotoUrl(String photoUrl) {
|
||||
this.photoUrl = photoUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPhotoSize() {
|
||||
return photoSize;
|
||||
}
|
||||
|
||||
public SendInvoice setPhotoSize(Integer photoSize) {
|
||||
this.photoSize = photoSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPhotoWidth() {
|
||||
return photoWidth;
|
||||
}
|
||||
|
||||
public SendInvoice setPhotoWidth(Integer photoWidth) {
|
||||
this.photoWidth = photoWidth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPhotoHeight() {
|
||||
return photoHeight;
|
||||
}
|
||||
|
||||
public SendInvoice setPhotoHeight(Integer photoHeight) {
|
||||
this.photoHeight = photoHeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getNeedName() {
|
||||
return needName;
|
||||
}
|
||||
|
||||
public SendInvoice setNeedName(Boolean needName) {
|
||||
this.needName = needName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getNeedPhoneNumber() {
|
||||
return needPhoneNumber;
|
||||
}
|
||||
|
||||
public SendInvoice setNeedPhoneNumber(Boolean needPhoneNumber) {
|
||||
this.needPhoneNumber = needPhoneNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getNeedEmail() {
|
||||
return needEmail;
|
||||
}
|
||||
|
||||
public SendInvoice setNeedEmail(Boolean needEmail) {
|
||||
this.needEmail = needEmail;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getNeedShippingAddress() {
|
||||
return needShippingAddress;
|
||||
}
|
||||
|
||||
public SendInvoice setNeedShippingAddress(Boolean needShippingAddress) {
|
||||
this.needShippingAddress = needShippingAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getSendPhoneNumberToProvider() { return sendPhoneNumberToProvider; }
|
||||
|
||||
public SendInvoice setSendPhoneNumberToProvider(Boolean sendPhoneNumberToProvider) {
|
||||
this.sendPhoneNumberToProvider = sendPhoneNumberToProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getSendEmailToProvider() { return sendEmailToProvider; }
|
||||
|
||||
public SendInvoice setSendEmailToProvider(Boolean sendEmailToProvider) {
|
||||
this.sendEmailToProvider = sendEmailToProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlexible() {
|
||||
return isFlexible;
|
||||
}
|
||||
|
||||
public SendInvoice setFlexible(Boolean flexible) {
|
||||
isFlexible = flexible;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendInvoice setDisableNotification(Boolean disableNotification) {
|
||||
this.disableNotification = disableNotification;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendInvoice setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendInvoice setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProviderData() {
|
||||
return providerData;
|
||||
}
|
||||
|
||||
public SendInvoice setProviderData(String providerData) {
|
||||
this.providerData = providerData;
|
||||
return this;
|
||||
}
|
||||
@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
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -396,33 +189,4 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendInvoice{" +
|
||||
"chatId=" + chatId +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", payload='" + payload + '\'' +
|
||||
", providerToken='" + providerToken + '\'' +
|
||||
", startParameter='" + startParameter + '\'' +
|
||||
", currency='" + currency + '\'' +
|
||||
", prices=" + prices +
|
||||
", photoUrl='" + photoUrl + '\'' +
|
||||
", photoSize=" + photoSize +
|
||||
", photoWidth=" + photoWidth +
|
||||
", photoHeight=" + photoHeight +
|
||||
", needName=" + needName +
|
||||
", needPhoneNumber=" + needPhoneNumber +
|
||||
", needEmail=" + needEmail +
|
||||
", needShippingAddress=" + needShippingAddress +
|
||||
", sendPhoneNumberToProvider=" + sendPhoneNumberToProvider +
|
||||
", sendEmailToProvider=" + sendEmailToProvider +
|
||||
", isFlexible=" + isFlexible +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", providerData='" + providerData + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,37 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send point on the map. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendLocation extends BotApiMethod<Message> {
|
||||
public static final String PATH = "sendlocation";
|
||||
|
||||
@ -29,13 +43,20 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String LIVEPERIOD_FIELD = "live_period";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
|
||||
private static final String HEADING_FIELD = "heading";
|
||||
private static final String APPROACHINGNOTIFICATIONDISTANCE_FIELD = "approaching_notification_distance";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(LATITUDE_FIELD)
|
||||
private Float latitude; ///< Latitude of location
|
||||
@NonNull
|
||||
private Double latitude; ///< Latitude of location
|
||||
@JsonProperty(LONGITUDE_FIELD)
|
||||
private Float longitude; ///< Longitude of location
|
||||
@NonNull
|
||||
private Double longitude; ///< Longitude of location
|
||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
@JsonProperty(REPLYTOMESSAGEID_FIELD)
|
||||
@ -44,91 +65,35 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
@JsonProperty(LIVEPERIOD_FIELD)
|
||||
private Integer livePeriod; ///< Optional. Period in seconds for which the location will be updated (see Live Locations), should be between 60 and 86400.
|
||||
@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
|
||||
/**
|
||||
* Optional.
|
||||
* The radius of uncertainty for the location, measured in meters; 0-1500
|
||||
*/
|
||||
@JsonProperty(HORIZONTALACCURACY_FIELD)
|
||||
private Double horizontalAccuracy;
|
||||
/**
|
||||
* Optional.
|
||||
* For live locations, a direction in which the user is moving, in degrees.
|
||||
* Must be between 1 and 360 if specified.
|
||||
*/
|
||||
@JsonProperty(HEADING_FIELD)
|
||||
private Integer heading;
|
||||
/**
|
||||
* Optional.
|
||||
* For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* Must be between 1 and 100000 if specified.
|
||||
*/
|
||||
@JsonProperty(APPROACHINGNOTIFICATIONDISTANCE_FIELD)
|
||||
private Integer approachingNotificationDistance;
|
||||
|
||||
public SendLocation() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SendLocation(Float latitude, Float longitude) {
|
||||
super();
|
||||
this.latitude = checkNotNull(latitude);
|
||||
this.longitude = checkNotNull(longitude);
|
||||
}
|
||||
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendLocation setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendLocation setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Float getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public SendLocation setLatitude(Float latitude) {
|
||||
Objects.requireNonNull(latitude);
|
||||
this.latitude = latitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Float getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public SendLocation setLongitude(Float longitude) {
|
||||
Objects.requireNonNull(longitude);
|
||||
this.longitude = longitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendLocation setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendLocation setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendLocation enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendLocation disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getLivePeriod() {
|
||||
return livePeriod;
|
||||
}
|
||||
|
||||
public SendLocation setLivePeriod(Integer livePeriod) {
|
||||
this.livePeriod = livePeriod;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,6 +127,15 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
if (longitude == null) {
|
||||
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
|
||||
}
|
||||
if (horizontalAccuracy != null && (horizontalAccuracy < 0 || horizontalAccuracy > 1500)) {
|
||||
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (heading != null && (heading < 1 || heading > 360)) {
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (approachingNotificationDistance != null && (approachingNotificationDistance < 1 || approachingNotificationDistance > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
@ -169,17 +143,4 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("Live period parameter must be between 60 and 86400", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendLocation{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", livePeriod=" + livePeriod +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,22 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.media.InputMedia;
|
||||
import org.telegram.telegrambots.meta.api.objects.media.InputMediaPhoto;
|
||||
import org.telegram.telegrambots.meta.api.objects.media.InputMediaVideo;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.media.InputMediaAnimation;
|
||||
import org.telegram.telegrambots.meta.api.objects.media.InputMediaAudio;
|
||||
import org.telegram.telegrambots.meta.api.objects.media.InputMediaDocument;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
@ -15,16 +25,23 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 3.5
|
||||
*
|
||||
* Use this method to send a group of photos or videos as an album.
|
||||
* On success, an array of the sent Messages is returned.
|
||||
* Use this method to send a group of photos, videos, documents or audios as an album.
|
||||
* Documents and audio files can be only group in an album with messages of the same type.
|
||||
* On success, an array of Messages that were sent is returned.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
|
||||
public static final String PATH = "sendMediaGroup";
|
||||
|
||||
@ -32,75 +49,27 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
|
||||
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";
|
||||
|
||||
@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)
|
||||
private List<InputMedia> media; ///< A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
|
||||
@NonNull
|
||||
private List<InputMedia> medias; ///< A JSON-serialized array describing photos and videos to be sent, must include 2–10 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
|
||||
|
||||
public SendMediaGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SendMediaGroup(String chatId, List<InputMedia> media) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.media = checkNotNull(media);
|
||||
}
|
||||
|
||||
public SendMediaGroup(Long chatId, List<InputMedia> media) {
|
||||
super();
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.media = checkNotNull(media);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendMediaGroup setChatId(String chatId) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMediaGroup setChatId(Long chatId) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendMediaGroup setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendMediaGroup enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMediaGroup disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<InputMedia> getMedia() {
|
||||
return media;
|
||||
}
|
||||
|
||||
public void setMedia(List<InputMedia> media) {
|
||||
this.media = media;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,26 +94,30 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (media == null || media.isEmpty()) {
|
||||
if (medias == null || medias.isEmpty()) {
|
||||
throw new TelegramApiValidationException("Media parameter can't be empty", this);
|
||||
} else if (medias.size() < 2 || medias.size() > 10) {
|
||||
throw new TelegramApiValidationException("Number of media should be between 2 and 10", this);
|
||||
}
|
||||
|
||||
for (InputMedia inputMedia : media) {
|
||||
if (inputMedia instanceof InputMediaPhoto || inputMedia instanceof InputMediaVideo) {
|
||||
inputMedia.validate();
|
||||
for (InputMedia inputMedia : medias) {
|
||||
if (inputMedia == null) {
|
||||
throw new TelegramApiValidationException("Media parameter can not be empty", this);
|
||||
} else if (inputMedia instanceof InputMediaAnimation) {
|
||||
throw new TelegramApiValidationException("Media parameter can not be an Animation", this);
|
||||
} else {
|
||||
throw new TelegramApiValidationException("Media parameter can only be Photo or Video", this);
|
||||
inputMedia.validate();
|
||||
}
|
||||
}
|
||||
|
||||
if (medias.stream().anyMatch(x -> x instanceof InputMediaAudio)) {
|
||||
if (!medias.stream().allMatch(x -> x instanceof InputMediaAudio)) {
|
||||
throw new TelegramApiValidationException("Media parameter containing Audio can not have other types", this);
|
||||
}
|
||||
} else if (medias.stream().anyMatch(x -> x instanceof InputMediaDocument)) {
|
||||
if (!medias.stream().allMatch(x -> x instanceof InputMediaDocument)) {
|
||||
throw new TelegramApiValidationException("Media parameter containing Document can not have other types", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendMediaGroup{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", media=" + media +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", disableNotification=" + disableNotification +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,24 +3,41 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.methods.ParseMode;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send text messages. On success, the sent Message is returned.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendMessage extends BotApiMethod<Message> {
|
||||
public static final String PATH = "sendmessage";
|
||||
|
||||
@ -31,10 +48,14 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String ENTITIES_FIELD = "entities";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(TEXT_FIELD)
|
||||
@NonNull
|
||||
private String text; ///< Text of the message to be sent
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and URL text in your bot's message.
|
||||
@ -47,121 +68,49 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
@JsonDeserialize()
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
@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
|
||||
@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
|
||||
|
||||
public SendMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SendMessage(String chatId, String text) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.text = checkNotNull(text);
|
||||
}
|
||||
|
||||
public SendMessage(Long chatId, String text) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.text = checkNotNull(text);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendMessage setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public SendMessage setText(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendMessage setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendMessage setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableWebPagePreview() {
|
||||
return disableWebPagePreview;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendMessage disableWebPagePreview() {
|
||||
public void disableWebPagePreview() {
|
||||
disableWebPagePreview = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage enableWebPagePreview() {
|
||||
public void enableWebPagePreview() {
|
||||
disableWebPagePreview = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage enableMarkdown(boolean enable) {
|
||||
public void enableMarkdown(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.MARKDOWN;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage enableHtml(boolean enable) {
|
||||
public void enableHtml(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.HTML;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendMessage enableMarkdownV2(boolean enable) {
|
||||
public void enableMarkdownV2(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.MARKDOWNV2;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,50 +141,11 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
if (text == null || text.isEmpty()) {
|
||||
throw new TelegramApiValidationException("Text parameter can't be empty", this);
|
||||
}
|
||||
if (parseMode != null && (entities != null && !entities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof SendMessage)) {
|
||||
return false;
|
||||
}
|
||||
SendMessage sendMessage = (SendMessage) o;
|
||||
return Objects.equals(chatId, sendMessage.chatId)
|
||||
&& Objects.equals(disableNotification, sendMessage.disableNotification)
|
||||
&& Objects.equals(disableWebPagePreview, sendMessage.disableWebPagePreview)
|
||||
&& Objects.equals(parseMode, sendMessage.parseMode)
|
||||
&& Objects.equals(replyMarkup, sendMessage.replyMarkup)
|
||||
&& Objects.equals(replyToMessageId, sendMessage.replyToMessageId)
|
||||
&& Objects.equals(text, sendMessage.text)
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
chatId,
|
||||
disableNotification,
|
||||
disableWebPagePreview,
|
||||
parseMode,
|
||||
replyMarkup,
|
||||
replyToMessageId,
|
||||
text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendMessage{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", text='" + text + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", disableNotification='" + disableNotification + '\'' +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,27 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -19,6 +29,14 @@ import java.util.Objects;
|
||||
* @version 1.0
|
||||
* Use this method to send photos. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendPhoto extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "sendphoto";
|
||||
|
||||
@ -29,110 +47,33 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@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).
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public SendPhoto() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendPhoto setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendPhoto setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
|
||||
public SendPhoto setPhoto(String photo) {
|
||||
this.photo = new InputFile(photo);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public SendPhoto setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendPhoto setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendPhoto setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendPhoto enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendPhoto disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendPhoto setPhoto(File file) {
|
||||
Objects.requireNonNull(file, "file cannot be null!");
|
||||
this.photo = new InputFile(file, file.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendPhoto setPhoto(InputFile photo) {
|
||||
public void setPhoto(InputFile photo) {
|
||||
Objects.requireNonNull(photo, "photo cannot be null!");
|
||||
this.photo = photo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendPhoto setPhoto(String photoName, InputStream inputStream) {
|
||||
Objects.requireNonNull(photoName, "photoName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.photo = new InputFile(inputStream, photoName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public SendPhoto setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -160,23 +101,13 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("Photo parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
photo.validate();
|
||||
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendPhoto{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", photo=" + photo +
|
||||
", caption='" + caption + '\'' +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,38 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send .webp stickers. On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendSticker extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "sendsticker";
|
||||
|
||||
@ -27,89 +41,27 @@ public class SendSticker extends PartialBotApiMethod<Message> {
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@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.
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
|
||||
public SendSticker() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendSticker setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendSticker setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getSticker() {
|
||||
return sticker;
|
||||
}
|
||||
|
||||
public SendSticker setSticker(String sticker) {
|
||||
this.sticker = new InputFile(sticker);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendSticker setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendSticker setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendSticker setSticker(InputFile sticker) {
|
||||
Objects.requireNonNull(sticker, "sticker cannot be null!");
|
||||
this.sticker = sticker;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendSticker setSticker(File file) {
|
||||
Objects.requireNonNull(file, "file cannot be null!");
|
||||
this.sticker = new InputFile(file, file.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendSticker setSticker(String stickerName, InputStream inputStream) {
|
||||
Objects.requireNonNull(stickerName, "stickerName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.sticker = new InputFile(inputStream, stickerName);
|
||||
return this;
|
||||
}
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendSticker enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendSticker disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -143,15 +95,4 @@ public class SendSticker extends PartialBotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendSticker{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", sticker=" + sticker +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,23 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -19,6 +26,14 @@ import java.util.Objects;
|
||||
* Use this method to send information about a venue. On success, the sent Message is
|
||||
* returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendVenue extends BotApiMethod<Message> {
|
||||
public static final String PATH = "sendVenue";
|
||||
|
||||
@ -32,19 +47,27 @@ public class SendVenue extends BotApiMethod<Message> {
|
||||
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String FOURSQUARETYPE_FIELD = "foursquare_type";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
private static final String GOOGLEPLACEID_FIELD = "google_place_id";
|
||||
private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@JsonProperty(LATITUDE_FIELD)
|
||||
private Float latitude; ///< Latitude of venue location
|
||||
@NonNull
|
||||
private Double latitude; ///< Latitude of venue location
|
||||
@JsonProperty(LONGITUDE_FIELD)
|
||||
private Float longitude; ///< Longitude of venue location
|
||||
@NonNull
|
||||
private Double longitude; ///< Longitude of venue location
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
@NonNull
|
||||
private String title; ///< Title of the venue
|
||||
@JsonProperty(ADDRESS_FIELD)
|
||||
@NonNull
|
||||
private String address; ///< Address of the venue
|
||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
@JsonProperty(ADDRESS_FIELD)
|
||||
private String address; ///< Address of the venue
|
||||
@JsonProperty(FOURSQUAREID_FIELD)
|
||||
private String foursquareId; ///< Optional. Foursquare identifier of the venue
|
||||
@JsonProperty(REPLYTOMESSAGEID_FIELD)
|
||||
@ -53,110 +76,19 @@ public class SendVenue extends BotApiMethod<Message> {
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
@JsonProperty(FOURSQUARETYPE_FIELD)
|
||||
private String foursquareType; ///< Optional. Foursquare type of the venue, if known.
|
||||
@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
|
||||
@JsonProperty(GOOGLEPLACEID_FIELD)
|
||||
private String googlePlaceId; ///< Optional. Google Places identifier of the venue
|
||||
@JsonProperty(GOOGLEPLACETYPE_FIELD)
|
||||
private String googlePlaceType; ///< Optional. Google Places type of the venue. (See supported types.)
|
||||
|
||||
public SendVenue() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendVenue setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVenue setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Float getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public SendVenue setLatitude(Float latitude) {
|
||||
this.latitude = latitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Float getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public SendVenue setLongitude(Float longitude) {
|
||||
this.longitude = longitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendVenue setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendVenue setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendVenue enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVenue disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public SendVenue setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public SendVenue setAddress(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFoursquareId() {
|
||||
return foursquareId;
|
||||
}
|
||||
|
||||
public SendVenue setFoursquareId(String foursquareId) {
|
||||
this.foursquareId = foursquareId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFoursquareType() {
|
||||
return foursquareType;
|
||||
}
|
||||
|
||||
public SendVenue setFoursquareType(String foursquareType) {
|
||||
this.foursquareType = foursquareType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -200,20 +132,4 @@ public class SendVenue extends BotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendVenue{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", title='" + title + '\'' +
|
||||
", disableNotification=" + disableNotification +
|
||||
", address='" + address + '\'' +
|
||||
", foursquareId='" + foursquareId + '\'' +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", foursquareType='" + foursquareType + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,27 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -20,6 +29,14 @@ import java.util.Objects;
|
||||
* Use this method to send video files, Telegram clients support mp4 videos (other formats
|
||||
* may be sent as Document). On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendVideo extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "sendvideo";
|
||||
|
||||
@ -35,8 +52,12 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@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
|
||||
private String caption; ///< Optional. Video caption (may also be used when resending videos by file_id).
|
||||
@ -46,8 +67,9 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
/**
|
||||
* Optional.
|
||||
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||
* A thumbnail’s width and height should not exceed 320.
|
||||
* Ignored if the file is not uploaded using multipart/form-data.
|
||||
@ -55,147 +77,16 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
||||
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
|
||||
*/
|
||||
private InputFile thumb;
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public SendVideo() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendVideo setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getVideo() {
|
||||
return video;
|
||||
}
|
||||
|
||||
public SendVideo setVideo(String video) {
|
||||
this.video = new InputFile(video);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideo setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public SendVideo setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public SendVideo setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendVideo setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendVideo setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendVideo enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideo disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public SendVideo setWidth(Integer width) {
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public SendVideo setHeight(Integer height) {
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideo setVideo(InputFile video) {
|
||||
Objects.requireNonNull(video, "video cannot be null!");
|
||||
this.video = video;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideo setVideo(File file) {
|
||||
Objects.requireNonNull(file, "file cannot be null!");
|
||||
this.video = new InputFile(file, file.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideo setVideo(String videoName, InputStream inputStream) {
|
||||
Objects.requireNonNull(videoName, "videoName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.video = new InputFile(inputStream, videoName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getSupportsStreaming() {
|
||||
return supportsStreaming;
|
||||
}
|
||||
|
||||
public SendVideo setSupportsStreaming(Boolean supportsStreaming) {
|
||||
this.supportsStreaming = supportsStreaming;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public SendVideo setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public SendVideo setThumb(InputFile thumb) {
|
||||
this.thumb = thumb;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -223,6 +114,10 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
||||
throw new TelegramApiValidationException("Video parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
|
||||
video.validate();
|
||||
|
||||
if (thumb != null) {
|
||||
@ -232,22 +127,4 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendVideo{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", video=" + video +
|
||||
", duration=" + duration +
|
||||
", caption='" + caption + '\'' +
|
||||
", width=" + width +
|
||||
", height=" + height +
|
||||
", supportsStreaming=" + supportsStreaming +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", thumb=" + thumb +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,24 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -23,6 +27,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Use this method to send video messages. On success, the sent Message is returned.
|
||||
*/
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendVideoNote extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "sendvideonote";
|
||||
|
||||
@ -34,8 +46,11 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
@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
|
||||
private Integer length; ///< Optional. Video width and height
|
||||
@ -50,174 +65,14 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
|
||||
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
|
||||
*/
|
||||
private InputFile thumb;
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public SendVideoNote() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new video note with a video already present in telegram servers
|
||||
* @param chatId Chat Id to send the video note
|
||||
* @param videoNote Video note file_id to send
|
||||
*/
|
||||
public SendVideoNote(String chatId, String videoNote) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.setVideoNote(checkNotNull(videoNote));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new video note with a video already present in telegram servers
|
||||
* @param chatId Chat Id to send the video note
|
||||
* @param videoNote Video note file_id to send
|
||||
*/
|
||||
public SendVideoNote(Long chatId, String videoNote) {
|
||||
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.setVideoNote(checkNotNull(videoNote));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new video note with a new video note
|
||||
* @param chatId Chat Id to send the video note
|
||||
* @param videoNote Video note file to upload
|
||||
*/
|
||||
public SendVideoNote(String chatId, File videoNote) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.setVideoNote(videoNote);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new video note with a video already present in telegram servers
|
||||
* @param chatId Chat Id to send the video note
|
||||
* @param videoNote Video note file to upload
|
||||
*/
|
||||
public SendVideoNote(Integer chatId, File videoNote) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.setVideoNote(videoNote);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new video note with a new video note
|
||||
* @param chatId Chat Id to send the video note
|
||||
* @param videoNoteName Name of the video note file
|
||||
* @param videoNote Video note file to upload
|
||||
*/
|
||||
public SendVideoNote(String chatId, String videoNoteName, InputStream videoNote) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.setVideoNote(videoNoteName, videoNote);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new video note with a video already present in telegram servers
|
||||
* @param chatId Chat Id to send the video note
|
||||
* @param videoNoteName Name of the video note file
|
||||
* @param videoNote Video note file to upload
|
||||
*/
|
||||
public SendVideoNote(Integer chatId, String videoNoteName, InputStream videoNote) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.setVideoNote(videoNoteName, videoNote);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendVideoNote setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getVideoNote() {
|
||||
return videoNote;
|
||||
}
|
||||
|
||||
public SendVideoNote setVideoNote(String videoNote) {
|
||||
this.videoNote = new InputFile(videoNote);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public SendVideoNote setLength(Integer length) {
|
||||
this.length = length;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideoNote setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public SendVideoNote setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendVideoNote setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendVideoNote setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendVideoNote enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideoNote disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideoNote setVideoNote(InputFile videoNote) {
|
||||
Objects.requireNonNull(videoNote, "videoNote cannot be null!");
|
||||
this.videoNote = videoNote;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideoNote setVideoNote(File file) {
|
||||
Objects.requireNonNull(file, "file cannot be null!");
|
||||
this.videoNote = new InputFile(file, file.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVideoNote setVideoNote(String videoName, InputStream inputStream) {
|
||||
Objects.requireNonNull(videoName, "videoName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.videoNote = new InputFile(inputStream, videoName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public SendVideoNote setThumb(InputFile thumb) {
|
||||
this.thumb = thumb;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -254,18 +109,4 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendVideoNote{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", videoNote=" + videoNote +
|
||||
", duration=" + duration +
|
||||
", length=" + length +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", thumb=" + thumb +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,27 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -21,6 +30,14 @@ import java.util.Objects;
|
||||
* playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS
|
||||
* (other formats may be sent as Audio or Document).
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendVoice extends PartialBotApiMethod<Message> {
|
||||
public static final String PATH = "sendvoice";
|
||||
|
||||
@ -32,121 +49,29 @@ public class SendVoice extends PartialBotApiMethod<Message> {
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
public static final String CAPTION_FIELD = "caption";
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
|
||||
@NonNull
|
||||
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
|
||||
@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.
|
||||
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
private Integer duration; ///< Optional. Duration of sent audio in seconds
|
||||
private String caption; ///< Optional. Voice caption (may also be used when resending videos by file_id).
|
||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
|
||||
public SendVoice() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public SendVoice enableNotification() {
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice disableNotification() {
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public SendVoice setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getVoice() {
|
||||
return voice;
|
||||
}
|
||||
|
||||
public SendVoice setVoice(String voice) {
|
||||
Objects.requireNonNull(voice, "voice cannot be null!");
|
||||
this.voice = new InputFile(voice);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice setVoice(File voice) {
|
||||
Objects.requireNonNull(voice, "voice cannot be null!");
|
||||
this.voice = new InputFile(voice, voice.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice setVoice(InputFile voice) {
|
||||
Objects.requireNonNull(voice, "voice cannot be null!");
|
||||
this.voice = voice;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice setVoice(String voiceName, InputStream inputStream) {
|
||||
Objects.requireNonNull(voiceName, "voiceName cannot be null!");
|
||||
Objects.requireNonNull(inputStream, "inputStream cannot be null!");
|
||||
this.voice = new InputFile(inputStream, voiceName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getReplyToMessageId() {
|
||||
return replyToMessageId;
|
||||
}
|
||||
|
||||
public SendVoice setReplyToMessageId(Integer replyToMessageId) {
|
||||
this.replyToMessageId = replyToMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public SendVoice setReplyMarkup(ReplyKeyboard replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public SendVoice setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public SendVoice setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public SendVoice setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -173,25 +98,13 @@ public class SendVoice extends PartialBotApiMethod<Message> {
|
||||
if (voice == null) {
|
||||
throw new TelegramApiValidationException("Voice parameter can't be empty", this);
|
||||
}
|
||||
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
voice.validate();
|
||||
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendVoice{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", voice=" + voice +
|
||||
", disableNotification=" + disableNotification +
|
||||
", replyToMessageId=" + replyToMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", duration=" + duration +
|
||||
", caption='" + caption + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,15 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.stickers;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
@ -8,12 +17,7 @@ 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.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -25,6 +29,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Static sticker sets can have up to 120 stickers.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
|
||||
public static final String PATH = "addStickerToSet";
|
||||
|
||||
@ -35,11 +47,15 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
|
||||
public static final String EMOJIS_FIELD = "emojis";
|
||||
public static final String MASKPOSITION_FIELD = "mask_position";
|
||||
|
||||
@NonNull
|
||||
private Integer userId; ///< User identifier of sticker set owner
|
||||
@NonNull
|
||||
private String name; ///< Sticker set name
|
||||
@NonNull
|
||||
private String emojis; ///< One or more emoji corresponding to the sticker
|
||||
private MaskPosition maskPosition; ///< Position where the mask should be placed on faces
|
||||
private MaskPosition maskPosition; ///< Optional. Position where the mask should be placed on faces
|
||||
/**
|
||||
* Optional.
|
||||
* Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px,
|
||||
* and either width or height must be exactly 512px. Pass a file_id as a String to send a file
|
||||
* that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram
|
||||
@ -47,93 +63,12 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
|
||||
*/
|
||||
private InputFile pngSticker;
|
||||
/**
|
||||
* Optional.
|
||||
* TGS animation with the sticker, uploaded using multipart/form-data.
|
||||
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||
*/
|
||||
private InputFile tgsSticker;
|
||||
|
||||
public AddStickerToSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AddStickerToSet(Integer userId, String name, String emojis) {
|
||||
this.userId = checkNotNull(userId);
|
||||
this.name = checkNotNull(name);
|
||||
this.emojis = checkNotNull(emojis);
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public AddStickerToSet setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getPngSticker() {
|
||||
return pngSticker;
|
||||
}
|
||||
|
||||
public AddStickerToSet setPngSticker(String pngSticker) {
|
||||
this.pngSticker = new InputFile(pngSticker);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AddStickerToSet setPngSticker(File pngSticker) {
|
||||
Objects.requireNonNull(pngSticker, "pngSticker cannot be null!");
|
||||
this.pngSticker = new InputFile(pngSticker, pngSticker.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public AddStickerToSet setPngSticker(String pngStickerName, InputStream pngSticker) {
|
||||
Objects.requireNonNull(pngStickerName, "pngStickerName cannot be null!");
|
||||
Objects.requireNonNull(pngSticker, "pngSticker cannot be null!");
|
||||
this.pngSticker = new InputFile(pngSticker, pngStickerName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AddStickerToSet setTgsSticker(File tgsSticker) {
|
||||
this.tgsSticker = new InputFile(checkNotNull(tgsSticker), tgsSticker.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public AddStickerToSet setTgsSticker(String tgsStickerName, InputStream tgsSticker) {
|
||||
this.tgsSticker = new InputFile(checkNotNull(tgsSticker), checkNotNull(tgsStickerName));
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getTgsSticker() {
|
||||
return tgsSticker;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public AddStickerToSet setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEmojis() {
|
||||
return emojis;
|
||||
}
|
||||
|
||||
public AddStickerToSet setEmojis(String emojis) {
|
||||
this.emojis = emojis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MaskPosition getMaskPosition() {
|
||||
return maskPosition;
|
||||
}
|
||||
|
||||
public AddStickerToSet setMaskPosition(MaskPosition maskPosition) {
|
||||
this.maskPosition = maskPosition;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
@ -180,16 +115,4 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
|
||||
maskPosition.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AddStickerToSet{" +
|
||||
"userId=" + userId +
|
||||
", name='" + name + '\'' +
|
||||
", emojis='" + emojis + '\'' +
|
||||
", maskPosition=" + maskPosition +
|
||||
", pngSticker=" + pngSticker +
|
||||
", tgsSticker=" + tgsSticker +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,15 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.stickers;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
@ -8,12 +17,7 @@ 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.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -22,6 +26,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* You must use exactly one of the fields png_sticker or tgs_sticker.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
||||
public static final String PATH = "createNewStickerSet";
|
||||
|
||||
@ -34,6 +46,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
||||
public static final String CONTAINSMASKS_FIELD = "contains_masks";
|
||||
public static final String MASKPOSITION_FIELD = "mask_position";
|
||||
|
||||
@NonNull
|
||||
private Integer userId; ///< User identifier of created sticker set owner
|
||||
/**
|
||||
* Name of sticker set, to be used in t.me/addstickers/<name> URLs.
|
||||
@ -41,12 +54,16 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
||||
* Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”.
|
||||
* <bot_username> is case insensitive. 7-64 characters.
|
||||
*/
|
||||
@NonNull
|
||||
private String name; ///< Sticker set title, 1-64 characters
|
||||
@NonNull
|
||||
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; ///< Pass True, if a set of mask stickers should be created
|
||||
private MaskPosition maskPosition; ///< Position where the mask should be placed on faces
|
||||
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.
|
||||
* Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px,
|
||||
* and either width or height must be exactly 512px.
|
||||
* Pass a file_id as a String to send a file that already exists on the Telegram servers,
|
||||
@ -56,117 +73,12 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
||||
private InputFile pngSticker;
|
||||
|
||||
/**
|
||||
* @Optional
|
||||
* TGS animation with the sticker, uploaded using multipart/form-data.
|
||||
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||
*/
|
||||
private InputFile tgsSticker;
|
||||
|
||||
public CreateNewStickerSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CreateNewStickerSet(Integer userId, String name, String title, String emojis) {
|
||||
this.userId = checkNotNull(userId);
|
||||
this.name = checkNotNull(name);
|
||||
this.title = checkNotNull(title);
|
||||
this.emojis = checkNotNull(emojis);
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public InputFile getPngSticker() {
|
||||
return pngSticker;
|
||||
}
|
||||
|
||||
public CreateNewStickerSet setPngSticker(String pngSticker) {
|
||||
this.pngSticker = new InputFile(pngSticker);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreateNewStickerSet setPngStickerFile(InputFile pngStickerFile) {
|
||||
Objects.requireNonNull(pngStickerFile, "pngStickerFile cannot be null!");
|
||||
this.pngSticker = pngStickerFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreateNewStickerSet setPngStickerFile(File pngStickerFile) {
|
||||
Objects.requireNonNull(pngStickerFile, "pngStickerFile cannot be null!");
|
||||
this.pngSticker = new InputFile(pngStickerFile, pngStickerFile.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreateNewStickerSet setPngStickerStream(String pngStickerName, InputStream pngStickerStream) {
|
||||
Objects.requireNonNull(pngStickerName, "pngStickerName cannot be null!");
|
||||
Objects.requireNonNull(pngStickerStream, "pngStickerStream cannot be null!");
|
||||
this.pngSticker = new InputFile(pngStickerStream, pngStickerName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreateNewStickerSet setTgsSticker(InputFile tgsSticker) {
|
||||
this.tgsSticker = checkNotNull(tgsSticker);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreateNewStickerSet setTgsSticker(File tgsStickerFile) {
|
||||
this.tgsSticker = new InputFile(checkNotNull(tgsStickerFile), tgsStickerFile.getName());;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreateNewStickerSet setTgsSticker(String tgsStickerName, InputStream tgsStickerStream) {
|
||||
this.pngSticker = new InputFile(checkNotNull(tgsStickerStream), checkNotNull(tgsStickerName));
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getEmojis() {
|
||||
return emojis;
|
||||
}
|
||||
|
||||
public void setEmojis(String emojis) {
|
||||
this.emojis = emojis;
|
||||
}
|
||||
|
||||
public Boolean getContainsMasks() {
|
||||
return containsMasks;
|
||||
}
|
||||
|
||||
public void setContainsMasks(Boolean containsMasks) {
|
||||
this.containsMasks = containsMasks;
|
||||
}
|
||||
|
||||
public MaskPosition getMaskPosition() {
|
||||
return maskPosition;
|
||||
}
|
||||
|
||||
public void setMaskPosition(MaskPosition maskPosition) {
|
||||
this.maskPosition = maskPosition;
|
||||
}
|
||||
|
||||
public InputFile getTgsSticker() {
|
||||
return tgsSticker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
@ -216,18 +128,4 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
||||
maskPosition.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CreateNewStickerSet{" +
|
||||
"userId=" + userId +
|
||||
", name='" + name + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", emojis='" + emojis + '\'' +
|
||||
", containsMasks=" + containsMasks +
|
||||
", maskPosition=" + maskPosition +
|
||||
", pngSticker=" + pngSticker +
|
||||
", tgsSticker=" + tgsSticker +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
@ -9,30 +17,27 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to delete a sticker from a set created by the bot. Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class DeleteStickerFromSet extends BotApiMethod<Boolean> {
|
||||
private static final String PATH = "deleteStickerFromSet";
|
||||
|
||||
private static final String STICKER_FIELD = "sticker";
|
||||
|
||||
@JsonProperty(STICKER_FIELD)
|
||||
@NonNull
|
||||
private String sticker; ///< File identifier of the sticker
|
||||
|
||||
public DeleteStickerFromSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DeleteStickerFromSet(String sticker) {
|
||||
super();
|
||||
this.sticker = checkNotNull(sticker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -59,20 +64,4 @@ public class DeleteStickerFromSet extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("sticker can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSticker() {
|
||||
return sticker;
|
||||
}
|
||||
|
||||
public DeleteStickerFromSet setSticker(String sticker) {
|
||||
this.sticker = sticker;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeleteStickerFromSet{" +
|
||||
"sticker='" + sticker + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.stickers.StickerSet;
|
||||
@ -10,30 +18,27 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to get a sticker set. On success, a StickerSet object is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetStickerSet extends BotApiMethod<StickerSet> {
|
||||
private static final String PATH = "getStickerSet";
|
||||
|
||||
private static final String NAME_FIELD = "name";
|
||||
|
||||
@JsonProperty(NAME_FIELD)
|
||||
@NonNull
|
||||
private String name; ///< Name of the sticker set
|
||||
|
||||
public GetStickerSet(String name) {
|
||||
super();
|
||||
this.name = checkNotNull(name);
|
||||
}
|
||||
|
||||
public GetStickerSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -60,20 +65,4 @@ public class GetStickerSet extends BotApiMethod<StickerSet> {
|
||||
throw new TelegramApiValidationException("Name can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public GetStickerSet setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetStickerSet{" +
|
||||
"name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
@ -9,13 +17,18 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
|
||||
private static final String PATH = "setStickerPositionInSet";
|
||||
|
||||
@ -23,19 +36,12 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
|
||||
private static final String POSITION_FIELD = "position";
|
||||
|
||||
@JsonProperty(STICKER_FIELD)
|
||||
@NonNull
|
||||
private String sticker; ///< File identifier of the sticker
|
||||
@JsonProperty(POSITION_FIELD)
|
||||
@NonNull
|
||||
private Integer position; ///< New sticker position in the set, zero-based
|
||||
|
||||
public SetStickerPositionInSet(String sticker, Integer position) {
|
||||
this.sticker = checkNotNull(sticker);
|
||||
this.position = checkNotNull(position);
|
||||
}
|
||||
|
||||
public SetStickerPositionInSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -65,30 +71,4 @@ public class SetStickerPositionInSet extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("position can't be null", this);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSticker() {
|
||||
return sticker;
|
||||
}
|
||||
|
||||
public SetStickerPositionInSet setSticker(String sticker) {
|
||||
this.sticker = checkNotNull(sticker);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public SetStickerPositionInSet setPosition(Integer position) {
|
||||
this.position = checkNotNull(position);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetStickerPositionInSet{" +
|
||||
"sticker='" + sticker + '\'' +
|
||||
", position=" + position +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,21 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.stickers;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -19,6 +23,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetStickerSetThumb extends BotApiMethod<Boolean> {
|
||||
private static final String PATH = "setStickerSetThumb";
|
||||
|
||||
@ -26,7 +37,9 @@ public class SetStickerSetThumb extends BotApiMethod<Boolean> {
|
||||
public static final String USERID_FIELD = "user_id";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
|
||||
@NonNull
|
||||
private String name; ///< Sticker set name
|
||||
@NonNull
|
||||
private Integer userId; ///< User identifier of the sticker set owner
|
||||
/**
|
||||
* A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px,
|
||||
@ -36,58 +49,9 @@ public class SetStickerSetThumb extends BotApiMethod<Boolean> {
|
||||
* String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
|
||||
* Animated sticker set thumbnail can't be uploaded via HTTP URL.
|
||||
*/
|
||||
@NonNull
|
||||
private InputFile thumb;
|
||||
|
||||
public SetStickerSetThumb() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SetStickerSetThumb(String name, Integer userId, InputFile thumb) {
|
||||
this.name = name;
|
||||
this.userId = userId;
|
||||
this.thumb = thumb;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public InputFile getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public SetStickerSetThumb setThumb(String thumb) {
|
||||
this.thumb = new InputFile(thumb);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetStickerSetThumb setThumb(InputFile thumb) {
|
||||
this.thumb = thumb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetStickerSetThumb setThumb(File thumbFile) {
|
||||
this.thumb = new InputFile(checkNotNull(thumbFile), thumbFile.getName());;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetStickerSetThumb setThumb(String thumbName, InputStream thumbStream) {
|
||||
this.thumb = new InputFile(checkNotNull(thumbStream), checkNotNull(thumbName));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -121,13 +85,4 @@ public class SetStickerSetThumb extends BotApiMethod<Boolean> {
|
||||
}
|
||||
thumb.validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetStickerSetThumb{" +
|
||||
"name='" + name + '\'' +
|
||||
", userId=" + userId +
|
||||
", thumb=" + thumb +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.stickers;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.File;
|
||||
import org.telegram.telegrambots.meta.api.objects.InputFile;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -19,28 +24,28 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet
|
||||
* methods (can be used multiple times). Returns the uploaded File on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class UploadStickerFile extends PartialBotApiMethod<File> {
|
||||
public static final String PATH = "uploadStickerFile";
|
||||
|
||||
public static final String USERID_FIELD = "user_id";
|
||||
public static final String PNGSTICKER_FIELD = "png_sticker";
|
||||
|
||||
@NonNull
|
||||
private Integer userId; ///< User identifier of sticker file owner
|
||||
/**
|
||||
* Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px,
|
||||
* and either width or height must be exactly 512px. More info on Sending Files »
|
||||
*/
|
||||
@NonNull
|
||||
private InputFile pngSticker; ///< New sticker file
|
||||
|
||||
public UploadStickerFile() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UploadStickerFile(Integer userId) {
|
||||
super();
|
||||
this.userId = checkNotNull(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
@ -68,35 +73,4 @@ public class UploadStickerFile extends PartialBotApiMethod<File> {
|
||||
|
||||
pngSticker.validate();
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public UploadStickerFile setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputFile getPngSticker() {
|
||||
return pngSticker;
|
||||
}
|
||||
|
||||
public UploadStickerFile setPngSticker(java.io.File pngSticker) {
|
||||
this.pngSticker = new InputFile(pngSticker, pngSticker.getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UploadStickerFile setPngSticker(String pngStickerName, InputStream pngStickerStream) {
|
||||
this.pngSticker = new InputFile(pngStickerStream, pngStickerName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UploadStickerFile{" +
|
||||
"userId=" + userId +
|
||||
", pngSticker=" + pngSticker +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.updates;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.WebhookInfo;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 2.4
|
||||
* Use this method to close the bot instance before moving it from one local server to another.
|
||||
* You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart.
|
||||
* The method will return error 429 in the first 10 minutes after the bot is launched.
|
||||
* Returns True on success.
|
||||
* Requires no parameters.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class Close extends BotApiMethod<WebhookInfo> {
|
||||
public static final String PATH = "close";
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebhookInfo deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
ApiResponse<WebhookInfo> result = OBJECT_MAPPER.readValue(answer,
|
||||
new TypeReference<ApiResponse<WebhookInfo>>() {
|
||||
});
|
||||
if (result.getOk()) {
|
||||
return result.getResult();
|
||||
} else {
|
||||
throw new TelegramApiRequestException("Error logging out info", result);
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
}
|
||||
}
|
@ -1,7 +1,14 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.updates;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
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.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
@ -15,12 +22,20 @@ import java.io.IOException;
|
||||
* Use this method to receive incoming updates using long polling (wiki). An Array of Update
|
||||
* objects is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class DeleteWebhook extends BotApiMethod<Boolean>{
|
||||
public static final String PATH = "deleteWebhook";
|
||||
|
||||
public DeleteWebhook() {
|
||||
super();
|
||||
}
|
||||
private static final String DROPPENDINGUPDATES_FIELD = "drop_pending_updates";
|
||||
|
||||
@JsonProperty(DROPPENDINGUPDATES_FIELD)
|
||||
private Boolean dropPendingUpdates; ///< Optional. Pass True to drop all pending updates
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -46,9 +61,4 @@ public class DeleteWebhook extends BotApiMethod<Boolean>{
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeleteWebhook{}";
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,17 @@ package org.telegram.telegrambots.meta.api.methods.updates;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
@ -19,6 +26,13 @@ import java.util.List;
|
||||
* Use this method to receive incoming updates using long polling (wiki). An Array of Update
|
||||
* objects is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetUpdates extends BotApiMethod<ArrayList<Update>>{
|
||||
public static final String PATH = "getupdates";
|
||||
|
||||
@ -59,48 +73,9 @@ public class GetUpdates extends BotApiMethod<ArrayList<Update>>{
|
||||
* so unwanted updates may be received for a short period of time.
|
||||
*/
|
||||
@JsonProperty(ALLOWEDUPDATES_FIELD)
|
||||
@Singular
|
||||
private List<String> allowedUpdates;
|
||||
|
||||
public GetUpdates() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Integer getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public GetUpdates setOffset(Integer offset) {
|
||||
this.offset = offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public GetUpdates setLimit(Integer limit) {
|
||||
this.limit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public GetUpdates setTimeout(Integer timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getAllowedUpdates() {
|
||||
return allowedUpdates;
|
||||
}
|
||||
|
||||
public GetUpdates setAllowedUpdates(List<String> allowedUpdates) {
|
||||
this.allowedUpdates = allowedUpdates;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -125,14 +100,4 @@ public class GetUpdates extends BotApiMethod<ArrayList<Update>>{
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetUpdates{" +
|
||||
"offset=" + offset +
|
||||
", limit=" + limit +
|
||||
", timeout=" + timeout +
|
||||
", allowedUpdates=" + allowedUpdates +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.updates;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.WebhookInfo;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.WebhookInfo;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
@ -18,18 +23,15 @@ import java.io.IOException;
|
||||
* On success, returns a WebhookInfo object.
|
||||
* Will throw an error, if the bot is using getUpdates.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetWebhookInfo extends BotApiMethod<WebhookInfo> {
|
||||
public static final String PATH = "getwebhookinfo";
|
||||
|
||||
public GetWebhookInfo() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetWebhookInfo{}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
|
@ -0,0 +1,60 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.updates;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
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.WebhookInfo;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 2.4
|
||||
* Use this method to log out from the cloud Bot API server before launching the bot locally.
|
||||
* You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates.
|
||||
* After a successful call, you will not be able to log in again using the same token for 10 minutes.
|
||||
* Returns True on success.
|
||||
* Requires no parameters.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class LogOut extends BotApiMethod<WebhookInfo> {
|
||||
public static final String PATH = "logOut";
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebhookInfo deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
ApiResponse<WebhookInfo> result = OBJECT_MAPPER.readValue(answer,
|
||||
new TypeReference<ApiResponse<WebhookInfo>>() {
|
||||
});
|
||||
if (result.getOk()) {
|
||||
return result.getResult();
|
||||
} else {
|
||||
throw new TelegramApiRequestException("Error logging out info", result);
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
}
|
||||
}
|
@ -1,31 +1,64 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.updates;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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.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.InputFile;
|
||||
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 1.0
|
||||
* @brief Use this method to specify a url and receive incoming updates via an outgoing webhook.
|
||||
* Use this method to specify a url and receive incoming updates via an outgoing webhook.
|
||||
* Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url,
|
||||
* containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a
|
||||
* reasonable amount of attempts.
|
||||
* @date 20 of June of 2015
|
||||
* 20 of June of 2015
|
||||
*/
|
||||
public class SetWebhook {
|
||||
public static final String PATH = "setwebhook";
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SetWebhook extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "setWebhook";
|
||||
|
||||
public static final String URL_FIELD = "url";
|
||||
public static final String CERTIFICATE_FIELD = "certificate";
|
||||
public static final String MAXCONNECTIONS_FIELD = "max_connections";
|
||||
public static final String ALLOWEDUPDATES_FIELD = "allowed_updates";
|
||||
public static final String IPADDRESS_FIELD = "ip_address";
|
||||
public static final String DROPPENDINGUPDATES_FIELD = "drop_pending_updates";
|
||||
|
||||
@JsonProperty(URL_FIELD)
|
||||
@NonNull
|
||||
private String url; ///< Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration
|
||||
private String certificateFile; ///< Optional. Upload your public key certificate so that the root certificate in use can be checked
|
||||
@JsonProperty(CERTIFICATE_FIELD)
|
||||
private InputFile certificate; ///< Optional. Upload your public key certificate so that the root certificate in use can be checked
|
||||
/**
|
||||
* Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100.
|
||||
* Defaults to 40. Use lower values to limit the load on your bot‘s server,
|
||||
* and higher values to increase your bot’s throughput.
|
||||
*/
|
||||
@JsonProperty(MAXCONNECTIONS_FIELD)
|
||||
private Integer maxConnections;
|
||||
/**
|
||||
* List the types of updates you want your bot to receive.
|
||||
@ -36,55 +69,43 @@ public class SetWebhook {
|
||||
* Please note that this parameter doesn't affect updates created before the call to the setWebhook,
|
||||
* so unwanted updates may be received for a short period of time.
|
||||
*/
|
||||
@JsonProperty(ALLOWEDUPDATES_FIELD)
|
||||
@Singular
|
||||
private List<String> allowedUpdates;
|
||||
@JsonProperty(IPADDRESS_FIELD)
|
||||
private String ipAddress;
|
||||
@JsonProperty(DROPPENDINGUPDATES_FIELD)
|
||||
private Boolean dropPendingUpdates;
|
||||
|
||||
public SetWebhook() {
|
||||
this.url = "";
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public SetWebhook setUrl(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCertificateFile() {
|
||||
return certificateFile;
|
||||
}
|
||||
|
||||
public SetWebhook setCertificateFile(String certificateFile) {
|
||||
this.certificateFile = certificateFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMaxConnections() {
|
||||
return maxConnections;
|
||||
}
|
||||
|
||||
public SetWebhook setMaxConnections(Integer maxConnections) {
|
||||
this.maxConnections = maxConnections;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getAllowedUpdates() {
|
||||
return allowedUpdates;
|
||||
}
|
||||
|
||||
public SetWebhook setAllowedUpdates(List<String> allowedUpdates) {
|
||||
this.allowedUpdates = allowedUpdates;
|
||||
return this;
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetWebhook{" +
|
||||
"url='" + url + '\'' +
|
||||
", certificateFile='" + certificateFile + '\'' +
|
||||
", maxConnections=" + maxConnections +
|
||||
", allowedUpdates=" + allowedUpdates +
|
||||
'}';
|
||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
|
||||
new TypeReference<ApiResponse<Boolean>>(){});
|
||||
if (result.getOk()) {
|
||||
return result.getResult();
|
||||
} else {
|
||||
throw new TelegramApiRequestException("Error setting webhook", result);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TelegramApiRequestException("Unable to deserialize response", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new TelegramApiValidationException("URL parameter can't be empty", this);
|
||||
}
|
||||
if (certificate != null) {
|
||||
if (!certificate.isNew()) {
|
||||
throw new TelegramApiValidationException("Certificate parameter must be a new file to upload", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -25,6 +30,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class DeleteMessage extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "deleteMessage";
|
||||
|
||||
@ -35,51 +47,15 @@ public class DeleteMessage extends BotApiMethod<Boolean> {
|
||||
* Unique identifier for the chat to send the message to (Or username for channels)
|
||||
*/
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private String chatId;
|
||||
/**
|
||||
* Identifier of the message to delete
|
||||
*/
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
@NonNull
|
||||
private Integer messageId;
|
||||
|
||||
public DeleteMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DeleteMessage(String chatId, Integer messageId) {
|
||||
this.chatId = checkNotNull(chatId);
|
||||
this.messageId = checkNotNull(messageId);
|
||||
}
|
||||
|
||||
public DeleteMessage(Long chatId, Integer messageId) {
|
||||
this.chatId = checkNotNull(chatId).toString();
|
||||
this.messageId = checkNotNull(messageId);
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public DeleteMessage setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeleteMessage setChatId(Long chatId) {
|
||||
Objects.requireNonNull(chatId);
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public DeleteMessage setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -110,12 +86,4 @@ public class DeleteMessage extends BotApiMethod<Boolean> {
|
||||
throw new TelegramApiValidationException("MessageId parameter can't be empty", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeleteMessage{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,25 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
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.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -19,6 +28,13 @@ import java.io.Serializable;
|
||||
* Use this method to edit captions of messages.
|
||||
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EditMessageCaption extends BotApiMethod<Serializable> {
|
||||
public static final String PATH = "editmessagecaption";
|
||||
|
||||
@ -28,6 +44,7 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
|
||||
private static final String CAPTION_FIELD = "caption";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||
private static final String CAPTION_ENTITIES_FIELD = "caption_entities";
|
||||
|
||||
/**
|
||||
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
|
||||
@ -50,65 +67,10 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
|
||||
public EditMessageCaption() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public EditMessageCaption setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public EditMessageCaption setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public EditMessageCaption setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public EditMessageCaption setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public EditMessageCaption setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public EditMessageCaption setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
@JsonProperty(CAPTION_ENTITIES_FIELD)
|
||||
@Singular
|
||||
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -158,20 +120,11 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
|
||||
throw new TelegramApiValidationException("MessageId parameter must be empty if inlineMessageId is provided", this);
|
||||
}
|
||||
}
|
||||
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EditMessageCaption{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", caption='" + caption + '\'' +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
@ -11,16 +19,22 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to edit live location.
|
||||
* A location can be edited until its live_period expires or editing is explicitly disabled by a call to
|
||||
* stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned,
|
||||
* stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned,
|
||||
* otherwise True is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
public static final String PATH = "editMessageLiveLocation";
|
||||
|
||||
@ -30,6 +44,9 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
private static final String LATITUDE_FIELD = "latitude";
|
||||
private static final String LONGITUDE_FIELD = "longitude";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
|
||||
private static final String HEADING_FIELD = "heading";
|
||||
private static final String APPROACHINGNOTIFICATIONDISTANCE_FIELD = "approaching_notification_distance";
|
||||
|
||||
/**
|
||||
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
|
||||
@ -48,76 +65,33 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
|
||||
private String inlineMessageId;
|
||||
@JsonProperty(LATITUDE_FIELD)
|
||||
private Float latitude; ///< Latitude of new location
|
||||
@NonNull
|
||||
private Double latitude; ///< Latitude of new location
|
||||
@JsonProperty(LONGITUDE_FIELD)
|
||||
private Float longitude; ///< Longitude of new location
|
||||
@NonNull
|
||||
private Double longitude; ///< Longitude of new location
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
||||
|
||||
public EditMessageLiveLocation() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Float getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setLatitude(Float latitude) {
|
||||
Objects.requireNonNull(latitude);
|
||||
this.latitude = latitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Float getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public EditMessageLiveLocation setLongitude(Float longitude) {
|
||||
Objects.requireNonNull(longitude);
|
||||
this.longitude = longitude;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Optional.
|
||||
* The radius of uncertainty for the location, measured in meters; 0-1500
|
||||
*/
|
||||
@JsonProperty(HORIZONTALACCURACY_FIELD)
|
||||
private Double horizontalAccuracy;
|
||||
/**
|
||||
* Optional.
|
||||
* For live locations, a direction in which the user is moving, in degrees.
|
||||
* Must be between 1 and 360 if specified.
|
||||
*/
|
||||
@JsonProperty(HEADING_FIELD)
|
||||
private Integer heading;
|
||||
/**
|
||||
* Optional.
|
||||
* For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
|
||||
* Must be between 1 and 100000 if specified.
|
||||
*/
|
||||
@JsonProperty(APPROACHINGNOTIFICATIONDISTANCE_FIELD)
|
||||
private Integer approachingNotificationDistance;
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -173,20 +147,17 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
if (longitude == null) {
|
||||
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
|
||||
}
|
||||
if (horizontalAccuracy != null && (horizontalAccuracy < 0 || horizontalAccuracy > 1500)) {
|
||||
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (heading != null && (heading < 1 || heading > 360)) {
|
||||
throw new TelegramApiValidationException("Heading Accuracy parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (approachingNotificationDistance != null && (approachingNotificationDistance < 1 || approachingNotificationDistance > 100000)) {
|
||||
throw new TelegramApiValidationException("Approaching notification distance parameter must be between 0 and 1500", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EditMessageLiveLocation{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,19 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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 org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.media.InputMedia;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
@ -17,11 +26,20 @@ import java.io.Serializable;
|
||||
* @author Ruben Bermudez
|
||||
* @version 4.0.0
|
||||
* Use this method to edit audio, document, photo, or video messages.
|
||||
* If a message is a part of a message album, then it can be edited only to a photo or a video.
|
||||
* Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded.
|
||||
* Use previously uploaded file via its file_id or specify a URL.
|
||||
* f a message is part of a message album, then it can be edited only to an audio for audio albums,
|
||||
* only to a document for document albums and to a photo or a video otherwise
|
||||
* When an inline message is edited, a new file can't be uploaded.
|
||||
* Use a previously uploaded file via its file_id or specify a URL.
|
||||
* On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EditMessageMedia extends PartialBotApiMethod<Serializable> {
|
||||
public static final String PATH = "editMessageMedia";
|
||||
|
||||
@ -50,65 +68,13 @@ public class EditMessageMedia extends PartialBotApiMethod<Serializable> {
|
||||
/**
|
||||
* A JSON-serialized object for a new media content of the message
|
||||
*/
|
||||
@NonNull
|
||||
@JsonProperty(MEDIA_FIELD)
|
||||
private InputMedia media;
|
||||
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
||||
|
||||
public EditMessageMedia() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public EditMessageMedia setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageMedia setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public EditMessageMedia setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public EditMessageMedia setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputMedia getMedia() {
|
||||
return media;
|
||||
}
|
||||
|
||||
public void setMedia(InputMedia media) {
|
||||
this.media = media;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public EditMessageMedia setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||
try {
|
||||
@ -162,15 +128,4 @@ public class EditMessageMedia extends PartialBotApiMethod<Serializable> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EditMessageMedia{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", media=" + media +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,16 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
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.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
@ -20,6 +26,13 @@ import java.io.Serializable;
|
||||
* On success, if edited message is sent by the bot, the edited Message is returned,
|
||||
* otherwise True is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EditMessageReplyMarkup extends BotApiMethod<Serializable> {
|
||||
public static final String PATH = "editmessagereplymarkup";
|
||||
|
||||
@ -47,51 +60,6 @@ public class EditMessageReplyMarkup extends BotApiMethod<Serializable> {
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
||||
|
||||
public EditMessageReplyMarkup() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public EditMessageReplyMarkup setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageReplyMarkup setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public EditMessageReplyMarkup setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public EditMessageReplyMarkup setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public EditMessageReplyMarkup setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return PATH;
|
||||
@ -144,14 +112,4 @@ public class EditMessageReplyMarkup extends BotApiMethod<Serializable> {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EditMessageReplyMarkup{" +
|
||||
"chatId=" + chatId +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId=" + inlineMessageId +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,27 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
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 org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.methods.ParseMode;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
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.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
@ -20,6 +30,15 @@ import java.io.Serializable;
|
||||
* Use this method to edit text messages. On
|
||||
* success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EditMessageText extends BotApiMethod<Serializable> {
|
||||
public static final String PATH = "editmessagetext";
|
||||
|
||||
@ -30,6 +49,7 @@ public class EditMessageText extends BotApiMethod<Serializable> {
|
||||
private static final String PARSE_MODE_FIELD = "parse_mode";
|
||||
private static final String DISABLE_WEB_PREVIEW_FIELD = "disable_web_page_preview";
|
||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private static final String ENTITIES_FIELD = "entities";
|
||||
|
||||
/**
|
||||
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
|
||||
@ -51,6 +71,7 @@ public class EditMessageText extends BotApiMethod<Serializable> {
|
||||
* New text of the message
|
||||
*/
|
||||
@JsonProperty(TEXT_FIELD)
|
||||
@NonNull
|
||||
private String text;
|
||||
/**
|
||||
* Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width
|
||||
@ -62,93 +83,35 @@ public class EditMessageText extends BotApiMethod<Serializable> {
|
||||
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in this message
|
||||
@JsonProperty(REPLYMARKUP_FIELD)
|
||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
||||
@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
|
||||
|
||||
public EditMessageText() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public EditMessageText setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageText setChatId(Long chatId) {
|
||||
public void setChatId(Long chatId) {
|
||||
this.chatId = chatId.toString();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public EditMessageText setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return inlineMessageId;
|
||||
}
|
||||
|
||||
public EditMessageText setInlineMessageId(String inlineMessageId) {
|
||||
this.inlineMessageId = inlineMessageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public EditMessageText setText(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public EditMessageText setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageText disableWebPagePreview() {
|
||||
public void disableWebPagePreview() {
|
||||
disableWebPagePreview = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageText enableWebPagePreview() {
|
||||
public void enableWebPagePreview() {
|
||||
disableWebPagePreview = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageText enableMarkdown(boolean enable) {
|
||||
public void enableMarkdown(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.MARKDOWN;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditMessageText enableHtml(boolean enable) {
|
||||
public void enableHtml(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = ParseMode.HTML;
|
||||
} else {
|
||||
this.parseMode = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public EditMessageText setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -202,21 +165,11 @@ public class EditMessageText extends BotApiMethod<Serializable> {
|
||||
if (text == null || text.isEmpty()) {
|
||||
throw new TelegramApiValidationException("Text parameter can't be empty", this);
|
||||
}
|
||||
if (parseMode != null && (entities != null && !entities.isEmpty()) ) {
|
||||
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EditMessageText{" +
|
||||
"chatId=" + chatId +
|
||||
", messageId=" + messageId +
|
||||
", inlineMessageId=" + inlineMessageId +
|
||||
", text=" + text +
|
||||
", parseMode=" + parseMode +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -8,6 +14,12 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
* @version 1.0
|
||||
* This object represents an audio file
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Audio implements BotApiObject {
|
||||
|
||||
private static final String FILEID_FIELD = "file_id";
|
||||
@ -18,6 +30,7 @@ public class Audio implements BotApiObject {
|
||||
private static final String TITLE_FIELD = "title";
|
||||
private static final String PERFORMER_FIELD = "performer";
|
||||
private static final String THUMB_FIELD = "thumb";
|
||||
private static final String FILENAME_FIELD = "file_name";
|
||||
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
|
||||
@ -39,54 +52,6 @@ public class Audio implements BotApiObject {
|
||||
private String performer; ///< Optional. Performer of the audio as defined by sender or by audio tags
|
||||
@JsonProperty(THUMB_FIELD)
|
||||
private PhotoSize thumb; ///< Optional. Thumbnail of the album cover to which the music file belongs
|
||||
|
||||
public Audio() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public Integer getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getPerformer() {
|
||||
return performer;
|
||||
}
|
||||
|
||||
public PhotoSize getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public String getFileUniqueId() {
|
||||
return fileUniqueId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Audio{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", duration=" + duration +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", fileSize=" + fileSize +
|
||||
", title='" + title + '\'' +
|
||||
", performer='" + performer + '\'' +
|
||||
", thumb=" + thumb +
|
||||
", fileUniqueId=" + fileUniqueId +
|
||||
'}';
|
||||
}
|
||||
@JsonProperty(FILENAME_FIELD)
|
||||
private String fileName; ///< Optional. Original filename as defined by sender
|
||||
}
|
||||
|
@ -1,24 +1,34 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* @brief This object represents an incoming callback query from a
|
||||
* 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,
|
||||
* the field message will be present. If the button was attached to a message sent via the bot
|
||||
* (in inline mode), the field inline_message_id will be present.
|
||||
* @note Exactly one of the fields data or game_short_name will be present.
|
||||
* @note After the user presses an inline button, Telegram clients will display a progress bar
|
||||
* @apiNote Exactly one of the fields data or game_short_name will be present.
|
||||
* @apiNote After the user presses an inline button, Telegram clients will display a progress bar
|
||||
* 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).
|
||||
* @date 10 of April of 2016
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CallbackQuery implements BotApiObject {
|
||||
|
||||
private static final String ID_FIELD = "id";
|
||||
@ -37,7 +47,7 @@ public class CallbackQuery implements BotApiObject {
|
||||
* Optional.
|
||||
* Message with the callback button that originated the query.
|
||||
*
|
||||
* @note The message content and message date will not be available if the message is too old
|
||||
* @apiNote The message content and message date will not be available if the message is too old
|
||||
*/
|
||||
@JsonProperty(MESSAGE_FIELD)
|
||||
private Message message;
|
||||
@ -46,7 +56,7 @@ public class CallbackQuery implements BotApiObject {
|
||||
/**
|
||||
*
|
||||
* Optional. Data associated with the callback button.
|
||||
* @note Be aware that a bad client can send arbitrary data in this field
|
||||
* @apiNote Be aware that a bad client can send arbitrary data in this field
|
||||
*/
|
||||
@JsonProperty(DATA_FIELD)
|
||||
private String data;
|
||||
@ -61,49 +71,4 @@ public class CallbackQuery implements BotApiObject {
|
||||
*/
|
||||
@JsonProperty(CHAT_INSTANCE_FIELD)
|
||||
private String chatInstance;
|
||||
|
||||
public CallbackQuery() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public User getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
|
||||
public Message getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public String getInlineMessageId() {
|
||||
return this.inlineMessageId;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getGameShortName() {
|
||||
return gameShortName;
|
||||
}
|
||||
|
||||
public String getChatInstance() {
|
||||
return chatInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CallbackQuery{" +
|
||||
"id='" + id + '\'' +
|
||||
", from=" + from +
|
||||
", message=" + message +
|
||||
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||
", data='" + data + '\'' +
|
||||
", gameShortName='" + gameShortName + '\'' +
|
||||
", chatInstance='" + chatInstance + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,13 @@ package org.telegram.telegrambots.meta.api.objects;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
|
||||
/**
|
||||
@ -15,7 +18,10 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
* This object represents a Telegram chat with an user or a group
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ -27,6 +33,7 @@ public class Chat implements BotApiObject {
|
||||
private static final String USERNAME_FIELD = "username";
|
||||
private static final String FIRSTNAME_FIELD = "first_name";
|
||||
private static final String LASTNAME_FIELD = "last_name";
|
||||
private static final String BIO_FIELD = "bio";
|
||||
private static final String ALL_MEMBERS_ARE_ADMINISTRATORS_FIELD = "all_members_are_administrators";
|
||||
private static final String PHOTO_FIELD = "photo";
|
||||
private static final String DESCRIPTION_FIELD = "description";
|
||||
@ -36,6 +43,8 @@ public class Chat implements BotApiObject {
|
||||
private static final String CANSETSTICKERSET_FIELD = "can_set_sticker_set";
|
||||
private static final String PERMISSIONS_FIELD = "permissions";
|
||||
private static final String SLOWMODEDELAY_FIELD = "slow_mode_delay";
|
||||
private static final String LINKEDCHATID_FIELD = "linked_chat_id";
|
||||
private static final String LOCATION_FIELD = "location";
|
||||
|
||||
private static final String USERCHATTYPE = "private";
|
||||
private static final String GROUPCHATTYPE = "group";
|
||||
@ -53,7 +62,7 @@ public class Chat implements BotApiObject {
|
||||
private Long id; ///< Unique identifier for this chat, not exceeding 1e13 by absolute value
|
||||
@JsonProperty(TYPE_FIELD)
|
||||
@NonNull
|
||||
private String type; ///< Type of the chat, one of “private”, “group” or “channel”
|
||||
private String type; ///< Type of the chat, one of “private”, “group” or “channel” or "supergroup"
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
private String title; ///< Optional. Title of the chat, only for channels and group chat
|
||||
@JsonProperty(FIRSTNAME_FIELD)
|
||||
@ -80,7 +89,7 @@ public class Chat implements BotApiObject {
|
||||
@JsonProperty(INVITELINK_FIELD)
|
||||
private String inviteLink;
|
||||
@JsonProperty(PINNEDMESSAGE_FIELD)
|
||||
private Message pinnedMessage; ///< Optional. Pinned message, for groups, supergroups and channels. Returned only in getChat.
|
||||
private Message pinnedMessage; ///< Optional. The most recent pinned message (by sending date). Returned only in getChat.
|
||||
@JsonProperty(STICKERSETNAME_FIELD)
|
||||
private String stickerSetName; ///< Optional. For supergroups, name of Group sticker set. Returned only in getChat.
|
||||
@JsonProperty(CANSETSTICKERSET_FIELD)
|
||||
@ -94,6 +103,22 @@ public class Chat implements BotApiObject {
|
||||
*/
|
||||
@JsonProperty(SLOWMODEDELAY_FIELD)
|
||||
private Integer slowModeDelay;
|
||||
@JsonProperty(BIO_FIELD)
|
||||
private String bio; ///< Optional. Bio of the other party in a private chat. Returned only in getChat.
|
||||
/**
|
||||
* Optional.
|
||||
* Unique identifier for the linked chat,
|
||||
* i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats.
|
||||
* This identifier may be greater than 32 bits and some programming
|
||||
* languages may have difficulty/silent defects in interpreting it.
|
||||
* But it is smaller than 52 bits, so a signed 64 bit integer or
|
||||
* double-precision float type are safe for storing this identifier.
|
||||
* Returned only in getChat.
|
||||
*/
|
||||
@JsonProperty(LINKEDCHATID_FIELD)
|
||||
private Long linkedChatId;
|
||||
@JsonProperty(LOCATION_FIELD)
|
||||
private ChatLocation location; ///< Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
|
||||
|
||||
@JsonIgnore
|
||||
public Boolean isGroupChat() {
|
||||
|
@ -0,0 +1,33 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 5.0
|
||||
* Represents a location to which a chat is connected.
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ChatLocation implements BotApiObject {
|
||||
|
||||
private static final String LOCATION_FIELD = "location";
|
||||
private static final String ADDRESS_FIELD = "address";
|
||||
|
||||
@JsonProperty(LOCATION_FIELD)
|
||||
private Location location; ///< The location to which the supergroup is connected
|
||||
@JsonProperty(ADDRESS_FIELD)
|
||||
private String address; ///< Location address; 1-64 characters, as defined by the chat owner
|
||||
}
|
@ -1,6 +1,12 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
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;
|
||||
|
||||
import java.time.Instant;
|
||||
@ -10,6 +16,12 @@ import java.time.Instant;
|
||||
* @version 1.0
|
||||
* This object contains information about one member of the chat.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ChatMember implements BotApiObject {
|
||||
private static final String USER_FIELD = "user";
|
||||
private static final String STATUS_FIELD = "status";
|
||||
@ -30,6 +42,7 @@ public class ChatMember implements BotApiObject {
|
||||
private static final String CAN_SEND_POLLS_FIELD = "can_send_polls";
|
||||
private static final String ISMEMBER_FIELD = "is_member";
|
||||
private static final String CUSTOMTITLE_FIELD = "custom_title";
|
||||
private static final String ISANONYMOUS_FIELD = "is_anonymous";
|
||||
|
||||
@JsonProperty(USER_FIELD)
|
||||
private User user; ///< Information about the user
|
||||
@ -69,22 +82,8 @@ public class ChatMember implements BotApiObject {
|
||||
private Boolean isMemberField; ///< True, if the user is a member of the chat at the moment of the request. For example, it can be false for the chat creator or for a restricted user.
|
||||
@JsonProperty(CUSTOMTITLE_FIELD)
|
||||
private String customTitle; ///< Optional. Owner and administrators only. Custom title for this user
|
||||
|
||||
public ChatMember() {
|
||||
super();
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Integer getUntilDate() {
|
||||
return untilDate;
|
||||
}
|
||||
@JsonProperty(ISANONYMOUS_FIELD)
|
||||
private Boolean isAnonymous; ///< Optional. Owner and administrators only. True, if the user's presence in the chat is hidden
|
||||
|
||||
public Instant getUntilDateAsInstant() {
|
||||
if (untilDate == null) {
|
||||
@ -92,93 +91,4 @@ public class ChatMember implements BotApiObject {
|
||||
}
|
||||
return Instant.ofEpochSecond(untilDate);
|
||||
}
|
||||
|
||||
public Boolean getCanBeEdited() {
|
||||
return canBeEdited;
|
||||
}
|
||||
|
||||
public Boolean getCanChangeInformation() {
|
||||
return canChangeInformation;
|
||||
}
|
||||
|
||||
public Boolean getCanPostMessages() {
|
||||
return canPostMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanEditMessages() {
|
||||
return canEditMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanDeleteMessages() {
|
||||
return canDeleteMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanInviteUsers() {
|
||||
return canInviteUsers;
|
||||
}
|
||||
|
||||
public Boolean getCanRestrictMembers() {
|
||||
return canRestrictMembers;
|
||||
}
|
||||
|
||||
public Boolean getCanPinMessages() {
|
||||
return canPinMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanPromoteMembers() {
|
||||
return canPromoteMembers;
|
||||
}
|
||||
|
||||
public Boolean getCanSendMessages() {
|
||||
return canSendMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanSendMediaMessages() {
|
||||
return canSendMediaMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanSendOtherMessages() {
|
||||
return canSendOtherMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanAddWebPagePreviews() {
|
||||
return canAddWebPagePreviews;
|
||||
}
|
||||
|
||||
public Boolean getCanSendPolls() {
|
||||
return canSendPolls;
|
||||
}
|
||||
|
||||
public Boolean getMemberField() {
|
||||
return isMemberField;
|
||||
}
|
||||
|
||||
public String getCustomTitle() {
|
||||
return customTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatMember{" +
|
||||
"user=" + user +
|
||||
", status='" + status + '\'' +
|
||||
", untilDate=" + untilDate +
|
||||
", canBeEdited=" + canBeEdited +
|
||||
", canChangeInformation=" + canChangeInformation +
|
||||
", canPostMessages=" + canPostMessages +
|
||||
", canEditMessages=" + canEditMessages +
|
||||
", canDeleteMessages=" + canDeleteMessages +
|
||||
", canInviteUsers=" + canInviteUsers +
|
||||
", canRestrictMembers=" + canRestrictMembers +
|
||||
", canPinMessages=" + canPinMessages +
|
||||
", canPromoteMembers=" + canPromoteMembers +
|
||||
", canSendMessages=" + canSendMessages +
|
||||
", canSendMediaMessages=" + canSendMediaMessages +
|
||||
", canSendOtherMessages=" + canSendOtherMessages +
|
||||
", canAddWebPagePreviews=" + canAddWebPagePreviews +
|
||||
", canSendPolls=" + canSendPolls +
|
||||
", isMemberField=" + isMemberField +
|
||||
", customTitle=" + customTitle +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,13 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
|
||||
/**
|
||||
@ -10,6 +17,13 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
* Returns True on success.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ChatPermissions implements BotApiObject {
|
||||
private static final String CAN_SEND_MESSAGES_FIELD = "can_send_messages";
|
||||
private static final String CAN_SEND_MEDIA_MESSAGES_FIELD = "can_send_media_messages";
|
||||
@ -36,86 +50,4 @@ public class ChatPermissions implements BotApiObject {
|
||||
private Boolean canInviteUsers; ///< Optional. True, if the user is allowed to invite new users to the chat
|
||||
@JsonProperty(CAN_PIN_MESSAGES_FIELD)
|
||||
private Boolean canPinMessages; ///< Optional. True, if the user is allowed to pin messages. Ignored in public supergroups
|
||||
|
||||
public ChatPermissions() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Boolean getCanSendMessages() {
|
||||
return canSendMessages;
|
||||
}
|
||||
|
||||
public Boolean getGetCanSendMediaMessages() {
|
||||
return getCanSendMediaMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanSendPolls() {
|
||||
return canSendPolls;
|
||||
}
|
||||
|
||||
public Boolean getCanSendOtherMessages() {
|
||||
return canSendOtherMessages;
|
||||
}
|
||||
|
||||
public Boolean getCanAddWebPagePreviews() {
|
||||
return canAddWebPagePreviews;
|
||||
}
|
||||
|
||||
public Boolean getCanChangeInfo() {
|
||||
return canChangeInfo;
|
||||
}
|
||||
|
||||
public Boolean getCanInviteUsers() {
|
||||
return canInviteUsers;
|
||||
}
|
||||
|
||||
public Boolean getCanPinMessages() {
|
||||
return canPinMessages;
|
||||
}
|
||||
|
||||
public void setCanSendMessages(Boolean canSendMessages) {
|
||||
this.canSendMessages = canSendMessages;
|
||||
}
|
||||
|
||||
public void setGetCanSendMediaMessages(Boolean getCanSendMediaMessages) {
|
||||
this.getCanSendMediaMessages = getCanSendMediaMessages;
|
||||
}
|
||||
|
||||
public void setCanSendPolls(Boolean canSendPolls) {
|
||||
this.canSendPolls = canSendPolls;
|
||||
}
|
||||
|
||||
public void setCanSendOtherMessages(Boolean canSendOtherMessages) {
|
||||
this.canSendOtherMessages = canSendOtherMessages;
|
||||
}
|
||||
|
||||
public void setCanAddWebPagePreviews(Boolean canAddWebPagePreviews) {
|
||||
this.canAddWebPagePreviews = canAddWebPagePreviews;
|
||||
}
|
||||
|
||||
public void setCanChangeInfo(Boolean canChangeInfo) {
|
||||
this.canChangeInfo = canChangeInfo;
|
||||
}
|
||||
|
||||
public void setCanInviteUsers(Boolean canInviteUsers) {
|
||||
this.canInviteUsers = canInviteUsers;
|
||||
}
|
||||
|
||||
public void setCanPinMessages(Boolean canPinMessages) {
|
||||
this.canPinMessages = canPinMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatPermissions{" +
|
||||
"canSendMessages=" + canSendMessages +
|
||||
", getCanSendMediaMessages=" + getCanSendMediaMessages +
|
||||
", canSendPolls=" + canSendPolls +
|
||||
", canSendOtherMessages=" + canSendOtherMessages +
|
||||
", canAddWebPagePreviews=" + canAddWebPagePreviews +
|
||||
", canChangeInfo=" + canChangeInfo +
|
||||
", canInviteUsers=" + canInviteUsers +
|
||||
", canPinMessages=" + canPinMessages +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -8,6 +14,12 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
* @version 1.0
|
||||
* This object represents a chat photo (profile picture of a user, group or channel)
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ChatPhoto implements BotApiObject {
|
||||
private static final String SMALLFILEID_FIELD = "small_file_id";
|
||||
private static final String SMALLFILEUNIQUEID_FIELD = "small_file_unique_id";
|
||||
@ -40,34 +52,4 @@ public class ChatPhoto implements BotApiObject {
|
||||
*/
|
||||
@JsonProperty(BIGFILEUNIQUEID_FIELD)
|
||||
private String bigFileUniqueId;
|
||||
|
||||
public ChatPhoto() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getSmallFileId() {
|
||||
return smallFileId;
|
||||
}
|
||||
|
||||
public String getBigFileId() {
|
||||
return bigFileId;
|
||||
}
|
||||
|
||||
public String getSmallFileUniqueId() {
|
||||
return smallFileUniqueId;
|
||||
}
|
||||
|
||||
public String getBigFileUniqueId() {
|
||||
return bigFileUniqueId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatPhoto{" +
|
||||
"smallFileId='" + smallFileId + '\'' +
|
||||
", smallFileUniqueId='" + smallFileUniqueId + '\'' +
|
||||
", bigFileId='" + bigFileId + '\'' +
|
||||
", bigFileUniqueId='" + bigFileUniqueId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user