Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl albums #263

Merged
merged 6 commits into from
Sep 12, 2024
Merged

feat: impl albums #263

merged 6 commits into from
Sep 12, 2024

Conversation

AndrielFR
Copy link
Contributor

  • add InputMedia struct.
  • add send_album, reply_album and respond_album methods.

lib/grammers-client/src/client/messages.rs Outdated Show resolved Hide resolved
lib/grammers-client/src/client/messages.rs Show resolved Hide resolved
lib/grammers-client/src/client/messages.rs Outdated Show resolved Hide resolved
lib/grammers-client/src/client/messages.rs Outdated Show resolved Hide resolved
lib/grammers-client/src/client/messages.rs Outdated Show resolved Hide resolved
lib/grammers-client/src/client/messages.rs Outdated Show resolved Hide resolved
lib/grammers-client/src/types/input_media.rs Outdated Show resolved Hide resolved
lib/grammers-client/src/types/input_media.rs Show resolved Hide resolved
/// Shorthand for `Client::send_album`.
pub async fn respond_album(
&self,
medias: Vec<InputMedia>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had in mind a slice of InputMedia. But perhaps using a Vec is okay, as it means we can take ownership and reduce clones. Not sure what's best.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Vec is the best option right now

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely convinced. But we can definitely merge it like this for the time being and see how it feels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@dimentyy
Copy link
Contributor

Isn't InputMedia just a smaller version of InputMessage? Why not use InputMessage?

@Lonami
Copy link
Owner

Lonami commented Sep 12, 2024

Isn't InputMedia just a smaller version of InputMessage? Why not use InputMessage?

Yes, but this was deliberate, because not all messages are valid for album media.

I think a new type is justified, because albums require media to be set, while InputMessage don't. We would have to add even more validations, and then return Err, and the current Error type used by the client methods is already complex enough. So I'm not sure it's worth reusing the type.

What I did consider however, was using InputMedia for attaching it to the InputMessage. But that's a different problem entirely.

@Lonami Lonami merged commit 612fc03 into Lonami:master Sep 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants