Skip to content

Commit 7a4ae93

Browse files
committed
Telegram Bot API April 26, 2021 updates (v5.2)
1 parent eb1d790 commit 7a4ae93

File tree

10 files changed

+459
-67
lines changed

10 files changed

+459
-67
lines changed

build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
enablePlugins(GitPlugin)
22

33
ThisBuild / version := Version.mkVersion(
4-
"4.51.1",
4+
"4.52.0",
55
git.gitCurrentBranch.value,
66
git.gitHeadCommit.value,
77
git.gitDescribedVersion.value,
@@ -23,7 +23,7 @@ ThisBuild / buildTimestamp := Version.timestamp
2323
ThisBuild / name := "telegramium"
2424
ThisBuild / organization := "io.github.apimorphism"
2525
ThisBuild / homepage := Some(url("https://github.com/apimorphism/telegramium"))
26-
ThisBuild / licenses := List(("MIT", url("http://opensource.org/licenses/MIT")))
26+
ThisBuild / licenses := List(("MIT", url("https://opensource.org/licenses/MIT")))
2727
ThisBuild / scmInfo := Some(ScmInfo(
2828
url("https://github.com/apimorphism/telegramium"),
2929
"[email protected]:apimorphism/telegramium.git"
@@ -66,14 +66,14 @@ lazy val `telegramium-examples` = project
6666
)
6767
.settings(settings: _*)
6868
.settings(
69-
skip in publish := true
69+
publish / skip := true
7070
)
7171
.settings(libraryDependencies ++= Dependencies.telegramiumExam)
7272

7373
lazy val telegramium = (project in file("."))
7474
.settings(
7575
name := "F[Tg]",
76-
skip in publish := true,
76+
publish / skip := true,
7777
crossScalaVersions := Nil,
7878
)
7979
.aggregate(

telegramium-core/src/main/scala/telegramium/bots/InlineQuery.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@ package telegramium.bots
55
*
66
* @param id Unique identifier for this query
77
* @param from Sender
8-
* @param location Optional. Sender location, only for bots that request user
9-
* location
108
* @param query Text of the query (up to 256 characters)
119
* @param offset Offset of the results to be returned, can be controlled by
12-
* the bot */
10+
* the bot
11+
* @param chatType Optional. Type of the chat, from which the inline query was
12+
* sent. Can be either “sender” for a private chat with the
13+
* inline query sender, “private”, “group”, “supergroup”, or
14+
* “channel”. The chat type should be always known for requests
15+
* sent from official clients and most third-party clients,
16+
* unless the request was sent from a secret chat
17+
* @param location Optional. Sender location, only for bots that request user
18+
* location */
1319
final case class InlineQuery(id: String,
1420
from: User,
15-
location: Option[Location] = Option.empty,
1621
query: String,
17-
offset: String)
22+
offset: String,
23+
chatType: Option[String] = Option.empty,
24+
location: Option[Location] = Option.empty)

telegramium-core/src/main/scala/telegramium/bots/InputMessageContent.scala

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,79 @@ final case class InputVenueMessageContent(latitude: Float,
2626
googlePlaceType: Option[String] = Option.empty)
2727
extends InputMessageContent
2828

29+
/** Represents the content of an invoice message to be sent as the result of an
30+
* inline query.
31+
*
32+
* @param title Product name, 1-32 characters
33+
* @param description Product description, 1-255 characters
34+
* @param payload Bot-defined invoice payload, 1-128 bytes. This will not be
35+
* displayed to the user, use for your internal processes.
36+
* @param providerToken Payment provider token, obtained via Botfather
37+
* @param currency Three-letter ISO 4217 currency code, see more on currencies
38+
* @param prices Price breakdown, a JSON-serialized list of components (e.g.
39+
* product price, tax, discount, delivery cost, delivery tax,
40+
* bonus, etc.)
41+
* @param maxTipAmount Optional. The maximum accepted amount for tips in the
42+
* smallest units of the currency (integer, not float/double).
43+
* For example, for a maximum tip of US$ 1.45 pass
44+
* max_tip_amount = 145. See the exp parameter in
45+
* currencies.json, it shows the number of digits past the
46+
* decimal point for each currency (2 for the majority of
47+
* currencies). Defaults to 0
48+
* @param suggestedTipAmounts Optional. A JSON-serialized array of suggested amounts of
49+
* tip in the smallest units of the currency (integer, not
50+
* float/double). At most 4 suggested tip amounts can be
51+
* specified. The suggested tip amounts must be positive,
52+
* passed in a strictly increased order and must not exceed
53+
* max_tip_amount.
54+
* @param providerData Optional. A JSON-serialized object for data about the
55+
* invoice, which will be shared with the payment provider. A
56+
* detailed description of the required fields should be
57+
* provided by the payment provider.
58+
* @param photoUrl Optional. URL of the product photo for the invoice. Can be
59+
* a photo of the goods or a marketing image for a service.
60+
* People like it better when they see what they are paying
61+
* for.
62+
* @param photoSize Optional. Photo size
63+
* @param photoWidth Optional. Photo width
64+
* @param photoHeight Optional. Photo height
65+
* @param needName Optional. Pass True, if you require the user's full name to
66+
* complete the order
67+
* @param needPhoneNumber Optional. Pass True, if you require the user's phone number
68+
* to complete the order
69+
* @param needEmail Optional. Pass True, if you require the user's email
70+
* address to complete the order
71+
* @param needShippingAddress Optional. Pass True, if you require the user's shipping
72+
* address to complete the order
73+
* @param sendPhoneNumberToProvider Optional. Pass True, if user's phone number should be sent
74+
* to provider
75+
* @param sendEmailToProvider Optional. Pass True, if user's email address should be sent
76+
* to provider
77+
* @param isFlexible Optional. Pass True, if the final price depends on the
78+
* shipping method */
79+
final case class InputInvoiceMessageContent(title: String,
80+
description: String,
81+
payload: String,
82+
providerToken: String,
83+
currency: String,
84+
prices: List[LabeledPrice] = List.empty,
85+
maxTipAmount: Option[Int] = Option.empty,
86+
suggestedTipAmounts: List[Int] = List.empty,
87+
providerData: Option[String] = Option.empty,
88+
photoUrl: Option[String] = Option.empty,
89+
photoSize: Option[Int] = Option.empty,
90+
photoWidth: Option[Int] = Option.empty,
91+
photoHeight: Option[Int] = Option.empty,
92+
needName: Option[Boolean] = Option.empty,
93+
needPhoneNumber: Option[Boolean] = Option.empty,
94+
needEmail: Option[Boolean] = Option.empty,
95+
needShippingAddress: Option[Boolean] = Option.empty,
96+
sendPhoneNumberToProvider: Option[Boolean] =
97+
Option.empty,
98+
sendEmailToProvider: Option[Boolean] = Option.empty,
99+
isFlexible: Option[Boolean] = Option.empty)
100+
extends InputMessageContent
101+
29102
/** Represents the content of a contact message to be sent as the result of an
30103
* inline query.
31104
*

telegramium-core/src/main/scala/telegramium/bots/Message.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ package telegramium.bots
118118
* @param passportData Optional. Telegram Passport data
119119
* @param proximityAlertTriggered Optional. Service message. A user in the chat triggered
120120
* another user's proximity alert while sharing Live Location.
121+
* @param voiceChatScheduled Optional. Service message: voice chat scheduled
121122
* @param voiceChatStarted Optional. Service message: voice chat started
122123
* @param voiceChatEnded Optional. Service message: voice chat ended
123124
* @param voiceChatParticipantsInvited Optional. Service message: new participants invited to a
@@ -176,6 +177,7 @@ final case class Message(
176177
connectedWebsite: Option[String] = Option.empty,
177178
passportData: Option[PassportData] = Option.empty,
178179
proximityAlertTriggered: Option[ProximityAlertTriggered] = Option.empty,
180+
voiceChatScheduled: Option[VoiceChatScheduled] = Option.empty,
179181
voiceChatStarted: Option[VoiceChatStarted.type] = Option.empty,
180182
voiceChatEnded: Option[VoiceChatEnded] = Option.empty,
181183
voiceChatParticipantsInvited: Option[VoiceChatParticipantsInvited] = Option.empty,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package telegramium.bots
2+
3+
/** This object represents a service message about a voice chat scheduled in the
4+
* chat.
5+
*
6+
* @param startDate Point in time (Unix timestamp) when the voice chat is
7+
* supposed to be started by a chat administrator */
8+
final case class VoiceChatScheduled(startDate: Int)

telegramium-core/src/main/scala/telegramium/bots/client/Methods.scala

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -888,9 +888,10 @@ trait Methods {
888888
MethodReq[Boolean]("setChatTitle", req.asJson)
889889
}
890890

891-
/** Use this method to copy messages of any kind. The method is analogous to the
892-
* method forwardMessage, but the copied message doesn't have a link to the
893-
* original message. Returns the MessageId of the sent message on success.
891+
/** Use this method to copy messages of any kind. Service messages and invoice
892+
* messages can't be copied. The method is analogous to the method forwardMessage,
893+
* but the copied message doesn't have a link to the original message. Returns the
894+
* MessageId of the sent message on success.
894895
*
895896
* @param chatId Unique identifier for the target chat or username of the
896897
* target channel (in the format @channelusername)
@@ -1039,18 +1040,35 @@ trait Methods {
10391040

10401041
/** Use this method to send invoices. On success, the sent Message is returned.
10411042
*
1042-
* @param chatId Unique identifier for the target private chat
1043+
* @param chatId Unique identifier for the target chat or username of the
1044+
* target channel (in the format @channelusername)
10431045
* @param title Product name, 1-32 characters
10441046
* @param description Product description, 1-255 characters
10451047
* @param payload Bot-defined invoice payload, 1-128 bytes. This will not be
10461048
* displayed to the user, use for your internal processes.
10471049
* @param providerToken Payments provider token, obtained via Botfather
1048-
* @param startParameter Unique deep-linking parameter that can be used to generate
1049-
* this invoice when used as a start parameter
10501050
* @param currency Three-letter ISO 4217 currency code, see more on currencies
10511051
* @param prices Price breakdown, a JSON-serialized list of components (e.g.
10521052
* product price, tax, discount, delivery cost, delivery tax,
10531053
* bonus, etc.)
1054+
* @param maxTipAmount The maximum accepted amount for tips in the smallest units
1055+
* of the currency (integer, not float/double). For example,
1056+
* for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See
1057+
* the exp parameter in currencies.json, it shows the number of
1058+
* digits past the decimal point for each currency (2 for the
1059+
* majority of currencies). Defaults to 0
1060+
* @param suggestedTipAmounts A JSON-serialized array of suggested amounts of tips in the
1061+
* smallest units of the currency (integer, not float/double).
1062+
* At most 4 suggested tip amounts can be specified. The
1063+
* suggested tip amounts must be positive, passed in a strictly
1064+
* increased order and must not exceed max_tip_amount.
1065+
* @param startParameter Unique deep-linking parameter. If left empty, forwarded
1066+
* copies of the sent message will have a Pay button, allowing
1067+
* multiple users to pay directly from the forwarded message,
1068+
* using the same invoice. If non-empty, forwarded copies of
1069+
* the sent message will have a URL button with a deep link to
1070+
* the bot (instead of a Pay button), with the value used as
1071+
* the start parameter
10541072
* @param providerData A JSON-serialized data about the invoice, which will be
10551073
* shared with the payment provider. A detailed description of
10561074
* required fields should be provided by the payment provider.
@@ -1082,14 +1100,16 @@ trait Methods {
10821100
* @param replyMarkup A JSON-serialized object for an inline keyboard. If empty,
10831101
* one 'Pay total price' button will be shown. If not empty,
10841102
* the first button must be a Pay button. */
1085-
def sendInvoice(chatId: Int,
1103+
def sendInvoice(chatId: ChatId,
10861104
title: String,
10871105
description: String,
10881106
payload: String,
10891107
providerToken: String,
1090-
startParameter: String,
10911108
currency: String,
10921109
prices: List[LabeledPrice] = List.empty,
1110+
maxTipAmount: Option[Int] = Option.empty,
1111+
suggestedTipAmounts: List[Int] = List.empty,
1112+
startParameter: Option[String] = Option.empty,
10931113
providerData: Option[String] = Option.empty,
10941114
photoUrl: Option[String] = Option.empty,
10951115
photoSize: Option[Int] = Option.empty,
@@ -1112,9 +1132,11 @@ trait Methods {
11121132
description,
11131133
payload,
11141134
providerToken,
1115-
startParameter,
11161135
currency,
11171136
prices,
1137+
maxTipAmount,
1138+
suggestedTipAmounts,
1139+
startParameter,
11181140
providerData,
11191141
photoUrl,
11201142
photoSize,
@@ -1395,8 +1417,8 @@ trait Methods {
13951417
MethodReq[User]("getMe", req.asJson)
13961418
}
13971419

1398-
/** Use this method to forward messages of any kind. On success, the sent Message
1399-
* is returned.
1420+
/** Use this method to forward messages of any kind. Service messages can't be
1421+
* forwarded. On success, the sent Message is returned.
14001422
*
14011423
* @param chatId Unique identifier for the target chat or username of the
14021424
* target channel (in the format @channelusername)
@@ -1530,8 +1552,7 @@ trait Methods {
15301552
* users and can pin messages, channels only
15311553
* @param canDeleteMessages Pass True, if the administrator can delete messages of
15321554
* other users
1533-
* @param canManageVoiceChats Pass True, if the administrator can manage voice chats,
1534-
* supergroups only
1555+
* @param canManageVoiceChats Pass True, if the administrator can manage voice chats
15351556
* @param canRestrictMembers Pass True, if the administrator can restrict, ban or unban
15361557
* chat members
15371558
* @param canPromoteMembers Pass True, if the administrator can add new administrators

telegramium-core/src/main/scala/telegramium/bots/client/PromoteChatMemberReq.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import telegramium.bots.ChatId
1818
* users and can pin messages, channels only
1919
* @param canDeleteMessages Pass True, if the administrator can delete messages of
2020
* other users
21-
* @param canManageVoiceChats Pass True, if the administrator can manage voice chats,
22-
* supergroups only
21+
* @param canManageVoiceChats Pass True, if the administrator can manage voice chats
2322
* @param canRestrictMembers Pass True, if the administrator can restrict, ban or unban
2423
* chat members
2524
* @param canPromoteMembers Pass True, if the administrator can add new administrators

telegramium-core/src/main/scala/telegramium/bots/client/SendInvoiceReq.scala

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
package telegramium.bots.client
22

3+
import telegramium.bots.ChatId
34
import telegramium.bots.LabeledPrice
45
import telegramium.bots.InlineKeyboardMarkup
56

6-
/** @param chatId Unique identifier for the target private chat
7+
/** @param chatId Unique identifier for the target chat or username of the
8+
* target channel (in the format @channelusername)
79
* @param title Product name, 1-32 characters
810
* @param description Product description, 1-255 characters
911
* @param payload Bot-defined invoice payload, 1-128 bytes. This will not be
1012
* displayed to the user, use for your internal processes.
1113
* @param providerToken Payments provider token, obtained via Botfather
12-
* @param startParameter Unique deep-linking parameter that can be used to generate
13-
* this invoice when used as a start parameter
1414
* @param currency Three-letter ISO 4217 currency code, see more on currencies
1515
* @param prices Price breakdown, a JSON-serialized list of components (e.g.
1616
* product price, tax, discount, delivery cost, delivery tax,
1717
* bonus, etc.)
18+
* @param maxTipAmount The maximum accepted amount for tips in the smallest units
19+
* of the currency (integer, not float/double). For example,
20+
* for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See
21+
* the exp parameter in currencies.json, it shows the number of
22+
* digits past the decimal point for each currency (2 for the
23+
* majority of currencies). Defaults to 0
24+
* @param suggestedTipAmounts A JSON-serialized array of suggested amounts of tips in the
25+
* smallest units of the currency (integer, not float/double).
26+
* At most 4 suggested tip amounts can be specified. The
27+
* suggested tip amounts must be positive, passed in a strictly
28+
* increased order and must not exceed max_tip_amount.
29+
* @param startParameter Unique deep-linking parameter. If left empty, forwarded
30+
* copies of the sent message will have a Pay button, allowing
31+
* multiple users to pay directly from the forwarded message,
32+
* using the same invoice. If non-empty, forwarded copies of
33+
* the sent message will have a URL button with a deep link to
34+
* the bot (instead of a Pay button), with the value used as
35+
* the start parameter
1836
* @param providerData A JSON-serialized data about the invoice, which will be
1937
* shared with the payment provider. A detailed description of
2038
* required fields should be provided by the payment provider.
@@ -46,14 +64,16 @@ import telegramium.bots.InlineKeyboardMarkup
4664
* @param replyMarkup A JSON-serialized object for an inline keyboard. If empty,
4765
* one 'Pay total price' button will be shown. If not empty,
4866
* the first button must be a Pay button. */
49-
final case class SendInvoiceReq(chatId: Int,
67+
final case class SendInvoiceReq(chatId: ChatId,
5068
title: String,
5169
description: String,
5270
payload: String,
5371
providerToken: String,
54-
startParameter: String,
5572
currency: String,
5673
prices: List[LabeledPrice] = List.empty,
74+
maxTipAmount: Option[Int] = Option.empty,
75+
suggestedTipAmounts: List[Int] = List.empty,
76+
startParameter: Option[String] = Option.empty,
5777
providerData: Option[String] = Option.empty,
5878
photoUrl: Option[String] = Option.empty,
5979
photoSize: Option[Int] = Option.empty,

0 commit comments

Comments
 (0)