diff --git a/README.md b/README.md index 489712a..9bcda06 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # F[Tg] - Telegramium -[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-7.7%20(July%207%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes) +[![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) [![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) diff --git a/build.sbt b/build.sbt index 3add47b..ddae358 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ enablePlugins(GitPlugin) ThisBuild / version := Version.mkVersion( - "9.77.0", + "9.78.0", git.gitCurrentBranch.value, git.gitDescribedVersion.value, git.gitUncommittedChanges.value diff --git a/telegramium-core/src/main/scala/telegramium/bots/User.scala b/telegramium-core/src/main/scala/telegramium/bots/User.scala index 0e37eec..f73635f 100644 --- a/telegramium-core/src/main/scala/telegramium/bots/User.scala +++ b/telegramium-core/src/main/scala/telegramium/bots/User.scala @@ -29,6 +29,8 @@ package telegramium.bots * @param canConnectToBusiness * Optional. True, if the bot can be connected to a Telegram Business account to receive its messages. Returned only * in getMe. + * @param hasMainWebApp + * Optional. True, if the bot has a main Web App. Returned only in getMe. */ final case class User( id: Long, @@ -42,5 +44,6 @@ final case class User( canJoinGroups: Option[Boolean] = Option.empty, canReadAllGroupMessages: Option[Boolean] = Option.empty, supportsInlineQueries: Option[Boolean] = Option.empty, - canConnectToBusiness: Option[Boolean] = Option.empty + canConnectToBusiness: Option[Boolean] = Option.empty, + hasMainWebApp: Option[Boolean] = Option.empty ) diff --git a/telegramium-core/src/main/scala/telegramium/bots/client/Methods.scala b/telegramium-core/src/main/scala/telegramium/bots/client/Methods.scala index 1e0831d..5e3f668 100644 --- a/telegramium-core/src/main/scala/telegramium/bots/client/Methods.scala +++ b/telegramium-core/src/main/scala/telegramium/bots/client/Methods.scala @@ -1400,6 +1400,8 @@ trait Methods { * Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param messageId * Identifier of a message to pin + * @param businessConnectionId + * Unique identifier of the business connection on behalf of which the message will be pinned * @param disableNotification * Pass True if it is not necessary to send a notification to all chat members about the new pinned message. * Notifications are always disabled in channels and private chats. @@ -1407,9 +1409,10 @@ trait Methods { def pinChatMessage( chatId: ChatId, messageId: Int, + businessConnectionId: Option[String] = Option.empty, disableNotification: Option[Boolean] = Option.empty ): Method[Boolean] = { - val req = PinChatMessageReq(chatId, messageId, disableNotification) + val req = PinChatMessageReq(chatId, messageId, businessConnectionId, disableNotification) MethodReq[Boolean]("pinChatMessage", req.asJson) } @@ -3321,10 +3324,10 @@ trait Methods { * @param thumbnail * A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of * exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see - * https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), - * or a WEBM video with the thumbnail up to 32 kilobytes in size; see - * https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a - * file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for + * https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a + * WEBM video with the thumbnail up to 32 kilobytes in size; see + * https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id + * as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for * Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video * sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first * sticker is used as the thumbnail. @@ -3542,12 +3545,18 @@ trait Methods { * * @param chatId * Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param businessConnectionId + * Unique identifier of the business connection on behalf of which the message will be unpinned * @param messageId - * Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be - * unpinned. + * Identifier of the message to unpin. Required if business_connection_id is specified. If not specified, the most + * recent pinned message (by sending date) will be unpinned. */ - def unpinChatMessage(chatId: ChatId, messageId: Option[Int] = Option.empty): Method[Boolean] = { - val req = UnpinChatMessageReq(chatId, messageId) + def unpinChatMessage( + chatId: ChatId, + businessConnectionId: Option[String] = Option.empty, + messageId: Option[Int] = Option.empty + ): Method[Boolean] = { + val req = UnpinChatMessageReq(chatId, businessConnectionId, messageId) MethodReq[Boolean]("unpinChatMessage", req.asJson) } diff --git a/telegramium-core/src/main/scala/telegramium/bots/client/PinChatMessageReq.scala b/telegramium-core/src/main/scala/telegramium/bots/client/PinChatMessageReq.scala index 29c2153..1ff6d31 100644 --- a/telegramium-core/src/main/scala/telegramium/bots/client/PinChatMessageReq.scala +++ b/telegramium-core/src/main/scala/telegramium/bots/client/PinChatMessageReq.scala @@ -6,8 +6,15 @@ import telegramium.bots.ChatId * Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param messageId * Identifier of a message to pin + * @param businessConnectionId + * Unique identifier of the business connection on behalf of which the message will be pinned * @param disableNotification * Pass True if it is not necessary to send a notification to all chat members about the new pinned message. * Notifications are always disabled in channels and private chats. */ -final case class PinChatMessageReq(chatId: ChatId, messageId: Int, disableNotification: Option[Boolean] = Option.empty) +final case class PinChatMessageReq( + chatId: ChatId, + messageId: Int, + businessConnectionId: Option[String] = Option.empty, + disableNotification: Option[Boolean] = Option.empty +) diff --git a/telegramium-core/src/main/scala/telegramium/bots/client/SetStickerSetThumbnailReq.scala b/telegramium-core/src/main/scala/telegramium/bots/client/SetStickerSetThumbnailReq.scala index 32b8f66..b448e82 100644 --- a/telegramium-core/src/main/scala/telegramium/bots/client/SetStickerSetThumbnailReq.scala +++ b/telegramium-core/src/main/scala/telegramium/bots/client/SetStickerSetThumbnailReq.scala @@ -12,13 +12,12 @@ import telegramium.bots.IFile * @param thumbnail * A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of * exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see - * https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or - * a WEBM video with the thumbnail up to 32 kilobytes in size; see - * https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a - * file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for - * Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video - * sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first - * sticker is used as the thumbnail. + * https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a WEBM + * video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for + * video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the + * Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one + * using multipart/form-data. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, + * then the thumbnail is dropped and the first sticker is used as the thumbnail. */ final case class SetStickerSetThumbnailReq( name: String, diff --git a/telegramium-core/src/main/scala/telegramium/bots/client/UnpinChatMessageReq.scala b/telegramium-core/src/main/scala/telegramium/bots/client/UnpinChatMessageReq.scala index c83880a..2e4c990 100644 --- a/telegramium-core/src/main/scala/telegramium/bots/client/UnpinChatMessageReq.scala +++ b/telegramium-core/src/main/scala/telegramium/bots/client/UnpinChatMessageReq.scala @@ -4,8 +4,14 @@ import telegramium.bots.ChatId /** @param chatId * Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param businessConnectionId + * Unique identifier of the business connection on behalf of which the message will be unpinned * @param messageId - * Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be - * unpinned. + * Identifier of the message to unpin. Required if business_connection_id is specified. If not specified, the most + * recent pinned message (by sending date) will be unpinned. */ -final case class UnpinChatMessageReq(chatId: ChatId, messageId: Option[Int] = Option.empty) +final case class UnpinChatMessageReq( + chatId: ChatId, + businessConnectionId: Option[String] = Option.empty, + messageId: Option[Int] = Option.empty +) diff --git a/telegramium-core/src/main/scala/telegramium/bots/client/package.scala b/telegramium-core/src/main/scala/telegramium/bots/client/package.scala index e2e9edc..a5ef5fc 100644 --- a/telegramium-core/src/main/scala/telegramium/bots/client/package.scala +++ b/telegramium-core/src/main/scala/telegramium/bots/client/package.scala @@ -799,10 +799,11 @@ object CirceImplicits { (x: PinChatMessageReq) => { Json.fromFields( List( - "chat_id" -> x.chatId.asJson, - "message_id" -> x.messageId.asJson, - "disable_notification" -> x.disableNotification.asJson, - "method" -> "pinChatMessage".asJson + "business_connection_id" -> x.businessConnectionId.asJson, + "chat_id" -> x.chatId.asJson, + "message_id" -> x.messageId.asJson, + "disable_notification" -> x.disableNotification.asJson, + "method" -> "pinChatMessage".asJson ).filter(!_._2.isNull) ) } @@ -1700,9 +1701,10 @@ object CirceImplicits { (x: UnpinChatMessageReq) => { Json.fromFields( List( - "chat_id" -> x.chatId.asJson, - "message_id" -> x.messageId.asJson, - "method" -> "unpinChatMessage".asJson + "business_connection_id" -> x.businessConnectionId.asJson, + "chat_id" -> x.chatId.asJson, + "message_id" -> x.messageId.asJson, + "method" -> "unpinChatMessage".asJson ).filter(!_._2.isNull) ) } diff --git a/telegramium-core/src/main/scala/telegramium/bots/package.scala b/telegramium-core/src/main/scala/telegramium/bots/package.scala index 26386e4..f5183da 100644 --- a/telegramium-core/src/main/scala/telegramium/bots/package.scala +++ b/telegramium-core/src/main/scala/telegramium/bots/package.scala @@ -6764,7 +6764,8 @@ object CirceImplicits { "can_join_groups" -> x.canJoinGroups.asJson, "can_read_all_group_messages" -> x.canReadAllGroupMessages.asJson, "supports_inline_queries" -> x.supportsInlineQueries.asJson, - "can_connect_to_business" -> x.canConnectToBusiness.asJson + "can_connect_to_business" -> x.canConnectToBusiness.asJson, + "has_main_web_app" -> x.hasMainWebApp.asJson ).filter(!_._2.isNull) ) } @@ -6784,6 +6785,7 @@ object CirceImplicits { _canReadAllGroupMessages <- h.get[Option[Boolean]]("can_read_all_group_messages") _supportsInlineQueries <- h.get[Option[Boolean]]("supports_inline_queries") _canConnectToBusiness <- h.get[Option[Boolean]]("can_connect_to_business") + _hasMainWebApp <- h.get[Option[Boolean]]("has_main_web_app") } yield { User( id = _id, @@ -6797,7 +6799,8 @@ object CirceImplicits { canJoinGroups = _canJoinGroups, canReadAllGroupMessages = _canReadAllGroupMessages, supportsInlineQueries = _supportsInlineQueries, - canConnectToBusiness = _canConnectToBusiness + canConnectToBusiness = _canConnectToBusiness, + hasMainWebApp = _hasMainWebApp ) } }