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

Feature/support tba 6.6 #1040

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

syrtcevvi
Copy link
Contributor

Close #1035

For more information, see the changes on the Telegram page and the teloxide-core CHANGELOG

@teloxidebot
Copy link
Collaborator

r? @WaffleLapkin

(teloxidebot has picked a reviewer for you, use r? to override)

@teloxidebot teloxidebot added A-requester Area: requester trait, bot adaptors A-requests Area: representation of telegram bot API requests/methods A-tba-types Area: representation of telegram bot API types C-core crate: teloxide-core C-main crate: teloxide S-waiting-on-review Status: Awaiting review from the assignee labels Apr 4, 2024
@syrtcevvi
Copy link
Contributor Author

I bet one day they will rename "thumbnail" back to "thumb"...

CHANGELOG.md changes in progress

Comment on lines 48 to 62
- Support for TBA 6.6 ([#1040](pr1040))
- Add methods for working with bot's description:
- `set_my_description`
- `get_my_description`
- `set_my_short_description`
- `get_my_short_description`
- Add methods for working with sticker sets:
- `set_custom_emoji_sticker_set_thumbnail`
- `set_sticker_set_title`
- `delete_sticker_set`
- `set_sticker_emoji_list`
- `set_sticker_keywords`
- `set_sticker_mask_position`
- Add parameter `emoji` to the `send_sticker` method
- Add field `needs_repainting` to the struct `Sticker`
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be missing some changes from the bot API. Did you forget to do them, or only to document them?

  1. Added support for the creation of custom emoji sticker sets in createNewStickerSet.
  2. Added the parameter needs_repainting to the method createNewStickerSet to automatically change the color of emoji based on context (e.g., use text color in messages, accent color in statuses, etc.).
  3. Replaced the parameters png_sticker, tgs_sticker, webm_sticker, emojis and mask_position in the method addStickerToSet with the parameter sticker of the type InputSticker.
  4. Added support for the creation of sticker sets with multiple initial stickers in createNewStickerSet by replacing the parameters png_sticker, tgs_sticker, webm_sticker, emojis and mask_position with the parameters stickers and sticker_format.
  5. Added support for .WEBP files in createNewStickerSet and addStickerToSet.
    • probably no code changes, but the documentation should be adjusted
  6. Added support for .WEBP, .TGS, and .WEBM files in uploadStickerFile by replacing the parameter png_sticker in the method uploadStickerFile with the parameters sticker and sticker_format.
  7. Added the ability to specify search keywords for stickers added to sticker sets.
  8. Renamed the method setStickerSetThumb to setStickerSetThumbnail and its parameter thumb to thumbnail.

Copy link
Contributor Author

@syrtcevvi syrtcevvi Apr 7, 2024

Choose a reason for hiding this comment

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

When I was making the to-do list I just copied changes one by one from the telegram's changelog. Eventually I noticed that some of them are internal changes with no code changes, so I left them as is.

I did all necessary changes according to the list except the first one ("Added support for the creation of custom emoji sticker sets in createNewStickerSet."). It is documented in a strange way and if I'm not mistaken doesn't require any code changes. (or it refers to other changes which are implemented)

Yeah, it seems that I forgot to document some changes, will adjust it soon

@syrtcevvi
Copy link
Contributor Author

@teloxidebot review

Comment on lines +59 to +60
// FIXME: CreateNewStickerSet has to be be only Debug + Clone + Serialize (maybe
// better fix?)
Copy link
Member

Choose a reason for hiding this comment

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

wdym?

Comment on lines +19 to +21
/// Format of the added sticker, must be one of “static” for a .WEBP or .PNG
/// image, “animated” for a .TGS animation, “video” for a WEBM video
pub format: StickerFormat,
Copy link
Member

Choose a reason for hiding this comment

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

This field was only added in 7.2.

/// PNG image with the sticker, must be up to 512 kilobytes in size,
/// dimensions must not exceed 512px, and either width or height must be
/// exactly 512px.
pub struct InputSticker {
Copy link
Member

Choose a reason for hiding this comment

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

Have you tested that all methods that take InputSticker still work with this different serialization?

Comment on lines +54 to +58

/// True, if the sticker must be repainted to a text color in messages, the
/// color of the Telegram Premium badge in emoji status, white color on
/// chat photos, or another appropriate color in other places
pub needs_repainting: Option<True>,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// True, if the sticker must be repainted to a text color in messages, the
/// color of the Telegram Premium badge in emoji status, white color on
/// chat photos, or another appropriate color in other places
pub needs_repainting: Option<True>,
/// `true`, if the sticker must be repainted to a text color in messages, the
/// color of the Telegram Premium badge in emoji status, white color on
/// chat photos, or another appropriate color in other places
#[serde(default)]
pub needs_repainting: bool,

@@ -44,13 +44,18 @@ pub struct Sticker {
pub format: StickerFormat,

/// Sticker thumbnail in the `.webp` or `.jpg` format.
pub thumb: Option<PhotoSize>,
pub thumbnail: Option<PhotoSize>,

/// Emoji associated with the sticker.
pub emoji: Option<String>,

/// Name of the sticker set to which the sticker belongs.
pub set_name: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't all those options have #[serde(default)]s? 🤔

Could you investigate? (separately from this PR)

@@ -107,6 +127,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Methods of the Message type: `delete_chat_photo`, `group_chat_created`, `super_group_chat_created`, `channel_chat_created`, `chat_migration`, `migrate_to_chat_id`, `migrate_from_chat_id` now return shared reference instead of owned value inside `Option` ([#982][pr982])
- Methods `delete_chat_photo`, `group_chat_created`, `super_group_chat_created`, `channel_chat_created` now return appropriate structs not `Option<True>` ([#982][pr982])
- MSRV (Minimal Supported Rust Version) was bumped from `1.68.0` to `1.70.0` ([#996][pr996])
- Renamed `SendAnimation::thumb`, `SendAudio::thumb`, `SendDocument::thumb`, `SendSticker::thumb`, `SendVideo::thumb`, `SendVideoNote::thumb` into `thumbnail`([#1040][pr1040])
- Renamed `{Animation, Audio, Document, Sticker, Video, VideoNote, InputMediaAnimation, InputMediaAudio, InputMediaDocument, InputMediaVideo, StickerSet}::thumb` into `thumbnail` ([#1040][pr1040])
- Renamed `StickerFormat::Raster` into `StickerFormat::Static` ([#1040][pr1040])
Copy link
Member

Choose a reason for hiding this comment

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

Please also mention all the is_rater->is_static functions

@@ -146,11 +146,20 @@ mod tests {

#[tokio::test]
async fn test_add_sticker_to_set() {
// FIXME: rewrite according to the new schema
Copy link
Member

Choose a reason for hiding this comment

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

?

- Renamed `thumb_url`, `thumb_width`, `thumb_height` into `thumbnail_url`, `thumbnail_width`, `thumbnail_height` in `InlineQueryResultArticle`, `InlineQueryResultContact`, `InlineQueryResultDocument`, `InlineQueryResultLocation`, `InlineQueryResultVenue` ([#1040][pr1040])
- Renamed `thumb_url` into `thumbnail_url` in `InlineQueryResultPhoto`, `InlineQueryResultVideo` ([#1040][pr1040])
- Renamed `thumb_url` into `thumbnail_url` in `InlineQueryResultGif`, `InlineQueryResultMpeg4Gif` ([#1040][pr1040])
- `InputSticker` now is the struct that is used as parameter-bucket for sticker-related functionality, previously it was a wrap over the `png`, `tgs` and `webm` files ([#1040][pr1040])
Copy link
Member

Choose a reason for hiding this comment

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

Instead of repeating the PR all the time do

  • Implement Telegram Bot API version ... [#...][...]
    • blah
    • blah

@teloxidebot teloxidebot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author and removed S-waiting-on-review Status: Awaiting review from the assignee labels Apr 11, 2024
@syrtcevvi syrtcevvi marked this pull request as draft May 2, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-requester Area: requester trait, bot adaptors A-requests Area: representation of telegram bot API requests/methods A-tba-types Area: representation of telegram bot API types C-core crate: teloxide-core C-main crate: teloxide S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add support for Bot API 6.6
3 participants