From f21f3255bc07415e9b59edd2f9673be15700a727 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Wed, 9 Nov 2022 22:25:27 +0100 Subject: [PATCH] (#170) Dependencies: upgrade Funogram to the latest version --- Emulsion.Telegram/Emulsion.Telegram.fsproj | 4 +- Emulsion.Telegram/Funogram.fs | 2 +- Emulsion.Tests/Telegram/FunogramTests.fs | 64 ++++++++----------- Emulsion.Tests/Telegram/LinkGeneratorTests.fs | 23 +++---- 4 files changed, 39 insertions(+), 54 deletions(-) diff --git a/Emulsion.Telegram/Emulsion.Telegram.fsproj b/Emulsion.Telegram/Emulsion.Telegram.fsproj index a25ed85a..2360231b 100644 --- a/Emulsion.Telegram/Emulsion.Telegram.fsproj +++ b/Emulsion.Telegram/Emulsion.Telegram.fsproj @@ -11,8 +11,8 @@ - - + + diff --git a/Emulsion.Telegram/Funogram.fs b/Emulsion.Telegram/Funogram.fs index aadf6ae1..10b5e7d5 100644 --- a/Emulsion.Telegram/Funogram.fs +++ b/Emulsion.Telegram/Funogram.fs @@ -356,7 +356,7 @@ let sendGetFile (botConfig: BotConfig) (fileId: string): Async = async { let sendMessage (settings: TelegramSettings) (botConfig: BotConfig) (OutgoingMessage content): Async = let sendHtmlMessage (groupId: ChatId) text = - Req.SendMessage.Make(groupId, text, ParseMode.HTML) + Req.SendMessage.Make(chatId = groupId, text = text, parseMode = ParseMode.HTML) let groupId = Int(int64 settings.GroupId) let message = prepareHtmlMessage content diff --git a/Emulsion.Tests/Telegram/FunogramTests.fs b/Emulsion.Tests/Telegram/FunogramTests.fs index ba0b9de3..176572aa 100644 --- a/Emulsion.Tests/Telegram/FunogramTests.fs +++ b/Emulsion.Tests/Telegram/FunogramTests.fs @@ -57,24 +57,20 @@ let private createForwardedMessage from (forwarded: Funogram.Telegram.Types.Mess ForwardFrom = forwarded.From Text = forwarded.Text } -let private createStickerMessage from emoji = +let private createStickerMessage from (emoji: string option) = { defaultMessage with From = Some from Chat = currentChat - Sticker = Some { - FileId = "" - FileUniqueId = "" - Width = 0 - Height = 0 - Thumb = None - FileSize = None - Emoji = emoji - SetName = None - MaskPosition = None - IsAnimated = false - IsVideo = false - PremiumAnimation = None - } + Sticker = Some <| Sticker.Create( + fileId = "", + fileUniqueId = "", + ``type`` = "", + width = 0, + height = 0, + isAnimated = false, + isVideo = false, + ?emoji = emoji + ) } let private createPhoto() = [| @@ -137,14 +133,12 @@ let private authoredTelegramReplyMessage author text replyTo = let private eventTelegramMessage text = { main = Event { text = text }; replyTo = None } -let private createEntity t offset length url = { - Type = t - Offset = offset - Length = length - Url = Some url - User = None - Language = None -} +let private createEntity t offset length url = MessageEntity.Create( + ``type`` = t, + offset = offset, + length = length, + url = url +) let private createEntities t offset length url = Some <| [| createEntity t offset length url @@ -302,12 +296,11 @@ module ReadMessageTests = [] let readNoneTextLinkMessage() = let message = { createMessage (Some originalUser) (Some "Original text") with - Entities = Some <| [| { Type = "text_link" - Url = None - Offset = 0L - Length = 5L - User = None - Language = None } |] } + Entities = Some <| [| MessageEntity.Create( + ``type`` = "text_link", + offset = 0L, + length = 5L + ) |] } Assert.Equal( authoredTelegramMessage "@originalUser" "Original text", readMessage message @@ -541,14 +534,11 @@ module ReadMessageTests = with Id = selfUserId } Text = Some "Myself\nTests" Entities = Some <| [| - { - Type = "bold" - Offset = 0L - Length = int64 "Myself".Length - Url = None - User = None - Language = None - } + MessageEntity.Create( + ``type`` = "bold", + offset = 0L, + length = int64 "Myself".Length + ) |] } let reply = createReplyMessage (Some replyingUser) (Some "reply text") originalMessage diff --git a/Emulsion.Tests/Telegram/LinkGeneratorTests.fs b/Emulsion.Tests/Telegram/LinkGeneratorTests.fs index e4960554..32838a20 100644 --- a/Emulsion.Tests/Telegram/LinkGeneratorTests.fs +++ b/Emulsion.Tests/Telegram/LinkGeneratorTests.fs @@ -98,20 +98,15 @@ let private messageWithMultiplePhotos = let private messageWithSticker = { messageTemplate with - Sticker = Some { - FileId = fileId1 - FileUniqueId = fileId1 - Width = 0 - Height = 0 - IsAnimated = false - Thumb = None - Emoji = None - SetName = None - MaskPosition = None - FileSize = None - IsVideo = false - PremiumAnimation = None - } + Sticker = Some <| Sticker.Create( + fileId = fileId1, + fileUniqueId = fileId1, + ``type`` = "", + width = 0, + height = 0, + isAnimated = false, + isVideo = false + ) } let private messageWithVideo =