commit
7351def280
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.httpcomponents:httpclient:4.5.1">
|
||||
<library name="Maven: org.apache.httpcomponents:httpclient:4.5.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.1/httpclient-4.5.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.1/httpclient-4.5.1-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.1/httpclient-4.5.1-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.httpcomponents:httpcore:4.4.3">
|
||||
<library name="Maven: org.apache.httpcomponents:httpcore:4.4.4">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.3/httpcore-4.4.3.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.3/httpcore-4.4.3-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.3/httpcore-4.4.3-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.httpcomponents:httpmime:4.5.1">
|
||||
<library name="Maven: org.apache.httpcomponents:httpmime:4.5.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.1/httpmime-4.5.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.2/httpmime-4.5.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.1/httpmime-4.5.1-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.2/httpmime-4.5.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.1/httpmime-4.5.1-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.2/httpmime-4.5.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -48,10 +48,10 @@
|
||||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-servlet:1.19" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.json:json:20151123" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
|
||||
</component>
|
||||
</module>
|
30
pom.xml
30
pom.xml
@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.1</version>
|
||||
|
||||
<name>Telegram Bots</name>
|
||||
<description>Easy to use library to create Telegram Bots</description>
|
||||
@ -82,6 +82,30 @@
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin> <!-- Create sources.jar -->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
|
@ -80,37 +80,6 @@ public class TelegramBotsApi {
|
||||
webhook.startServer();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bot
|
||||
*/
|
||||
public void registerBot(TelegramLongPollingBot bot) throws TelegramApiException {
|
||||
setWebhook(bot.getBotToken());
|
||||
new UpdatesThread(bot.getBotToken(), bot);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bot
|
||||
*/
|
||||
public void registerBot(TelegramWebhookBot bot) throws TelegramApiException {
|
||||
if (useWebhook) {
|
||||
webhook.registerWebhook(bot);
|
||||
setWebhook(bot.getBotToken());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param botToken
|
||||
*/
|
||||
private void setWebhook(String botToken) throws TelegramApiException {
|
||||
if (botToken == null) {
|
||||
throw new TelegramApiException("Parameter botToken can not be null");
|
||||
}
|
||||
setWebhook(extrenalUrl == null ? "" : extrenalUrl, botToken, pathToCertificate, publicCertificateName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param externalUrl
|
||||
@ -158,4 +127,35 @@ public class TelegramBotsApi {
|
||||
throw new TelegramApiException("Error executing setWebook method", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bot
|
||||
*/
|
||||
public void registerBot(TelegramLongPollingBot bot) throws TelegramApiException {
|
||||
setWebhook(bot.getBotToken());
|
||||
new UpdatesThread(bot.getBotToken(), bot);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bot
|
||||
*/
|
||||
public void registerBot(TelegramWebhookBot bot) throws TelegramApiException {
|
||||
if (useWebhook) {
|
||||
webhook.registerWebhook(bot);
|
||||
setWebhook(bot.getBotToken());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param botToken
|
||||
*/
|
||||
private void setWebhook(String botToken) throws TelegramApiException {
|
||||
if (botToken == null) {
|
||||
throw new TelegramApiException("Parameter botToken can not be null");
|
||||
}
|
||||
setWebhook(extrenalUrl == null ? "" : extrenalUrl, botToken, pathToCertificate, publicCertificateName);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.objects.InlineQueryResult;
|
||||
@ -20,14 +21,14 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
|
||||
public static final String PATH = "answerInlineQuery";
|
||||
|
||||
public static final String INLINEQUERYID_FIELD = "inline_query_id";
|
||||
private String inlineQueryId; ///< Unique identifier for answered query
|
||||
public static final String RESULTS_FIELD = "results";
|
||||
private List<InlineQueryResult> results; ///< A JSON-serialized array of results for the inline query
|
||||
public static final String CACHETIME_FIELD = "cache_time";
|
||||
private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server
|
||||
public static final String ISPERSONAL_FIELD = "is_personal";
|
||||
private Boolean isPersonal; ///< Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
|
||||
public static final String NEXTOFFSET_FIELD = "next_offset";
|
||||
private String inlineQueryId; ///< Unique identifier for answered query
|
||||
private List<InlineQueryResult> results; ///< A JSON-serialized array of results for the inline query
|
||||
private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server
|
||||
private Boolean isPersonal; ///< Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
|
||||
private String nextOffset; ///< Optional Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
|
||||
|
||||
public AnswerInlineQuery() {
|
||||
@ -135,4 +136,15 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AnswerInlineQuery{" +
|
||||
"inlineQueryId='" + inlineQueryId + '\'' +
|
||||
", results=" + results +
|
||||
", cacheTime=" + cacheTime +
|
||||
", isPersonal=" + isPersonal +
|
||||
", nextOffset='" + nextOffset + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.objects.Message;
|
||||
|
||||
@ -23,6 +24,14 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
private Integer fromChatId; ///< Unique identifier for the chat where the original message was sent — User or GroupChat id
|
||||
public static final String MESSAGEID_FIELD = "message_id";
|
||||
private Integer messageId; ///< Unique message identifier
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
|
||||
public ForwardMessage() {
|
||||
super();
|
||||
@ -52,6 +61,18 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
gen.writeStartObject();
|
||||
@ -59,6 +80,9 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
gen.writeStringField(CHATID_FIELD, chatId);
|
||||
gen.writeNumberField(FROMCHATID_FIELD, fromChatId);
|
||||
gen.writeNumberField(MESSAGEID_FIELD, messageId);
|
||||
if (disableNotification != null) {
|
||||
gen.writeBooleanField(DISABLENOTIFICATION_FIELD, disableNotification);
|
||||
}
|
||||
gen.writeEndObject();
|
||||
gen.flush();
|
||||
}
|
||||
@ -74,6 +98,9 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
jsonObject.put(CHATID_FIELD, chatId);
|
||||
jsonObject.put(FROMCHATID_FIELD, fromChatId);
|
||||
jsonObject.put(MESSAGEID_FIELD, messageId);
|
||||
if (disableNotification != null) {
|
||||
jsonObject.put(DISABLENOTIFICATION_FIELD, disableNotification);
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@ -89,4 +116,13 @@ public class ForwardMessage extends BotApiMethod<Message> {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForwardMessage{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", fromChatId=" + fromChatId +
|
||||
", messageId=" + messageId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.objects.File;
|
||||
|
||||
@ -21,7 +22,7 @@ import java.io.IOException;
|
||||
* @date 20 of June of 2015
|
||||
*/
|
||||
public class GetFile extends BotApiMethod<File> {
|
||||
public static final String PATH = "getfield";
|
||||
public static final String PATH = "getFile";
|
||||
|
||||
public static final String FILEID_FIELD = "file_id";
|
||||
private String fileId; ///< File identifier to get info about
|
||||
@ -71,4 +72,11 @@ public class GetFile extends BotApiMethod<File> {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetFile{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.objects.User;
|
||||
|
||||
@ -47,4 +48,6 @@ public class GetMe extends BotApiMethod<User> {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,13 @@ public class GetUpdates implements IToJson {
|
||||
|
||||
public static final String OFFSET_FIELD = "offset";
|
||||
/**
|
||||
* Optional Identifier of the first update to be returned.
|
||||
* Must be greater by one than the highest among the identifiers of previously received updates.
|
||||
* By default, updates starting with the earliest unconfirmed update are returned.
|
||||
* Optional. Identifier of the first update to be returned.
|
||||
* Must be greater by one than the highest among the identifiers
|
||||
* of previously received updates. By default, updates starting with the
|
||||
* earliest unconfirmed update are returned. An update is considered confirmed as soon as
|
||||
* getUpdates is called with an offset higher than its update_id. The negative offset can
|
||||
* be specified to retrieve updates starting from -offset update from the end of
|
||||
* the updates queue. All previous updates will forgotten.
|
||||
*/
|
||||
private Integer offset;
|
||||
public static final String LIMIT_FIELD = "limit";
|
||||
@ -74,4 +78,13 @@ public class GetUpdates implements IToJson {
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetUpdates{" +
|
||||
"offset=" + offset +
|
||||
", limit=" + limit +
|
||||
", timeout=" + timeout +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.objects.UserProfilePhotos;
|
||||
|
||||
@ -18,13 +19,13 @@ public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> {
|
||||
public static final String PATH = "getuserprofilephotos";
|
||||
|
||||
public static final String USERID_FIELD = "user_id";
|
||||
private Integer userId; ///< Unique identifier of the target user
|
||||
public static final String OFFSET_FIELD = "offset";
|
||||
public static final String LIMIT_FIELD = "limit";
|
||||
private Integer userId; ///< Unique identifier of the target user
|
||||
/**
|
||||
* Sequential number of the first photo to be returned. By default, all photos are returned.
|
||||
*/
|
||||
private Integer offset;
|
||||
public static final String LIMIT_FIELD = "limit";
|
||||
/**
|
||||
* Optional. Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
|
||||
*/
|
||||
@ -99,4 +100,13 @@ public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetUserProfilePhotos{" +
|
||||
"userId=" + userId +
|
||||
", offset=" + offset +
|
||||
", limit=" + limit +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -10,27 +10,34 @@ import org.telegram.telegrambots.api.objects.ReplyKeyboard;
|
||||
* 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 backward compatibility, when both fields title and description are empty and mime-type of the sent
|
||||
* file is not “audio/mpeg”, file is sent as playable voice message.
|
||||
* In this case, your audio must be in an .ogg file encoded with OPUS.
|
||||
* This will be removed in the future. You need to use sendVoice method instead.
|
||||
* @note For sending voice notes, use sendVoice method instead.
|
||||
*
|
||||
* @date 16 of July of 2015
|
||||
*/
|
||||
public class SendAudio {
|
||||
public static final String PATH = "sendaudio";
|
||||
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
public static final String CHATID_FIELD = "chat_id";
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
|
||||
public static final String AUDIO_FIELD = "audio";
|
||||
private String audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
public static final String PERFOMER_FIELD = "performer";
|
||||
private String performer; ///< Optional. Performer of sent audio
|
||||
public static final String TITLE_FIELD = "title";
|
||||
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
|
||||
private String audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||
private String performer; ///< Optional. Performer of sent audio
|
||||
private String title; ///< Optional. Title of sent audio
|
||||
private boolean isNewAudio;
|
||||
private String audioName;
|
||||
@ -39,6 +46,14 @@ public class SendAudio {
|
||||
super();
|
||||
}
|
||||
|
||||
public Integer getDuration(){
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
@ -51,11 +66,22 @@ public class SendAudio {
|
||||
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 void setAudio(String audio) {
|
||||
this.audio = audio;
|
||||
this.isNewAudio = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the audio to a new file
|
||||
* @param audio Path to the new file in your server
|
||||
* @param audioName Name of the file itself
|
||||
*/
|
||||
public void setNewAudio(String audio, String audioName) {
|
||||
this.audio = audio;
|
||||
this.isNewAudio = true;
|
||||
@ -94,6 +120,18 @@ public class SendAudio {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public boolean isNewAudio() {
|
||||
return isNewAudio;
|
||||
}
|
||||
@ -101,4 +139,18 @@ public class SendAudio {
|
||||
public String getAudioName() {
|
||||
return audioName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendAudio{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", audio='" + audio + '\'' +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
", performer='" + performer + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", isNewAudio=" + isNewAudio +
|
||||
", audioName='" + audioName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -20,8 +21,8 @@ public class SendChatAction extends BotApiMethod<Boolean>{
|
||||
public static final String PATH = "sendChatAction";
|
||||
|
||||
public static final String CHATID_FIELD = "chat_id";
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
public static final String ACTION_FIELD = "action";
|
||||
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:
|
||||
@ -83,4 +84,12 @@ public class SendChatAction extends BotApiMethod<Boolean>{
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendChatAction{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", action='" + action + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,16 @@ public class SendDocument {
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
|
||||
public static final String DOCUMENT_FIELD = "document";
|
||||
private String document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers
|
||||
public static final String CAPTION_FIELD = "caption";
|
||||
private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
@ -66,6 +76,26 @@ public class SendDocument {
|
||||
this.replayToMessageId = replayToMessageId;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public void setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplayMarkup() {
|
||||
return replayMarkup;
|
||||
}
|
||||
@ -73,4 +103,16 @@ public class SendDocument {
|
||||
public void setReplayMarkup(ReplyKeyboard replayMarkup) {
|
||||
this.replayMarkup = replayMarkup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendDocument{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", document='" + document + '\'' +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
", isNewDocument=" + isNewDocument +
|
||||
", documentName='" + documentName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.objects.Message;
|
||||
import org.telegram.telegrambots.api.objects.ReplyKeyboard;
|
||||
@ -24,6 +25,14 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
private Float latitude; ///< Latitude of location
|
||||
public static final String LONGITUDE_FIELD = "longitude";
|
||||
private Float longitude; ///< Longitude of location
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
@ -69,6 +78,18 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
this.replayMarkup = replayMarkup;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return PATH;
|
||||
@ -88,6 +109,9 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
jsonObject.put(CHATID_FIELD, chatId);
|
||||
jsonObject.put(LATITUDE_FIELD, latitude);
|
||||
jsonObject.put(LONGITUDE_FIELD, longitude);
|
||||
if (disableNotification != null) {
|
||||
jsonObject.put(DISABLENOTIFICATION_FIELD, disableNotification);
|
||||
}
|
||||
if (replayToMessageId != null) {
|
||||
jsonObject.put(REPLYTOMESSAGEID_FIELD, replayToMessageId);
|
||||
}
|
||||
@ -105,6 +129,9 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
gen.writeStringField(CHATID_FIELD, chatId);
|
||||
gen.writeNumberField(LATITUDE_FIELD, latitude);
|
||||
gen.writeNumberField(LONGITUDE_FIELD, longitude);
|
||||
if (disableNotification != null) {
|
||||
gen.writeBooleanField(DISABLENOTIFICATION_FIELD, disableNotification);
|
||||
}
|
||||
if (replayToMessageId != null) {
|
||||
gen.writeNumberField(REPLYTOMESSAGEID_FIELD, replayToMessageId);
|
||||
}
|
||||
@ -120,4 +147,15 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendLocation{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.api.methods;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.objects.Message;
|
||||
import org.telegram.telegrambots.api.objects.ReplyKeyboard;
|
||||
@ -26,6 +27,14 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and URL text in your bot's message.
|
||||
public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
|
||||
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in this message
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
@ -75,6 +84,18 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
this.disableWebPagePreview = disableWebPagePreview;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public void enableMarkdown(boolean enable) {
|
||||
if (enable) {
|
||||
this.parseMode = "Markdown";
|
||||
@ -102,6 +123,9 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
if (disableWebPagePreview != null) {
|
||||
jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, disableWebPagePreview);
|
||||
}
|
||||
if (disableNotification != null) {
|
||||
jsonObject.put(DISABLENOTIFICATION_FIELD, disableNotification);
|
||||
}
|
||||
if (replayToMessageId != null) {
|
||||
jsonObject.put(REPLYTOMESSAGEID_FIELD, replayToMessageId);
|
||||
}
|
||||
@ -138,6 +162,9 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
if (disableWebPagePreview != null) {
|
||||
gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, disableWebPagePreview);
|
||||
}
|
||||
if (disableNotification != null) {
|
||||
gen.writeBooleanField(DISABLENOTIFICATION_FIELD, disableNotification);
|
||||
}
|
||||
if (replayToMessageId != null) {
|
||||
gen.writeNumberField(REPLYTOMESSAGEID_FIELD, replayToMessageId);
|
||||
}
|
||||
@ -153,4 +180,16 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendMessage{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", text='" + text + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,14 @@ public class SendPhoto {
|
||||
private String photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers
|
||||
public static final String CAPTION_FIELD = "photo";
|
||||
private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
@ -74,6 +82,18 @@ public class SendPhoto {
|
||||
return photoName;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public void setPhoto(String photo) {
|
||||
this.photo = photo;
|
||||
this.isNewPhoto = false;
|
||||
@ -84,4 +104,17 @@ public class SendPhoto {
|
||||
this.isNewPhoto = true;
|
||||
this.photoName = photoName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendPhoto{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", photo='" + photo + '\'' +
|
||||
", caption='" + caption + '\'' +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
", isNewPhoto=" + isNewPhoto +
|
||||
", photoName='" + photoName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,14 @@ public class SendSticker {
|
||||
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
||||
public static final String STICKER_FIELD = "sticker";
|
||||
private String sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
@ -66,6 +74,18 @@ public class SendSticker {
|
||||
this.stickerName = stickerName;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public boolean isNewSticker() {
|
||||
return isNewSticker;
|
||||
}
|
||||
@ -73,4 +93,16 @@ public class SendSticker {
|
||||
public String getStickerName() {
|
||||
return stickerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendSticker{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", sticker='" + sticker + '\'' +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
", isNewSticker=" + isNewSticker +
|
||||
", stickerName='" + stickerName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,18 @@ public class SendVideo {
|
||||
private Integer duration; ///< Optional. Duration of sent video in seconds
|
||||
public static final String CAPTION_FIELD = "caption";
|
||||
private String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
|
||||
public static final String WIDTH_FIELD = "width";
|
||||
private Integer width; ///< Optional. Video width
|
||||
public static final String HEIGHT_FIELD = "height";
|
||||
private Integer height; ///< OptionaL. Video height
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
@ -85,6 +97,34 @@ public class SendVideo {
|
||||
return videoName;
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public Integer getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(Integer width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public Integer getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(Integer height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void setVideo(String video) {
|
||||
this.video = video;
|
||||
this.isNewVideo = false;
|
||||
@ -95,4 +135,18 @@ public class SendVideo {
|
||||
this.isNewVideo = true;
|
||||
this.videoName = videoName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendVideo{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", video='" + video + '\'' +
|
||||
", duration=" + duration +
|
||||
", caption='" + caption + '\'' +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
", isNewVideo=" + isNewVideo +
|
||||
", videoName='" + videoName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,15 @@ public class SendVoice {
|
||||
public static final String CHATID_FIELD = "chat_id";
|
||||
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
|
||||
public static final String AUDIO_FIELD = "audio";
|
||||
private String audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers
|
||||
private String audio; ///< 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.
|
||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||
/**
|
||||
* Optional. Sends the message silently.
|
||||
* iOS users will not receive a notification,
|
||||
* Android users will receive a notification with no sound.
|
||||
* Other apps coming soon
|
||||
*/
|
||||
private Boolean disableNotification;
|
||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
||||
@ -25,7 +33,88 @@ public class SendVoice {
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
private Integer duration; ///< Optional. Duration of sent audio in seconds
|
||||
|
||||
private boolean isNewVoice; ///< True to upload a new voice note, false to use a fileId
|
||||
private String voiceName; ///< Name of the voice note
|
||||
|
||||
public SendVoice() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SendVoice{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", audio='" + audio + '\'' +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
", duration=" + duration +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Boolean getDisableNotification() {
|
||||
return disableNotification;
|
||||
}
|
||||
|
||||
public void enableNotification() {
|
||||
this.disableNotification = false;
|
||||
}
|
||||
|
||||
public void disableNotification() {
|
||||
this.disableNotification = true;
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public void setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
}
|
||||
|
||||
public String getAudio() {
|
||||
return audio;
|
||||
}
|
||||
|
||||
public void setAudio(String audio) {
|
||||
this.audio = audio;
|
||||
this.isNewVoice = false;
|
||||
}
|
||||
|
||||
public void setNewAudio(String audio, String audioName) {
|
||||
this.audio = audio;
|
||||
this.isNewVoice = false;
|
||||
this.voiceName = audioName;
|
||||
}
|
||||
|
||||
public Integer getReplayToMessageId() {
|
||||
return replayToMessageId;
|
||||
}
|
||||
|
||||
public void setReplayToMessageId(Integer replayToMessageId) {
|
||||
this.replayToMessageId = replayToMessageId;
|
||||
}
|
||||
|
||||
public ReplyKeyboard getReplayMarkup() {
|
||||
return replayMarkup;
|
||||
}
|
||||
|
||||
public void setReplayMarkup(ReplyKeyboard replayMarkup) {
|
||||
this.replayMarkup = replayMarkup;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public boolean isNewVoice() {
|
||||
return isNewVoice;
|
||||
}
|
||||
|
||||
public String getVoiceName() {
|
||||
return voiceName;
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,12 @@ public class SetWebhook {
|
||||
public void setCertificateFile(String certificateFile) {
|
||||
this.certificateFile = certificateFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetWebhook{" +
|
||||
"url='" + url + '\'' +
|
||||
", certificateFile='" + certificateFile + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,21 +19,21 @@ import java.io.IOException;
|
||||
public class Audio implements IBotApiObject {
|
||||
|
||||
public static final String FILEID_FIELD = "file_id";
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
public static final String TITLE_FIELD = "title";
|
||||
public static final String PERFORMER_FIELD = "performer";
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
private String fileId; ///< Unique identifier for this file
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
@JsonProperty(DURATION_FIELD)
|
||||
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
@JsonProperty(MIMETYPE_FIELD)
|
||||
private String mimeType; ///< Optional. MIME type of the file as defined by sender
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILESIZE_FIELD)
|
||||
private Integer fileSize; ///< Optional. File size
|
||||
public static final String TITLE_FIELD = "title";
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
private String title; ///< Optional. Title of the audio as defined by sender or by audio tags
|
||||
public static final String PERFORMER_FIELD = "performer";
|
||||
@JsonProperty(PERFORMER_FIELD)
|
||||
private String performer; ///< Optional. Performer of the audio as defined by sender or by audio tags
|
||||
|
||||
@ -131,4 +132,16 @@ public class Audio implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Audio{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", duration=" + duration +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", fileSize=" + fileSize +
|
||||
", title='" + title + '\'' +
|
||||
", performer='" + performer + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -16,27 +17,26 @@ import java.io.IOException;
|
||||
* @date 24 of June of 2015
|
||||
*/
|
||||
public class Chat implements IBotApiObject {
|
||||
public static final String ID_FIELD = "id";
|
||||
public static final String TYPE_FIELD = "type";
|
||||
public static final String TITLE_FIELD = "title";
|
||||
public static final String FIRSTNAME_FIELD = "first_name";
|
||||
public static final String LASTNAME_FIELD = "last_name";
|
||||
public static final String USERNAME_FIELD = "username";
|
||||
private static final String USERCHATTYPE = "private";
|
||||
private static final String GROUPCHATTYPE = "group";
|
||||
private static final String CHANNELCHATTYPE = "channel";
|
||||
private static final String SUPERGROUPCHATTYPE = "supergroup";
|
||||
|
||||
public static final String ID_FIELD = "id";
|
||||
@JsonProperty(ID_FIELD)
|
||||
private Long id; ///< Unique identifier for this chat, not exciding 1e13 by absolute value
|
||||
public static final String TYPE_FIELD = "type";
|
||||
@JsonProperty(TYPE_FIELD)
|
||||
private String type; ///< Type of the chat, one of “private”, “group” or “channel”
|
||||
public static final String TITLE_FIELD = "title";
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
private String title; ///< Optional. Title of the chat, only for channels and group chat
|
||||
public static final String FIRSTNAME_FIELD = "first_name";
|
||||
@JsonProperty(FIRSTNAME_FIELD)
|
||||
private String firstName; ///< Optional. Username of the chat, only for private chats and channels if available
|
||||
public static final String LASTNAME_FIELD = "last_name";
|
||||
@JsonProperty(LASTNAME_FIELD)
|
||||
private String lastName; ///< Optional. Interlocutor's first name for private chats
|
||||
public static final String USERNAME_FIELD = "username";
|
||||
@JsonProperty(USERNAME_FIELD)
|
||||
private String userName; ///< Optional. Interlocutor's last name for private chats
|
||||
|
||||
@ -126,4 +126,16 @@ public class Chat implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Chat{" +
|
||||
"id=" + id +
|
||||
", type='" + type + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", userName='" + userName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -16,13 +17,14 @@ import java.io.IOException;
|
||||
* @date 01 of January of 2016
|
||||
*/
|
||||
public class ChosenInlineQuery implements IBotApiObject {
|
||||
public static final String RESULTID_FIELD = "id";
|
||||
public static final String RESULTID_FIELD = "result_id";
|
||||
public static final String FROM_FIELD = "from";
|
||||
public static final String QUERY_FIELD = "query";
|
||||
|
||||
@JsonProperty(RESULTID_FIELD)
|
||||
private String resultId; ///< The unique identifier for the result that was chosen.
|
||||
public static final String FROM_FIELD = "from";
|
||||
@JsonProperty(FROM_FIELD)
|
||||
private User from; ///< The user that chose the result.
|
||||
public static final String QUERY_FIELD = "query";
|
||||
@JsonProperty(QUERY_FIELD)
|
||||
private String query; ///< The query that was used to obtain the result.
|
||||
|
||||
@ -63,4 +65,13 @@ public class ChosenInlineQuery implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChosenInlineQuery{" +
|
||||
"resultId='" + resultId + '\'' +
|
||||
", from=" + from +
|
||||
", query='" + query + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,15 +19,15 @@ import java.io.IOException;
|
||||
public class Contact implements IBotApiObject {
|
||||
|
||||
public static final String PHONENUMBER_FIELD = "phone_number";
|
||||
public static final String FIRSTNAME_FIELD = "first_name";
|
||||
public static final String LASTNAME_FIELD = "last_name";
|
||||
public static final String USERID_FIELD = "user_id";
|
||||
@JsonProperty(PHONENUMBER_FIELD)
|
||||
private String phoneNumber; ///< Contact's phone number
|
||||
public static final String FIRSTNAME_FIELD = "first_name";
|
||||
@JsonProperty(FIRSTNAME_FIELD)
|
||||
private String firstName; ///< Contact's first name
|
||||
public static final String LASTNAME_FIELD = "last_name";
|
||||
@JsonProperty(LASTNAME_FIELD)
|
||||
private String lastName; ///< Optional. Contact's last name
|
||||
public static final String USERID_FIELD = "user_id";
|
||||
@JsonProperty(USERID_FIELD)
|
||||
private Integer userID; ///< Optional. Contact's user identifier in Telegram
|
||||
|
||||
@ -65,4 +66,14 @@ public class Contact implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Contact{" +
|
||||
"phoneNumber='" + phoneNumber + '\'' +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", userID=" + userID +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -19,18 +20,18 @@ import java.io.IOException;
|
||||
public class Document implements IBotApiObject {
|
||||
|
||||
public static final String FILEID_FIELD = "file_id";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String FILENAME_FIELD = "file_name";
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
private String fileId; ///< Unique identifier for this file
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
@JsonProperty(THUMB_FIELD)
|
||||
private PhotoSize thumb; ///< Document thumbnail as defined by sender
|
||||
public static final String FILENAME_FIELD = "file_name";
|
||||
@JsonProperty(FILENAME_FIELD)
|
||||
private String fileName; ///< Optional. Original filename as defined by sender
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
@JsonProperty(MIMETYPE_FIELD)
|
||||
private String mimeType; ///< Optional. Mime type of a file as defined by sender
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILESIZE_FIELD)
|
||||
private Integer fileSize; ///< Optional. File size
|
||||
|
||||
@ -116,4 +117,15 @@ public class Document implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Document{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", thumb=" + thumb +
|
||||
", fileName='" + fileName + '\'' +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", fileSize=" + fileSize +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -17,12 +18,12 @@ import java.io.IOException;
|
||||
*/
|
||||
public class File implements IBotApiObject {
|
||||
public static final String FILE_ID = "file_id";
|
||||
public static final String FILE_SIZE_FIELD = "file_size";
|
||||
public static final String FILE_PATH_FIELD = "file_path";
|
||||
@JsonProperty(FILE_ID)
|
||||
private String fileId; ///< Unique identifier for this file
|
||||
public static final String FILE_SIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILE_SIZE_FIELD)
|
||||
private Integer fileSize; ///< Optional. File size, if known
|
||||
public static final String FILE_PATH_FIELD = "first_name";
|
||||
@JsonProperty(FILE_PATH_FIELD)
|
||||
private String filePath; ///< Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
|
||||
|
||||
@ -83,4 +84,13 @@ public class File implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "File{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", fileSize=" + fileSize +
|
||||
", filePath='" + filePath + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -20,12 +21,12 @@ import java.io.IOException;
|
||||
public class ForceReplyKeyboard implements ReplyKeyboard {
|
||||
|
||||
public static final String FORCEREPLY_FIELD = "force_reply";
|
||||
public static final String SELECTIVE_FIELD = "selective";
|
||||
/**
|
||||
* Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'
|
||||
*/
|
||||
@JsonProperty(FORCEREPLY_FIELD)
|
||||
private Boolean forceReply;
|
||||
public static final String SELECTIVE_FIELD = "selective";
|
||||
/**
|
||||
* Use this parameter if you want to force reply from specific users only.
|
||||
* Targets:
|
||||
@ -91,4 +92,12 @@ public class ForceReplyKeyboard implements ReplyKeyboard {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForceReplyKeyboard{" +
|
||||
"forceReply=" + forceReply +
|
||||
", selective=" + selective +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,15 +19,15 @@ import java.io.IOException;
|
||||
*/
|
||||
public class InlineQuery implements IBotApiObject {
|
||||
public static final String ID_FIELD = "id";
|
||||
public static final String FROM_FIELD = "from";
|
||||
public static final String QUERY_FIELD = "query";
|
||||
public static final String OFFSET_FIELD = "offset";
|
||||
@JsonProperty(ID_FIELD)
|
||||
private String id; ///< Unique identifier for this query
|
||||
public static final String FROM_FIELD = "from";
|
||||
@JsonProperty(FROM_FIELD)
|
||||
private User from; ///< Sender
|
||||
public static final String QUERY_FIELD = "query";
|
||||
@JsonProperty(QUERY_FIELD)
|
||||
private String query; ///< Text of the query
|
||||
public static final String OFFSET_FIELD = "offset";
|
||||
@JsonProperty(OFFSET_FIELD)
|
||||
private String offset; ///< Offset of the results to be returned, can be controlled by the bot
|
||||
|
||||
@ -73,4 +74,15 @@ public class InlineQuery implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InlineQuery{" +
|
||||
"id='" + id + '\'' +
|
||||
", from=" + from +
|
||||
", query='" + query + '\'' +
|
||||
", offset='" + offset + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -27,7 +28,7 @@ public class InlineQueryResultArticle implements InlineQueryResult {
|
||||
private String title; ///< Title of the result
|
||||
public static final String MESSAGETEXT_FIELD = "message_text";
|
||||
@JsonProperty(MESSAGETEXT_FIELD)
|
||||
private String messageText; ///< Text of a message to be sent
|
||||
private String messageText; ///< Text of a message to be sent, 1-4096 characters
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
|
||||
@ -238,4 +239,22 @@ public class InlineQueryResultArticle implements InlineQueryResult {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InlineQueryResultArticle{" +
|
||||
"type='" + type + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", messageText='" + messageText + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
", url='" + url + '\'' +
|
||||
", hideUrl=" + hideUrl +
|
||||
", description='" + description + '\'' +
|
||||
", thumbUrl='" + thumbUrl + '\'' +
|
||||
", thumbWidth=" + thumbWidth +
|
||||
", thumbHeight=" + thumbHeight +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -43,7 +44,7 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
||||
private String caption; ///< Optional. Caption of the GIF file to be sent
|
||||
public static final String MESSAGETEXT_FIELD = "message_text";
|
||||
@JsonProperty(MESSAGETEXT_FIELD)
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the animation
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the animation, 1-4096 characters
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
|
||||
@ -222,4 +223,21 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InlineQueryResultGif{" +
|
||||
"type='" + type + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", gifUrl='" + gifUrl + '\'' +
|
||||
", gifWidth=" + gifWidth +
|
||||
", gifHeight=" + gifHeight +
|
||||
", thumbUrl='" + thumbUrl + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", caption='" + caption + '\'' +
|
||||
", messageText='" + messageText + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -44,7 +45,7 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
|
||||
private String caption; ///< Optional. Caption of the MPEG-4 file to be sent
|
||||
public static final String MESSAGETEXT_FIELD = "message_text";
|
||||
@JsonProperty(MESSAGETEXT_FIELD)
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the animation
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the animation, 1-4096 characters
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
|
||||
@ -223,4 +224,21 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InlineQueryResultMpeg4Gif{" +
|
||||
"type='" + type + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", mpeg4Url='" + mpeg4Url + '\'' +
|
||||
", mpeg4Width=" + mpeg4Width +
|
||||
", mpeg4Height=" + mpeg4Height +
|
||||
", thumbUrl='" + thumbUrl + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", caption='" + caption + '\'' +
|
||||
", messageText='" + messageText + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -49,7 +50,7 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
|
||||
private String caption; ///< Optional. Caption of the photo to be sent
|
||||
public static final String MESSAGETEXT_FIELD = "message_text";
|
||||
@JsonProperty(MESSAGETEXT_FIELD)
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the photo
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the photo, 1-4096 characters
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
|
||||
@ -258,4 +259,23 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InlineQueryResultPhoto{" +
|
||||
"type='" + type + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", photoUrl='" + photoUrl + '\'' +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", photoWidth=" + photoWidth +
|
||||
", photoHeight=" + photoHeight +
|
||||
", thumbUrl='" + thumbUrl + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", caption='" + caption + '\'' +
|
||||
", messageText='" + messageText + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -48,7 +49,7 @@ public class InlineQueryResultVideo implements InlineQueryResult {
|
||||
private String description; ///< Optional. Short description of the result
|
||||
public static final String MESSAGETEXT_FIELD = "message_text";
|
||||
@JsonProperty(MESSAGETEXT_FIELD)
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the video
|
||||
private String messageText; ///< Optional. Text of a message to be sent instead of the video, 1-4096 characters
|
||||
public static final String PARSEMODE_FIELD = "parse_mode";
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
|
||||
@ -254,4 +255,23 @@ public class InlineQueryResultVideo implements InlineQueryResult {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InlineQueryResultVideo{" +
|
||||
"type='" + type + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", videoUrl='" + videoUrl + '\'' +
|
||||
", videoWidth=" + videoWidth +
|
||||
", videoHeight=" + videoHeight +
|
||||
", videoDuration=" + videoDuration +
|
||||
", thumbUrl='" + thumbUrl + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", messageText='" + messageText + '\'' +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
", disableWebPagePreview=" + disableWebPagePreview +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,9 +19,9 @@ import java.io.IOException;
|
||||
public class Location implements IBotApiObject {
|
||||
|
||||
public static final String LONGITUDE_FIELD = "longitude";
|
||||
public static final String LATITUDE_FIELD = "latitude";
|
||||
@JsonProperty(LONGITUDE_FIELD)
|
||||
private Double longitude; ///< Longitude as defined by sender
|
||||
public static final String LATITUDE_FIELD = "latitude";
|
||||
@JsonProperty(LATITUDE_FIELD)
|
||||
private Double latitude; ///< Latitude as defined by sender
|
||||
|
||||
@ -63,4 +64,12 @@ public class Location implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Location{" +
|
||||
"longitude=" + longitude +
|
||||
", latitude=" + latitude +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
@ -20,81 +21,81 @@ import java.util.List;
|
||||
*/
|
||||
public class Message implements IBotApiObject {
|
||||
public static final String MESSAGEID_FIELD = "message_id";
|
||||
public static final String FROM_FIELD = "from";
|
||||
public static final String DATE_FIELD = "date";
|
||||
public static final String CHAT_FIELD = "chat";
|
||||
public static final String FORWARDFROM_FIELD = "forward_from";
|
||||
public static final String FORWARDDATE_FIELD = "forward_date";
|
||||
public static final String TEXT_FIELD = "text";
|
||||
public static final String AUDIO_FIELD = "audio";
|
||||
public static final String DOCUMENT_FIELD = "document";
|
||||
public static final String PHOTO_FIELD = "photo";
|
||||
public static final String STICKER_FIELD = "sticker";
|
||||
public static final String VIDEO_FIELD = "video";
|
||||
public static final String CONTACT_FIELD = "contact";
|
||||
public static final String LOCATION_FIELD = "location";
|
||||
public static final String NEWCHATPARTICIPANT_FIELD = "new_chat_participant";
|
||||
public static final String LEFTCHATPARTICIPANT_FIELD = "left_chat_participant";
|
||||
public static final String NEWCHATTITLE_FIELD = "new_chat_title";
|
||||
public static final String NEWCHATPHOTO_FIELD = "new_chat_photo";
|
||||
public static final String DELETECHATPHOTO_FIELD = "delete_chat_photo";
|
||||
public static final String GROUPCHATCREATED_FIELD = "group_chat_created";
|
||||
public static final String REPLYTOMESSAGE_FIELD = "reply_to_message";
|
||||
public static final String VOICE_FIELD = "voice";
|
||||
public static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created";
|
||||
public static final String CHANNELCHATCREATED_FIELD = "channel_chat_created";
|
||||
public static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id";
|
||||
public static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id";
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
private Integer messageId; ///< Integer Unique message identifier
|
||||
public static final String FROM_FIELD = "from";
|
||||
@JsonProperty(FROM_FIELD)
|
||||
private User from; ///< Optional. Sender, can be empty for messages sent to channels
|
||||
public static final String DATE_FIELD = "date";
|
||||
@JsonProperty(DATE_FIELD)
|
||||
private Integer date; ///< Date the message was sent in Unix time
|
||||
public static final String CHAT_FIELD = "chat";
|
||||
@JsonProperty(CHAT_FIELD)
|
||||
private Chat chat; ///< Conversation the message belongs to
|
||||
public static final String FORWARDFROM_FIELD = "forward_from";
|
||||
@JsonProperty(FORWARDFROM_FIELD)
|
||||
private User forwardFrom; ///< Optional. For forwarded messages, sender of the original message
|
||||
public static final String FORWARDDATE_FIELD = "forward_date";
|
||||
@JsonProperty(FORWARDDATE_FIELD)
|
||||
private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent
|
||||
public static final String TEXT_FIELD = "text";
|
||||
@JsonProperty(TEXT_FIELD)
|
||||
private String text; ///< Optional. For text messages, the actual UTF-8 text of the message
|
||||
public static final String AUDIO_FIELD = "audio";
|
||||
@JsonProperty(AUDIO_FIELD)
|
||||
private Audio audio; ///< Optional. Message is an audio file, information about the file
|
||||
public static final String DOCUMENT_FIELD = "document";
|
||||
@JsonProperty(DOCUMENT_FIELD)
|
||||
private Document document; ///< Optional. Message is a general file, information about the file
|
||||
public static final String PHOTO_FIELD = "photo";
|
||||
@JsonProperty(PHOTO_FIELD)
|
||||
private List<PhotoSize> photo; ///< Optional. Message is a photo, available sizes of the photo
|
||||
public static final String STICKER_FIELD = "sticker";
|
||||
@JsonProperty(STICKER_FIELD)
|
||||
private Sticker sticker; ///< Optional. Message is a sticker, information about the sticker
|
||||
public static final String VIDEO_FIELD = "video";
|
||||
@JsonProperty(VIDEO_FIELD)
|
||||
private Video video; ///< Optional. Message is a video, information about the video
|
||||
public static final String CONTACT_FIELD = "contact";
|
||||
@JsonProperty(CONTACT_FIELD)
|
||||
private Contact contact; ///< Optional. Message is a shared contact, information about the contact
|
||||
public static final String LOCATION_FIELD = "location";
|
||||
@JsonProperty(LOCATION_FIELD)
|
||||
private Location location; ///< Optional. Message is a shared location, information about the location
|
||||
public static final String NEWCHATPARTICIPANT_FIELD = "new_chat_participant";
|
||||
@JsonProperty(NEWCHATPARTICIPANT_FIELD)
|
||||
private User newChatParticipant; ///< Optional. A new member was added to the group, information about them (this member may be bot itself)
|
||||
public static final String LEFTCHATPARTICIPANT_FIELD = "left_chat_participant";
|
||||
@JsonProperty(LEFTCHATPARTICIPANT_FIELD)
|
||||
private User leftChatParticipant; ///< Optional. A member was removed from the group, information about them (this member may be bot itself)
|
||||
public static final String NEWCHATTITLE_FIELD = "new_chat_title";
|
||||
@JsonProperty(NEWCHATTITLE_FIELD)
|
||||
private String newChatTitle; ///< Optional. A chat title was changed to this value
|
||||
public static final String NEWCHATPHOTO_FIELD = "new_chat_photo";
|
||||
@JsonProperty(NEWCHATPHOTO_FIELD)
|
||||
private List<PhotoSize> newChatPhoto; ///< Optional. A chat photo was change to this value
|
||||
public static final String DELETECHATPHOTO_FIELD = "delete_chat_photo";
|
||||
@JsonProperty(DELETECHATPHOTO_FIELD)
|
||||
private Boolean deleteChatPhoto; ///< Optional. Informs that the chat photo was deleted
|
||||
public static final String GROUPCHATCREATED_FIELD = "group_chat_created";
|
||||
@JsonProperty(GROUPCHATCREATED_FIELD)
|
||||
private Boolean groupchatCreated; ///< Optional. Informs that the group has been created
|
||||
public static final String REPLYTOMESSAGE_FIELD = "reply_to_message";
|
||||
@JsonProperty(REPLYTOMESSAGE_FIELD)
|
||||
private Message replyToMessage;
|
||||
public static final String VOICE_FIELD = "voice";
|
||||
@JsonProperty(VOICE_FIELD)
|
||||
private Voice voice; ///< Optional. Message is a voice message, information about the file
|
||||
public static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created";
|
||||
@JsonProperty(SUPERGROUPCREATED_FIELD)
|
||||
private Boolean superGroupCreated; ///< Optional. Informs that the supergroup has been created
|
||||
public static final String CHANNELCHATCREATED_FIELD = "channel_chat_created";
|
||||
@JsonProperty(CHANNELCHATCREATED_FIELD)
|
||||
private Boolean channelChatCreated; ///< Optional. Informs that the channel has been created
|
||||
public static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id";
|
||||
@JsonProperty(MIGRATETOCHAT_FIELD)
|
||||
private Long migrateToChatId; ///< Optional. The chat has been migrated to a chat with specified identifier, not exceeding 1e13 by absolute value
|
||||
public static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id";
|
||||
@JsonProperty(MIGRATEFROMCHAT_FIELD)
|
||||
private Long migrateFromChatId; ///< Optional. The chat has been migrated from a chat with specified identifier, not exceeding 1e13 by absolute value
|
||||
|
||||
@ -525,4 +526,36 @@ public class Message implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message{" +
|
||||
"messageId=" + messageId +
|
||||
", from=" + from +
|
||||
", date=" + date +
|
||||
", chat=" + chat +
|
||||
", forwardFrom=" + forwardFrom +
|
||||
", forwardDate=" + forwardDate +
|
||||
", text='" + text + '\'' +
|
||||
", audio=" + audio +
|
||||
", document=" + document +
|
||||
", photo=" + photo +
|
||||
", sticker=" + sticker +
|
||||
", video=" + video +
|
||||
", contact=" + contact +
|
||||
", location=" + location +
|
||||
", newChatParticipant=" + newChatParticipant +
|
||||
", leftChatParticipant=" + leftChatParticipant +
|
||||
", newChatTitle='" + newChatTitle + '\'' +
|
||||
", newChatPhoto=" + newChatPhoto +
|
||||
", deleteChatPhoto=" + deleteChatPhoto +
|
||||
", groupchatCreated=" + groupchatCreated +
|
||||
", replyToMessage=" + replyToMessage +
|
||||
", voice=" + voice +
|
||||
", superGroupCreated=" + superGroupCreated +
|
||||
", channelChatCreated=" + channelChatCreated +
|
||||
", migrateToChatId=" + migrateToChatId +
|
||||
", migrateFromChatId=" + migrateFromChatId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -29,6 +30,9 @@ public class PhotoSize implements IBotApiObject {
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILESIZE_FIELD)
|
||||
private Integer fileSize; ///< Optional. File size
|
||||
private static final String FILEPATH_FIELD = "file_path";
|
||||
@JsonProperty(FILEPATH_FIELD)
|
||||
private String filePath; ///< Undocumented field. Optional. Can contain the path to download the file direclty without calling to getFile
|
||||
|
||||
public PhotoSize() {
|
||||
super();
|
||||
@ -42,6 +46,9 @@ public class PhotoSize implements IBotApiObject {
|
||||
if (jsonObject.has(FILESIZE_FIELD)) {
|
||||
this.fileSize = jsonObject.getInt(FILESIZE_FIELD);
|
||||
}
|
||||
if (jsonObject.has(FILEPATH_FIELD)) {
|
||||
this.filePath = jsonObject.getString(FILEPATH_FIELD);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
@ -76,6 +83,14 @@ public class PhotoSize implements IBotApiObject {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
gen.writeStartObject();
|
||||
@ -85,6 +100,9 @@ public class PhotoSize implements IBotApiObject {
|
||||
if (fileSize != null) {
|
||||
gen.writeNumberField(FILESIZE_FIELD, fileSize);
|
||||
}
|
||||
if (filePath != null) {
|
||||
gen.writeStringField(FILEPATH_FIELD, filePath);
|
||||
}
|
||||
gen.writeEndObject();
|
||||
gen.flush();
|
||||
}
|
||||
@ -93,4 +111,14 @@ public class PhotoSize implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PhotoSize{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", width=" + width +
|
||||
", height=" + height +
|
||||
", fileSize=" + fileSize +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -21,9 +22,9 @@ import java.io.IOException;
|
||||
public class ReplyKeyboardHide implements ReplyKeyboard {
|
||||
|
||||
public static final String HIDEKEYBOARD_FIELD = "hide_keyboard";
|
||||
public static final String SELECTIVE_FIELD = "selective";
|
||||
@JsonProperty(HIDEKEYBOARD_FIELD)
|
||||
private Boolean hideKeyboard; ///< Requests clients to hide the custom keyboard
|
||||
public static final String SELECTIVE_FIELD = "selective";
|
||||
/**
|
||||
* Optional. Use this parameter if you want to show the keyboard to specific users only.
|
||||
* Targets:
|
||||
@ -85,4 +86,12 @@ public class ReplyKeyboardHide implements ReplyKeyboard {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplyKeyboardHide{" +
|
||||
"hideKeyboard=" + hideKeyboard +
|
||||
", selective=" + selective +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -20,15 +21,15 @@ import java.util.List;
|
||||
public class ReplyKeyboardMarkup implements ReplyKeyboard {
|
||||
|
||||
public static final String KEYBOARD_FIELD = "keyboard";
|
||||
public static final String RESIZEKEYBOARD_FIELD = "resize_keyboard";
|
||||
public static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard";
|
||||
public static final String SELECTIVE_FIELD = "selective";
|
||||
@JsonProperty(KEYBOARD_FIELD)
|
||||
private List<List<String>> keyboard; ///< Array of button rows, each represented by an Array of Strings
|
||||
public static final String RESIZEKEYBOARD_FIELD = "resize_keyboard";
|
||||
@JsonProperty(RESIZEKEYBOARD_FIELD)
|
||||
private Boolean resizeKeyboard; ///< Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false.
|
||||
public static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard";
|
||||
@JsonProperty(ONETIMEKEYBOARD_FIELD)
|
||||
private Boolean oneTimeKeyboad; ///< Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
|
||||
public static final String SELECTIVE_FIELD = "selective";
|
||||
/**
|
||||
* Optional. Use this parameter if you want to show the keyboard to specific users only.
|
||||
* Targets:
|
||||
@ -153,4 +154,14 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplyKeyboardMarkup{" +
|
||||
"keyboard=" + keyboard +
|
||||
", resizeKeyboard=" + resizeKeyboard +
|
||||
", oneTimeKeyboad=" + oneTimeKeyboad +
|
||||
", selective=" + selective +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,18 +19,18 @@ import java.io.IOException;
|
||||
public class Sticker implements IBotApiObject {
|
||||
|
||||
public static final String FILEID_FIELD = "file_id";
|
||||
public static final String WIDTH_FIELD = "width";
|
||||
public static final String HEIGHT_FIELD = "height";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
private String fileId; ///< Unique identifier for this file
|
||||
public static final String WIDTH_FIELD = "width";
|
||||
@JsonProperty(WIDTH_FIELD)
|
||||
private Integer width; ///< Sticker width
|
||||
public static final String HEIGHT_FIELD = "height";
|
||||
@JsonProperty(HEIGHT_FIELD)
|
||||
private Integer height; ///< Sticker height
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
@JsonProperty(THUMB_FIELD)
|
||||
private PhotoSize thumb; ///< Optional. Sticker thumbnail in .webp or .jpg format
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILESIZE_FIELD)
|
||||
private Integer fileSize; ///< Optional. File size
|
||||
|
||||
@ -70,4 +71,15 @@ public class Sticker implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Sticker{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", width=" + width +
|
||||
", height=" + height +
|
||||
", thumb=" + thumb +
|
||||
", fileSize=" + fileSize +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,15 +19,15 @@ import java.io.IOException;
|
||||
*/
|
||||
public class Update implements IBotApiObject {
|
||||
public static final String UPDATEID_FIELD = "update_id";
|
||||
public static final String MESSAGE_FIELD = "message";
|
||||
public static final String INLINEQUERY_FIELD = "inline_query";
|
||||
public static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result";
|
||||
@JsonProperty(UPDATEID_FIELD)
|
||||
private Integer updateId;
|
||||
public static final String MESSAGE_FIELD = "message";
|
||||
@JsonProperty(MESSAGE_FIELD)
|
||||
private Message message; ///< Optional. New incoming message of any kind — text, photo, sticker, etc.
|
||||
public static final String INLINEQUERY_FIELD = "inline_query";
|
||||
@JsonProperty(INLINEQUERY_FIELD)
|
||||
private InlineQuery inlineQuery; ///< Optional. New incoming inline query
|
||||
public static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result";
|
||||
@JsonProperty(CHOSENINLINEQUERY_FIELD)
|
||||
private ChosenInlineQuery chosenInlineQuery; ///< Optional. The result of a inline query that was chosen by a user and sent to their chat partner
|
||||
|
||||
@ -101,4 +102,14 @@ public class Update implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Update{" +
|
||||
"updateId=" + updateId +
|
||||
", message=" + message +
|
||||
", inlineQuery=" + inlineQuery +
|
||||
", chosenInlineQuery=" + chosenInlineQuery +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,15 +19,15 @@ import java.io.IOException;
|
||||
public class User implements IBotApiObject {
|
||||
|
||||
public static final String ID_FIELD = "id";
|
||||
public static final String FIRSTNAME_FIELD = "first_name";
|
||||
public static final String LASTNAME_FIELD = "last_name";
|
||||
public static final String USERNAME_FIELD = "username";
|
||||
@JsonProperty(ID_FIELD)
|
||||
private Integer id; ///< Unique identifier for this user or bot
|
||||
public static final String FIRSTNAME_FIELD = "first_name";
|
||||
@JsonProperty(FIRSTNAME_FIELD)
|
||||
private String firstName; ///< User‘s or bot’s first name
|
||||
public static final String LASTNAME_FIELD = "last_name";
|
||||
@JsonProperty(LASTNAME_FIELD)
|
||||
private String lastName; ///< Optional. User‘s or bot’s last name
|
||||
public static final String USERNAME_FIELD = "username";
|
||||
@JsonProperty(USERNAME_FIELD)
|
||||
private String userName; ///< Optional. User‘s or bot’s username
|
||||
|
||||
@ -81,4 +82,14 @@ public class User implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", userName='" + userName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
@ -21,9 +22,9 @@ import java.util.List;
|
||||
public class UserProfilePhotos implements IBotApiObject {
|
||||
|
||||
public static final String TOTALCOUNT_FIELD = "total_count";
|
||||
public static final String PHOTOS_FIELD = "photos";
|
||||
@JsonProperty(TOTALCOUNT_FIELD)
|
||||
private Integer totalCount; ///< Total number of profile pictures the target user has
|
||||
public static final String PHOTOS_FIELD = "photos";
|
||||
@JsonProperty(PHOTOS_FIELD)
|
||||
private List<List<PhotoSize>> photos; ///< Requested profile pictures (in up to 4 sizes each)
|
||||
|
||||
@ -87,4 +88,12 @@ public class UserProfilePhotos implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserProfilePhotos{" +
|
||||
"totalCount=" + totalCount +
|
||||
", photos=" + photos +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -18,24 +19,24 @@ import java.io.IOException;
|
||||
public class Video implements IBotApiObject {
|
||||
|
||||
public static final String FILEID_FIELD = "file_id";
|
||||
public static final String WIDTH_FIELD = "width";
|
||||
public static final String HEIGHT_FIELD = "height";
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
private String fileId; ///< Unique identifier for this file
|
||||
public static final String WIDTH_FIELD = "width";
|
||||
@JsonProperty(WIDTH_FIELD)
|
||||
private Integer width; ///< Video width as defined by sender
|
||||
public static final String HEIGHT_FIELD = "height";
|
||||
@JsonProperty(HEIGHT_FIELD)
|
||||
private Integer height; ///< Video height as defined by sender
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
@JsonProperty(DURATION_FIELD)
|
||||
private Integer duration; ///< Duration of the video in seconds as defined by sender
|
||||
public static final String THUMB_FIELD = "thumb";
|
||||
@JsonProperty(THUMB_FIELD)
|
||||
private PhotoSize thumb; ///< Video thumbnail
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
@JsonProperty(MIMETYPE_FIELD)
|
||||
private String mimeType; ///< Optional. Mime type of a file as defined by sender
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILESIZE_FIELD)
|
||||
private Integer fileSize; ///< Optional. File size
|
||||
|
||||
@ -139,4 +140,17 @@ public class Video implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Video{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", width=" + width +
|
||||
", height=" + height +
|
||||
", duration=" + duration +
|
||||
", thumb=" + thumb +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", fileSize=" + fileSize +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||
|
||||
@ -17,15 +18,15 @@ import java.io.IOException;
|
||||
*/
|
||||
public class Voice implements IBotApiObject {
|
||||
public static final String FILEID_FIELD = "file_id";
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
private String fileId; ///< Unique identifier for this file
|
||||
public static final String DURATION_FIELD = "duration";
|
||||
@JsonProperty(DURATION_FIELD)
|
||||
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
|
||||
public static final String MIMETYPE_FIELD = "mime_type";
|
||||
@JsonProperty(MIMETYPE_FIELD)
|
||||
private String mimeType; ///< Optional. MIME type of the file as defined by sender
|
||||
public static final String FILESIZE_FIELD = "file_size";
|
||||
@JsonProperty(FILESIZE_FIELD)
|
||||
private Integer fileSize; ///< Optional. File size
|
||||
|
||||
@ -96,4 +97,14 @@ public class Voice implements IBotApiObject {
|
||||
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
|
||||
serialize(gen, serializers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Voice{" +
|
||||
"fileId='" + fileId + '\'' +
|
||||
", duration=" + duration +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", fileSize=" + fileSize +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,21 @@ import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.TelegramApiException;
|
||||
import org.telegram.telegrambots.api.Constants;
|
||||
import org.telegram.telegrambots.api.methods.*;
|
||||
import org.telegram.telegrambots.api.methods.AnswerInlineQuery;
|
||||
import org.telegram.telegrambots.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.api.methods.ForwardMessage;
|
||||
import org.telegram.telegrambots.api.methods.GetFile;
|
||||
import org.telegram.telegrambots.api.methods.GetMe;
|
||||
import org.telegram.telegrambots.api.methods.GetUserProfilePhotos;
|
||||
import org.telegram.telegrambots.api.methods.SendAudio;
|
||||
import org.telegram.telegrambots.api.methods.SendChatAction;
|
||||
import org.telegram.telegrambots.api.methods.SendDocument;
|
||||
import org.telegram.telegrambots.api.methods.SendLocation;
|
||||
import org.telegram.telegrambots.api.methods.SendMessage;
|
||||
import org.telegram.telegrambots.api.methods.SendPhoto;
|
||||
import org.telegram.telegrambots.api.methods.SendSticker;
|
||||
import org.telegram.telegrambots.api.methods.SendVideo;
|
||||
import org.telegram.telegrambots.api.methods.SendVoice;
|
||||
import org.telegram.telegrambots.api.objects.File;
|
||||
import org.telegram.telegrambots.api.objects.Message;
|
||||
import org.telegram.telegrambots.api.objects.User;
|
||||
@ -35,12 +49,16 @@ import java.util.concurrent.Executors;
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* @brief TODO
|
||||
* @brief Implementation of all the methods needed to interact with Telegram Servers
|
||||
* @date 14 of January of 2016
|
||||
*/
|
||||
public abstract class AbsSender {
|
||||
private final ExecutorService exe = Executors.newSingleThreadExecutor();
|
||||
|
||||
/**
|
||||
* Returns the token of the bot to be able to perform Telegram Api Requests
|
||||
* @return Token of the bot
|
||||
*/
|
||||
public abstract String getBotToken();
|
||||
|
||||
public Message sendMessage(SendMessage sendMessage) throws TelegramApiException {
|
||||
@ -90,6 +108,17 @@ public abstract class AbsSender {
|
||||
|
||||
return (UserProfilePhotos) sendApiMethod(getUserProfilePhotos);
|
||||
}
|
||||
|
||||
public File getFile(GetFile getFile) throws TelegramApiException{
|
||||
if(getFile == null){
|
||||
throw new TelegramApiException("Parameter getFile can not be null");
|
||||
}
|
||||
else if(getFile.getFileId() == null){
|
||||
throw new TelegramApiException("Attribute file_id in parameter getFile can not be null");
|
||||
}
|
||||
return (File)sendApiMethod(getFile);
|
||||
|
||||
}
|
||||
|
||||
public User getMe() throws TelegramApiException {
|
||||
GetMe getMe = new GetMe();
|
||||
@ -185,7 +214,6 @@ public abstract class AbsSender {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
String url = getBaseUrl() + SendDocument.PATH;
|
||||
HttpPost httppost = new HttpPost(url);
|
||||
|
||||
if (sendDocument.isNewDocument()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId());
|
||||
@ -196,6 +224,12 @@ public abstract class AbsSender {
|
||||
if (sendDocument.getReplayToMessageId() != null) {
|
||||
builder.addTextBody(SendDocument.REPLYTOMESSAGEID_FIELD, sendDocument.getReplayToMessageId().toString());
|
||||
}
|
||||
if (sendDocument.getCaption() != null) {
|
||||
builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption());
|
||||
}
|
||||
if (sendDocument.getDisableNotification() != null) {
|
||||
builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString());
|
||||
}
|
||||
HttpEntity multipart = builder.build();
|
||||
httppost.setEntity(multipart);
|
||||
} else {
|
||||
@ -208,6 +242,12 @@ public abstract class AbsSender {
|
||||
if (sendDocument.getReplayToMessageId() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendDocument.REPLYTOMESSAGEID_FIELD, sendDocument.getReplayToMessageId().toString()));
|
||||
}
|
||||
if (sendDocument.getCaption() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendDocument.CAPTION_FIELD, sendDocument.getCaption()));
|
||||
}
|
||||
if (sendDocument.getReplayToMessageId() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString()));
|
||||
}
|
||||
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
|
||||
}
|
||||
|
||||
@ -233,7 +273,6 @@ public abstract class AbsSender {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
String url = getBaseUrl() + SendPhoto.PATH;
|
||||
HttpPost httppost = new HttpPost(url);
|
||||
|
||||
if (sendPhoto.isNewPhoto()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendPhoto.CHATID_FIELD, sendPhoto.getChatId());
|
||||
@ -247,6 +286,9 @@ public abstract class AbsSender {
|
||||
if (sendPhoto.getCaption() != null) {
|
||||
builder.addTextBody(SendPhoto.CAPTION_FIELD, sendPhoto.getCaption());
|
||||
}
|
||||
if (sendPhoto.getDisableNotification() != null) {
|
||||
builder.addTextBody(SendPhoto.DISABLENOTIFICATION_FIELD, sendPhoto.getDisableNotification().toString());
|
||||
}
|
||||
HttpEntity multipart = builder.build();
|
||||
httppost.setEntity(multipart);
|
||||
} else {
|
||||
@ -262,6 +304,9 @@ public abstract class AbsSender {
|
||||
if (sendPhoto.getCaption() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendPhoto.CAPTION_FIELD, sendPhoto.getCaption()));
|
||||
}
|
||||
if (sendPhoto.getDisableNotification() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendPhoto.DISABLENOTIFICATION_FIELD, sendPhoto.getDisableNotification().toString()));
|
||||
}
|
||||
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
|
||||
}
|
||||
|
||||
@ -287,7 +332,6 @@ public abstract class AbsSender {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
String url = getBaseUrl() + SendVideo.PATH;
|
||||
HttpPost httppost = new HttpPost(url);
|
||||
|
||||
if (sendVideo.isNewVideo()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendVideo.CHATID_FIELD, sendVideo.getChatId());
|
||||
@ -304,6 +348,15 @@ public abstract class AbsSender {
|
||||
if (sendVideo.getDuration() != null) {
|
||||
builder.addTextBody(SendVideo.DURATION_FIELD, sendVideo.getDuration().toString());
|
||||
}
|
||||
if (sendVideo.getWidth() != null) {
|
||||
builder.addTextBody(SendVideo.WIDTH_FIELD, sendVideo.getWidth().toString());
|
||||
}
|
||||
if (sendVideo.getHeight() != null) {
|
||||
builder.addTextBody(SendVideo.HEIGHT_FIELD, sendVideo.getHeight().toString());
|
||||
}
|
||||
if (sendVideo.getDisableNotification() != null) {
|
||||
builder.addTextBody(SendVideo.DISABLENOTIFICATION_FIELD, sendVideo.getDisableNotification().toString());
|
||||
}
|
||||
HttpEntity multipart = builder.build();
|
||||
httppost.setEntity(multipart);
|
||||
} else {
|
||||
@ -322,6 +375,15 @@ public abstract class AbsSender {
|
||||
if (sendVideo.getDuration() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVideo.DURATION_FIELD, sendVideo.getDuration().toString()));
|
||||
}
|
||||
if (sendVideo.getWidth() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVideo.WIDTH_FIELD, sendVideo.getWidth().toString()));
|
||||
}
|
||||
if (sendVideo.getHeight() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVideo.HEIGHT_FIELD, sendVideo.getHeight().toString()));
|
||||
}
|
||||
if (sendVideo.getDisableNotification() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVideo.DISABLENOTIFICATION_FIELD, sendVideo.getDisableNotification().toString()));
|
||||
}
|
||||
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
|
||||
}
|
||||
|
||||
@ -348,7 +410,6 @@ public abstract class AbsSender {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
String url = getBaseUrl() + SendSticker.PATH;
|
||||
HttpPost httppost = new HttpPost(url);
|
||||
|
||||
if (sendSticker.isNewSticker()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendSticker.CHATID_FIELD, sendSticker.getChatId());
|
||||
@ -359,6 +420,9 @@ public abstract class AbsSender {
|
||||
if (sendSticker.getReplayToMessageId() != null) {
|
||||
builder.addTextBody(SendSticker.REPLYTOMESSAGEID_FIELD, sendSticker.getReplayToMessageId().toString());
|
||||
}
|
||||
if (sendSticker.getDisableNotification() != null) {
|
||||
builder.addTextBody(SendSticker.DISABLENOTIFICATION_FIELD, sendSticker.getDisableNotification().toString());
|
||||
}
|
||||
HttpEntity multipart = builder.build();
|
||||
httppost.setEntity(multipart);
|
||||
} else {
|
||||
@ -371,6 +435,9 @@ public abstract class AbsSender {
|
||||
if (sendSticker.getReplayToMessageId() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendSticker.REPLYTOMESSAGEID_FIELD, sendSticker.getReplayToMessageId().toString()));
|
||||
}
|
||||
if (sendSticker.getDisableNotification() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendSticker.DISABLENOTIFICATION_FIELD, sendSticker.getDisableNotification().toString()));
|
||||
}
|
||||
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
|
||||
}
|
||||
|
||||
@ -390,6 +457,156 @@ public abstract class AbsSender {
|
||||
return new Message(jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a file using Send Audio method (https://core.telegram.org/bots/api#sendaudio)
|
||||
* @param sendAudio Information to send
|
||||
* @return If success, the sent Message is returned
|
||||
* @throws TelegramApiException If there is any error sending the audio
|
||||
*/
|
||||
public Message sendAudio(SendAudio sendAudio) throws TelegramApiException {
|
||||
String responseContent;
|
||||
|
||||
|
||||
try {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
String url = getBaseUrl() + SendAudio.PATH;
|
||||
HttpPost httppost = new HttpPost(url);
|
||||
|
||||
if (sendAudio.isNewAudio()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendAudio.CHATID_FIELD, sendAudio.getChatId());
|
||||
builder.addBinaryBody(SendAudio.AUDIO_FIELD, new java.io.File(sendAudio.getAudio()), ContentType.create("audio/mpeg"), sendAudio.getAudioName());
|
||||
if (sendAudio.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendAudio.REPLYMARKUP_FIELD, sendAudio.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
if (sendAudio.getReplayToMessageId() != null) {
|
||||
builder.addTextBody(SendAudio.REPLYTOMESSAGEID_FIELD, sendAudio.getReplayToMessageId().toString());
|
||||
}
|
||||
if (sendAudio.getPerformer() != null) {
|
||||
builder.addTextBody(SendAudio.PERFOMER_FIELD, sendAudio.getPerformer());
|
||||
}
|
||||
if (sendAudio.getTitle() != null) {
|
||||
builder.addTextBody(SendAudio.TITLE_FIELD, sendAudio.getTitle());
|
||||
}
|
||||
if(sendAudio.getDuration() != null){
|
||||
builder.addTextBody(SendAudio.DURATION_FIELD, sendAudio.getDuration().toString());
|
||||
}
|
||||
if (sendAudio.getDisableNotification() != null) {
|
||||
builder.addTextBody(SendAudio.DISABLENOTIFICATION_FIELD, sendAudio.getDisableNotification().toString());
|
||||
}
|
||||
HttpEntity multipart = builder.build();
|
||||
httppost.setEntity(multipart);
|
||||
} else {
|
||||
List<NameValuePair> nameValuePairs = new ArrayList<>();
|
||||
nameValuePairs.add(new BasicNameValuePair(SendAudio.CHATID_FIELD, sendAudio.getChatId()));
|
||||
nameValuePairs.add(new BasicNameValuePair(SendAudio.AUDIO_FIELD, sendAudio.getAudio()));
|
||||
if (sendAudio.getReplayMarkup() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendAudio.REPLYMARKUP_FIELD, sendAudio.getReplayMarkup().toString()));
|
||||
}
|
||||
if (sendAudio.getReplayToMessageId() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendAudio.REPLYTOMESSAGEID_FIELD, sendAudio.getReplayToMessageId().toString()));
|
||||
}
|
||||
if (sendAudio.getPerformer() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendAudio.PERFOMER_FIELD, sendAudio.getPerformer()));
|
||||
}
|
||||
if (sendAudio.getTitle() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendAudio.TITLE_FIELD, sendAudio.getTitle()));
|
||||
}
|
||||
if (sendAudio.getDisableNotification() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendAudio.DISABLENOTIFICATION_FIELD, sendAudio.getDisableNotification().toString()));
|
||||
}
|
||||
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
|
||||
}
|
||||
|
||||
CloseableHttpResponse response = httpClient.execute(httppost);
|
||||
HttpEntity ht = response.getEntity();
|
||||
BufferedHttpEntity buf = new BufferedHttpEntity(ht);
|
||||
responseContent = EntityUtils.toString(buf, "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new TelegramApiException("Unable to send sticker", e);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject(responseContent);
|
||||
|
||||
/* if we got not an "ok" with false, we have a response like that
|
||||
*
|
||||
* {"description":"[Error]: Bad Request: chat not found","error_code":400,"ok":false}
|
||||
*/
|
||||
if(!jsonObject.getBoolean("ok")){
|
||||
throw new TelegramApiException("Error at sendAudio", jsonObject.getString("description"));
|
||||
}
|
||||
|
||||
// and if not, we can expect a "result" section. and out of this can a new Message object be built
|
||||
return new Message(jsonObject.getJSONObject("result"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a voice note using Send Voice method (https://core.telegram.org/bots/api#sendvoice)
|
||||
* @param sendVoice Information to send
|
||||
* @return If success, the sent Message is returned
|
||||
* @throws TelegramApiException If there is any error sending the audio
|
||||
*/
|
||||
public Message sendVoice(SendVoice sendVoice) throws TelegramApiException {
|
||||
String responseContent;
|
||||
|
||||
try {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
String url = getBaseUrl() + SendVoice.PATH;
|
||||
HttpPost httppost = new HttpPost(url);
|
||||
|
||||
if (sendVoice.isNewVoice()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendVoice.CHATID_FIELD, sendVoice.getChatId());
|
||||
builder.addBinaryBody(SendVoice.AUDIO_FIELD, new java.io.File(sendVoice.getAudio()), ContentType.create("audio/ogg"), sendVoice.getVoiceName());
|
||||
if (sendVoice.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendVoice.REPLYMARKUP_FIELD, sendVoice.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
if (sendVoice.getReplayToMessageId() != null) {
|
||||
builder.addTextBody(SendVoice.REPLYTOMESSAGEID_FIELD, sendVoice.getReplayToMessageId().toString());
|
||||
}
|
||||
if (sendVoice.getDisableNotification() != null) {
|
||||
builder.addTextBody(SendVoice.DISABLENOTIFICATION_FIELD, sendVoice.getDisableNotification().toString());
|
||||
}
|
||||
if (sendVoice.getDuration() != null) {
|
||||
builder.addTextBody(SendVoice.DURATION_FIELD, sendVoice.getDuration().toString());
|
||||
}
|
||||
HttpEntity multipart = builder.build();
|
||||
httppost.setEntity(multipart);
|
||||
} else {
|
||||
List<NameValuePair> nameValuePairs = new ArrayList<>();
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.CHATID_FIELD, sendVoice.getChatId()));
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.AUDIO_FIELD, sendVoice.getAudio()));
|
||||
if (sendVoice.getReplayMarkup() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.REPLYMARKUP_FIELD, sendVoice.getReplayMarkup().toString()));
|
||||
}
|
||||
if (sendVoice.getReplayToMessageId() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.REPLYTOMESSAGEID_FIELD, sendVoice.getReplayToMessageId().toString()));
|
||||
}
|
||||
if (sendVoice.getDisableNotification() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.DISABLENOTIFICATION_FIELD, sendVoice.getDisableNotification().toString()));
|
||||
}
|
||||
if (sendVoice.getDuration() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.DURATION_FIELD, sendVoice.getDuration().toString()));
|
||||
}
|
||||
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
|
||||
}
|
||||
|
||||
CloseableHttpResponse response = httpClient.execute(httppost);
|
||||
HttpEntity ht = response.getEntity();
|
||||
BufferedHttpEntity buf = new BufferedHttpEntity(ht);
|
||||
responseContent = EntityUtils.toString(buf, "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new TelegramApiException("Unable to send sticker", e);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject(responseContent);
|
||||
if (!jsonObject.getBoolean("ok")) {
|
||||
throw new TelegramApiException("Error at sendVoice", jsonObject.getString("description"));
|
||||
}
|
||||
|
||||
return new Message(jsonObject);
|
||||
}
|
||||
|
||||
private void sendApiMethodAsync(BotApiMethod method, SentCallback callback) {
|
||||
exe.submit(() -> {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user