Skip to content

Commit

Permalink
fix(client): handle external media types in edit inline bot message
Browse files Browse the repository at this point in the history
Refactored the `edit_inline_bot_message` method to properly handle external media types such as `PhotoExternal` and `DocumentExternal`. This ensures that the media is correctly passed to the `EditInlineBotMessage` function.
  • Loading branch information
AndrielFR authored and Lonami committed Jan 25, 2025
1 parent ca27bda commit b2ebb36
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/grammers-client/src/client/bots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ impl Client {
) -> Result<bool, InvocationError> {
let message: InputMessage = input_message.into();
let entities = parse_mention_entities(self, message.entities);
let result = if message.media.is_some() {
if message.media.as_ref().is_some_and(|media| {
!matches!(
media,
tl::enums::InputMedia::PhotoExternal(_)
| tl::enums::InputMedia::DocumentExternal(_),
)
}) {
let dc_id = message_id.dc_id();
self.invoke_in_dc(
&tl::functions::messages::EditInlineBotMessage {
Expand All @@ -180,19 +186,18 @@ impl Client {
},
dc_id,
)
.await?
.await
} else {
self.invoke(&tl::functions::messages::EditInlineBotMessage {
id: message_id,
message: Some(message.text),
media: None,
media: message.media,
entities,
no_webpage: !message.link_preview,
reply_markup: message.reply_markup,
invert_media: message.invert_media,
})
.await?
};
Ok(result)
.await
}
}
}

0 comments on commit b2ebb36

Please sign in to comment.