Skip to content

Commit

Permalink
(#170) Dependencies: upgrade Funogram to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Nov 9, 2022
1 parent 7397864 commit f21f325
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 54 deletions.
4 changes: 2 additions & 2 deletions Emulsion.Telegram/Emulsion.Telegram.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<Compile Include="Client.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Funogram" Version="2.0.4" />
<PackageReference Include="Funogram.Telegram" Version="6.1.0.1" />
<PackageReference Include="Funogram" Version="2.0.5" />
<PackageReference Include="Funogram.Telegram" Version="6.3.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Telegram/Funogram.fs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ let sendGetFile (botConfig: BotConfig) (fileId: string): Async<File> = async {

let sendMessage (settings: TelegramSettings) (botConfig: BotConfig) (OutgoingMessage content): Async<unit> =
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
Expand Down
64 changes: 27 additions & 37 deletions Emulsion.Tests/Telegram/FunogramTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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() = [|
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -302,12 +296,11 @@ module ReadMessageTests =
[<Fact>]
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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 9 additions & 14 deletions Emulsion.Tests/Telegram/LinkGeneratorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit f21f325

Please sign in to comment.