Skip to content

Commit

Permalink
Telegram Bot API July 31, 2024 updates (v7.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnspade committed Aug 2, 2024
1 parent d1b1bb9 commit ac787e2
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion telegramium-core/src/main/scala/telegramium/bots/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -1400,16 +1400,19 @@ 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.
*/
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)
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}
Expand Down Expand Up @@ -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)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}
Expand All @@ -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,
Expand All @@ -6797,7 +6799,8 @@ object CirceImplicits {
canJoinGroups = _canJoinGroups,
canReadAllGroupMessages = _canReadAllGroupMessages,
supportsInlineQueries = _supportsInlineQueries,
canConnectToBusiness = _canConnectToBusiness
canConnectToBusiness = _canConnectToBusiness,
hasMainWebApp = _hasMainWebApp
)
}
}
Expand Down

0 comments on commit ac787e2

Please sign in to comment.