From 9f0fe3520d9a666bdff69a61d72fc5676c8acad6 Mon Sep 17 00:00:00 2001 From: OlegYch Date: Wed, 17 Jul 2024 18:03:57 +0200 Subject: [PATCH] CopyMessage returns MessageId, fixes #410 (#411) --- .../com/bot4s/telegram/marshalling/CirceDecoders.scala | 1 + .../com/bot4s/telegram/marshalling/CirceEncoders.scala | 3 ++- core/src/com/bot4s/telegram/methods/CopyMessage.scala | 4 ++-- core/src/com/bot4s/telegram/models/MessageId.scala | 10 ++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 core/src/com/bot4s/telegram/models/MessageId.scala diff --git a/core/src/com/bot4s/telegram/marshalling/CirceDecoders.scala b/core/src/com/bot4s/telegram/marshalling/CirceDecoders.scala index de161499..539c4bb4 100644 --- a/core/src/com/bot4s/telegram/marshalling/CirceDecoders.scala +++ b/core/src/com/bot4s/telegram/marshalling/CirceDecoders.scala @@ -175,6 +175,7 @@ trait CirceDecoders extends StrictLogging { implicit val stickerDecoder: Decoder[Sticker] = deriveDecoder[Sticker] implicit val messageDecoder: Decoder[Message] = deriveDecoder[Message] + implicit val messageIdDecoder: Decoder[MessageId] = deriveDecoder[MessageId] implicit val callbackQueryDecoder: Decoder[CallbackQuery] = deriveDecoder[CallbackQuery] implicit val stickerSetDecoder: Decoder[StickerSet] = deriveDecoder[StickerSet] diff --git a/core/src/com/bot4s/telegram/marshalling/CirceEncoders.scala b/core/src/com/bot4s/telegram/marshalling/CirceEncoders.scala index 21c70447..a778420c 100644 --- a/core/src/com/bot4s/telegram/marshalling/CirceEncoders.scala +++ b/core/src/com/bot4s/telegram/marshalling/CirceEncoders.scala @@ -57,7 +57,8 @@ trait CirceEncoders { implicit val animationEncoder: Encoder[Animation] = deriveConfiguredEncoder[Animation] implicit val gameEncoder: Encoder[Game] = deriveConfiguredEncoder[Game] - implicit val messageEncoder: Encoder[Message] = deriveConfiguredEncoder[Message] + implicit val messageEncoder: Encoder[Message] = deriveConfiguredEncoder[Message] + implicit val messageIdEncoder: Encoder[MessageId] = deriveConfiguredEncoder[MessageId] implicit val messageEntityTypeEncoder: Encoder[MessageEntityType] = Encoder[String].contramap[MessageEntityType](e => CaseConversions.snakenize(e.toString)) diff --git a/core/src/com/bot4s/telegram/methods/CopyMessage.scala b/core/src/com/bot4s/telegram/methods/CopyMessage.scala index 0c4afd7a..dac1d1c9 100644 --- a/core/src/com/bot4s/telegram/methods/CopyMessage.scala +++ b/core/src/com/bot4s/telegram/methods/CopyMessage.scala @@ -1,7 +1,7 @@ package com.bot4s.telegram.methods import ParseMode.ParseMode -import com.bot4s.telegram.models.{ ChatId, Message, MessageEntity, ReplyMarkup } +import com.bot4s.telegram.models.{ ChatId, MessageEntity, MessageId, ReplyMarkup } /** * Use this method to copy messages of any kind. @@ -39,4 +39,4 @@ case class CopyMessage( allowSendingWithoutReply: Option[Boolean] = None, replyMarkup: Option[ReplyMarkup] = None, messageThreadId: Option[Int] = None -) extends JsonRequest[Message] +) extends JsonRequest[MessageId] diff --git a/core/src/com/bot4s/telegram/models/MessageId.scala b/core/src/com/bot4s/telegram/models/MessageId.scala new file mode 100644 index 00000000..8f323fa0 --- /dev/null +++ b/core/src/com/bot4s/telegram/models/MessageId.scala @@ -0,0 +1,10 @@ +package com.bot4s.telegram.models + +/** + * This object represents a unique message identifier. + * + * @param messageId Unique message identifier + */ +case class MessageId( + messageId: Int +)