nadia
nadia copied to clipboard
Sending media group raises FunctionClauseError
Hello,
thank you for developing this library.
I have been trying to send a media group (e.g. multiple images in one message) and I encounter the following issue:
iex(3)> Nadia.API.request("sendMediaGroup", [chat_id: chat_id, media: Jason.encode!([%{type: "photo", media: file_id_1}, %{type: "photo", media: file_id_2}])])
** (FunctionClauseError) no function clause matching in anonymous fn/2 in Kernel.struct/2
The following arguments were given to anonymous fn/2 in Kernel.struct/2:
# 1
%{
chat: %{first_name: "first_name", id: 123456789, type: "private"},
date: 1606318961,
from: %{...},
media_group_id: "...",
message_id: 30,
photo: [
%{
file_id: "...",
file_size: 544,
file_unique_id: "...",
height: 38,
width: 64
}
]
}
# 2
%Nadia.Model.Message{
audio: nil,
caption: nil,
channel_chat_created: nil,
chat: nil,
contact: nil,
date: nil,
delete_chat_photo: nil,
document: nil,
edit_date: nil,
entities: nil,
forward_date: nil,
forward_from: nil,
forward_from_chat: nil,
from: nil,
group_chat_created: nil,
left_chat_member: nil,
location: nil,
message_id: nil,
migrate_from_chat_id: nil,
migrate_to_chat_id: nil,
new_chat_member: nil,
new_chat_photo: [],
new_chat_title: nil,
photo: [],
pinned_message: nil,
reply_to_message: nil,
sticker: nil,
supergroup_chat_created: nil,
text: nil,
venue: nil,
video: nil,
voice: nil
}
(elixir) lib/kernel.ex:2112: anonymous fn/2 in Kernel.struct/2
(elixir) lib/enum.ex:1948: Enum."-reduce/3-lists^foldl/2-0-"/3
(nadia) lib/nadia/api.ex:15: Nadia.API.process_response/2
The message is sent correctly, but it crashes on parsing the response. Would be nice if you could add support for that :-)