Skip to content

Commit 0baf57e

Browse files
committed
Telegram Bot API August 18, 2023 updates (v6.8)
1 parent fc85aa5 commit 0baf57e

File tree

13 files changed

+81
-12
lines changed

13 files changed

+81
-12
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-6.7%20(April%2021%2C%202023)-blue)](https://core.telegram.org/bots/api#recent-changes)
3+
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-6.8%20(August%2018%2C%202023)-blue)](https://core.telegram.org/bots/api#recent-changes)
44
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
55
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_2.13)
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-
"8.67.2",
4+
"8.68.0",
55
git.gitCurrentBranch.value,
66
git.gitDescribedVersion.value,
77
git.gitUncommittedChanges.value

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ package telegramium.bots
2525
* Returned only in getChat.
2626
* @param emojiStatusCustomEmojiId
2727
* Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.
28+
* @param emojiStatusExpirationDate
29+
* Optional. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in
30+
* getChat.
2831
* @param bio
2932
* Optional. Bio of the other party in a private chat. Returned only in getChat.
3033
* @param hasPrivateForwards
@@ -83,6 +86,7 @@ final case class Chat(
8386
photo: Option[ChatPhoto] = Option.empty,
8487
activeUsernames: List[String] = List.empty,
8588
emojiStatusCustomEmojiId: Option[String] = Option.empty,
89+
emojiStatusExpirationDate: Option[Int] = Option.empty,
8690
bio: Option[String] = Option.empty,
8791
hasPrivateForwards: Option[Boolean] = Option.empty,
8892
hasRestrictedVoiceAndVideoMessages: Option[Boolean] = Option.empty,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ package telegramium.bots
1919
* @param switchInlineQuery
2020
* Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert
2121
* the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's
22-
* username will be inserted. Note: This offers an easy way for users to start using your bot in inline mode when
23-
* they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this
24-
* case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.
22+
* username will be inserted.
2523
* @param switchInlineQueryCurrentChat
2624
* Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current
2725
* chat's input field. May be empty, in which case only the bot's username will be inserted. This offers a quick way

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ package telegramium.bots
6767
* Optional. Message is a photo, available sizes of the photo
6868
* @param sticker
6969
* Optional. Message is a sticker, information about the sticker
70+
* @param story
71+
* Optional. Message is a forwarded story
7072
* @param video
7173
* Optional. Message is a video, information about the video
7274
* @param videoNote
@@ -199,6 +201,7 @@ final case class Message(
199201
document: Option[Document] = Option.empty,
200202
photo: List[PhotoSize] = List.empty,
201203
sticker: Option[Sticker] = Option.empty,
204+
story: Option[Story.type] = Option.empty,
202205
video: Option[Video] = Option.empty,
203206
videoNote: Option[VideoNote] = Option.empty,
204207
voice: Option[Voice] = Option.empty,

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ package telegramium.bots
44
*
55
* @param pollId
66
* Unique poll identifier
7+
* @param voterChat
8+
* Optional. The chat that changed the answer to the poll, if the voter is anonymous
79
* @param user
8-
* The user, who changed the answer to the poll
10+
* Optional. The user that changed the answer to the poll, if the voter isn't anonymous
911
* @param optionIds
10-
* 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.
12+
* 0-based identifiers of chosen answer options. May be empty if the vote was retracted.
1113
*/
12-
final case class PollAnswer(pollId: String, user: User, optionIds: List[Int] = List.empty)
14+
final case class PollAnswer(
15+
pollId: String,
16+
voterChat: Option[Chat] = Option.empty,
17+
user: Option[User] = Option.empty,
18+
optionIds: List[Int] = List.empty
19+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package telegramium.bots
2+
3+
/** This object represents a message about a forwarded story in the chat. Currently holds no information.
4+
*/
5+
case object Story

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,19 @@ trait Methods {
22812281
MethodReq[Boolean]("promoteChatMember", req.asJson)
22822282
}
22832283

2284+
/** Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in
2285+
* the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True
2286+
* on success.
2287+
*
2288+
* @param chatId
2289+
* Unique identifier for the target chat or username of the target supergroup (in the format
2290+
* @supergroupusername)
2291+
*/
2292+
def unpinAllGeneralForumTopicMessages(chatId: ChatId): Method[Boolean] = {
2293+
val req = UnpinAllGeneralForumTopicMessagesReq(chatId)
2294+
MethodReq[Boolean]("unpinAllGeneralForumTopicMessages", req.asJson)
2295+
}
2296+
22842297
/** Use this method to edit captions of messages. On success, if the edited message is not an inline message, the
22852298
* edited Message is returned, otherwise True is returned.
22862299
*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 supergroup (in the format
7+
* @supergroupusername)
8+
*/
9+
final case class UnpinAllGeneralForumTopicMessagesReq(chatId: ChatId)

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,6 +2407,25 @@ object CirceImplicits {
24072407
}
24082408
}
24092409

2410+
implicit lazy val unpinallgeneralforumtopicmessagesreqEncoder: Encoder[UnpinAllGeneralForumTopicMessagesReq] =
2411+
(x: UnpinAllGeneralForumTopicMessagesReq) => {
2412+
Json.fromFields(
2413+
List(
2414+
"chat_id" -> x.chatId.asJson,
2415+
"method" -> "unpinAllGeneralForumTopicMessages".asJson
2416+
).filter(!_._2.isNull)
2417+
)
2418+
}
2419+
2420+
implicit lazy val unpinallgeneralforumtopicmessagesreqDecoder: Decoder[UnpinAllGeneralForumTopicMessagesReq] =
2421+
Decoder.instance { h =>
2422+
for {
2423+
_chatId <- h.get[ChatId]("chat_id")
2424+
} yield {
2425+
UnpinAllGeneralForumTopicMessagesReq(chatId = _chatId)
2426+
}
2427+
}
2428+
24102429
implicit lazy val editmessagecaptionreqEncoder: Encoder[EditMessageCaptionReq] =
24112430
(x: EditMessageCaptionReq) => {
24122431
Json.fromFields(

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,6 +2816,7 @@ object CirceImplicits {
28162816
"photo" -> x.photo.asJson,
28172817
"active_usernames" -> x.activeUsernames.asJson,
28182818
"emoji_status_custom_emoji_id" -> x.emojiStatusCustomEmojiId.asJson,
2819+
"emoji_status_expiration_date" -> x.emojiStatusExpirationDate.asJson,
28192820
"bio" -> x.bio.asJson,
28202821
"has_private_forwards" -> x.hasPrivateForwards.asJson,
28212822
"has_restricted_voice_and_video_messages" -> x.hasRestrictedVoiceAndVideoMessages.asJson,
@@ -2851,6 +2852,7 @@ object CirceImplicits {
28512852
_photo <- h.get[Option[ChatPhoto]]("photo")
28522853
_activeUsernames <- h.getOrElse[List[String]]("active_usernames")(List.empty)
28532854
_emojiStatusCustomEmojiId <- h.get[Option[String]]("emoji_status_custom_emoji_id")
2855+
_emojiStatusExpirationDate <- h.get[Option[Int]]("emoji_status_expiration_date")
28542856
_bio <- h.get[Option[String]]("bio")
28552857
_hasPrivateForwards <- h.get[Option[Boolean]]("has_private_forwards")
28562858
_hasRestrictedVoiceAndVideoMessages <- h.get[Option[Boolean]]("has_restricted_voice_and_video_messages")
@@ -2881,6 +2883,7 @@ object CirceImplicits {
28812883
photo = _photo,
28822884
activeUsernames = _activeUsernames,
28832885
emojiStatusCustomEmojiId = _emojiStatusCustomEmojiId,
2886+
emojiStatusExpirationDate = _emojiStatusExpirationDate,
28842887
bio = _bio,
28852888
hasPrivateForwards = _hasPrivateForwards,
28862889
hasRestrictedVoiceAndVideoMessages = _hasRestrictedVoiceAndVideoMessages,
@@ -3538,6 +3541,7 @@ object CirceImplicits {
35383541
Json.fromFields(
35393542
List(
35403543
"poll_id" -> x.pollId.asJson,
3544+
"voter_chat" -> x.voterChat.asJson,
35413545
"user" -> x.user.asJson,
35423546
"option_ids" -> x.optionIds.asJson
35433547
).filter(!_._2.isNull)
@@ -3548,10 +3552,11 @@ object CirceImplicits {
35483552
Decoder.instance { h =>
35493553
for {
35503554
_pollId <- h.get[String]("poll_id")
3551-
_user <- h.get[User]("user")
3555+
_voterChat <- h.get[Option[Chat]]("voter_chat")
3556+
_user <- h.get[Option[User]]("user")
35523557
_optionIds <- h.getOrElse[List[Int]]("option_ids")(List.empty)
35533558
} yield {
3554-
PollAnswer(pollId = _pollId, user = _user, optionIds = _optionIds)
3559+
PollAnswer(pollId = _pollId, voterChat = _voterChat, user = _user, optionIds = _optionIds)
35553560
}
35563561
}
35573562

@@ -3895,6 +3900,9 @@ object CirceImplicits {
38953900
}
38963901
}
38973902

3903+
implicit lazy val storyEncoder: Encoder[Story.type] = (_: Story.type) => ().asJson
3904+
implicit lazy val storyDecoder: Decoder[Story.type] = (_: HCursor) => Right(Story)
3905+
38983906
implicit lazy val passportdataEncoder: Encoder[PassportData] =
38993907
(x: PassportData) => {
39003908
Json.fromFields(
@@ -4573,6 +4581,7 @@ object CirceImplicits {
45734581
"document" -> x.document.asJson,
45744582
"photo" -> x.photo.asJson,
45754583
"sticker" -> x.sticker.asJson,
4584+
"story" -> x.story.asJson,
45764585
"video" -> x.video.asJson,
45774586
"video_note" -> x.videoNote.asJson,
45784587
"voice" -> x.voice.asJson,
@@ -4651,6 +4660,7 @@ object CirceImplicits {
46514660
_document <- h.get[Option[Document]]("document")
46524661
_photo <- h.getOrElse[List[PhotoSize]]("photo")(List.empty)
46534662
_sticker <- h.get[Option[Sticker]]("sticker")
4663+
_story <- h.get[Option[Story.type]]("story")
46544664
_video <- h.get[Option[Video]]("video")
46554665
_videoNote <- h.get[Option[VideoNote]]("video_note")
46564666
_voice <- h.get[Option[Voice]]("voice")
@@ -4726,6 +4736,7 @@ object CirceImplicits {
47264736
document = _document,
47274737
photo = _photo,
47284738
sticker = _sticker,
4739+
story = _story,
47294740
video = _video,
47304741
videoNote = _videoNote,
47314742
voice = _voice,

telegramium-high/src/test/scala/telegramium/bots/high/LongPollBotISpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class LongPollBotISpec
166166
mockServerClient
167167
.when(sendMessageRequest("onPollAnswer"))
168168
.respond(sendMessageResponse)
169-
bot.onUpdate(testUpdate.copy(pollAnswer = PollAnswer("0", testUser).some)).unsafeRunSync()
169+
bot.onUpdate(testUpdate.copy(pollAnswer = PollAnswer("0", user = testUser.some).some)).unsafeRunSync()
170170
}
171171

172172
"The bot's chat member status was updated in a chat" in {

telegramium-high/src/test/scala/telegramium/bots/high/WebhookBotISpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class WebhookBotISpec
297297
mockServerClient
298298
.when(sendMessageRequest("onPollAnswer"))
299299
.respond(sendMessageResponse)
300-
verifyResult(testUpdate.copy(pollAnswer = PollAnswer("0", testUser).some), "onPollAnswerReply")
300+
verifyResult(testUpdate.copy(pollAnswer = PollAnswer("0", user = testUser.some).some), "onPollAnswerReply")
301301
}
302302

303303
"The bot's chat member status was updated in a chat" in {

0 commit comments

Comments
 (0)