Skip to content

Commit 55dbb4e

Browse files
committed
Telegram Bot API August 14, 2024 updates (v7.9)
1 parent 015f868 commit 55dbb4e

13 files changed

+166
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# F[Tg] - Telegramium
22

3-
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-7.8%20(July%2031%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes)
3+
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-7.9%20(August%2014%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes)
44
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_3)
55

66

build.sbt

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

33
ThisBuild / version := Version.mkVersion(
4-
"9.78.0",
4+
"9.79.0",
55
git.gitCurrentBranch.value,
66
git.gitDescribedVersion.value,
77
git.gitUncommittedChanges.value

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ final case class ChatMemberLeft(user: User) extends ChatMember
9090
*
9191
* @param user
9292
* Information about the user
93+
* @param untilDate
94+
* Optional. Date when the user's subscription will expire; Unix time
9395
*/
94-
final case class ChatMemberMember(user: User) extends ChatMember
96+
final case class ChatMemberMember(user: User, untilDate: Option[Int] = Option.empty) extends ChatMember
9597

9698
/** Represents a chat member that was banned in the chat and can't return to the chat or view chat messages.
9799
*

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ sealed trait MaybeInaccessibleMessage {}
1313
* @param messageThreadId
1414
* Optional. Unique identifier of a message thread to which the message belongs; for supergroups only
1515
* @param from
16-
* Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field
17-
* contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
16+
* Optional. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the
17+
* message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats
1818
* @param senderChat
19-
* Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the
20-
* supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically
21-
* forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in
22-
* non-channel chats, if the message was sent on behalf of a chat.
19+
* Optional. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages
20+
* sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's
21+
* discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains
22+
* a fake sender user in non-channel chats.
2323
* @param senderBoostCount
2424
* Optional. If the sender of the message boosted the chat, the number of boosts added by the user
2525
* @param senderBusinessBot

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package telegramium.bots
22

33
sealed trait ReactionType {}
44

5+
/** The reaction is paid. */
6+
case object ReactionTypePaid extends ReactionType
7+
58
/** The reaction is based on an emoji.
69
*
710
* @param emoji

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ case object TransactionPartnerTelegramAds extends TransactionPartner
1414
* Information about the user
1515
* @param invoicePayload
1616
* Optional. Bot-specified invoice payload
17+
* @param paidMedia
18+
* Optional. Information about the paid media bought by the user
1719
*/
18-
final case class TransactionPartnerUser(user: User, invoicePayload: Option[String] = Option.empty)
19-
extends TransactionPartner
20+
final case class TransactionPartnerUser(
21+
user: User,
22+
invoicePayload: Option[String] = Option.empty,
23+
paidMedia: List[iozhik.OpenEnum[PaidMedia]] = List.empty
24+
) extends TransactionPartner
2025

2126
/** Describes a withdrawal transaction with Fragment.
2227
*
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package telegramium.bots.client
2+
3+
import telegramium.bots.ChatId
4+
5+
/** @param chatId
6+
* Unique identifier for the target channel chat or username of the target channel (in the format
7+
* @channelusername)
8+
* @param subscriptionPeriod
9+
* The number of seconds the subscription will be active for before the next payment. Currently, it must always be
10+
* 2592000 (30 days).
11+
* @param subscriptionPrice
12+
* The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a
13+
* member of the chat; 1-2500
14+
* @param name
15+
* Invite link name; 0-32 characters
16+
*/
17+
final case class CreateChatSubscriptionInviteLinkReq(
18+
chatId: ChatId,
19+
subscriptionPeriod: Int,
20+
subscriptionPrice: Int,
21+
name: Option[String] = Option.empty
22+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package telegramium.bots.client
2+
3+
import telegramium.bots.ChatId
4+
5+
/** @param chatId
6+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
7+
* @param inviteLink
8+
* The invite link to edit
9+
* @param name
10+
* Invite link name; 0-32 characters
11+
*/
12+
final case class EditChatSubscriptionInviteLinkReq(
13+
chatId: ChatId,
14+
inviteLink: String,
15+
name: Option[String] = Option.empty
16+
)

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

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,32 @@ trait Methods {
411411
MethodReq[ChatInviteLink]("createChatInviteLink", req.asJson)
412412
}
413413

414+
/** Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users
415+
* administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the
416+
* method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
417+
*
418+
* @param chatId
419+
* Unique identifier for the target channel chat or username of the target channel (in the format
420+
* @channelusername)
421+
* @param subscriptionPeriod
422+
* The number of seconds the subscription will be active for before the next payment. Currently, it must always be
423+
* 2592000 (30 days).
424+
* @param subscriptionPrice
425+
* The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a
426+
* member of the chat; 1-2500
427+
* @param name
428+
* Invite link name; 0-32 characters
429+
*/
430+
def createChatSubscriptionInviteLink(
431+
chatId: ChatId,
432+
subscriptionPeriod: Int,
433+
subscriptionPrice: Int,
434+
name: Option[String] = Option.empty
435+
): Method[ChatInviteLink] = {
436+
val req = CreateChatSubscriptionInviteLinkReq(chatId, subscriptionPeriod, subscriptionPrice, name)
437+
MethodReq[ChatInviteLink]("createChatSubscriptionInviteLink", req.asJson)
438+
}
439+
414440
/** Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for
415441
* this to work and must have the can_manage_topics administrator rights. Returns information about the created topic
416442
* as a ForumTopic object.
@@ -734,9 +760,28 @@ trait Methods {
734760
MethodReq[ChatInviteLink]("editChatInviteLink", req.asJson)
735761
}
736762

763+
/** Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users
764+
* administrator rights. Returns the edited invite link as a ChatInviteLink object.
765+
*
766+
* @param chatId
767+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
768+
* @param inviteLink
769+
* The invite link to edit
770+
* @param name
771+
* Invite link name; 0-32 characters
772+
*/
773+
def editChatSubscriptionInviteLink(
774+
chatId: ChatId,
775+
inviteLink: String,
776+
name: Option[String] = Option.empty
777+
): Method[ChatInviteLink] = {
778+
val req = EditChatSubscriptionInviteLinkReq(chatId, inviteLink, name)
779+
MethodReq[ChatInviteLink]("editChatSubscriptionInviteLink", req.asJson)
780+
}
781+
737782
/** Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in
738-
* the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the
739-
* topic. Returns True on success.
783+
* the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of
784+
* the topic. Returns True on success.
740785
*
741786
* @param chatId
742787
* Unique identifier for the target chat or username of the target supergroup (in the format
@@ -761,8 +806,8 @@ trait Methods {
761806
}
762807

763808
/** Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an
764-
* administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on
765-
* success.
809+
* administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True
810+
* on success.
766811
*
767812
* @param chatId
768813
* Unique identifier for the target chat or username of the target supergroup (in the format
@@ -2361,12 +2406,16 @@ trait Methods {
23612406
MethodReq[Message]("sendMessage", req.asJson)
23622407
}
23632408

2364-
/** Use this method to send paid media to channel chats. On success, the sent Message is returned.
2409+
/** Use this method to send paid media. On success, the sent Message is returned.
23652410
*
23662411
* @param chatId
2367-
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
2412+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername).
2413+
* If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance.
2414+
* Otherwise, they will be credited to the bot's balance.
23682415
* @param starCount
23692416
* The number of Telegram Stars that must be paid to buy access to the media
2417+
* @param businessConnectionId
2418+
* Unique identifier of the business connection on behalf of which the message will be sent
23702419
* @param media
23712420
* A JSON-serialized array describing the media to be sent; up to 10 items
23722421
* @param caption
@@ -2391,6 +2440,7 @@ trait Methods {
23912440
def sendPaidMedia(
23922441
chatId: ChatId,
23932442
starCount: Int,
2443+
businessConnectionId: Option[String] = Option.empty,
23942444
media: List[InputPaidMedia] = List.empty,
23952445
caption: Option[String] = Option.empty,
23962446
parseMode: Option[ParseMode] = Option.empty,
@@ -2404,6 +2454,7 @@ trait Methods {
24042454
val req = SendPaidMediaReq(
24052455
chatId,
24062456
starCount,
2457+
businessConnectionId,
24072458
media,
24082459
caption,
24092460
parseMode,
@@ -3128,7 +3179,7 @@ trait Methods {
31283179

31293180
/** Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically
31303181
* forwarded messages from a channel to its discussion group have the same available reactions as messages in the
3131-
* channel. Returns True on success.
3182+
* channel. Bots can't use paid reactions. Returns True on success.
31323183
*
31333184
* @param chatId
31343185
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -3138,7 +3189,7 @@ trait Methods {
31383189
* @param reaction
31393190
* A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up
31403191
* to one reaction per message. A custom emoji reaction can be used if it is either already present on the message
3141-
* or explicitly allowed by chat administrators.
3192+
* or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
31423193
* @param isBig
31433194
* Pass True to set the reaction with a big animation
31443195
*/

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import telegramium.bots.ReplyParameters
88
import telegramium.bots.KeyboardMarkup
99

1010
/** @param chatId
11-
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
11+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername). If
12+
* the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance.
13+
* Otherwise, they will be credited to the bot's balance.
1214
* @param starCount
1315
* The number of Telegram Stars that must be paid to buy access to the media
16+
* @param businessConnectionId
17+
* Unique identifier of the business connection on behalf of which the message will be sent
1418
* @param media
1519
* A JSON-serialized array describing the media to be sent; up to 10 items
1620
* @param caption
@@ -35,6 +39,7 @@ import telegramium.bots.KeyboardMarkup
3539
final case class SendPaidMediaReq(
3640
chatId: ChatId,
3741
starCount: Int,
42+
businessConnectionId: Option[String] = Option.empty,
3843
media: List[InputPaidMedia] = List.empty,
3944
caption: Option[String] = Option.empty,
4045
parseMode: Option[ParseMode] = Option.empty,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import telegramium.bots.ReactionType
1111
* @param reaction
1212
* A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up
1313
* to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or
14-
* explicitly allowed by chat administrators.
14+
* explicitly allowed by chat administrators. Paid reactions can't be used by bots.
1515
* @param isBig
1616
* Pass True to set the reaction with a big animation
1717
*/

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ object CirceImplicits {
44

55
import io.circe.syntax._
66
import io.circe.{Encoder, Decoder, Json}
7-
import iozhik._
87
import telegramium.bots.InputSticker
98
import telegramium.bots.CirceImplicits._
109
import telegramium.bots.InlineQueryResult
@@ -238,6 +237,19 @@ object CirceImplicits {
238237
)
239238
}
240239

240+
implicit lazy val createchatsubscriptioninvitelinkreqEncoder: Encoder[CreateChatSubscriptionInviteLinkReq] =
241+
(x: CreateChatSubscriptionInviteLinkReq) => {
242+
Json.fromFields(
243+
List(
244+
"chat_id" -> x.chatId.asJson,
245+
"name" -> x.name.asJson,
246+
"subscription_period" -> x.subscriptionPeriod.asJson,
247+
"subscription_price" -> x.subscriptionPrice.asJson,
248+
"method" -> "createChatSubscriptionInviteLink".asJson
249+
).filter(!_._2.isNull)
250+
)
251+
}
252+
241253
implicit lazy val createforumtopicreqEncoder: Encoder[CreateForumTopicReq] =
242254
(x: CreateForumTopicReq) => {
243255
Json.fromFields(
@@ -415,6 +427,18 @@ object CirceImplicits {
415427
)
416428
}
417429

430+
implicit lazy val editchatsubscriptioninvitelinkreqEncoder: Encoder[EditChatSubscriptionInviteLinkReq] =
431+
(x: EditChatSubscriptionInviteLinkReq) => {
432+
Json.fromFields(
433+
List(
434+
"chat_id" -> x.chatId.asJson,
435+
"invite_link" -> x.inviteLink.asJson,
436+
"name" -> x.name.asJson,
437+
"method" -> "editChatSubscriptionInviteLink".asJson
438+
).filter(!_._2.isNull)
439+
)
440+
}
441+
418442
implicit lazy val editforumtopicreqEncoder: Encoder[EditForumTopicReq] =
419443
(x: EditForumTopicReq) => {
420444
Json.fromFields(
@@ -1151,6 +1175,7 @@ object CirceImplicits {
11511175
(x: SendPaidMediaReq) => {
11521176
Json.fromFields(
11531177
List(
1178+
"business_connection_id" -> x.businessConnectionId.asJson,
11541179
"chat_id" -> x.chatId.asJson,
11551180
"star_count" -> x.starCount.asJson,
11561181
"media" -> x.media.asJson,

0 commit comments

Comments
 (0)