Skip to content

Commit

Permalink
Telegram Bot API 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiducho committed Dec 1, 2021
1 parent 1124889 commit d0eb3c1
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.cadiducho'
version = '5.1'
version = '5.2'
sourceCompatibility = '1.8'

java {
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/com/cadiducho/telegrambotapi/BotAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
* Interface to build Telegrams Bots
* Telegram Bot API version 5.1
* Telegram Bot API version 5.2
*/
public interface BotAPI {

Expand Down Expand Up @@ -675,10 +675,10 @@ default Message sendDice(Object chat_id) throws TelegramException {
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
* Watch more in https://core.telegram.org/bots/api#sendchataction
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param action Type of action to broadcast.
* Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos,
* record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files,
* find_location for location data.
* @param action Type of action to broadcast.
* Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos,
* record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files,
* choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
* @return On success, True is returned.
* @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers
*/
Expand All @@ -698,10 +698,10 @@ enum ChatAction {
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
* Watch more in https://core.telegram.org/bots/api#sendchataction
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param action Type of action to broadcast.
* Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos,
* record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files,
* find_location for location data.
* @param action Type of action to broadcast.
* Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos,
* record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files,
* choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
* @return On success, True is returned.
* @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers
*/
Expand Down Expand Up @@ -1560,14 +1560,16 @@ Boolean answerInlineQuery(String inlineQueryId, List<InlineQueryResult> results,
* @param description Product description
* @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
* @param provider_token Payments provider token, obtained via Botfather
* @param start_parameter Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter
* @param currency Three-letter ISO 4217 currency code, see more on https://core.telegram.org/bots/payments#supported-currencies
* @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
* @param max_tip_amount The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0
* @param suggested_tip_amounts A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
* @param start_parameter Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter
* @return {@link Message}
* @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers
*/
default Message sendInvoice(Integer chat_id, String title, String description, String payload, String provider_token, String start_parameter, String currency,
List<LabeledPrice> prices) throws TelegramException {
default Message sendInvoice(Integer chat_id, String title, String description, String payload, String provider_token, String currency,
List<LabeledPrice> prices, Integer max_tip_amount, List<Integer> suggested_tip_amounts, String start_parameter) throws TelegramException {
return sendInvoice(chat_id, title, description, payload, provider_token, start_parameter, currency, prices, null, null, null, null, null, false, false, false, false, false, false, false, false, null, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ public class InlineQuery {
* Offset of the results to be returned, can be controlled by the bot
*/
private String offset;

/**
* Optional. Type of the chat, from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”.
* The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat
*/
private String chat_type;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.cadiducho.telegrambotapi.inline;

import com.cadiducho.telegrambotapi.payment.LabeledPrice;
import com.squareup.moshi.Json;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

/**
* Represents the content of an invoice message to be sent as the result of an inline query.
*/
@ToString
@Getter
@Setter
public class InputInvoiceMessageContent extends InputMessageContent {

/**
* Product name, 1-32 characters
*/
private String title;

/**
* Product description, 1-255 characters
*/
private String description;

/**
* Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
*/
private String payload;

/**
* Payment provider token, obtained via Botfather
*/
@Json(name = "provider_token") private String providerToken;

/**
* Three-letter ISO 4217 currency code, see more on https://core.telegram.org/bots/payments#supported-currencies
*/
private String currency;

/**
* Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
*/
private List<LabeledPrice> prices;

/**
* Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double).
* For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
* Defaults to 0
*/
@Json(name = "max_tip_amount") private Integer maxTipAmount;

/**
* Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified.
* The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
*/
@Json(name = "suggested_tip_amounts") private List<Integer> suggestedTipAmounts;

/**
* Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider.
* A detailed description of the required fields should be provided by the payment provider.
*/
@Json(name = "provider_data") private String providerData;

/**
* Optional. URL of the product photo for the invoice.
* Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
*/
@Json(name = "photo_url") private String photo_url;

/**
* Optional. Photo size
*/
@Json(name = "photo_size") private Integer photoSize;

/**
* Optional. Photo width
*/
@Json(name = "photo_width") private Integer photoWidth;

/**
* Optional. Photo height
*/
@Json(name = "photo_height") private Integer photoHeight;

/**
* Optional. Pass True, if you require the user's full name to complete the order
*/
@Json(name = "need_name") private Boolean needName;

/**
* Optional. Pass True, if you require the user's phone number to complete the order
*/
@Json(name = "need_phone_number") private Boolean needPhoneNumber;

/**
* Optional. Pass True, if you require the user's email address to complete the order
*/
@Json(name = "need_email") private Boolean needEmail;

/**
* Optional. Pass True, if you require the user's shipping address to complete the order
*/
@Json(name = "need_shipping_address") private Boolean needShippingAddress;

/**
* Optional. Pass True, if user's phone number should be sent to provider
*/
@Json(name = "send_phone_number_to_provider") private Boolean sendPhoneNumberToProvider;

/**
* Optional. Pass True, if user's email address should be sent to provider
*/
@Json(name = "send_email_to_provider") private Boolean sendEmailToProvider;

/**
* Optional. Pass True, if the final price depends on the shipping method
*/
@Json(name = "is_flexible") private Boolean isFlexible;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* <li>{@link InputLocationMessageContent}</li>
* <li>{@link InputVenueMessageContent}</li>
* <li>{@link InputContactMessageContent}</li>
* <li>{@link InputInvoiceMessageContent}</li>
* </ul>
*/
@ToString
Expand Down

0 comments on commit d0eb3c1

Please sign in to comment.