Merge pull request #1146 from Propheci/tba7.2

Add support for TBA 7.2
This commit is contained in:
Сырцев Вадим Игоревич 2024-08-24 10:38:19 +00:00 committed by GitHub
commit 4cbcd426d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
71 changed files with 1178 additions and 339 deletions

View file

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `filter_boost_added` and `filter_reply_to_story` filters to `MessageFilterExt` trait
- Add `filter_mention_command` filter to `HandlerExt` trait ([issue #494](https://github.com/teloxide/teloxide/issues/494))
- Add `filter_business_connection`, `filter_business_message`, `filter_edited_business_message`, and `filter_deleted_business_messages` filters to update filters ([PR 1146](https://github.com/teloxide/teloxide/pull/1146))
## 0.13.0 - 2024-08-16

View file

@ -11,7 +11,7 @@
<img src="https://img.shields.io/crates/v/teloxide.svg">
</a>
<a href="https://core.telegram.org/bots/api">
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%207.1%20(inclusively)-green.svg">
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%207.2%20(inclusively)-green.svg">
</a>
<a href="https://t.me/teloxide">
<img src="https://img.shields.io/badge/support-t.me%2Fteloxide-blueviolet">

View file

@ -19,13 +19,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `boost_added` and `reply_to_story` getters to `Message` struct
- Add `unrestrict_boost_count` and `custom_emoji_sticker_set_name` getters to `Chat` struct
[pr1131]: https://github.com/teloxide/teloxide/pull/1131
- Support for TBA 7.2 ([#1146](pr1146))
- Update documentation of `SendSticker` method
- Add `is_from_offline` field to `MessageCommon` struct
- Add `can_connect_to_business` field to `Me` struct
- Add `personal_chat` field to `ChatPrivate` struct
- Add `ReplaceStickerInSet` and `GetBusinessConnection` methods
- Add `Birthdate` struct and corresponding field `birthdate` in `ChatPrivate`
- Add `request_name`, `request_username` and `request_photo` fields to `KeyboardButtonRequestUsers` struct
- Add `request_title`, `request_username` and `request_photo` fields to `KeyboardButtonRequestChat` struct
- Add `SharedUser` struct
- Add `title`, `username` and `photo` fields to `ChatShared` struct
- Add `format` field to `InputSticker` struct
- Add `format` parameter to `SetStickerSetThumbnail` method
- Add `BusinessConnectionId` struct
- Add `business_connection_id` parameter to `SendMessage`, `SendPhoto`, `SendVideo`, `SendAnimation`, `SendAudio`, `SendDocument`, `SendSticker`, `SendVideoNote`, `SendVoice`, `SendLocation`, `SendVenue`, `SendContact`, `SendPoll`, `SendDice`, `SendGame`, and `SendMediaGroup` methods
- Add `sender_business_bot` and `business_connection_id` fields to `Message` struct
- Add `BusinessIntro` struct and corresponding field `business_intro` to `ChatPrivate` struct
- Add `BusinessLocation` struct and corresponding field `business_location` to `ChatPrivate` struct
- Add `BusinessOpeningHoursInterval` and `BusinessOpeningHours` structs and corresponding field `business_opening_hours` to `ChatPrivate` struct
- Add `BusinessConnection` struct
- Add `BusinessMessagesDeleted` struct
- Add `BusinessConnection`, `BusinessMessage`, `EditedBusinessMessage` and `DeletedBusinessMessages` variants to `UpdateKind` enum
### Changed
- `MaybeAnonymousUser` type introduced, which replaced `PollAnswer::voter: Voter` and `MessageReactionUpdated::{user, actor_chat}` in `MessageReactionUpdated`([#1134][pr1134])
- Support for TBA 7.2 ([#1146](pr1146))
- Remove `flags` field from `StickerSet` struct
- Remove `sticker_format` parameter from `CreateNewStickerSet` method
- Wrap `Public` variant of `ChatKind` in `Box`
- Replaced `user_ids` with `users` in `UsersShared` struct
[pr1131]: https://github.com/teloxide/teloxide/pull/1131
[pr1134]: https://github.com/teloxide/teloxide/pull/1134
[pr1146]: https://github.com/teloxide/teloxide/pull/1146
## 0.10.1 - 2024-08-17

View file

@ -12,7 +12,7 @@
<img src="https://img.shields.io/badge/license-MIT-blue.svg">
</a>
<a href="https://core.telegram.org/bots/api">
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%207.1%20(inclusively)-green.svg">
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%207.2%20(inclusively)-green.svg">
</a>
<a href="https://crates.io/crates/teloxide_core">
<img src="https://img.shields.io/crates/v/teloxide_core.svg">

View file

@ -39,7 +39,7 @@
//! [github]: https://github.com/WaffleLapkin/tg-methods-schema
Schema(
api_version: ApiVersion(ver: "7.1", date: "February 16, 2024"),
api_version: ApiVersion(ver: "7.2", date: "March 31, 2024"),
methods: [
Method(
names: ("getUpdates", "GetUpdates", "get_updates"),
@ -224,6 +224,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendmessage",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -279,7 +284,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -448,7 +453,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -520,6 +525,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendphoto",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -583,7 +593,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -605,6 +615,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendaudio",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -686,7 +701,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -705,6 +720,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#senddocument",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -776,7 +796,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -798,6 +818,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendvideo",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -889,7 +914,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -909,6 +934,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendanimation",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -995,7 +1025,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1018,6 +1048,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendvoice",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1076,7 +1111,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1098,6 +1133,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendvideonote",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1156,7 +1196,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1176,6 +1216,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendmediagroup",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1221,6 +1266,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendlocation",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1286,7 +1336,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1344,7 +1394,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1398,7 +1448,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1435,7 +1485,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1464,7 +1514,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1484,6 +1534,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendvenue",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1559,7 +1614,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1578,6 +1633,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendcontact",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1633,7 +1693,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1652,6 +1712,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendpoll",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1747,7 +1812,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1766,6 +1831,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#senddice",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -1803,7 +1873,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -1822,6 +1892,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendchataction",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the action will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -2977,6 +3052,20 @@ Schema(
),
],
),
Method(
names: ("getBusinessConnection", "GetBusinessConnection", "get_business_connection"),
return_ty: RawTy("BusinessConnection"),
doc: Doc(md: "Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success."),
tg_doc: "https://core.telegram.org/bots/api#getbusinessconnection",
tg_category: "Available methods",
params: [
Param(
name: "business_connection_id",
ty: RawTy("BusinessConnectionId"),
descr: Doc(md: "Unique identifier of the business connection"),
),
],
),
Method(
names: ("getMyCommands", "GetMyCommands", "get_my_commands"),
return_ty: ArrayOf(RawTy("BotCommand")),
@ -3631,12 +3720,17 @@ Schema(
names: ("sendSticker", "SendSticker", "send_sticker"),
return_ty: RawTy("Message"),
doc: Doc(
md: "Use this method to send static .WEBP or [animated] .TGS stickers. On success, the sent Message is returned.",
md: "Use this method to send static .WEBP, .TGS or .WEBM stickers. On success, the sent Message is returned.",
md_links: {"animated": "https://telegram.org/blog/animated-stickers"}
),
tg_doc: "https://core.telegram.org/bots/api#sendsticker",
tg_category: "Stickers",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("Recipient"),
@ -3682,7 +3776,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.",
md: "Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.",
md_links: {
"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",
"custom reply keyboard": "https://core.telegram.org/bots#keyboards",
@ -3723,10 +3817,11 @@ Schema(
names: ("uploadStickerFile", "UploadStickerFile", "upload_sticker_file"),
return_ty: RawTy("FileMeta"),
doc: Doc(
md: "Use this method to upload a file with a sticker for later use in the [CreateNewStickerSet] and [AddStickerToSet] methods (the file can be used multiple times). Returns the uploaded [File] on success.",
md: "Use this method to upload a file with a sticker for later use in the [CreateNewStickerSet], [AddStickerToSet] or [ReplaceStickerInSet] methods (the file can be used multiple times). Returns the uploaded [File] on success.",
md_links: {
"CreateNewStickerSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.CreateNewStickerSet.html",
"AddStickerToSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.AddStickerToSet.html",
"ReplaceStickerInSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.ReplaceStickerInSet.html",
"File": "https://core.telegram.org/bots/api#file"
}
),
@ -3783,11 +3878,6 @@ Schema(
ty: ArrayOf(RawTy("InputSticker")),
descr: Doc(md: "A JSON-serialized list of 1-50 initial stickers to be added to the sticker set")
),
Param(
name: "sticker_format",
ty: RawTy("StickerFormat"),
descr: Doc(md: "Format of the sticker, must be one of “static”, “animated”, “video”")
),
Param(
name: "sticker_type",
ty: Option(RawTy("StickerType")),
@ -3859,6 +3949,42 @@ Schema(
),
],
),
Method(
names: ("replaceStickerInSet", "ReplaceStickerInSet", "replace_sticker_in_set"),
return_ty: True,
doc: Doc(
md: "Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling [DeleteStickerFromSet], then [AddStickerToSet], then [SetStickerPositionInSet]. Returns _True_ on success.",
md_links: {
"DeleteStickerFromSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.DeleteStickerFromSet.html",
"AddStickerToSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.AddStickerToSet.html",
"SetStickerPositionInSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.SetStickerPositionInSet.html",
}
),
tg_doc: "https://core.telegram.org/bots/api#replacestickerinset",
tg_category: "Stickers",
params: [
Param(
name: "user_id",
ty: RawTy("UserId"),
descr: Doc(md: "User identifier of the sticker set owner"),
),
Param(
name: "name",
ty: String,
descr: Doc(md: "Sticker set name"),
),
Param(
name: "old_sticker",
ty: String,
descr: Doc(md: "File identifier of the replaced sticker"),
),
Param(
name: "sticker",
ty: RawTy("InputSticker"),
descr: Doc(md: "A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged."),
),
],
),
Method(
names: ("setStickerSetThumbnail", "SetStickerSetThumbnail", "set_sticker_set_thumbnail"),
return_ty: True,
@ -3884,6 +4010,11 @@ Schema(
md_links: {"More info on Sending Files »": "https://core.telegram.org/bots/api#sending-files"},
),
),
Param(
name: "format",
ty: RawTy("StickerFormat"),
descr: Doc(md: "Format of the thumbnail, must be one of \"static\" for a .WEBP or .PNG image, \"animated\" for a .TGS animation, or \"video\" for a WEBM video")
)
],
),
Method(
@ -4357,6 +4488,11 @@ Schema(
tg_doc: "https://core.telegram.org/bots/api#sendgame",
tg_category: "Games",
params: [
Param(
name: "business_connection_id",
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
name: "chat_id",
ty: RawTy("ChatId"),
@ -4394,7 +4530,7 @@ Schema(
name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")),
descr: Doc(
md: "A JSON-serialized object for an [inline keyboard]. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.",
md: "A JSON-serialized object for an [inline keyboard]. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. Not supported for messages sent on behalf of a business account.",
md_links: {"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating"},
),
),

View file

@ -163,6 +163,7 @@ where
answer_callback_query,
get_user_chat_boosts,
set_my_commands,
get_business_connection,
get_my_commands,
set_my_name,
get_my_name,
@ -196,6 +197,7 @@ where
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
replace_sticker_in_set,
set_sticker_set_thumbnail,
set_custom_emoji_sticker_set_thumbnail,
set_sticker_set_title,

View file

@ -262,6 +262,7 @@ where
answer_callback_query,
get_user_chat_boosts,
set_my_commands,
get_business_connection,
get_my_commands,
set_my_name,
get_my_name,
@ -295,6 +296,7 @@ where
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
replace_sticker_in_set,
set_sticker_set_thumbnail,
set_custom_emoji_sticker_set_thumbnail,
set_sticker_set_title,
@ -750,6 +752,11 @@ trait ErasableRequester<'a> {
commands: Vec<BotCommand>,
) -> ErasedRequest<'a, SetMyCommands, Self::Err>;
fn get_business_connection(
&self,
business_connection_id: BusinessConnectionId,
) -> ErasedRequest<'a, GetBusinessConnection, Self::Err>;
fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err>;
fn set_my_name(&self) -> ErasedRequest<'a, SetMyName, Self::Err>;
@ -882,7 +889,6 @@ trait ErasableRequester<'a> {
name: String,
title: String,
stickers: Vec<InputSticker>,
sticker_format: StickerFormat,
) -> ErasedRequest<'a, CreateNewStickerSet, Self::Err>;
fn add_sticker_to_set(
@ -903,10 +909,19 @@ trait ErasableRequester<'a> {
sticker: String,
) -> ErasedRequest<'a, DeleteStickerFromSet, Self::Err>;
fn replace_sticker_in_set(
&self,
user_id: UserId,
name: String,
old_sticker: String,
sticker: InputSticker,
) -> ErasedRequest<'a, ReplaceStickerInSet, Self::Err>;
fn set_sticker_set_thumbnail(
&self,
name: String,
user_id: UserId,
format: StickerFormat,
) -> ErasedRequest<'a, SetStickerSetThumbnail, Self::Err>;
fn set_custom_emoji_sticker_set_thumbnail(
@ -1602,6 +1617,13 @@ where
Requester::set_my_commands(self, commands).erase()
}
fn get_business_connection(
&self,
business_connection_id: BusinessConnectionId,
) -> ErasedRequest<'a, GetBusinessConnection, Self::Err> {
Requester::get_business_connection(self, business_connection_id).erase()
}
fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err> {
Requester::get_my_commands(self).erase()
}
@ -1792,10 +1814,8 @@ where
name: String,
title: String,
stickers: Vec<InputSticker>,
sticker_format: StickerFormat,
) -> ErasedRequest<'a, CreateNewStickerSet, Self::Err> {
Requester::create_new_sticker_set(self, user_id, name, title, stickers, sticker_format)
.erase()
Requester::create_new_sticker_set(self, user_id, name, title, stickers).erase()
}
fn add_sticker_to_set(
@ -1822,12 +1842,23 @@ where
Requester::delete_sticker_from_set(self, sticker).erase()
}
fn replace_sticker_in_set(
&self,
user_id: UserId,
name: String,
old_sticker: String,
sticker: InputSticker,
) -> ErasedRequest<'a, ReplaceStickerInSet, Self::Err> {
Requester::replace_sticker_in_set(self, user_id, name, old_sticker, sticker).erase()
}
fn set_sticker_set_thumbnail(
&self,
name: String,
user_id: UserId,
format: StickerFormat,
) -> ErasedRequest<'a, SetStickerSetThumbnail, Self::Err> {
Requester::set_sticker_set_thumbnail(self, name, user_id).erase()
Requester::set_sticker_set_thumbnail(self, name, user_id, format).erase()
}
fn set_custom_emoji_sticker_set_thumbnail(

View file

@ -244,6 +244,7 @@ where
answer_callback_query,
get_user_chat_boosts,
set_my_commands,
get_business_connection,
get_my_commands,
set_my_name,
get_my_name,
@ -269,6 +270,7 @@ where
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
replace_sticker_in_set,
set_sticker_set_thumbnail,
set_custom_emoji_sticker_set_thumbnail,
set_sticker_set_title,

View file

@ -146,6 +146,7 @@ where
answer_callback_query,
get_user_chat_boosts,
set_my_commands,
get_business_connection,
get_my_commands,
set_my_name,
get_my_name,
@ -178,6 +179,7 @@ where
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
replace_sticker_in_set,
set_sticker_set_thumbnail,
set_custom_emoji_sticker_set_thumbnail,
set_sticker_set_title,

View file

@ -192,6 +192,7 @@ where
answer_callback_query,
get_user_chat_boosts,
set_my_commands,
get_business_connection,
get_my_commands,
set_my_name,
get_my_name,
@ -225,6 +226,7 @@ where
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
replace_sticker_in_set,
set_sticker_set_thumbnail,
set_custom_emoji_sticker_set_thumbnail,
set_sticker_set_title,

View file

@ -5,8 +5,9 @@ use crate::{
prelude::Requester,
requests::{JsonRequest, MultipartRequest},
types::{
BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia,
InputSticker, LabeledPrice, MessageId, Recipient, StickerFormat, ThreadId, UserId,
BotCommand, BusinessConnectionId, ChatId, ChatPermissions, InlineQueryResult, InputFile,
InputMedia, InputSticker, LabeledPrice, MessageId, Recipient, StickerFormat, ThreadId,
UserId,
},
Bot,
};
@ -881,6 +882,18 @@ impl Requester for Bot {
Self::SetMyCommands::new(self.clone(), payloads::SetMyCommands::new(commands))
}
type GetBusinessConnection = JsonRequest<payloads::GetBusinessConnection>;
fn get_business_connection(
&self,
business_connection_id: BusinessConnectionId,
) -> Self::GetBusinessConnection {
Self::GetBusinessConnection::new(
self.clone(),
payloads::GetBusinessConnection::new(business_connection_id),
)
}
type GetMyCommands = JsonRequest<payloads::GetMyCommands>;
fn get_my_commands(&self) -> Self::GetMyCommands {
@ -1173,7 +1186,7 @@ impl Requester for Bot {
&self,
user_id: UserId,
sticker: InputFile,
sticker_format: crate::types::StickerFormat,
sticker_format: StickerFormat,
) -> Self::UploadStickerFile {
Self::UploadStickerFile::new(
self.clone(),
@ -1189,7 +1202,6 @@ impl Requester for Bot {
name: N,
title: T,
stickers: S,
sticker_format: StickerFormat,
) -> Self::CreateNewStickerSet
where
N: Into<String>,
@ -1198,7 +1210,7 @@ impl Requester for Bot {
{
Self::CreateNewStickerSet::new(
self.clone(),
payloads::CreateNewStickerSet::new(user_id, name, title, stickers, sticker_format),
payloads::CreateNewStickerSet::new(user_id, name, title, stickers),
)
}
@ -1244,15 +1256,44 @@ impl Requester for Bot {
Self::DeleteStickerFromSet::new(self.clone(), payloads::DeleteStickerFromSet::new(sticker))
}
type ReplaceStickerInSet = JsonRequest<payloads::ReplaceStickerInSet>;
fn replace_sticker_in_set<N, O>(
&self,
user_id: UserId,
name: N,
old_sticker: O,
sticker: InputSticker,
) -> Self::ReplaceStickerInSet
where
N: Into<String>,
O: Into<String>,
{
Self::ReplaceStickerInSet::new(
self.clone(),
payloads::ReplaceStickerInSet {
user_id,
name: name.into(),
old_sticker: old_sticker.into(),
sticker,
},
)
}
type SetStickerSetThumbnail = MultipartRequest<payloads::SetStickerSetThumbnail>;
fn set_sticker_set_thumbnail<N>(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumbnail
fn set_sticker_set_thumbnail<N>(
&self,
name: N,
user_id: UserId,
format: StickerFormat,
) -> Self::SetStickerSetThumbnail
where
N: Into<String>,
{
Self::SetStickerSetThumbnail::new(
self.clone(),
payloads::SetStickerSetThumbnail::new(name, user_id),
payloads::SetStickerSetThumbnail::new(name, user_id, format),
)
}

View file

@ -1,7 +1,7 @@
//! Core part of the [`teloxide`] library.
//!
//! This library provides tools for making requests to the [Telegram Bot API]
//! (Currently, version `7.1` is supported) with ease. The library is fully
//! (Currently, version `7.2` is supported) with ease. The library is fully
//! asynchronous and built using [`tokio`].
//!
//!```toml

View file

@ -1069,6 +1069,14 @@ macro_rules! requester_forward {
$body!(set_my_commands this (commands: C))
}
};
(@method get_business_connection $body:ident $ty:ident) => {
type GetBusinessConnection = $ty![GetBusinessConnection];
fn get_business_connection(&self, business_connection_id: BusinessConnectionId) -> Self::GetBusinessConnection {
let this = self;
$body!(get_business_connection this (business_connection_id: BusinessConnectionId))
}
};
(@method get_my_commands $body:ident $ty:ident) => {
type GetMyCommands = $ty![GetMyCommands];
@ -1308,11 +1316,11 @@ macro_rules! requester_forward {
(@method create_new_sticker_set $body:ident $ty:ident) => {
type CreateNewStickerSet = $ty![CreateNewStickerSet];
fn create_new_sticker_set<N, T, S>(&self, user_id: UserId, name: N, title: T, stickers: S, sticker_format: StickerFormat) -> Self::CreateNewStickerSet where N: Into<String>,
fn create_new_sticker_set<N, T, S>(&self, user_id: UserId, name: N, title: T, stickers: S) -> Self::CreateNewStickerSet where N: Into<String>,
T: Into<String>,
S: IntoIterator<Item = InputSticker> {
let this = self;
$body!(create_new_sticker_set this (user_id: UserId, name: N, title: T, stickers: S, sticker_format: StickerFormat))
$body!(create_new_sticker_set this (user_id: UserId, name: N, title: T, stickers: S))
}
};
(@method add_sticker_to_set $body:ident $ty:ident) => {
@ -1339,12 +1347,21 @@ macro_rules! requester_forward {
$body!(delete_sticker_from_set this (sticker: S))
}
};
(@method replace_sticker_in_set $body:ident $ty:ident) => {
type ReplaceStickerInSet = $ty![ReplaceStickerInSet];
fn replace_sticker_in_set<N, O>(&self, user_id: UserId, name: N, old_sticker: O, sticker: InputSticker) -> Self::ReplaceStickerInSet where N: Into<String>,
O: Into<String> {
let this = self;
$body!(replace_sticker_in_set this (user_id: UserId, name: N, old_sticker: O, sticker: InputSticker))
}
};
(@method set_sticker_set_thumbnail $body:ident $ty:ident) => {
type SetStickerSetThumbnail = $ty![SetStickerSetThumbnail];
fn set_sticker_set_thumbnail<N>(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumbnail where N: Into<String> {
fn set_sticker_set_thumbnail<N>(&self, name: N, user_id: UserId, format: StickerFormat) -> Self::SetStickerSetThumbnail where N: Into<String> {
let this = self;
$body!(set_sticker_set_thumbnail this (name: N, user_id: UserId))
$body!(set_sticker_set_thumbnail this (name: N, user_id: UserId, format: StickerFormat))
}
};
(@method set_custom_emoji_sticker_set_thumbnail $body:ident $ty:ident) => {
@ -1515,7 +1532,7 @@ fn codegen_requester_forward() {
convert_params.sort_unstable();
let prefixes: IndexMap<_, _> = convert_params
let mut prefixes: IndexMap<_, _> = convert_params
.iter()
.copied()
// Workaround to output the last type as the first letter
@ -1524,6 +1541,18 @@ fn codegen_requester_forward() {
.map(|(l, r)| (l, min_prefix(l, r)))
.collect();
// FIXME: This hard-coded value has been set to avoid conflicting generic
// parameter 'B' with impl<B> Requester... in all the adaptors and other places
//
// One fix could be to take full abbrevation for all the parameters instead of
// just the first character. Other fix is to change the generic parameter name
// in all the impl blocks to something like 'Z' because that is very less likely
// to conflict in future.
if prefixes.contains_key("business_connection_id") {
prefixes["business_connection_id"] = "BCI";
}
let prefixes = prefixes;
let args = m
.params
.iter()

View file

@ -59,6 +59,7 @@ mod edit_message_text_inline;
mod export_chat_invite_link;
mod forward_message;
mod forward_messages;
mod get_business_connection;
mod get_chat;
mod get_chat_administrators;
mod get_chat_member;
@ -88,6 +89,7 @@ mod pin_chat_message;
mod promote_chat_member;
mod reopen_forum_topic;
mod reopen_general_forum_topic;
mod replace_sticker_in_set;
mod restrict_chat_member;
mod revoke_chat_invite_link;
mod send_animation;
@ -192,6 +194,7 @@ pub use edit_message_text_inline::{EditMessageTextInline, EditMessageTextInlineS
pub use export_chat_invite_link::{ExportChatInviteLink, ExportChatInviteLinkSetters};
pub use forward_message::{ForwardMessage, ForwardMessageSetters};
pub use forward_messages::{ForwardMessages, ForwardMessagesSetters};
pub use get_business_connection::{GetBusinessConnection, GetBusinessConnectionSetters};
pub use get_chat::{GetChat, GetChatSetters};
pub use get_chat_administrators::{GetChatAdministrators, GetChatAdministratorsSetters};
pub use get_chat_member::{GetChatMember, GetChatMemberSetters};
@ -225,6 +228,7 @@ pub use pin_chat_message::{PinChatMessage, PinChatMessageSetters};
pub use promote_chat_member::{PromoteChatMember, PromoteChatMemberSetters};
pub use reopen_forum_topic::{ReopenForumTopic, ReopenForumTopicSetters};
pub use reopen_general_forum_topic::{ReopenGeneralForumTopic, ReopenGeneralForumTopicSetters};
pub use replace_sticker_in_set::{ReplaceStickerInSet, ReplaceStickerInSetSetters};
pub use restrict_chat_member::{RestrictChatMember, RestrictChatMemberSetters};
pub use revoke_chat_invite_link::{RevokeChatInviteLink, RevokeChatInviteLinkSetters};
pub use send_animation::{SendAnimation, SendAnimationSetters};

View file

@ -40,7 +40,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,7 @@
use serde::Serialize;
use crate::types::{InputSticker, StickerFormat, StickerType, True, UserId};
use crate::types::{InputSticker, StickerType, True, UserId};
impl_payload! {
/// Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success.
@ -17,8 +17,6 @@ impl_payload! {
pub title: String [into],
/// A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
pub stickers: Vec<InputSticker> [collect],
/// Format of the sticker, must be one of “static”, “animated”, “video”
pub sticker_format: StickerFormat,
}
optional {
/// Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created.

View file

@ -30,7 +30,7 @@ impl_payload! {
pub heading: u16,
/// For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
pub proximity_alert_radius: u32,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -27,7 +27,7 @@ impl_payload! {
pub heading: u16,
/// For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
pub proximity_alert_radius: u32,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -0,0 +1,16 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{BusinessConnection, BusinessConnectionId};
impl_payload! {
/// Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub GetBusinessConnection (GetBusinessConnectionSetters) => BusinessConnection {
required {
/// Unique identifier of the business connection
pub business_connection_id: BusinessConnectionId,
}
}
}

View file

@ -0,0 +1,27 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{InputSticker, True, UserId};
impl_payload! {
@[multipart = sticker]
/// Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling [DeleteStickerFromSet], then [AddStickerToSet], then [SetStickerPositionInSet]. Returns _True_ on success.
///
/// [DeleteStickerFromSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.DeleteStickerFromSet.html
/// [AddStickerToSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.AddStickerToSet.html
/// [SetStickerPositionInSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.SetStickerPositionInSet.html
#[derive(Debug, Clone, Serialize)]
pub ReplaceStickerInSet (ReplaceStickerInSetSetters) => True {
required {
/// User identifier of the sticker set owner
pub user_id: UserId,
/// Sticker set name
pub name: String [into],
/// File identifier of the replaced sticker
pub old_sticker: String [into],
/// A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.
pub sticker: InputSticker,
}
}
}

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -22,6 +23,8 @@ impl_payload! {
pub animation: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Duration of the animation in seconds
@ -52,7 +55,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -25,6 +26,8 @@ impl_payload! {
pub audio: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Audio caption, 0-1024 characters after entities parsing
@ -53,7 +56,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,7 @@
use serde::Serialize;
use crate::types::{ChatAction, Recipient, ThreadId, True};
use crate::types::{BusinessConnectionId, ChatAction, Recipient, ThreadId, True};
impl_payload! {
/// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
@ -30,6 +30,8 @@ impl_payload! {
pub action: ChatAction,
}
optional {
/// Unique identifier of the business connection on behalf of which the action will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread; supergroups only
pub message_thread_id: ThreadId,
}

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send phone contacts. On success, the sent [`Message`] is returned.
@ -19,6 +21,8 @@ impl_payload! {
pub first_name: String [into],
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Contact's last name
@ -35,7 +39,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{DiceEmoji, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, DiceEmoji, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send an animated emoji that will display a random value. On success, the sent [`Message`] is returned.
@ -15,6 +17,8 @@ impl_payload! {
pub chat_id: Recipient [into],
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
@ -27,7 +31,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -22,6 +23,8 @@ impl_payload! {
pub document: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. [More info on Sending Files »]
@ -46,7 +49,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,7 @@
use serde::Serialize;
use crate::types::{ChatId, Message, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{BusinessConnectionId, ChatId, Message, ReplyMarkup, ReplyParameters, ThreadId};
impl_payload! {
/// Use this method to send a game. On success, the sent [`Message`] is returned.
@ -17,6 +17,8 @@ impl_payload! {
pub game_short_name: String [into],
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Sends the message [silently]. Users will receive a notification with no sound.
@ -27,7 +29,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// A JSON-serialized object for an [inline keyboard]. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.
/// A JSON-serialized object for an [inline keyboard]. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
pub reply_markup: ReplyMarkup [into],

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send point on the map. On success, the sent [`Message`] is returned.
@ -19,6 +21,8 @@ impl_payload! {
pub longitude: f64,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// The radius of uncertainty for the location, measured in meters; 0-1500
@ -39,7 +43,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{InputMedia, Message, Recipient, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, InputMedia, Message, Recipient, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [`Message`]s that were sent is returned.
@ -26,6 +28,8 @@ impl_payload! {
pub media: Vec<InputMedia> [collect],
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Sends the message [silently]. Users will receive a notification with no sound.

View file

@ -3,8 +3,8 @@
use serde::Serialize;
use crate::types::{
LinkPreviewOptions, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters,
ThreadId,
BusinessConnectionId, LinkPreviewOptions, Message, MessageEntity, ParseMode, Recipient,
ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
@ -20,6 +20,8 @@ impl_payload! {
pub text: String [into],
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Mode for parsing entities in the message text. See [formatting options] for more details.
@ -38,7 +40,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -22,6 +23,8 @@ impl_payload! {
pub photo: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Photo caption (may also be used when resending photos by _file\_id_), 0-1024 characters after entities parsing
@ -42,7 +45,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -4,7 +4,8 @@ use chrono::{DateTime, Utc};
use serde::Serialize;
use crate::types::{
Message, MessageEntity, ParseMode, PollType, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, Message, MessageEntity, ParseMode, PollType, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -22,6 +23,8 @@ impl_payload! {
pub options: Vec<String> [collect],
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// True, if the poll needs to be anonymous, defaults to True
@ -56,7 +59,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,11 +2,13 @@
use serde::Serialize;
use crate::types::{InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
@[multipart = sticker]
/// Use this method to send static .WEBP or [animated] .TGS stickers. On success, the sent Message is returned.
/// Use this method to send static .WEBP, .TGS or .WEBM stickers. On success, the sent Message is returned.
///
/// [animated]: https://telegram.org/blog/animated-stickers
#[derive(Debug, Clone, Serialize)]
@ -20,6 +22,8 @@ impl_payload! {
pub sticker: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Emoji associated with the sticker; only for just uploaded stickers
@ -32,7 +36,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send information about a venue. On success, the sent [`Message`] is returned.
@ -23,6 +25,8 @@ impl_payload! {
pub address: String [into],
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Foursquare identifier of the venue
@ -43,7 +47,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -23,6 +24,8 @@ impl_payload! {
pub video: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Duration of the video in seconds
@ -55,7 +58,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
@[multipart = video_note, thumbnail]
@ -21,6 +23,8 @@ impl_payload! {
pub video_note: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Duration of the video in seconds
@ -39,7 +43,7 @@ impl_payload! {
pub protect_content: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -24,6 +25,8 @@ impl_payload! {
pub voice: InputFile,
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Voice message caption, 0-1024 characters after entities parsing
@ -42,7 +45,7 @@ impl_payload! {
pub disable_notification: bool,
/// Description of the message to reply to
pub reply_parameters: ReplyParameters,
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -2,7 +2,7 @@
use serde::Serialize;
use crate::types::{InputFile, True, UserId};
use crate::types::{InputFile, StickerFormat, True, UserId};
impl_payload! {
@[multipart = thumbnail]
@ -14,6 +14,8 @@ impl_payload! {
pub name: String [into],
/// User identifier of sticker file owner
pub user_id: UserId,
/// Format of the thumbnail, must be one of "static" for a .WEBP or .PNG image, "animated" for a .TGS animation, or "video" for a WEBM video
pub format: StickerFormat,
}
optional {
/// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.

View file

@ -19,17 +19,18 @@ pub use crate::payloads::{
EditMessageReplyMarkupInlineSetters as _, EditMessageReplyMarkupSetters as _,
EditMessageTextInlineSetters as _, EditMessageTextSetters as _,
ExportChatInviteLinkSetters as _, ForwardMessageSetters as _, ForwardMessagesSetters as _,
GetChatAdministratorsSetters as _, GetChatMemberCountSetters as _, GetChatMemberSetters as _,
GetChatMembersCountSetters as _, GetChatMenuButtonSetters as _, GetChatSetters as _,
GetCustomEmojiStickersSetters as _, GetFileSetters as _, GetForumTopicIconStickersSetters as _,
GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _,
GetMyDefaultAdministratorRightsSetters as _, GetMyDescriptionSetters as _,
GetMyNameSetters as _, GetMyShortDescriptionSetters as _, GetStickerSetSetters as _,
GetUpdatesSetters as _, GetUserChatBoostsSetters as _, GetUserProfilePhotosSetters as _,
GetWebhookInfoSetters as _, HideGeneralForumTopicSetters as _, KickChatMemberSetters as _,
LeaveChatSetters as _, LogOutSetters as _, PinChatMessageSetters as _,
PromoteChatMemberSetters as _, ReopenForumTopicSetters as _,
ReopenGeneralForumTopicSetters as _, RestrictChatMemberSetters as _,
GetBusinessConnectionSetters as _, GetChatAdministratorsSetters as _,
GetChatMemberCountSetters as _, GetChatMemberSetters as _, GetChatMembersCountSetters as _,
GetChatMenuButtonSetters as _, GetChatSetters as _, GetCustomEmojiStickersSetters as _,
GetFileSetters as _, GetForumTopicIconStickersSetters as _, GetGameHighScoresSetters as _,
GetMeSetters as _, GetMyCommandsSetters as _, GetMyDefaultAdministratorRightsSetters as _,
GetMyDescriptionSetters as _, GetMyNameSetters as _, GetMyShortDescriptionSetters as _,
GetStickerSetSetters as _, GetUpdatesSetters as _, GetUserChatBoostsSetters as _,
GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _,
HideGeneralForumTopicSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _,
LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _,
ReopenForumTopicSetters as _, ReopenGeneralForumTopicSetters as _,
ReplaceStickerInSetSetters as _, RestrictChatMemberSetters as _,
RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, SendAudioSetters as _,
SendChatActionSetters as _, SendContactSetters as _, SendDiceSetters as _,
SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _,

View file

@ -21,7 +21,7 @@ impl_payload! {
pub message_id: MessageId,
}
optional {
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -17,7 +17,7 @@ impl_payload! {
pub inline_message_id: String [into],
}
optional {
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [custom reply keyboard]: https://core.telegram.org/bots#keyboards

View file

@ -6,10 +6,11 @@ use crate::types::{FileMeta, InputFile, StickerFormat, UserId};
impl_payload! {
@[multipart = sticker]
/// Use this method to upload a file with a sticker for later use in the [CreateNewStickerSet] and [AddStickerToSet] methods (the file can be used multiple times). Returns the uploaded [`File`] on success.
/// Use this method to upload a file with a sticker for later use in the [CreateNewStickerSet], [AddStickerToSet] or [ReplaceStickerInSet] methods (the file can be used multiple times). Returns the uploaded [`File`] on success.
///
/// [CreateNewStickerSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.CreateNewStickerSet.html
/// [AddStickerToSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.AddStickerToSet.html
/// [ReplaceStickerInSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.ReplaceStickerInSet.html
/// [`File`]: crate::types::File
#[derive(Debug, Clone, Serialize)]
pub UploadStickerFile (UploadStickerFileSetters) => FileMeta {

View file

@ -831,6 +831,14 @@ pub trait Requester {
where
C: IntoIterator<Item = BotCommand>;
type GetBusinessConnection: Request<Payload = GetBusinessConnection, Err = Self::Err>;
/// For Telegram documentation see [`GetBusinessConnection`].
fn get_business_connection(
&self,
business_connection_id: BusinessConnectionId,
) -> Self::GetBusinessConnection;
type GetMyCommands: Request<Payload = GetMyCommands, Err = Self::Err>;
/// For Telegram documentation see [`GetMyCommands`].
@ -1071,7 +1079,6 @@ pub trait Requester {
name: N,
title: T,
stickers: S,
sticker_format: StickerFormat,
) -> Self::CreateNewStickerSet
where
N: Into<String>,
@ -1108,6 +1115,20 @@ pub trait Requester {
where
S: Into<String>;
type ReplaceStickerInSet: Request<Payload = ReplaceStickerInSet, Err = Self::Err>;
/// For Telegram documentation see [`ReplaceStickerInSet`].
fn replace_sticker_in_set<N, O>(
&self,
user_id: UserId,
name: N,
old_sticker: O,
sticker: InputSticker,
) -> Self::ReplaceStickerInSet
where
N: Into<String>,
O: Into<String>;
type SetStickerSetThumbnail: Request<Payload = SetStickerSetThumbnail, Err = Self::Err>;
/// For Telegram documentation see [`SetStickerSetThumbnail`].
@ -1115,6 +1136,7 @@ pub trait Requester {
&self,
name: N,
user_id: UserId,
format: StickerFormat,
) -> Self::SetStickerSetThumbnail
where
N: Into<String>;
@ -1372,6 +1394,7 @@ macro_rules! forward_all {
answer_callback_query,
get_user_chat_boosts,
set_my_commands,
get_business_connection,
get_my_commands,
set_my_name,
get_my_name,
@ -1405,6 +1428,7 @@ macro_rules! forward_all {
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
replace_sticker_in_set,
set_sticker_set_thumbnail,
set_custom_emoji_sticker_set_thumbnail,
set_sticker_set_title,

View file

@ -90,7 +90,7 @@ mod tests {
types::{
ChatId, InputFile, InputMedia, InputMediaAnimation, InputMediaAudio,
InputMediaDocument, InputMediaPhoto, InputMediaVideo, InputSticker, MessageEntity,
MessageEntityKind, ParseMode, UserId,
MessageEntityKind, ParseMode, StickerFormat, UserId,
},
};
@ -157,6 +157,7 @@ mod tests {
emoji_list: vec!["✈️⚙️".to_owned()],
keywords: vec![],
mask_position: None,
format: StickerFormat::Static,
},
))
.unwrap()

View file

@ -3,11 +3,19 @@
pub use allowed_update::*;
pub use animation::*;
pub use audio::*;
pub use birthdate::*;
pub use bot_command::*;
pub use bot_command_scope::*;
pub use bot_description::*;
pub use bot_name::*;
pub use bot_short_description::*;
pub use business_connection::*;
pub use business_connection_id::*;
pub use business_intro::*;
pub use business_location::*;
pub use business_messages_deleted::*;
pub use business_opening_hours::*;
pub use business_opening_hours_interval::*;
pub use callback_game::*;
pub use callback_query::*;
pub use chat::*;
@ -121,6 +129,7 @@ pub use reply_parameters::*;
pub use request_id::*;
pub use response_parameters::*;
pub use sent_web_app_message::*;
pub use shared_user::*;
pub use shipping_address::*;
pub use shipping_option::*;
pub use shipping_query::*;
@ -156,11 +165,19 @@ pub use write_access_allowed::*;
mod allowed_update;
mod animation;
mod audio;
mod birthdate;
mod bot_command;
mod bot_command_scope;
mod bot_description;
mod bot_name;
mod bot_short_description;
mod business_connection;
mod business_connection_id;
mod business_intro;
mod business_location;
mod business_messages_deleted;
mod business_opening_hours;
mod business_opening_hours_interval;
mod callback_game;
mod callback_query;
mod chat;
@ -246,6 +263,7 @@ mod reply_parameters;
mod request_id;
mod response_parameters;
mod sent_web_app_message;
mod shared_user;
mod shipping_address;
mod shipping_option;
mod shipping_query;

View file

@ -7,6 +7,10 @@ pub enum AllowedUpdate {
EditedMessage,
ChannelPost,
EditedChannelPost,
BusinessConnection,
BusinessMessage,
EditedBusinessMessage,
DeletedBusinessMessages,
MessageReaction,
MessageReactionCount,
InlineQuery,

View file

@ -0,0 +1,15 @@
use serde::{Deserialize, Serialize};
/// Describes the birthdate of a user.
#[serde_with::skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Birthdate {
/// Day of the user's birth; 1-31
pub day: u8,
/// Month of the user's birth; 1-12
pub month: u8,
/// Year of the user's birth
pub year: Option<u32>,
}

View file

@ -0,0 +1,29 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::types::{BusinessConnectionId, User, UserId};
/// Describes the connection of the bot with a business account.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BusinessConnection {
/// Unique identifier of the business connection
pub id: BusinessConnectionId,
/// Business account user that created the business connection
pub user: User,
/// The user id of the private chat with the user who created the business
/// connection
pub user_chat_id: UserId,
/// Date the connection was established in Unix time
#[serde(with = "crate::types::serde_date_from_unix_timestamp")]
pub date: DateTime<Utc>,
/// `true`, if the bot can act on behalf of the business account in chats
/// that were active in the last 24 hours
pub can_reply: bool,
/// `true`, if the connection is alive
pub is_enabled: bool,
}

View file

@ -0,0 +1,25 @@
use serde::{Deserialize, Serialize};
/// A unique business connection identifier.
#[derive(Default, Clone, Debug, derive_more::Display, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct BusinessConnectionId(pub String);
#[cfg(test)]
mod tests {
use crate::types::BusinessConnectionId;
#[test]
fn business_connection_id_deser() {
let json = r#""abcd1234""#;
let bcid: BusinessConnectionId = serde_json::from_str(json).unwrap();
assert_eq!(bcid, BusinessConnectionId(String::from("abcd1234")));
}
#[test]
fn business_connection_id_ser() {
let bcid: BusinessConnectionId = BusinessConnectionId(String::from("abcd1234"));
let json = serde_json::to_string(&bcid).unwrap();
assert_eq!(json, r#""abcd1234""#);
}
}

View file

@ -0,0 +1,16 @@
use serde::{Deserialize, Serialize};
use crate::types::Sticker;
/// An introduction for a Business.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct BusinessIntro {
/// Title text of the business intro
pub title: Option<String>,
/// Message text of the business intro
pub message: Option<String>,
/// Sticker of the business intro
pub sticker: Option<Sticker>,
}

View file

@ -0,0 +1,13 @@
use serde::{Deserialize, Serialize};
use crate::types::Location;
/// Details about the location of a Business
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct BusinessLocation {
/// Address of the business.
pub address: String,
/// Location of the business.
pub location: Option<Location>,
}

View file

@ -0,0 +1,19 @@
use serde::{Deserialize, Serialize};
use crate::types::{BusinessConnectionId, Chat, MessageId};
/// This object is received when messages are deleted from a connected business
/// account.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BusinessMessagesDeleted {
/// Unique identifier of the business connection.
pub business_connection_id: BusinessConnectionId,
/// Information about a chat in the business account. The bot may not have
/// access to the chat or the corresponding user.
pub chat: Chat,
/// The list of identifiers of deleted messages in the chat of the business
/// account.
pub message_ids: Vec<MessageId>,
}

View file

@ -0,0 +1,13 @@
use serde::{Deserialize, Serialize};
use crate::types::BusinessOpeningHoursInterval;
/// Details about the opening hours of a Business.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct BusinessOpeningHours {
/// Unique name of the time zone for which the opening hours are defined.
pub time_zone_name: String,
/// List of time intervals describing business opening hours.
pub opening_hours: Vec<BusinessOpeningHoursInterval>,
}

View file

@ -0,0 +1,15 @@
use serde::{Deserialize, Serialize};
/// Time intervals used to describe the opening hours of a Business.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BusinessOpeningHoursInterval {
/// The minute's sequence number in a week, starting on Monday, marking the
/// start of the time interval during which the business is open;
/// 0 - 7 * 24* 60
pub opening_minute: u16,
/// The minute's sequence number in a week, starting on Monday, marking the
/// end of the time interval during which the business is open;
/// 0 - 8 * 24* 60
pub closing_minute: u16,
}

View file

@ -1,8 +1,8 @@
use serde::{Deserialize, Serialize};
use crate::types::{
ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, ReactionType, Seconds,
True, User,
Birthdate, BusinessIntro, BusinessLocation, BusinessOpeningHours, ChatFullInfo, ChatId,
ChatLocation, ChatPermissions, ChatPhoto, Message, ReactionType, Seconds, True, User,
};
/// This object represents a chat.
@ -63,7 +63,7 @@ pub struct Chat {
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChatKind {
Public(ChatPublic),
Public(Box<ChatPublic>),
Private(ChatPrivate),
}
@ -133,6 +133,36 @@ pub struct ChatPrivate {
///
/// [`GetChat`]: crate::payloads::GetChat
pub has_restricted_voice_and_video_messages: Option<True>,
/// For private chats, the personal channel of the user. Returned only in
/// [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub personal_chat: Option<Box<Chat>>,
/// For private chats, the date of birth of the user. Returned only in
/// [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub birthdate: Option<Birthdate>,
/// For private chats with business accounts, the intro of the business.
/// Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub business_intro: Option<BusinessIntro>,
/// For private chats with business accounts, the location of the business.
/// Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub business_location: Option<BusinessLocation>,
/// For private chats with business accounts, the opening hours of the
/// business. Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub business_opening_hours: Option<BusinessOpeningHours>,
}
#[serde_with::skip_serializing_none]
@ -256,20 +286,29 @@ impl Chat {
#[must_use]
pub fn is_group(&self) -> bool {
matches!(self.kind, ChatKind::Public(ChatPublic { kind: PublicChatKind::Group(_), .. }))
if let ChatKind::Public(chat_pub) = &self.kind {
matches!(**chat_pub, ChatPublic { kind: PublicChatKind::Group(_), .. })
} else {
false
}
}
#[must_use]
pub fn is_supergroup(&self) -> bool {
matches!(
self.kind,
ChatKind::Public(ChatPublic { kind: PublicChatKind::Supergroup(_), .. })
)
if let ChatKind::Public(chat_pub) = &self.kind {
matches!(**chat_pub, ChatPublic { kind: PublicChatKind::Supergroup(_), .. })
} else {
false
}
}
#[must_use]
pub fn is_channel(&self) -> bool {
matches!(self.kind, ChatKind::Public(ChatPublic { kind: PublicChatKind::Channel(_), .. }))
if let ChatKind::Public(chat_pub) = &self.kind {
matches!(**chat_pub, ChatPublic { kind: PublicChatKind::Channel(_), .. })
} else {
false
}
}
#[must_use]
@ -563,7 +602,7 @@ impl Chat {
}
mod serde_helper {
use crate::types::True;
use crate::types::{Birthdate, BusinessIntro, BusinessLocation, BusinessOpeningHours, True};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
@ -584,6 +623,11 @@ mod serde_helper {
bio: Option<String>,
has_private_forwards: Option<True>,
has_restricted_voice_and_video_messages: Option<True>,
personal_chat: Option<Box<super::Chat>>,
birthdate: Option<Birthdate>,
business_intro: Option<BusinessIntro>,
business_location: Option<BusinessLocation>,
business_opening_hours: Option<BusinessOpeningHours>,
}
impl From<ChatPrivate> for super::ChatPrivate {
@ -596,6 +640,11 @@ mod serde_helper {
bio,
has_private_forwards,
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
business_location,
business_opening_hours,
}: ChatPrivate,
) -> Self {
Self {
@ -605,6 +654,11 @@ mod serde_helper {
bio,
has_private_forwards,
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
business_location,
business_opening_hours,
}
}
}
@ -618,6 +672,11 @@ mod serde_helper {
bio,
has_private_forwards,
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
business_location,
business_opening_hours,
}: super::ChatPrivate,
) -> Self {
Self {
@ -628,6 +687,11 @@ mod serde_helper {
bio,
has_private_forwards,
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
business_location,
business_opening_hours,
}
}
}
@ -643,7 +707,7 @@ mod tests {
fn channel_de() {
let expected = Chat {
id: ChatId(-1),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: None,
kind: PublicChatKind::Channel(PublicChatChannel {
username: Some("channel_name".into()),
@ -652,7 +716,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
photo: None,
available_reactions: Some(vec![ReactionType::Emoji { emoji: "🌭".to_owned() }]),
pinned_message: None,
@ -690,6 +754,11 @@ mod tests {
bio: None,
has_private_forwards: None,
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
business_location: None,
business_opening_hours: None,
}),
photo: None,
available_reactions: Some(vec![ReactionType::Emoji { emoji: "🌭".to_owned() }]),
@ -728,6 +797,11 @@ mod tests {
bio: None,
has_private_forwards: None,
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
business_location: None,
business_opening_hours: None,
}),
photo: None,
available_reactions: None,

View file

@ -1,8 +1,8 @@
use serde::{Deserialize, Serialize};
use crate::types::{ChatId, RequestId};
use crate::types::{ChatId, PhotoSize, RequestId};
/// Information about the chat whose identifier was shared with the bot using a
/// Information about a chat that was shared with the bot using a
/// [`KeyboardButtonRequestChat`] button.
///
/// [`KeyboardButtonRequestChat`]: crate::types::KeyboardButtonRequestChat
@ -10,6 +10,16 @@ use crate::types::{ChatId, RequestId};
pub struct ChatShared {
/// Identifier of the request.
pub request_id: RequestId,
/// Identifier of the shared chat.
pub chat_id: ChatId,
/// Title of the chat, if it was requested.
pub title: Option<String>,
/// Username of the chat, if it was requested.
pub username: Option<String>,
/// Available sizes of the chat photo, if it was requested.
pub photo: Option<Vec<PhotoSize>>,
}

View file

@ -2,6 +2,8 @@ use serde::Serialize;
use crate::types::{InputFile, MaskPosition};
use super::StickerFormat;
/// This object describes a sticker to be added to a sticker set.
#[serde_with::skip_serializing_none]
#[derive(Clone, Debug, Serialize)]
@ -16,6 +18,10 @@ pub struct InputSticker {
/// More information on Sending Files <https://core.telegram.org/bots/api#sending-files>
pub sticker: InputFile,
/// 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,
/// List of 1-20 emoji associated with the sticker
pub emoji_list: Vec<String>,

View file

@ -2,9 +2,10 @@ use serde::{Deserialize, Serialize};
use crate::types::{ChatAdministratorRights, RequestId};
/// This object defines the criteria used to request a suitable chat. The
/// identifier of the selected chat will be shared with the bot when the
/// corresponding button is pressed. [More about requesting chats »]
/// This object defines the criteria used to request a suitable chat.
/// Information about the selected chat will be shared with the bot when the
/// corresponding button is pressed. The bot will be granted requested rights in
/// the chat if appropriate. [More about requesting chats »]
///
/// [More about requesting chats »]: https://core.telegram.org/bots/features#chat-and-user-selection
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
@ -53,6 +54,18 @@ pub struct KeyboardButtonRequestChat {
/// additional restrictions are applied.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub bot_is_member: bool,
/// Pass `true` to request the chat's title.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_title: bool,
/// Pass `true` to request the chat's username.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_username: bool,
/// Pass `true` to request the chat's photo.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_photo: bool,
}
impl KeyboardButtonRequestChat {
@ -67,6 +80,9 @@ impl KeyboardButtonRequestChat {
user_administrator_rights: None,
bot_administrator_rights: None,
bot_is_member: false,
request_title: false,
request_username: false,
request_photo: false,
}
}
@ -111,4 +127,25 @@ impl KeyboardButtonRequestChat {
self.bot_is_member = value;
self
}
/// Setter for `request_title` field.
#[must_use]
pub fn request_title(mut self) -> Self {
self.request_title = true;
self
}
/// Setter for `request_username` field.
#[must_use]
pub fn request_username(mut self) -> Self {
self.request_username = true;
self
}
/// Setter for `request_photo` field.
#[must_use]
pub fn request_photo(mut self) -> Self {
self.request_photo = true;
self
}
}

View file

@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
use crate::types::RequestId;
/// This object defines the criteria used to request a suitable users. The
/// identifiers of the selected users will be shared with the bot when the
/// This object defines the criteria used to request a suitable users.
/// Information about the selected users will be shared with the bot when the
/// corresponding button is pressed. More about requesting users »
///
/// [More about requesting users »]: https://core.telegram.org/bots/features#chat-and-user-selection
@ -30,33 +30,77 @@ pub struct KeyboardButtonRequestUsers {
/// The maximum number of users to be selected; 1-10. Defaults to 1.
#[serde(default = "one", skip_serializing_if = "is_one")]
pub max_quantity: u8,
/// Pass `true` to request the users' first and last names
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_name: bool,
/// Pass `true` to request the users' username
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_username: bool,
/// Pass `true` to request the users' photos
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_photo: bool,
}
impl KeyboardButtonRequestUsers {
/// Creates a new [`KeyboardButtonRequestUsers`].
pub fn new(request_id: RequestId) -> Self {
Self { request_id, user_is_bot: None, user_is_premium: None, max_quantity: 1 }
Self {
request_id,
user_is_bot: None,
user_is_premium: None,
max_quantity: 1,
request_name: false,
request_username: false,
request_photo: false,
}
}
/// Setter for `user_is_bot` field
#[must_use]
pub fn user_is_bot(mut self, value: bool) -> Self {
self.user_is_bot = Some(value);
self
}
/// Setter for `user_is_premium` field
#[must_use]
pub fn user_is_premium(mut self, value: bool) -> Self {
self.user_is_premium = Some(value);
self
}
/// Setter for `max_quantity` field, the value must be in the range 1..=10
#[must_use]
pub fn max_quantity(mut self, value: u8) -> Self {
assert!((1..=10).contains(&value));
self.max_quantity = value;
self
}
/// Setter for `request_name` field
#[must_use]
pub fn request_name(mut self) -> Self {
self.request_name = true;
self
}
/// Setter for `request_username` field
#[must_use]
pub fn request_username(mut self) -> Self {
self.request_username = true;
self
}
/// Setter for `request_photo` field
#[must_use]
pub fn request_photo(mut self) -> Self {
self.request_photo = true;
self
}
}
fn one() -> u8 {

View file

@ -23,6 +23,11 @@ pub struct Me {
/// `true`, if the bot supports inline queries.
pub supports_inline_queries: bool,
/// `true`, if the bot can be connected to a Telegram Business account to
/// receive its messages.
#[serde(default)]
pub can_connect_to_business: bool,
}
impl Me {
@ -73,6 +78,7 @@ mod tests {
can_join_groups: false,
can_read_all_group_messages: false,
supports_inline_queries: false,
can_connect_to_business: false,
};
assert_eq!(me.username(), "SomethingSomethingBot");

View file

@ -5,10 +5,10 @@ use serde::{Deserialize, Serialize};
use url::Url;
use crate::types::{
Animation, Audio, BareChatId, Chat, ChatBoostAdded, ChatId, ChatShared, Contact, Dice,
Document, ExternalReplyInfo, ForumTopicClosed, ForumTopicCreated, ForumTopicEdited,
ForumTopicReopened, Game, GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway,
GiveawayCompleted, GiveawayCreated, GiveawayWinners, InlineKeyboardMarkup, Invoice,
Animation, Audio, BareChatId, BusinessConnectionId, Chat, ChatBoostAdded, ChatId, ChatShared,
Contact, Dice, Document, ExternalReplyInfo, ForumTopicClosed, ForumTopicCreated,
ForumTopicEdited, ForumTopicReopened, Game, GeneralForumTopicHidden, GeneralForumTopicUnhidden,
Giveaway, GiveawayCompleted, GiveawayCreated, GiveawayWinners, InlineKeyboardMarkup, Invoice,
LinkPreviewOptions, Location, MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged,
MessageEntity, MessageEntityRef, MessageId, MessageOrigin, PassportData, PhotoSize, Poll,
ProximityAlertTriggered, Sticker, Story, SuccessfulPayment, TextQuote, ThreadId, True, User,
@ -54,6 +54,11 @@ pub struct Message {
/// Bot through which the message was sent.
pub via_bot: Option<User>,
/// The bot that actually sent the message on behalf of the business
/// account. Available only for outgoing messages sent on behalf of the
/// connected business account.
pub sender_business_bot: Option<User>,
#[serde(flatten)]
pub kind: MessageKind,
}
@ -154,6 +159,17 @@ pub struct MessageCommon {
/// `true`, if the message can't be forwarded.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub has_protected_content: bool,
/// `true`, if the message was sent by an implicit action, for example, as
/// an away or a greeting business message, or as a scheduled message
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub is_from_offline: bool,
/// Unique identifier of the business connection from which the message was
/// received. If non-empty, the message belongs to a chat of the
/// corresponding business account that is independent from any potential
/// bot chat which might share the same identifier.
pub business_connection_id: Option<BusinessConnectionId>,
}
#[serde_with::skip_serializing_none]
@ -1885,7 +1901,12 @@ mod tests {
username: Some("aka_dude".to_string()),
bio: None,
has_private_forwards: None,
has_restricted_voice_and_video_messages: None
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
business_location: None,
business_opening_hours: None,
}),
photo: None,
available_reactions: None,
@ -1895,10 +1916,14 @@ mod tests {
has_hidden_members: false,
chat_full_info: ChatFullInfo::default()
},
sender_business_bot: None,
kind: MessageKind::ChatShared(MessageChatShared {
chat_shared: ChatShared {
request_id: RequestId(348349),
chat_id: ChatId(384939)
chat_id: ChatId(384939),
title: None,
username: None,
photo: None,
}
}),
via_bot: None
@ -2108,7 +2133,7 @@ mod tests {
let group = Chat {
id: ChatId(-1001160242915),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("a".to_owned()),
kind: PublicChatKind::Supergroup(PublicChatSupergroup {
username: None,
@ -2128,7 +2153,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
message_auto_delete_time: None,
photo: None,
available_reactions: None,
@ -2413,7 +2438,7 @@ mod tests {
&Giveaway {
chats: vec![Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
username: None,
@ -2422,7 +2447,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,
@ -2522,7 +2547,7 @@ mod tests {
from: None,
sender_chat: Some(Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
linked_chat_id: None,
@ -2531,7 +2556,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None
}),
})),
chat_full_info: ChatFullInfo::default(),
available_reactions: None,
photo: None,
@ -2544,7 +2569,7 @@ mod tests {
date: DateTime::from_timestamp(1721161230, 0).unwrap(),
chat: Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
username: None,
@ -2553,7 +2578,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,
@ -2563,11 +2588,12 @@ mod tests {
chat_full_info: ChatFullInfo::default()
},
via_bot: None,
sender_business_bot: None,
kind: MessageKind::Giveaway(MessageGiveaway {
giveaway: Giveaway {
chats: vec![Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
username: None,
@ -2576,7 +2602,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,
@ -2668,7 +2694,7 @@ mod tests {
&GiveawayWinners {
chat: Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
username: None,
@ -2677,7 +2703,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,

View file

@ -13,11 +13,14 @@ pub struct ReplyParameters {
pub message_id: MessageId,
/// If the message to be replied to is from a different chat, unique
/// identifier for the chat or username of the channel (in the format
/// `@channelusername`)
/// `@channelusername`). Not supported for messages sent on behalf of a
/// business account.
pub chat_id: Option<Recipient>,
/// Pass _true_ if the message should be sent even if the specified message
/// to be replied to is not found; can be used only for replies in the
/// same chat and forum topic.
/// same chat and forum topic. Always `false` for replies in another chat or
/// forum topic. Always `true` for messages sent on behalf of a business
/// account.
pub allow_sending_without_reply: Option<bool>,
/// Quoted part of the message to be replied to; 0-1024 characters after
/// entities parsing. The quote must be an exact substring of the message to

View file

@ -0,0 +1,25 @@
use serde::{Deserialize, Serialize};
use crate::types::{PhotoSize, UserId};
/// This object contains information about a user that was shared with the bot
/// using a [`KeyboardButtonRequestUsers`] button.
///
/// [`KeyboardButtonRequestUsers`]: crate::types::KeyboardButtonRequestUsers
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct SharedUser {
/// Identifier of the shared user
pub user_id: UserId,
/// First name of the user, if it was requested by the bot
pub first_name: Option<String>,
/// Last name of the user, if it was requested by the bot
pub last_name: Option<String>,
/// Username of the user, if it was requested by the bot
pub username: Option<String>,
/// Available sizes of the chat photo, if it was requested
pub photo: Option<Vec<PhotoSize>>,
}

View file

@ -2,7 +2,7 @@ use std::ops::Deref;
use serde::{Deserialize, Serialize};
use crate::types::{PhotoSize, Sticker, StickerFormat, StickerFormatFlags, StickerType};
use crate::types::{PhotoSize, Sticker, StickerType};
/// This object represents a sticker set.
///
@ -20,11 +20,6 @@ pub struct StickerSet {
#[serde(flatten)]
pub kind: StickerType,
// FIXME: remove it in 7.2 https://core.telegram.org/bots/api#march-31-2024
/// Sticker format flags shared by all stickers in this set.
#[serde(flatten)]
pub flags: StickerFormatFlags,
/// List of all set stickers.
pub stickers: Vec<Sticker>,
@ -50,66 +45,6 @@ impl Deref for StickerSet {
}
}
impl StickerSet {
// FIXME: remove deprecation, when it will be a way to determine the format of
// the sticker set
/// Returns the format of the stickers in this set
///
/// Note: this method currently is useless, so the format is always
/// StickerFormat::Static
#[must_use]
#[deprecated(note = "TBA7.2 brought the breaking change: flags 'is_video' and 'is_animated' \
were removed, so currently there is no way to determine the format of \
the sticker set in the currently supported version (TBA6.6)")]
pub fn format(&self) -> StickerFormat {
self.flags.format()
}
/// Returns `true` is this is a "normal" raster sticker.
///
/// Alias to [`self.format().is_static()`].
///
/// [`self.format().is_static()`]: StickerFormat::is_static
#[must_use]
#[deprecated(note = "TBA7.2 brought the breaking change: flags 'is_video' and 'is_animated' \
were removed, so currently there is no way to determine the format of \
the sticker set in the currently supported version (TBA6.6)")]
pub fn is_static(&self) -> bool {
#[allow(deprecated)]
self.format().is_static()
}
/// Returns `true` is this is an [animated] sticker.
///
/// Alias to [`self.format().is_animated()`].
///
/// [`self.format().is_animated()`]: StickerFormat::is_animated
/// [animated]: https://telegram.org/blog/animated-stickers
#[must_use]
#[deprecated(note = "TBA7.2 brought the breaking change: flags 'is_video' and 'is_animated' \
were removed, so currently there is no way to determine the format of \
the sticker set in the currently supported version (TBA6.6)")]
pub fn is_animated(&self) -> bool {
#[allow(deprecated)]
self.format().is_animated()
}
/// Returns `true` is this is a [video] sticker.
///
/// Alias to [`self.format().is_video()`].
///
/// [`self.format().is_video()`]: StickerFormat::is_video
/// [video]: https://telegram.org/blog/video-stickers-better-reactions
#[must_use]
#[deprecated(note = "TBA7.2 brought the breaking change: flags 'is_video' and 'is_animated' \
were removed, so currently there is no way to determine the format of \
the sticker set in the currently supported version (TBA6.6)")]
pub fn is_video(&self) -> bool {
#[allow(deprecated)]
self.format().is_video()
}
}
#[cfg(test)]
mod tests {
use crate::types::StickerSet;

View file

@ -44,7 +44,7 @@ mod tests {
let story = Story {
chat: Chat {
id: ChatId(-1001389841361),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("GNOME".to_owned()),
kind: PublicChatKind::Supergroup(PublicChatSupergroup {
username: Some("gnome_ru".to_owned()),
@ -64,7 +64,7 @@ mod tests {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,

View file

@ -3,9 +3,10 @@ use serde::{de::MapAccess, Deserialize, Serialize, Serializer};
use serde_json::Value;
use crate::types::{
CallbackQuery, Chat, ChatBoostRemoved, ChatBoostUpdated, ChatJoinRequest, ChatMemberUpdated,
ChosenInlineResult, InlineQuery, Message, MessageReactionCountUpdated, MessageReactionUpdated,
Poll, PollAnswer, PreCheckoutQuery, ShippingQuery, User,
BusinessConnection, BusinessMessagesDeleted, CallbackQuery, Chat, ChatBoostRemoved,
ChatBoostUpdated, ChatJoinRequest, ChatMemberUpdated, ChosenInlineResult, InlineQuery, Message,
MessageReactionCountUpdated, MessageReactionUpdated, Poll, PollAnswer, PreCheckoutQuery,
ShippingQuery, User,
};
/// This [object] represents an incoming update.
@ -60,6 +61,19 @@ pub enum UpdateKind {
/// New version of a channel post that is known to the bot and was edited.
EditedChannelPost(Message),
/// The bot was connected to or disconnected from a business account, or a
/// user edited an existing connection with the bot
BusinessConnection(BusinessConnection),
/// New non-service message from a connected business account
BusinessMessage(Message),
/// New version of a message from a connected business account
EditedBusinessMessage(Message),
/// Messages were deleted from a connected business account
DeletedBusinessMessages(BusinessMessagesDeleted),
/// A reaction to a message was changed by a user. The bot must be an
/// administrator in the chat and must explicitly specify
/// [`AllowedUpdate::MessageReaction`] in the list of `allowed_updates`
@ -156,9 +170,14 @@ impl Update {
use UpdateKind::*;
let from = match &self.kind {
Message(m) | EditedMessage(m) | ChannelPost(m) | EditedChannelPost(m) => {
m.from.as_ref()?
}
Message(m)
| EditedMessage(m)
| ChannelPost(m)
| EditedChannelPost(m)
| BusinessMessage(m)
| EditedBusinessMessage(m) => m.from.as_ref()?,
BusinessConnection(conn) => &conn.user,
CallbackQuery(query) => &query.from,
ChosenInlineResult(chosen) => &chosen.from,
@ -173,7 +192,9 @@ impl Update {
ChatBoost(b) => return b.boost.source.user(),
RemovedChatBoost(b) => return b.source.user(),
MessageReactionCount(_) | Poll(_) | Error(_) => return None,
MessageReactionCount(_) | DeletedBusinessMessages(_) | Poll(_) | Error(_) => {
return None
}
};
Some(from)
@ -221,7 +242,9 @@ impl Update {
UpdateKind::Message(message)
| UpdateKind::EditedMessage(message)
| UpdateKind::ChannelPost(message)
| UpdateKind::EditedChannelPost(message) => i0(message.mentioned_users()),
| UpdateKind::EditedChannelPost(message)
| UpdateKind::BusinessMessage(message)
| UpdateKind::EditedBusinessMessage(message) => i0(message.mentioned_users()),
UpdateKind::MessageReaction(answer) => {
if let Some(user) = answer.user() {
@ -262,7 +285,10 @@ impl Update {
i6(empty())
}
UpdateKind::MessageReactionCount(_) | UpdateKind::Error(_) => i6(empty()),
UpdateKind::MessageReactionCount(_)
| UpdateKind::BusinessConnection(_)
| UpdateKind::DeletedBusinessMessages(_)
| UpdateKind::Error(_) => i6(empty()),
}
}
@ -272,7 +298,12 @@ impl Update {
use UpdateKind::*;
let chat = match &self.kind {
Message(m) | EditedMessage(m) | ChannelPost(m) | EditedChannelPost(m) => &m.chat,
Message(m)
| EditedMessage(m)
| ChannelPost(m)
| EditedChannelPost(m)
| BusinessMessage(m)
| EditedBusinessMessage(m) => &m.chat,
CallbackQuery(q) => q.message.as_ref()?.chat(),
ChatMember(m) => &m.chat,
MyChatMember(m) => &m.chat,
@ -281,8 +312,10 @@ impl Update {
MessageReactionCount(r) => &r.chat,
ChatBoost(b) => &b.chat,
RemovedChatBoost(b) => &b.chat,
DeletedBusinessMessages(m) => &m.chat,
InlineQuery(_)
| BusinessConnection(_)
| ChosenInlineResult(_)
| ShippingQuery(_)
| PreCheckoutQuery(_)
@ -350,6 +383,20 @@ impl<'de> Deserialize<'de> for UpdateKind {
"edited_channel_post" => {
map.next_value::<Message>().ok().map(UpdateKind::EditedChannelPost)
}
"business_connection" => map
.next_value::<BusinessConnection>()
.ok()
.map(UpdateKind::BusinessConnection),
"business_message" => {
map.next_value::<Message>().ok().map(UpdateKind::BusinessMessage)
}
"edited_business_message" => {
map.next_value::<Message>().ok().map(UpdateKind::EditedBusinessMessage)
}
"deleted_business_messages" => map
.next_value::<BusinessMessagesDeleted>()
.ok()
.map(UpdateKind::DeletedBusinessMessages),
"message_reaction" => map
.next_value::<MessageReactionUpdated>()
.ok()
@ -423,37 +470,49 @@ impl Serialize for UpdateKind {
UpdateKind::EditedChannelPost(v) => {
s.serialize_newtype_variant(name, 3, "edited_channel_post", v)
}
UpdateKind::BusinessConnection(v) => {
s.serialize_newtype_variant(name, 4, "business_connection", v)
}
UpdateKind::BusinessMessage(v) => {
s.serialize_newtype_variant(name, 5, "business_message", v)
}
UpdateKind::EditedBusinessMessage(v) => {
s.serialize_newtype_variant(name, 6, "edited_business_message", v)
}
UpdateKind::DeletedBusinessMessages(v) => {
s.serialize_newtype_variant(name, 7, "deleted_business_messages", v)
}
UpdateKind::MessageReaction(v) => {
s.serialize_newtype_variant(name, 4, "message_reaction", v)
s.serialize_newtype_variant(name, 8, "message_reaction", v)
}
UpdateKind::MessageReactionCount(v) => {
s.serialize_newtype_variant(name, 5, "message_reaction_count", v)
s.serialize_newtype_variant(name, 9, "message_reaction_count", v)
}
UpdateKind::InlineQuery(v) => s.serialize_newtype_variant(name, 6, "inline_query", v),
UpdateKind::InlineQuery(v) => s.serialize_newtype_variant(name, 10, "inline_query", v),
UpdateKind::ChosenInlineResult(v) => {
s.serialize_newtype_variant(name, 7, "chosen_inline_result", v)
s.serialize_newtype_variant(name, 11, "chosen_inline_result", v)
}
UpdateKind::CallbackQuery(v) => {
s.serialize_newtype_variant(name, 8, "callback_query", v)
s.serialize_newtype_variant(name, 12, "callback_query", v)
}
UpdateKind::ShippingQuery(v) => {
s.serialize_newtype_variant(name, 9, "shipping_query", v)
s.serialize_newtype_variant(name, 13, "shipping_query", v)
}
UpdateKind::PreCheckoutQuery(v) => {
s.serialize_newtype_variant(name, 10, "pre_checkout_query", v)
s.serialize_newtype_variant(name, 14, "pre_checkout_query", v)
}
UpdateKind::Poll(v) => s.serialize_newtype_variant(name, 11, "poll", v),
UpdateKind::PollAnswer(v) => s.serialize_newtype_variant(name, 12, "poll_answer", v),
UpdateKind::Poll(v) => s.serialize_newtype_variant(name, 15, "poll", v),
UpdateKind::PollAnswer(v) => s.serialize_newtype_variant(name, 16, "poll_answer", v),
UpdateKind::MyChatMember(v) => {
s.serialize_newtype_variant(name, 13, "my_chat_member", v)
s.serialize_newtype_variant(name, 17, "my_chat_member", v)
}
UpdateKind::ChatMember(v) => s.serialize_newtype_variant(name, 14, "chat_member", v),
UpdateKind::ChatMember(v) => s.serialize_newtype_variant(name, 18, "chat_member", v),
UpdateKind::ChatJoinRequest(v) => {
s.serialize_newtype_variant(name, 15, "chat_join_request", v)
s.serialize_newtype_variant(name, 19, "chat_join_request", v)
}
UpdateKind::ChatBoost(v) => s.serialize_newtype_variant(name, 16, "chat_boost", v),
UpdateKind::ChatBoost(v) => s.serialize_newtype_variant(name, 20, "chat_boost", v),
UpdateKind::RemovedChatBoost(v) => {
s.serialize_newtype_variant(name, 17, "removed_chat_boost", v)
s.serialize_newtype_variant(name, 21, "removed_chat_boost", v)
}
UpdateKind::Error(v) => v.serialize(s),
}
@ -535,6 +594,11 @@ mod test {
bio: None,
has_private_forwards: None,
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
business_location: None,
business_opening_hours: None,
}),
photo: None,
available_reactions: None,
@ -544,6 +608,7 @@ mod test {
has_aggressive_anti_spam_enabled: false,
chat_full_info: ChatFullInfo::default(),
},
sender_business_bot: None,
kind: MessageKind::Common(MessageCommon {
reply_to_message: None,
forward_origin: None,
@ -567,6 +632,8 @@ mod test {
author_signature: None,
is_automatic_forward: false,
has_protected_content: false,
is_from_offline: false,
business_connection_id: None,
}),
}),
};
@ -863,7 +930,7 @@ mod test {
kind: UpdateKind::MessageReaction(MessageReactionUpdated {
chat: Chat {
id: ChatId(-1002184233434),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Supergroup(PublicChatSupergroup {
username: None,
@ -883,7 +950,7 @@ mod test {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,
@ -940,7 +1007,7 @@ mod test {
"#;
let chat = Chat {
id: ChatId(-1002199793788),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("тест".to_owned()),
kind: PublicChatKind::Supergroup(PublicChatSupergroup {
username: None,
@ -960,7 +1027,7 @@ mod test {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,
@ -1023,7 +1090,7 @@ mod test {
kind: UpdateKind::MessageReactionCount(MessageReactionCountUpdated {
chat: Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
username: None,
@ -1032,7 +1099,7 @@ mod test {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,
@ -1096,7 +1163,7 @@ mod test {
kind: UpdateKind::ChatBoost(ChatBoostUpdated {
chat: Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
username: None,
@ -1105,7 +1172,7 @@ mod test {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,
@ -1171,7 +1238,7 @@ mod test {
kind: UpdateKind::RemovedChatBoost(ChatBoostRemoved {
chat: Chat {
id: ChatId(-1002236736395),
kind: ChatKind::Public(ChatPublic {
kind: ChatKind::Public(Box::new(ChatPublic {
title: Some("Test".to_owned()),
kind: PublicChatKind::Channel(PublicChatChannel {
username: None,
@ -1180,7 +1247,7 @@ mod test {
description: None,
invite_link: None,
has_protected_content: None,
}),
})),
photo: None,
available_reactions: None,
pinned_message: None,

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{RequestId, UserId};
use crate::types::{RequestId, SharedUser};
/// This object contains information about the users whose identifiers were
/// shared with the bot using a [KeyboardButtonRequestUsers] button.
@ -11,5 +11,5 @@ pub struct UsersShared {
/// Identifier of the request
pub request_id: RequestId,
/// Identifiers of the shared users
pub user_ids: Vec<UserId>,
pub users: Vec<SharedUser>,
}

View file

@ -155,6 +155,10 @@ define_update_ext! {
(filter_edited_message, UpdateKind::EditedMessage, EditedMessage),
(filter_channel_post, UpdateKind::ChannelPost, ChannelPost),
(filter_edited_channel_post, UpdateKind::EditedChannelPost, EditedChannelPost),
(filter_business_connection, UpdateKind::BusinessConnection, BusinessConnection),
(filter_business_message, UpdateKind::BusinessMessage, BusinessMessage),
(filter_edited_business_message, UpdateKind::EditedBusinessMessage, EditedBusinessMessage),
(filter_deleted_business_messages, UpdateKind::DeletedBusinessMessages, DeletedBusinessMessages),
(filter_message_reaction_updated, UpdateKind::MessageReaction, MessageReaction),
(filter_message_reaction_count_updated, UpdateKind::MessageReactionCount, MessageReactionCount),
(filter_inline_query, UpdateKind::InlineQuery, InlineQuery),

View file

@ -65,6 +65,10 @@ impl EventKind for Kind {
EditedMessage,
ChannelPost,
EditedChannelPost,
BusinessConnection,
BusinessMessage,
EditedBusinessMessage,
DeletedBusinessMessages,
MessageReaction,
MessageReactionCount,
InlineQuery,
@ -164,10 +168,28 @@ mod tests {
for update in allowed_updates_reference {
match update {
// CAUTION: Don't forget to add new `UpdateKind` to `allowed_updates_reference`!
Message | EditedMessage | ChannelPost | EditedChannelPost | MessageReaction
| MessageReactionCount | InlineQuery | ChosenInlineResult | CallbackQuery
| ShippingQuery | PreCheckoutQuery | Poll | PollAnswer | MyChatMember
| ChatMember | ChatJoinRequest | ChatBoost | RemovedChatBoost => {
Message
| EditedMessage
| ChannelPost
| EditedChannelPost
| MessageReaction
| MessageReactionCount
| InlineQuery
| ChosenInlineResult
| CallbackQuery
| ShippingQuery
| PreCheckoutQuery
| Poll
| PollAnswer
| MyChatMember
| ChatMember
| ChatJoinRequest
| ChatBoost
| RemovedChatBoost
| BusinessMessage
| BusinessConnection
| EditedBusinessMessage
| DeletedBusinessMessages => {
assert!(full_set.contains(&Kind(update)))
}
}

View file

@ -189,6 +189,7 @@ mod tests {
}),
sender_chat: None,
is_topic_message: false,
sender_business_bot: None,
date,
chat: Chat {
id: ChatId(109_998_024),
@ -199,6 +200,11 @@ mod tests {
bio: None,
has_private_forwards: None,
has_restricted_voice_and_video_messages: None,
business_intro: None,
business_location: None,
business_opening_hours: None,
birthdate: None,
personal_chat: None,
}),
photo: None,
available_reactions: None,
@ -231,6 +237,8 @@ mod tests {
has_protected_content: false,
reply_to_story: None,
sender_boost_count: None,
is_from_offline: false,
business_connection_id: None,
}),
}),
}
@ -251,6 +259,7 @@ mod tests {
can_join_groups: false,
can_read_all_group_messages: false,
supports_inline_queries: false,
can_connect_to_business: false,
}
}

View file

@ -1,6 +1,6 @@
//! A full-featured framework that empowers you to easily build [Telegram bots]
//! using [Rust]. It handles all the difficult stuff so you can focus only on
//! your business logic. Currently, version `7.1` of [Telegram Bot API] is
//! your business logic. Currently, version `7.2` of [Telegram Bot API] is
//! supported.
//!
//! For a high-level overview, see [our GitHub repository](https://github.com/teloxide/teloxide).