Merge pull request #789 from teloxide/tba63

TBA 6.3
This commit is contained in:
Waffle Maybe 2022-12-17 01:07:58 +04:00 committed by GitHub
commit 62ff003720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 1095 additions and 55 deletions

View file

@ -230,6 +230,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "text", name: "text",
ty: String, ty: String,
@ -304,6 +309,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "from_chat_id", name: "from_chat_id",
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
@ -344,6 +354,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "from_chat_id", name: "from_chat_id",
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
@ -423,6 +438,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "photo", name: "photo",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -503,6 +523,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "audio", name: "audio",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -603,6 +628,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "document", name: "document",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -696,6 +726,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "video", name: "video",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -802,6 +837,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "animation", name: "animation",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -898,7 +938,7 @@ Schema(
"Message": "https://core.telegram.org/bots/api#message", "Message": "https://core.telegram.org/bots/api#message",
}, },
), ),
tg_doc: "https://core.telegram.org/bots/api#sendaudio", tg_doc: "https://core.telegram.org/bots/api#sendvoice",
tg_category: "Available methods", tg_category: "Available methods",
params: [ params: [
Param( Param(
@ -906,6 +946,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "voice", name: "voice",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -986,6 +1031,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "video_note", name: "video_note",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -1064,6 +1114,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "media", name: "media",
ty: ArrayOf(RawTy("InputMedia")), ty: ArrayOf(RawTy("InputMedia")),
@ -1109,6 +1164,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "latitude", name: "latitude",
ty: f64, ty: f64,
@ -1392,6 +1452,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "latitude", name: "latitude",
ty: f64, ty: f64,
@ -1486,6 +1551,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "phone_number", name: "phone_number",
ty: String, ty: String,
@ -1560,6 +1630,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "question", name: "question",
ty: String, ty: String,
@ -1674,6 +1749,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "emoji", name: "emoji",
ty: Option(RawTy("DiceEmoji")), ty: Option(RawTy("DiceEmoji")),
@ -1942,11 +2022,6 @@ Schema(
ty: Option(bool), ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege"), descr: Doc(md: "Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege"),
), ),
Param(
name: "can_change_info",
ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can change chat title, photo and other settings")
),
Param( Param(
name: "can_post_messages", name: "can_post_messages",
ty: Option(bool), ty: Option(bool),
@ -1967,26 +2042,36 @@ Schema(
ty: Option(bool), ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can manage video chats, supergroups only") descr: Doc(md: "Pass True, if the administrator can manage video chats, supergroups only")
), ),
Param(
name: "can_invite_users",
ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can invite new users to the chat")
),
Param( Param(
name: "can_restrict_members", name: "can_restrict_members",
ty: Option(bool), ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can restrict, ban or unban chat members") descr: Doc(md: "Pass True, if the administrator can restrict, ban or unban chat members")
),
Param(
name: "can_pin_messages",
ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can pin messages, supergroups only")
), ),
Param( Param(
name: "can_promote_members", name: "can_promote_members",
ty: Option(bool), ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)") descr: Doc(md: "Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)")
), ),
Param(
name: "can_change_info",
ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can change chat title, photo and other settings")
),
Param(
name: "can_invite_users",
ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can invite new users to the chat")
),
Param(
name: "can_pin_messages",
ty: Option(bool),
descr: Doc(md: "Pass True, if the administrator can pin messages, supergroups only")
),
Param(
name: "can_manage_topics",
ty: Option(bool),
descr: Doc(md: "Pass True if the user is allowed to create, rename, close, and reopen forum topics, supergroups only")
),
], ],
), ),
Method( Method(
@ -2489,6 +2574,149 @@ Schema(
), ),
], ],
), ),
Method(
names: ("getForumTopicIconStickers", "GetForumTopicIconStickers", "get_forum_topic_icon_stickers"),
return_ty: ArrayOf(RawTy("Sticker")),
doc: Doc(md: "Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of `Sticker` objects."),
tg_doc: "https://core.telegram.org/bots/api#getforumtopiciconstickers",
tg_category: "Available methods",
params: [],
),
Method(
names: ("createForumTopic", "CreateForumTopic", "create_forum_topic"),
return_ty: RawTy("ForumTopic"),
doc: Doc(md: "Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_manage\\_topics_ administrator rights. Returns information about the created topic as a `ForumTopic` object."),
tg_doc: "https://core.telegram.org/bots/api#createforumtopic",
tg_category: "Available methods",
params: [
Param(
name: "chat_id",
ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
),
Param(
name: "name",
ty: String,
descr: Doc(md: "Topic name, 1-128 characters")
),
Param(
name: "icon_color",
// FIXME: use an Rgb or something
ty: u32,
descr: Doc(md: "Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)")
),
Param(
name: "icon_custom_emoji_id",
ty: String,
descr: Doc(md: "Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers.")
),
],
),
Method(
names: ("editForumTopic", "EditForumTopic", "edit_forum_topic"),
return_ty: True,
doc: Doc(md: "Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have _can\\_manage\\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#editforumtopic",
tg_category: "Available methods",
params: [
Param(
name: "chat_id",
ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
),
Param(
name: "message_thread_id",
ty: i32,
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
),
Param(
name: "name",
ty: String,
descr: Doc(md: "Topic name, 1-128 characters")
),
Param(
name: "icon_custom_emoji_id",
ty: String,
descr: Doc(md: "Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers.")
),
],
),
Method(
names: ("closeForumTopic", "CloseForumTopic", "close_forum_topic"),
return_ty: True,
doc: Doc(md: "Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_manage\\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#closeforumtopic",
tg_category: "Available methods",
params: [
Param(
name: "chat_id",
ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
),
Param(
name: "message_thread_id",
ty: i32,
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
),
],
),
Method(
names: ("reopenForumTopic", "ReopenForumTopic", "reopen_forum_topic"),
return_ty: True,
doc: Doc(md: "Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_manage\\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#reopenforumtopic",
tg_category: "Available methods",
params: [
Param(
name: "chat_id",
ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
),
Param(
name: "message_thread_id",
ty: i32,
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
),
],
),
Method(
names: ("deleteForumTopic", "DeleteForumTopic", "delete_forum_topic"),
return_ty: True,
doc: Doc(md: "Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_delete\\_messages_ administrator rights. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#deleteforumtopic",
tg_category: "Available methods",
params: [
Param(
name: "chat_id",
ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
),
Param(
name: "message_thread_id",
ty: i32,
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
),
],
),
Method(
names: ("unpinAllForumTopicMessages", "UnpinAllForumTopicMessages", "unpin_all_forum_topic_messages"),
return_ty: True,
doc: Doc(md: "Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the _can\\_pin\\_messages_ administrator right in the supergroup. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#deleteforumtopic",
tg_category: "Available methods",
params: [
Param(
name: "chat_id",
ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)")
),
Param(
name: "message_thread_id",
ty: i32,
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
),
],
),
Method( Method(
names: ("answerCallbackQuery", "AnswerCallbackQuery", "answer_callback_query"), names: ("answerCallbackQuery", "AnswerCallbackQuery", "answer_callback_query"),
return_ty: True, return_ty: True,
@ -3106,6 +3334,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).") descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).")
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "sticker", name: "sticker",
ty: RawTy("InputFile"), ty: RawTy("InputFile"),
@ -3359,6 +3592,11 @@ Schema(
ty: RawTy("Recipient"), ty: RawTy("Recipient"),
descr: Doc(md: "Unique identifier for the target private chat"), descr: Doc(md: "Unique identifier for the target private chat"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "title", name: "title",
ty: String, ty: String,
@ -3711,6 +3949,11 @@ Schema(
ty: u32, ty: u32,
descr: Doc(md: "Unique identifier for the target chat"), descr: Doc(md: "Unique identifier for the target chat"),
), ),
Param(
name: "message_thread_id",
ty: Option(i32),
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
),
Param( Param(
name: "game_short_name", name: "game_short_name",
ty: String, ty: String,

View file

@ -120,6 +120,13 @@ where
get_chat_member, get_chat_member,
set_chat_sticker_set, set_chat_sticker_set,
delete_chat_sticker_set, delete_chat_sticker_set,
get_forum_topic_icon_stickers,
create_forum_topic,
edit_forum_topic,
close_forum_topic,
reopen_forum_topic,
delete_forum_topic,
unpin_all_forum_topic_messages,
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,

View file

@ -144,6 +144,13 @@ where
get_chat_member, get_chat_member,
set_chat_sticker_set, set_chat_sticker_set,
delete_chat_sticker_set, delete_chat_sticker_set,
get_forum_topic_icon_stickers,
create_forum_topic,
edit_forum_topic,
close_forum_topic,
reopen_forum_topic,
delete_forum_topic,
unpin_all_forum_topic_messages,
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,

View file

@ -233,6 +233,13 @@ where
get_chat_member, get_chat_member,
set_chat_sticker_set, set_chat_sticker_set,
delete_chat_sticker_set, delete_chat_sticker_set,
get_forum_topic_icon_stickers,
create_forum_topic,
edit_forum_topic,
close_forum_topic,
reopen_forum_topic,
delete_forum_topic,
unpin_all_forum_topic_messages,
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
@ -605,6 +612,50 @@ trait ErasableRequester<'a> {
chat_id: Recipient, chat_id: Recipient,
) -> ErasedRequest<'a, DeleteChatStickerSet, Self::Err>; ) -> ErasedRequest<'a, DeleteChatStickerSet, Self::Err>;
fn get_forum_topic_icon_stickers(
&self,
) -> ErasedRequest<'a, GetForumTopicIconStickers, Self::Err>;
fn create_forum_topic(
&self,
chat_id: Recipient,
name: String,
icon_color: u32,
icon_custom_emoji_id: String,
) -> ErasedRequest<'a, CreateForumTopic, Self::Err>;
fn edit_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
name: String,
icon_custom_emoji_id: String,
) -> ErasedRequest<'a, EditForumTopic, Self::Err>;
fn close_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, CloseForumTopic, Self::Err>;
fn reopen_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, ReopenForumTopic, Self::Err>;
fn delete_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, DeleteForumTopic, Self::Err>;
fn unpin_all_forum_topic_messages(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, UnpinAllForumTopicMessages, Self::Err>;
fn answer_callback_query( fn answer_callback_query(
&self, &self,
callback_query_id: String, callback_query_id: String,
@ -1279,6 +1330,65 @@ where
Requester::delete_chat_sticker_set(self, chat_id).erase() Requester::delete_chat_sticker_set(self, chat_id).erase()
} }
fn get_forum_topic_icon_stickers(
&self,
) -> ErasedRequest<'a, GetForumTopicIconStickers, Self::Err> {
Requester::get_forum_topic_icon_stickers(self).erase()
}
fn create_forum_topic(
&self,
chat_id: Recipient,
name: String,
icon_color: u32,
icon_custom_emoji_id: String,
) -> ErasedRequest<'a, CreateForumTopic, Self::Err> {
Requester::create_forum_topic(self, chat_id, name, icon_color, icon_custom_emoji_id).erase()
}
fn edit_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
name: String,
icon_custom_emoji_id: String,
) -> ErasedRequest<'a, EditForumTopic, Self::Err> {
Requester::edit_forum_topic(self, chat_id, message_thread_id, name, icon_custom_emoji_id)
.erase()
}
fn close_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, CloseForumTopic, Self::Err> {
Requester::close_forum_topic(self, chat_id, message_thread_id).erase()
}
fn reopen_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, ReopenForumTopic, Self::Err> {
Requester::reopen_forum_topic(self, chat_id, message_thread_id).erase()
}
fn delete_forum_topic(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, DeleteForumTopic, Self::Err> {
Requester::delete_forum_topic(self, chat_id, message_thread_id).erase()
}
fn unpin_all_forum_topic_messages(
&self,
chat_id: Recipient,
message_thread_id: i32,
) -> ErasedRequest<'a, UnpinAllForumTopicMessages, Self::Err> {
Requester::unpin_all_forum_topic_messages(self, chat_id, message_thread_id).erase()
}
fn answer_callback_query( fn answer_callback_query(
&self, &self,
callback_query_id: String, callback_query_id: String,

View file

@ -143,6 +143,13 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
get_chat_member, get_chat_member,
set_chat_sticker_set, set_chat_sticker_set,
delete_chat_sticker_set, delete_chat_sticker_set,
get_forum_topic_icon_stickers,
create_forum_topic,
edit_forum_topic,
close_forum_topic,
reopen_forum_topic,
delete_forum_topic,
unpin_all_forum_topic_messages,
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,

View file

@ -127,6 +127,13 @@ where
get_chat_member, get_chat_member,
set_chat_sticker_set, set_chat_sticker_set,
delete_chat_sticker_set, delete_chat_sticker_set,
get_forum_topic_icon_stickers,
create_forum_topic,
edit_forum_topic,
close_forum_topic,
reopen_forum_topic,
delete_forum_topic,
unpin_all_forum_topic_messages,
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,

View file

@ -173,6 +173,13 @@ where
get_chat_member, get_chat_member,
set_chat_sticker_set, set_chat_sticker_set,
delete_chat_sticker_set, delete_chat_sticker_set,
get_forum_topic_icon_stickers,
create_forum_topic,
edit_forum_topic,
close_forum_topic,
reopen_forum_topic,
delete_forum_topic,
unpin_all_forum_topic_messages,
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,

View file

@ -644,6 +644,107 @@ impl Requester for Bot {
Self::DeleteChatStickerSet::new(self.clone(), payloads::DeleteChatStickerSet::new(chat_id)) Self::DeleteChatStickerSet::new(self.clone(), payloads::DeleteChatStickerSet::new(chat_id))
} }
type GetForumTopicIconStickers = JsonRequest<payloads::GetForumTopicIconStickers>;
fn get_forum_topic_icon_stickers(&self) -> Self::GetForumTopicIconStickers {
Self::GetForumTopicIconStickers::new(
self.clone(),
payloads::GetForumTopicIconStickers::new(),
)
}
type CreateForumTopic = JsonRequest<payloads::CreateForumTopic>;
fn create_forum_topic<C, N, I>(
&self,
chat_id: C,
name: N,
icon_color: u32,
icon_custom_emoji_id: I,
) -> Self::CreateForumTopic
where
C: Into<Recipient>,
N: Into<String>,
I: Into<String>,
{
Self::CreateForumTopic::new(
self.clone(),
payloads::CreateForumTopic::new(chat_id, name, icon_color, icon_custom_emoji_id),
)
}
type EditForumTopic = JsonRequest<payloads::EditForumTopic>;
fn edit_forum_topic<C, N, I>(
&self,
chat_id: C,
message_thread_id: i32,
name: N,
icon_custom_emoji_id: I,
) -> Self::EditForumTopic
where
C: Into<Recipient>,
N: Into<String>,
I: Into<String>,
{
Self::EditForumTopic::new(
self.clone(),
payloads::EditForumTopic::new(chat_id, message_thread_id, name, icon_custom_emoji_id),
)
}
type CloseForumTopic = JsonRequest<payloads::CloseForumTopic>;
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic
where
C: Into<Recipient>,
{
Self::CloseForumTopic::new(
self.clone(),
payloads::CloseForumTopic::new(chat_id, message_thread_id),
)
}
type ReopenForumTopic = JsonRequest<payloads::ReopenForumTopic>;
fn reopen_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic
where
C: Into<Recipient>,
{
Self::ReopenForumTopic::new(
self.clone(),
payloads::ReopenForumTopic::new(chat_id, message_thread_id),
)
}
type DeleteForumTopic = JsonRequest<payloads::DeleteForumTopic>;
fn delete_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic
where
C: Into<Recipient>,
{
Self::DeleteForumTopic::new(
self.clone(),
payloads::DeleteForumTopic::new(chat_id, message_thread_id),
)
}
type UnpinAllForumTopicMessages = JsonRequest<payloads::UnpinAllForumTopicMessages>;
fn unpin_all_forum_topic_messages<C>(
&self,
chat_id: C,
message_thread_id: i32,
) -> Self::UnpinAllForumTopicMessages
where
C: Into<Recipient>,
{
Self::UnpinAllForumTopicMessages::new(
self.clone(),
payloads::UnpinAllForumTopicMessages::new(chat_id, message_thread_id),
)
}
type AnswerCallbackQuery = JsonRequest<payloads::AnswerCallbackQuery>; type AnswerCallbackQuery = JsonRequest<payloads::AnswerCallbackQuery>;
fn answer_callback_query<C>(&self, callback_query_id: C) -> Self::AnswerCallbackQuery fn answer_callback_query<C>(&self, callback_query_id: C) -> Self::AnswerCallbackQuery

View file

@ -15,7 +15,6 @@ pub(crate) mod schema;
use std::{ use std::{
fs, fs,
io::{Read, Write},
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
@ -79,9 +78,7 @@ pub fn ensure_files_contents<'a>(
let mut err_count = 0; let mut err_count = 0;
for (path, contents) in files_and_contents { for (path, contents) in files_and_contents {
let mut file = fs::File::options().read(true).write(true).create(true).open(path).unwrap(); let old_contents = fs::read_to_string(path).unwrap();
let mut old_contents = String::with_capacity(contents.len());
file.read_to_string(&mut old_contents).unwrap();
if normalize_newlines(&old_contents) == normalize_newlines(contents) { if normalize_newlines(&old_contents) == normalize_newlines(contents) {
// File is already up to date. // File is already up to date.
@ -98,7 +95,7 @@ pub fn ensure_files_contents<'a>(
if let Some(parent) = path.parent() { if let Some(parent) = path.parent() {
let _ = fs::create_dir_all(parent); let _ = fs::create_dir_all(parent);
} }
file.write_all(contents.as_bytes()).unwrap(); fs::write(path, contents.as_bytes()).unwrap();
} }
let (s, were) = match err_count { let (s, were) = match err_count {

View file

@ -908,6 +908,66 @@ macro_rules! requester_forward {
$body!(delete_chat_sticker_set this (chat_id: C)) $body!(delete_chat_sticker_set this (chat_id: C))
} }
}; };
(@method get_forum_topic_icon_stickers $body:ident $ty:ident) => {
type GetForumTopicIconStickers = $ty![GetForumTopicIconStickers];
fn get_forum_topic_icon_stickers(&self, ) -> Self::GetForumTopicIconStickers {
let this = self;
$body!(get_forum_topic_icon_stickers this ())
}
};
(@method create_forum_topic $body:ident $ty:ident) => {
type CreateForumTopic = $ty![CreateForumTopic];
fn create_forum_topic<C, N, I>(&self, chat_id: C, name: N, icon_color: u32, icon_custom_emoji_id: I) -> Self::CreateForumTopic where C: Into<Recipient>,
N: Into<String>,
I: Into<String> {
let this = self;
$body!(create_forum_topic this (chat_id: C, name: N, icon_color: u32, icon_custom_emoji_id: I))
}
};
(@method edit_forum_topic $body:ident $ty:ident) => {
type EditForumTopic = $ty![EditForumTopic];
fn edit_forum_topic<C, N, I>(&self, chat_id: C, message_thread_id: i32, name: N, icon_custom_emoji_id: I) -> Self::EditForumTopic where C: Into<Recipient>,
N: Into<String>,
I: Into<String> {
let this = self;
$body!(edit_forum_topic this (chat_id: C, message_thread_id: i32, name: N, icon_custom_emoji_id: I))
}
};
(@method close_forum_topic $body:ident $ty:ident) => {
type CloseForumTopic = $ty![CloseForumTopic];
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic where C: Into<Recipient> {
let this = self;
$body!(close_forum_topic this (chat_id: C, message_thread_id: i32))
}
};
(@method reopen_forum_topic $body:ident $ty:ident) => {
type ReopenForumTopic = $ty![ReopenForumTopic];
fn reopen_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic where C: Into<Recipient> {
let this = self;
$body!(reopen_forum_topic this (chat_id: C, message_thread_id: i32))
}
};
(@method delete_forum_topic $body:ident $ty:ident) => {
type DeleteForumTopic = $ty![DeleteForumTopic];
fn delete_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic where C: Into<Recipient> {
let this = self;
$body!(delete_forum_topic this (chat_id: C, message_thread_id: i32))
}
};
(@method unpin_all_forum_topic_messages $body:ident $ty:ident) => {
type UnpinAllForumTopicMessages = $ty![UnpinAllForumTopicMessages];
fn unpin_all_forum_topic_messages<C>(&self, chat_id: C, message_thread_id: i32) -> Self::UnpinAllForumTopicMessages where C: Into<Recipient> {
let this = self;
$body!(unpin_all_forum_topic_messages this (chat_id: C, message_thread_id: i32))
}
};
(@method answer_callback_query $body:ident $ty:ident) => { (@method answer_callback_query $body:ident $ty:ident) => {
type AnswerCallbackQuery = $ty![AnswerCallbackQuery]; type AnswerCallbackQuery = $ty![AnswerCallbackQuery];

View file

@ -25,18 +25,22 @@ mod approve_chat_join_request;
mod ban_chat_member; mod ban_chat_member;
mod ban_chat_sender_chat; mod ban_chat_sender_chat;
mod close; mod close;
mod close_forum_topic;
mod copy_message; mod copy_message;
mod create_chat_invite_link; mod create_chat_invite_link;
mod create_forum_topic;
mod create_invoice_link; mod create_invoice_link;
mod create_new_sticker_set; mod create_new_sticker_set;
mod decline_chat_join_request; mod decline_chat_join_request;
mod delete_chat_photo; mod delete_chat_photo;
mod delete_chat_sticker_set; mod delete_chat_sticker_set;
mod delete_forum_topic;
mod delete_message; mod delete_message;
mod delete_my_commands; mod delete_my_commands;
mod delete_sticker_from_set; mod delete_sticker_from_set;
mod delete_webhook; mod delete_webhook;
mod edit_chat_invite_link; mod edit_chat_invite_link;
mod edit_forum_topic;
mod edit_message_caption; mod edit_message_caption;
mod edit_message_caption_inline; mod edit_message_caption_inline;
mod edit_message_live_location; mod edit_message_live_location;
@ -57,6 +61,7 @@ mod get_chat_members_count;
mod get_chat_menu_button; mod get_chat_menu_button;
mod get_custom_emoji_stickers; mod get_custom_emoji_stickers;
mod get_file; mod get_file;
mod get_forum_topic_icon_stickers;
mod get_game_high_scores; mod get_game_high_scores;
mod get_me; mod get_me;
mod get_my_commands; mod get_my_commands;
@ -70,6 +75,7 @@ mod leave_chat;
mod log_out; mod log_out;
mod pin_chat_message; mod pin_chat_message;
mod promote_chat_member; mod promote_chat_member;
mod reopen_forum_topic;
mod restrict_chat_member; mod restrict_chat_member;
mod revoke_chat_invite_link; mod revoke_chat_invite_link;
mod send_animation; mod send_animation;
@ -111,6 +117,7 @@ mod stop_poll;
mod unban_chat_member; mod unban_chat_member;
mod unban_chat_sender_chat; mod unban_chat_sender_chat;
mod unpin_all_chat_messages; mod unpin_all_chat_messages;
mod unpin_all_forum_topic_messages;
mod unpin_chat_message; mod unpin_chat_message;
mod upload_sticker_file; mod upload_sticker_file;
@ -124,18 +131,22 @@ pub use approve_chat_join_request::{ApproveChatJoinRequest, ApproveChatJoinReque
pub use ban_chat_member::{BanChatMember, BanChatMemberSetters}; pub use ban_chat_member::{BanChatMember, BanChatMemberSetters};
pub use ban_chat_sender_chat::{BanChatSenderChat, BanChatSenderChatSetters}; pub use ban_chat_sender_chat::{BanChatSenderChat, BanChatSenderChatSetters};
pub use close::{Close, CloseSetters}; pub use close::{Close, CloseSetters};
pub use close_forum_topic::{CloseForumTopic, CloseForumTopicSetters};
pub use copy_message::{CopyMessage, CopyMessageSetters}; pub use copy_message::{CopyMessage, CopyMessageSetters};
pub use create_chat_invite_link::{CreateChatInviteLink, CreateChatInviteLinkSetters}; pub use create_chat_invite_link::{CreateChatInviteLink, CreateChatInviteLinkSetters};
pub use create_forum_topic::{CreateForumTopic, CreateForumTopicSetters};
pub use create_invoice_link::{CreateInvoiceLink, CreateInvoiceLinkSetters}; pub use create_invoice_link::{CreateInvoiceLink, CreateInvoiceLinkSetters};
pub use create_new_sticker_set::{CreateNewStickerSet, CreateNewStickerSetSetters}; pub use create_new_sticker_set::{CreateNewStickerSet, CreateNewStickerSetSetters};
pub use decline_chat_join_request::{DeclineChatJoinRequest, DeclineChatJoinRequestSetters}; pub use decline_chat_join_request::{DeclineChatJoinRequest, DeclineChatJoinRequestSetters};
pub use delete_chat_photo::{DeleteChatPhoto, DeleteChatPhotoSetters}; pub use delete_chat_photo::{DeleteChatPhoto, DeleteChatPhotoSetters};
pub use delete_chat_sticker_set::{DeleteChatStickerSet, DeleteChatStickerSetSetters}; pub use delete_chat_sticker_set::{DeleteChatStickerSet, DeleteChatStickerSetSetters};
pub use delete_forum_topic::{DeleteForumTopic, DeleteForumTopicSetters};
pub use delete_message::{DeleteMessage, DeleteMessageSetters}; pub use delete_message::{DeleteMessage, DeleteMessageSetters};
pub use delete_my_commands::{DeleteMyCommands, DeleteMyCommandsSetters}; pub use delete_my_commands::{DeleteMyCommands, DeleteMyCommandsSetters};
pub use delete_sticker_from_set::{DeleteStickerFromSet, DeleteStickerFromSetSetters}; pub use delete_sticker_from_set::{DeleteStickerFromSet, DeleteStickerFromSetSetters};
pub use delete_webhook::{DeleteWebhook, DeleteWebhookSetters}; pub use delete_webhook::{DeleteWebhook, DeleteWebhookSetters};
pub use edit_chat_invite_link::{EditChatInviteLink, EditChatInviteLinkSetters}; pub use edit_chat_invite_link::{EditChatInviteLink, EditChatInviteLinkSetters};
pub use edit_forum_topic::{EditForumTopic, EditForumTopicSetters};
pub use edit_message_caption::{EditMessageCaption, EditMessageCaptionSetters}; pub use edit_message_caption::{EditMessageCaption, EditMessageCaptionSetters};
pub use edit_message_caption_inline::{EditMessageCaptionInline, EditMessageCaptionInlineSetters}; pub use edit_message_caption_inline::{EditMessageCaptionInline, EditMessageCaptionInlineSetters};
pub use edit_message_live_location::{EditMessageLiveLocation, EditMessageLiveLocationSetters}; pub use edit_message_live_location::{EditMessageLiveLocation, EditMessageLiveLocationSetters};
@ -160,6 +171,9 @@ pub use get_chat_members_count::{GetChatMembersCount, GetChatMembersCountSetters
pub use get_chat_menu_button::{GetChatMenuButton, GetChatMenuButtonSetters}; pub use get_chat_menu_button::{GetChatMenuButton, GetChatMenuButtonSetters};
pub use get_custom_emoji_stickers::{GetCustomEmojiStickers, GetCustomEmojiStickersSetters}; pub use get_custom_emoji_stickers::{GetCustomEmojiStickers, GetCustomEmojiStickersSetters};
pub use get_file::{GetFile, GetFileSetters}; pub use get_file::{GetFile, GetFileSetters};
pub use get_forum_topic_icon_stickers::{
GetForumTopicIconStickers, GetForumTopicIconStickersSetters,
};
pub use get_game_high_scores::{GetGameHighScores, GetGameHighScoresSetters}; pub use get_game_high_scores::{GetGameHighScores, GetGameHighScoresSetters};
pub use get_me::{GetMe, GetMeSetters}; pub use get_me::{GetMe, GetMeSetters};
pub use get_my_commands::{GetMyCommands, GetMyCommandsSetters}; pub use get_my_commands::{GetMyCommands, GetMyCommandsSetters};
@ -175,6 +189,7 @@ pub use leave_chat::{LeaveChat, LeaveChatSetters};
pub use log_out::{LogOut, LogOutSetters}; pub use log_out::{LogOut, LogOutSetters};
pub use pin_chat_message::{PinChatMessage, PinChatMessageSetters}; pub use pin_chat_message::{PinChatMessage, PinChatMessageSetters};
pub use promote_chat_member::{PromoteChatMember, PromoteChatMemberSetters}; pub use promote_chat_member::{PromoteChatMember, PromoteChatMemberSetters};
pub use reopen_forum_topic::{ReopenForumTopic, ReopenForumTopicSetters};
pub use restrict_chat_member::{RestrictChatMember, RestrictChatMemberSetters}; pub use restrict_chat_member::{RestrictChatMember, RestrictChatMemberSetters};
pub use revoke_chat_invite_link::{RevokeChatInviteLink, RevokeChatInviteLinkSetters}; pub use revoke_chat_invite_link::{RevokeChatInviteLink, RevokeChatInviteLinkSetters};
pub use send_animation::{SendAnimation, SendAnimationSetters}; pub use send_animation::{SendAnimation, SendAnimationSetters};
@ -222,6 +237,9 @@ pub use stop_poll::{StopPoll, StopPollSetters};
pub use unban_chat_member::{UnbanChatMember, UnbanChatMemberSetters}; pub use unban_chat_member::{UnbanChatMember, UnbanChatMemberSetters};
pub use unban_chat_sender_chat::{UnbanChatSenderChat, UnbanChatSenderChatSetters}; pub use unban_chat_sender_chat::{UnbanChatSenderChat, UnbanChatSenderChatSetters};
pub use unpin_all_chat_messages::{UnpinAllChatMessages, UnpinAllChatMessagesSetters}; pub use unpin_all_chat_messages::{UnpinAllChatMessages, UnpinAllChatMessagesSetters};
pub use unpin_all_forum_topic_messages::{
UnpinAllForumTopicMessages, UnpinAllForumTopicMessagesSetters,
};
pub use unpin_chat_message::{UnpinChatMessage, UnpinChatMessageSetters}; pub use unpin_chat_message::{UnpinChatMessage, UnpinChatMessageSetters};
pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters}; pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters};
// END BLOCK payload_modules // END BLOCK payload_modules

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{Recipient, True};
impl_payload! {
/// Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub CloseForumTopic (CloseForumTopicSetters) => True {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: Recipient [into],
/// Unique identifier for the target message thread of the forum topic
pub message_thread_id: i32,
}
}
}

View file

@ -20,6 +20,8 @@ impl_payload! {
pub message_id: MessageId, pub message_id: MessageId,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept /// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
pub caption: String [into], pub caption: String [into],
/// Mode for parsing entities in the photo caption. See [formatting options] for more details. /// Mode for parsing entities in the photo caption. See [formatting options] for more details.

View file

@ -0,0 +1,22 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{ForumTopic, Recipient};
impl_payload! {
/// Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. Returns information about the created topic as a `ForumTopic` object.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub CreateForumTopic (CreateForumTopicSetters) => ForumTopic {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: Recipient [into],
/// Topic name, 1-128 characters
pub name: String [into],
/// Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)
pub icon_color: u32,
/// Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers.
pub icon_custom_emoji_id: String [into],
}
}
}

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{Recipient, True};
impl_payload! {
/// Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_delete\_messages_ administrator rights. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub DeleteForumTopic (DeleteForumTopicSetters) => True {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: Recipient [into],
/// Unique identifier for the target message thread of the forum topic
pub message_thread_id: i32,
}
}
}

View file

@ -0,0 +1,22 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{Recipient, True};
impl_payload! {
/// Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub EditForumTopic (EditForumTopicSetters) => True {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: Recipient [into],
/// Unique identifier for the target message thread of the forum topic
pub message_thread_id: i32,
/// Topic name, 1-128 characters
pub name: String [into],
/// Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers.
pub icon_custom_emoji_id: String [into],
}
}
}

View file

@ -20,6 +20,8 @@ impl_payload! {
pub message_id: MessageId, pub message_id: MessageId,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Sends the message [silently]. Users will receive a notification with no sound. /// Sends the message [silently]. Users will receive a notification with no sound.
/// ///
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages

View file

@ -0,0 +1,13 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::Sticker;
impl_payload! {
/// Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of `Sticker` objects.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub GetForumTopicIconStickers (GetForumTopicIconStickersSetters) => Vec<Sticker> {
}
}

View file

@ -19,8 +19,6 @@ impl_payload! {
pub is_anonymous: bool, pub is_anonymous: bool,
/// Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege /// Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
pub can_manage_chat: bool, pub can_manage_chat: bool,
/// Pass True, if the administrator can change chat title, photo and other settings
pub can_change_info: bool,
/// Pass True, if the administrator can create channel posts, channels only /// Pass True, if the administrator can create channel posts, channels only
pub can_post_messages: bool, pub can_post_messages: bool,
/// Pass True, if the administrator can edit messages of other users and can pin messages, channels only /// Pass True, if the administrator can edit messages of other users and can pin messages, channels only
@ -29,14 +27,18 @@ impl_payload! {
pub can_delete_messages: bool, pub can_delete_messages: bool,
/// Pass True, if the administrator can manage video chats, supergroups only /// Pass True, if the administrator can manage video chats, supergroups only
pub can_manage_video_chats: bool, pub can_manage_video_chats: bool,
/// Pass True, if the administrator can invite new users to the chat
pub can_invite_users: bool,
/// Pass True, if the administrator can restrict, ban or unban chat members /// Pass True, if the administrator can restrict, ban or unban chat members
pub can_restrict_members: bool, pub can_restrict_members: bool,
/// Pass True, if the administrator can pin messages, supergroups only
pub can_pin_messages: bool,
/// Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) /// Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
pub can_promote_members: bool, pub can_promote_members: bool,
/// Pass True, if the administrator can change chat title, photo and other settings
pub can_change_info: bool,
/// Pass True, if the administrator can invite new users to the chat
pub can_invite_users: bool,
/// Pass True, if the administrator can pin messages, supergroups only
pub can_pin_messages: bool,
/// Pass True if the user is allowed to create, rename, close, and reopen forum topics, supergroups only
pub can_manage_topics: bool,
} }
} }
} }

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{Recipient, True};
impl_payload! {
/// Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub ReopenForumTopic (ReopenForumTopicSetters) => True {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: Recipient [into],
/// Unique identifier for the target message thread of the forum topic
pub message_thread_id: i32,
}
}
}

View file

@ -22,6 +22,8 @@ impl_payload! {
pub animation: InputFile, pub animation: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Duration of the animation in seconds /// Duration of the animation in seconds
pub duration: u32, pub duration: u32,
/// Animation width /// Animation width

View file

@ -25,6 +25,8 @@ impl_payload! {
pub audio: InputFile, pub audio: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Audio caption, 0-1024 characters after entities parsing /// Audio caption, 0-1024 characters after entities parsing
pub caption: String [into], pub caption: String [into],
/// Mode for parsing entities in the audio caption. See [formatting options] for more details. /// Mode for parsing entities in the audio caption. See [formatting options] for more details.

View file

@ -19,6 +19,8 @@ impl_payload! {
pub first_name: String [into], pub first_name: String [into],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Contact's last name /// Contact's last name
pub last_name: String [into], pub last_name: String [into],
/// Additional data about the contact in the form of a [vCard], 0-2048 bytes /// Additional data about the contact in the form of a [vCard], 0-2048 bytes

View file

@ -15,6 +15,8 @@ impl_payload! {
pub chat_id: Recipient [into], pub chat_id: Recipient [into],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// 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 “🎲” /// 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 “🎲”
pub emoji: DiceEmoji, pub emoji: DiceEmoji,
/// Sends the message [silently]. Users will receive a notification with no sound. /// Sends the message [silently]. Users will receive a notification with no sound.

View file

@ -22,6 +22,8 @@ impl_payload! {
pub document: InputFile, pub document: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// 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 »] /// 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 »]
/// ///
/// [More info on Sending Files »]: crate::types::InputFile /// [More info on Sending Files »]: crate::types::InputFile

View file

@ -17,6 +17,8 @@ impl_payload! {
pub game_short_name: String [into], pub game_short_name: String [into],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Sends the message [silently]. Users will receive a notification with no sound. /// Sends the message [silently]. Users will receive a notification with no sound.
/// ///
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages

View file

@ -30,6 +30,8 @@ impl_payload! {
pub prices: Vec<LabeledPrice> [collect], pub prices: Vec<LabeledPrice> [collect],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double). For example, for a maximum tip of `US$ 1.45` pass `max_tip_amount = 145`. See the exp parameter in [`currencies.json`], it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 /// The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double). For example, for a maximum tip of `US$ 1.45` pass `max_tip_amount = 145`. See the exp parameter in [`currencies.json`], it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0
/// ///
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json /// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json

View file

@ -19,6 +19,8 @@ impl_payload! {
pub longitude: f64, pub longitude: f64,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// The radius of uncertainty for the location, measured in meters; 0-1500 /// The radius of uncertainty for the location, measured in meters; 0-1500
pub horizontal_accuracy: f64, pub horizontal_accuracy: f64,
/// Period in seconds for which the location will be updated (see [Live Locations], should be between 60 and 86400. /// Period in seconds for which the location will be updated (see [Live Locations], should be between 60 and 86400.

View file

@ -17,6 +17,8 @@ impl_payload! {
pub media: Vec<InputMedia> [collect], pub media: Vec<InputMedia> [collect],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Sends the message [silently]. Users will receive a notification with no sound. /// Sends the message [silently]. Users will receive a notification with no sound.
/// ///
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages

View file

@ -17,6 +17,8 @@ impl_payload! {
pub text: String [into], pub text: String [into],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Mode for parsing entities in the message text. See [formatting options] for more details. /// Mode for parsing entities in the message text. See [formatting options] for more details.
/// ///
/// [formatting options]: https://core.telegram.org/bots/api#formatting-options /// [formatting options]: https://core.telegram.org/bots/api#formatting-options

View file

@ -22,6 +22,8 @@ impl_payload! {
pub photo: InputFile, pub photo: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Photo caption (may also be used when resending photos by _file\_id_), 0-1024 characters after entities parsing /// Photo caption (may also be used when resending photos by _file\_id_), 0-1024 characters after entities parsing
pub caption: String [into], pub caption: String [into],
/// Mode for parsing entities in the photo caption. See [formatting options] for more details. /// Mode for parsing entities in the photo caption. See [formatting options] for more details.

View file

@ -22,6 +22,8 @@ impl_payload! {
pub options: Vec<String> [collect], pub options: Vec<String> [collect],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// True, if the poll needs to be anonymous, defaults to True /// True, if the poll needs to be anonymous, defaults to True
pub is_anonymous: bool, pub is_anonymous: bool,
/// Poll type, “quiz” or “regular”, defaults to “regular” /// Poll type, “quiz” or “regular”, defaults to “regular”

View file

@ -20,6 +20,8 @@ impl_payload! {
pub sticker: InputFile, pub sticker: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Sends the message [silently]. Users will receive a notification with no sound. /// Sends the message [silently]. Users will receive a notification with no sound.
/// ///
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages

View file

@ -23,6 +23,8 @@ impl_payload! {
pub address: String [into], pub address: String [into],
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Foursquare identifier of the venue /// Foursquare identifier of the venue
pub foursquare_id: String [into], pub foursquare_id: String [into],
/// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) /// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)

View file

@ -23,6 +23,8 @@ impl_payload! {
pub video: InputFile, pub video: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Duration of the video in seconds /// Duration of the video in seconds
pub duration: u32, pub duration: u32,
/// Video width /// Video width

View file

@ -21,6 +21,8 @@ impl_payload! {
pub video_note: InputFile, pub video_note: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Duration of the video in seconds /// Duration of the video in seconds
pub duration: u32, pub duration: u32,
/// Video width and height, i.e. diameter of the video message /// Video width and height, i.e. diameter of the video message

View file

@ -24,6 +24,8 @@ impl_payload! {
pub voice: InputFile, pub voice: InputFile,
} }
optional { optional {
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: i32,
/// Voice message caption, 0-1024 characters after entities parsing /// Voice message caption, 0-1024 characters after entities parsing
pub caption: String [into], pub caption: String [into],
/// Mode for parsing entities in the voice message caption. See [formatting options] for more details. /// Mode for parsing entities in the voice message caption. See [formatting options] for more details.

View file

@ -5,27 +5,30 @@ pub use crate::payloads::{
AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _, AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _,
AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _, AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _,
AnswerWebAppQuerySetters as _, ApproveChatJoinRequestSetters as _, BanChatMemberSetters as _, AnswerWebAppQuerySetters as _, ApproveChatJoinRequestSetters as _, BanChatMemberSetters as _,
BanChatSenderChatSetters as _, CloseSetters as _, CopyMessageSetters as _, BanChatSenderChatSetters as _, CloseForumTopicSetters as _, CloseSetters as _,
CreateChatInviteLinkSetters as _, CreateInvoiceLinkSetters as _, CopyMessageSetters as _, CreateChatInviteLinkSetters as _, CreateForumTopicSetters as _,
CreateNewStickerSetSetters as _, DeclineChatJoinRequestSetters as _, CreateInvoiceLinkSetters as _, CreateNewStickerSetSetters as _,
DeleteChatPhotoSetters as _, DeleteChatStickerSetSetters as _, DeleteMessageSetters as _, DeclineChatJoinRequestSetters as _, DeleteChatPhotoSetters as _,
DeleteChatStickerSetSetters as _, DeleteForumTopicSetters as _, DeleteMessageSetters as _,
DeleteMyCommandsSetters as _, DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _, DeleteMyCommandsSetters as _, DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _,
EditChatInviteLinkSetters as _, EditMessageCaptionInlineSetters as _, EditChatInviteLinkSetters as _, EditForumTopicSetters as _,
EditMessageCaptionSetters as _, EditMessageLiveLocationInlineSetters as _, EditMessageCaptionInlineSetters as _, EditMessageCaptionSetters as _,
EditMessageLiveLocationSetters as _, EditMessageMediaInlineSetters as _, EditMessageLiveLocationInlineSetters as _, EditMessageLiveLocationSetters as _,
EditMessageMediaSetters as _, EditMessageReplyMarkupInlineSetters as _, EditMessageMediaInlineSetters as _, EditMessageMediaSetters as _,
EditMessageReplyMarkupSetters as _, EditMessageTextInlineSetters as _, EditMessageReplyMarkupInlineSetters as _, EditMessageReplyMarkupSetters as _,
EditMessageTextSetters as _, ExportChatInviteLinkSetters as _, ForwardMessageSetters as _, EditMessageTextInlineSetters as _, EditMessageTextSetters as _,
ExportChatInviteLinkSetters as _, ForwardMessageSetters as _,
GetChatAdministratorsSetters as _, GetChatMemberCountSetters as _, GetChatMemberSetters as _, GetChatAdministratorsSetters as _, GetChatMemberCountSetters as _, GetChatMemberSetters as _,
GetChatMembersCountSetters as _, GetChatMenuButtonSetters as _, GetChatSetters as _, GetChatMembersCountSetters as _, GetChatMenuButtonSetters as _, GetChatSetters as _,
GetCustomEmojiStickersSetters as _, GetFileSetters as _, GetGameHighScoresSetters as _, GetCustomEmojiStickersSetters as _, GetFileSetters as _, GetForumTopicIconStickersSetters as _,
GetMeSetters as _, GetMyCommandsSetters as _, GetMyDefaultAdministratorRightsSetters as _, GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _,
GetStickerSetSetters as _, GetUpdatesSetters as _, GetUserProfilePhotosSetters as _, GetMyDefaultAdministratorRightsSetters as _, GetStickerSetSetters as _, GetUpdatesSetters as _,
GetWebhookInfoSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _, GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _, KickChatMemberSetters as _,
LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _, LeaveChatSetters as _, LogOutSetters as _, PinChatMessageSetters as _,
RestrictChatMemberSetters as _, RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, PromoteChatMemberSetters as _, ReopenForumTopicSetters as _, RestrictChatMemberSetters as _,
SendAudioSetters as _, SendChatActionSetters as _, SendContactSetters as _, RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, SendAudioSetters as _,
SendDiceSetters as _, SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _, SendChatActionSetters as _, SendContactSetters as _, SendDiceSetters as _,
SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _,
SendLocationSetters as _, SendMediaGroupSetters as _, SendMessageSetters as _, SendLocationSetters as _, SendMediaGroupSetters as _, SendMessageSetters as _,
SendPhotoSetters as _, SendPollSetters as _, SendStickerSetters as _, SendVenueSetters as _, SendPhotoSetters as _, SendPollSetters as _, SendStickerSetters as _, SendVenueSetters as _,
SendVideoNoteSetters as _, SendVideoSetters as _, SendVoiceSetters as _, SendVideoNoteSetters as _, SendVideoSetters as _, SendVoiceSetters as _,
@ -37,5 +40,6 @@ pub use crate::payloads::{
SetStickerPositionInSetSetters as _, SetStickerSetThumbSetters as _, SetWebhookSetters as _, SetStickerPositionInSetSetters as _, SetStickerSetThumbSetters as _, SetWebhookSetters as _,
StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _, StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _,
StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _, StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _,
UnpinAllChatMessagesSetters as _, UnpinChatMessageSetters as _, UploadStickerFileSetters as _, UnpinAllChatMessagesSetters as _, UnpinAllForumTopicMessagesSetters as _,
UnpinChatMessageSetters as _, UploadStickerFileSetters as _,
}; };

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::{Recipient, True};
impl_payload! {
/// Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the _can\_pin\_messages_ administrator right in the supergroup. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub UnpinAllForumTopicMessages (UnpinAllForumTopicMessagesSetters) => True {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: Recipient [into],
/// Unique identifier for the target message thread of the forum topic
pub message_thread_id: i32,
}
}
}

View file

@ -659,6 +659,73 @@ pub trait Requester {
where where
C: Into<Recipient>; C: Into<Recipient>;
type GetForumTopicIconStickers: Request<Payload = GetForumTopicIconStickers, Err = Self::Err>;
/// For Telegram documentation see [`GetForumTopicIconStickers`].
fn get_forum_topic_icon_stickers(&self) -> Self::GetForumTopicIconStickers;
type CreateForumTopic: Request<Payload = CreateForumTopic, Err = Self::Err>;
/// For Telegram documentation see [`CreateForumTopic`].
fn create_forum_topic<C, N, I>(
&self,
chat_id: C,
name: N,
icon_color: u32,
icon_custom_emoji_id: I,
) -> Self::CreateForumTopic
where
C: Into<Recipient>,
N: Into<String>,
I: Into<String>;
type EditForumTopic: Request<Payload = EditForumTopic, Err = Self::Err>;
/// For Telegram documentation see [`EditForumTopic`].
fn edit_forum_topic<C, N, I>(
&self,
chat_id: C,
message_thread_id: i32,
name: N,
icon_custom_emoji_id: I,
) -> Self::EditForumTopic
where
C: Into<Recipient>,
N: Into<String>,
I: Into<String>;
type CloseForumTopic: Request<Payload = CloseForumTopic, Err = Self::Err>;
/// For Telegram documentation see [`CloseForumTopic`].
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic
where
C: Into<Recipient>;
type ReopenForumTopic: Request<Payload = ReopenForumTopic, Err = Self::Err>;
/// For Telegram documentation see [`ReopenForumTopic`].
fn reopen_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic
where
C: Into<Recipient>;
type DeleteForumTopic: Request<Payload = DeleteForumTopic, Err = Self::Err>;
/// For Telegram documentation see [`DeleteForumTopic`].
fn delete_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic
where
C: Into<Recipient>;
type UnpinAllForumTopicMessages: Request<Payload = UnpinAllForumTopicMessages, Err = Self::Err>;
/// For Telegram documentation see [`UnpinAllForumTopicMessages`].
fn unpin_all_forum_topic_messages<C>(
&self,
chat_id: C,
message_thread_id: i32,
) -> Self::UnpinAllForumTopicMessages
where
C: Into<Recipient>;
type AnswerCallbackQuery: Request<Payload = AnswerCallbackQuery, Err = Self::Err>; type AnswerCallbackQuery: Request<Payload = AnswerCallbackQuery, Err = Self::Err>;
/// For Telegram documentation see [`AnswerCallbackQuery`]. /// For Telegram documentation see [`AnswerCallbackQuery`].
@ -1103,6 +1170,13 @@ macro_rules! forward_all {
get_chat_member, get_chat_member,
set_chat_sticker_set, set_chat_sticker_set,
delete_chat_sticker_set, delete_chat_sticker_set,
get_forum_topic_icon_stickers,
create_forum_topic,
edit_forum_topic,
close_forum_topic,
reopen_forum_topic,
delete_forum_topic,
unpin_all_forum_topic_messages,
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,

View file

@ -27,6 +27,10 @@ pub use encrypted_credentials::*;
pub use encrypted_passport_element::*; pub use encrypted_passport_element::*;
pub use file::*; pub use file::*;
pub use force_reply::*; pub use force_reply::*;
pub use forum_topic::*;
pub use forum_topic_closed::*;
pub use forum_topic_created::*;
pub use forum_topic_reopened::*;
pub use game::*; pub use game::*;
pub use game_high_score::*; pub use game_high_score::*;
pub use inline_keyboard_button::*; pub use inline_keyboard_button::*;
@ -86,7 +90,6 @@ pub use reply_keyboard_remove::*;
pub use reply_markup::*; pub use reply_markup::*;
pub use response_parameters::*; pub use response_parameters::*;
pub use sent_web_app_message::*; pub use sent_web_app_message::*;
use serde::Serialize;
pub use shipping_address::*; pub use shipping_address::*;
pub use shipping_option::*; pub use shipping_option::*;
pub use shipping_query::*; pub use shipping_query::*;
@ -136,6 +139,10 @@ mod dice_emoji;
mod document; mod document;
mod file; mod file;
mod force_reply; mod force_reply;
mod forum_topic;
mod forum_topic_closed;
mod forum_topic_created;
mod forum_topic_reopened;
mod game; mod game;
mod game_high_score; mod game_high_score;
mod inline_keyboard_button; mod inline_keyboard_button;
@ -239,6 +246,8 @@ pub use chat_id::*;
pub use recipient::*; pub use recipient::*;
pub use user_id::*; pub use user_id::*;
use serde::Serialize;
/// Converts an `i64` timestump to a `choro::DateTime`, producing serde error /// Converts an `i64` timestump to a `choro::DateTime`, producing serde error
/// for invalid timestumps /// for invalid timestumps
pub(crate) fn serde_timestamp<E: serde::de::Error>( pub(crate) fn serde_timestamp<E: serde::de::Error>(
@ -420,3 +429,49 @@ where
{ {
this.map(|MessageId(id)| id).serialize(serializer) this.map(|MessageId(id)| id).serialize(serializer)
} }
pub(crate) mod serde_rgb {
use serde::{de::Visitor, Deserializer, Serializer};
pub fn serialize<S: Serializer>(&this: &[u8; 3], s: S) -> Result<S::Ok, S::Error> {
s.serialize_u32(to_u32(this))
}
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<[u8; 3], D::Error> {
struct V;
impl Visitor<'_> for V {
type Value = [u8; 3];
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
formatter.write_str("an integer represeting an RGB color")
}
fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
Ok(from_u32(v))
}
}
d.deserialize_u32(V)
}
fn to_u32([r, g, b]: [u8; 3]) -> u32 {
u32::from_be_bytes([0, r, g, b])
}
fn from_u32(rgb: u32) -> [u8; 3] {
let [_, r, g, b] = rgb.to_be_bytes();
[r, g, b]
}
#[test]
fn bytes() {
assert_eq!(to_u32([0xAA, 0xBB, 0xCC]), 0x00AABBCC);
assert_eq!(from_u32(0x00AABBCC), [0xAA, 0xBB, 0xCC]);
}
#[test]
fn json() {}
}

View file

@ -88,6 +88,13 @@ pub struct ChatPrivate {
/// A last name of the other party in a private chat. /// A last name of the other party in a private chat.
pub last_name: Option<String>, pub last_name: Option<String>,
/// Custom emoji identifier of emoji status of the other party in a private
/// chat. Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
// FIXME: CustomEmojiId
pub emoji_status_custom_emoji_id: Option<String>,
/// Bio of the other party in a private chat. Returned only in [`GetChat`]. /// Bio of the other party in a private chat. Returned only in [`GetChat`].
/// ///
/// [`GetChat`]: crate::payloads::GetChat /// [`GetChat`]: crate::payloads::GetChat
@ -148,6 +155,16 @@ pub struct PublicChatSupergroup {
/// available. /// available.
pub username: Option<String>, pub username: Option<String>,
/// If non-empty, the list of all active chat usernames; for private chats,
/// supergroups and channels. Returned only from [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub active_usernames: Option<Vec<String>>,
/// `true`, if the supergroup chat is a forum (has topics enabled).
#[serde(default)]
pub is_forum: bool,
/// For supergroups, name of group sticker set. Returned only from /// For supergroups, name of group sticker set. Returned only from
/// [`GetChat`]. /// [`GetChat`].
/// ///
@ -485,6 +502,7 @@ mod serde_helper {
bio: Option<String>, bio: Option<String>,
has_private_forwards: Option<True>, has_private_forwards: Option<True>,
has_restricted_voice_and_video_messages: Option<True>, has_restricted_voice_and_video_messages: Option<True>,
emoji_status_custom_emoji_id: Option<String>,
} }
impl From<ChatPrivate> for super::ChatPrivate { impl From<ChatPrivate> for super::ChatPrivate {
@ -497,6 +515,7 @@ mod serde_helper {
bio, bio,
has_private_forwards, has_private_forwards,
has_restricted_voice_and_video_messages, has_restricted_voice_and_video_messages,
emoji_status_custom_emoji_id,
}: ChatPrivate, }: ChatPrivate,
) -> Self { ) -> Self {
Self { Self {
@ -506,6 +525,7 @@ mod serde_helper {
bio, bio,
has_private_forwards, has_private_forwards,
has_restricted_voice_and_video_messages, has_restricted_voice_and_video_messages,
emoji_status_custom_emoji_id,
} }
} }
} }
@ -519,6 +539,7 @@ mod serde_helper {
bio, bio,
has_private_forwards, has_private_forwards,
has_restricted_voice_and_video_messages, has_restricted_voice_and_video_messages,
emoji_status_custom_emoji_id,
}: super::ChatPrivate, }: super::ChatPrivate,
) -> Self { ) -> Self {
Self { Self {
@ -529,6 +550,7 @@ mod serde_helper {
bio, bio,
has_private_forwards, has_private_forwards,
has_restricted_voice_and_video_messages, has_restricted_voice_and_video_messages,
emoji_status_custom_emoji_id,
} }
} }
} }
@ -574,6 +596,7 @@ mod tests {
bio: None, bio: None,
has_private_forwards: None, has_private_forwards: None,
has_restricted_voice_and_video_messages: None, has_restricted_voice_and_video_messages: None,
emoji_status_custom_emoji_id: None
}), }),
photo: None, photo: None,
pinned_message: None, pinned_message: None,
@ -595,6 +618,7 @@ mod tests {
bio: None, bio: None,
has_private_forwards: None, has_private_forwards: None,
has_restricted_voice_and_video_messages: None, has_restricted_voice_and_video_messages: None,
emoji_status_custom_emoji_id: None,
}), }),
photo: None, photo: None,
pinned_message: None, pinned_message: None,

View file

@ -45,4 +45,8 @@ pub struct ChatAdministratorRights {
/// `true`, if the user is allowed to pin messages; groups and /// `true`, if the user is allowed to pin messages; groups and
/// supergroups only /// supergroups only
pub can_pin_messages: Option<bool>, pub can_pin_messages: Option<bool>,
/// `true`, if the user is allowed to create, rename, close, and reopen
/// forum topics; supergroups only
pub can_manage_topics: Option<bool>,
} }

View file

@ -87,6 +87,10 @@ pub struct Administrator {
/// `true` if the administrator can pin messages, supergroups only. /// `true` if the administrator can pin messages, supergroups only.
pub can_pin_messages: Option<bool>, pub can_pin_messages: Option<bool>,
/// `true`, if the user is allowed to create, rename, close, and reopen
/// forum topics; supergroups only
pub can_manage_topics: Option<bool>,
/// `true` if the administrator can add new administrators with a subset of /// `true` if the administrator can add new administrators with a subset of
/// his own privileges or demote administrators that he has promoted, /// his own privileges or demote administrators that he has promoted,
/// directly or indirectly (promoted by administrators that were appointed /// directly or indirectly (promoted by administrators that were appointed
@ -130,6 +134,10 @@ pub struct Restricted {
/// `true` if the user is allowed to pin messages. /// `true` if the user is allowed to pin messages.
pub can_pin_messages: bool, pub can_pin_messages: bool,
/// `true`, if the user is allowed to create, rename, close, and reopen
/// forum topics
pub can_manage_topics: bool,
/// `true` if the user is allowed to send polls. /// `true` if the user is allowed to send polls.
pub can_send_polls: bool, pub can_send_polls: bool,
} }
@ -514,6 +522,27 @@ impl ChatMemberKind {
} }
} }
/// Returns `true` if the user is allowed to manage topics.
///
/// I.e. returns `true` if the user
/// - is the owner of the chat (even if the chat is not a supergroup)
/// - is an administrator in the given chat and has the
/// [`Administrator::can_manage_topics`] privilege.
/// - is restricted, but does have [`Restricted::can_manage_topics`]
/// privilege
/// Returns `false` otherwise.
#[must_use]
pub fn can_manage_topics(&self) -> bool {
match self {
ChatMemberKind::Owner(_) => true,
ChatMemberKind::Administrator(Administrator { can_manage_topics, .. }) => {
can_manage_topics.unwrap_or_default()
}
ChatMemberKind::Restricted(Restricted { can_manage_topics, .. }) => *can_manage_topics,
ChatMemberKind::Member | ChatMemberKind::Left | ChatMemberKind::Banned(_) => false,
}
}
/// Returns `true` if the user can add new administrators with a subset of /// Returns `true` if the user can add new administrators with a subset of
/// his own privileges or demote administrators that he has promoted, /// his own privileges or demote administrators that he has promoted,
/// directly or indirectly (promoted by administrators that were appointed /// directly or indirectly (promoted by administrators that were appointed
@ -780,6 +809,7 @@ mod tests {
can_restrict_members: true, can_restrict_members: true,
can_pin_messages: Some(true), can_pin_messages: Some(true),
can_promote_members: true, can_promote_members: true,
can_manage_topics: None,
}), }),
}; };
let actual = serde_json::from_str::<ChatMember>(json).unwrap(); let actual = serde_json::from_str::<ChatMember>(json).unwrap();

View file

@ -46,7 +46,7 @@ bitflags::bitflags! {
/// ``` /// ```
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(from = "ChatPermissionsRaw", into = "ChatPermissionsRaw")] #[serde(from = "ChatPermissionsRaw", into = "ChatPermissionsRaw")]
pub struct ChatPermissions: u8 { pub struct ChatPermissions: u16 {
/// Set if the user is allowed to send text messages, contacts, /// Set if the user is allowed to send text messages, contacts,
/// locations and venues. /// locations and venues.
const SEND_MESSAGES = 1; const SEND_MESSAGES = 1;
@ -78,9 +78,14 @@ bitflags::bitflags! {
/// Set if the user is allowed to pin messages. Ignored in public /// Set if the user is allowed to pin messages. Ignored in public
/// supergroups. /// supergroups.
const PIN_MESSAGES = (1 << 7); const PIN_MESSAGES = (1 << 7);
/// Set if the user is allowed to create, rename, close, and reopen forum topics.
const MANAGE_TOPICS = (1 << 8);
} }
} }
// FIXME: add `can_*` methods for convinience
/// Helper for (de)serialization /// Helper for (de)serialization
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
struct ChatPermissionsRaw { struct ChatPermissionsRaw {
@ -107,6 +112,13 @@ struct ChatPermissionsRaw {
#[serde(default, skip_serializing_if = "Not::not")] #[serde(default, skip_serializing_if = "Not::not")]
can_pin_messages: bool, can_pin_messages: bool,
// HACK: do not `skip_serializing_if = "Not::not"`, from tg docs:
// > If omitted defaults to the value of `can_pin_messages`
// but we don't have two different values for "absent" and "false"...
// or did they mean that `can_pin_messages` implies `can_manage_topics`?..
#[serde(default)]
can_manage_topics: bool,
} }
impl From<ChatPermissions> for ChatPermissionsRaw { impl From<ChatPermissions> for ChatPermissionsRaw {
@ -120,6 +132,7 @@ impl From<ChatPermissions> for ChatPermissionsRaw {
can_change_info: this.contains(ChatPermissions::CHANGE_INFO), can_change_info: this.contains(ChatPermissions::CHANGE_INFO),
can_invite_users: this.contains(ChatPermissions::INVITE_USERS), can_invite_users: this.contains(ChatPermissions::INVITE_USERS),
can_pin_messages: this.contains(ChatPermissions::PIN_MESSAGES), can_pin_messages: this.contains(ChatPermissions::PIN_MESSAGES),
can_manage_topics: this.contains(ChatPermissions::MANAGE_TOPICS),
} }
} }
} }
@ -135,6 +148,7 @@ impl From<ChatPermissionsRaw> for ChatPermissions {
can_change_info, can_change_info,
can_invite_users, can_invite_users,
can_pin_messages, can_pin_messages,
can_manage_topics,
}: ChatPermissionsRaw, }: ChatPermissionsRaw,
) -> Self { ) -> Self {
let mut this = Self::empty(); let mut this = Self::empty();
@ -163,6 +177,10 @@ impl From<ChatPermissionsRaw> for ChatPermissions {
if can_pin_messages { if can_pin_messages {
this |= Self::PIN_MESSAGES; this |= Self::PIN_MESSAGES;
} }
// FIXME: should we do `|| can_pin_messages` here? (the same tg doc weirdness)
if can_manage_topics {
this |= Self::MANAGE_TOPICS
}
this this
} }
@ -175,8 +193,7 @@ mod tests {
#[test] #[test]
fn serialization() { fn serialization() {
let permissions = ChatPermissions::SEND_MEDIA_MESSAGES | ChatPermissions::PIN_MESSAGES; let permissions = ChatPermissions::SEND_MEDIA_MESSAGES | ChatPermissions::PIN_MESSAGES;
let expected = let expected = r#"{"can_send_messages":true,"can_send_media_messages":true,"can_pin_messages":true,"can_manage_topics":false}"#;
r#"{"can_send_messages":true,"can_send_media_messages":true,"can_pin_messages":true}"#;
let actual = serde_json::to_string(&permissions).unwrap(); let actual = serde_json::to_string(&permissions).unwrap();
assert_eq!(expected, actual); assert_eq!(expected, actual);
} }

View file

@ -0,0 +1,24 @@
use serde::{Deserialize, Serialize};
/// This object represents a forum topic.
///
/// [The official docs](https://core.telegram.org/bots/api#forumtopiccreated).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ForumTopic {
/// Unique identifier of the forum topic
// FIXME: MessageThreadId or something
pub message_thread_id: i32,
/// Name of the topic.
pub name: String,
/// Color of the topic icon in RGB format.
// FIXME: use/add a specialized rgb color type?
#[serde(with = "crate::types::serde_rgb")]
pub icon_color: [u8; 3],
/// Unique identifier of the custom emoji shown as the topic icon.
// FIXME: CustomEmojiId
pub icon_custom_emoji_id: Option<String>,
}

View file

@ -0,0 +1,9 @@
use serde::{Deserialize, Serialize};
/// This object represents a service message about a forum topic closed in the
/// chat. Currently holds no information.
///
/// [The official docs](https://core.telegram.org/bots/api#forumtopiccreated).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ForumTopicClosed;

View file

@ -0,0 +1,21 @@
use serde::{Deserialize, Serialize};
/// This object represents a service message about a new forum topic created in
/// the chat.
///
/// [The official docs](https://core.telegram.org/bots/api#forumtopiccreated).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ForumTopicCreated {
/// Name of the topic.
pub name: String,
/// Color of the topic icon in RGB format.
// FIXME: use/add a specialized rgb color type?
#[serde(with = "crate::types::serde_rgb")]
pub icon_color: [u8; 3],
/// Unique identifier of the custom emoji shown as the topic icon.
// FIXME: CustomEmojiId
pub icon_custom_emoji_id: Option<String>,
}

View file

@ -0,0 +1,9 @@
use serde::{Deserialize, Serialize};
/// This object represents a service message about a forum topic reopened in the
/// chat. Currently holds no information.
///
/// [The official docs](https://core.telegram.org/bots/api#forumtopiccreated).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ForumTopicReopened;

View file

@ -5,11 +5,12 @@ use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
use crate::types::{ use crate::types::{
Animation, Audio, BareChatId, Chat, ChatId, Contact, Dice, Document, Game, Animation, Audio, BareChatId, Chat, ChatId, Contact, Dice, Document, ForumTopicClosed,
InlineKeyboardMarkup, Invoice, Location, MessageAutoDeleteTimerChanged, MessageEntity, ForumTopicCreated, ForumTopicReopened, Game, InlineKeyboardMarkup, Invoice, Location,
MessageEntityRef, MessageId, PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker, MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef, MessageId, PassportData,
SuccessfulPayment, True, User, Venue, Video, VideoChatEnded, VideoChatParticipantsInvited, PhotoSize, Poll, ProximityAlertTriggered, Sticker, SuccessfulPayment, True, User, Venue, Video,
VideoChatScheduled, VideoChatStarted, VideoNote, Voice, WebAppData, VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote,
Voice, WebAppData,
}; };
/// This object represents a message. /// This object represents a message.
@ -21,6 +22,11 @@ pub struct Message {
#[serde(flatten)] #[serde(flatten)]
pub id: MessageId, pub id: MessageId,
/// Unique identifier of a message thread to which the message belongs; for
/// supergroups only.
// FIXME: MessageThreadId or such
pub thread_id: Option<i32>,
/// Date the message was sent in Unix time. /// Date the message was sent in Unix time.
#[serde(with = "crate::types::serde_date_from_unix_timestamp")] #[serde(with = "crate::types::serde_date_from_unix_timestamp")]
pub date: DateTime<Utc>, pub date: DateTime<Utc>,
@ -55,6 +61,9 @@ pub enum MessageKind {
PassportData(MessagePassportData), PassportData(MessagePassportData),
Dice(MessageDice), Dice(MessageDice),
ProximityAlertTriggered(MessageProximityAlertTriggered), ProximityAlertTriggered(MessageProximityAlertTriggered),
ForumTopicCreated(ForumTopicCreated),
ForumTopicClosed(ForumTopicClosed),
ForumTopicReopened(ForumTopicReopened),
VideoChatScheduled(MessageVideoChatScheduled), VideoChatScheduled(MessageVideoChatScheduled),
VideoChatStarted(MessageVideoChatStarted), VideoChatStarted(MessageVideoChatStarted),
VideoChatEnded(MessageVideoChatEnded), VideoChatEnded(MessageVideoChatEnded),
@ -98,6 +107,10 @@ pub struct MessageCommon {
/// represented as ordinary `url` buttons. /// represented as ordinary `url` buttons.
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// `true`, if the message is sent to a forum topic.
#[serde(default)]
pub is_topic_message: bool,
/// `true`, if the message is a channel post that was automatically /// `true`, if the message is a channel post that was automatically
/// forwarded to the connected discussion group. /// forwarded to the connected discussion group.
#[serde(default)] #[serde(default)]
@ -493,6 +506,24 @@ pub struct MessageProximityAlertTriggered {
pub proximity_alert_triggered: ProximityAlertTriggered, pub proximity_alert_triggered: ProximityAlertTriggered,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageForumTopicCreated {
/// Service message: forum topic created.
pub forum_topic_created: ForumTopicCreated,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageForumTopicClosed {
/// Service message: forum topic closed.
pub forum_topic_closed: ForumTopicClosed,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageForumTopicReopened {
/// Service message: forum topic reopened.
pub forum_topic_reopened: ForumTopicReopened,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVideoChatScheduled { pub struct MessageVideoChatScheduled {
/// Service message: video chat scheduled /// Service message: video chat scheduled
@ -1543,6 +1574,8 @@ mod tests {
location: None, location: None,
join_by_request: None, join_by_request: None,
join_to_send_messages: None, join_to_send_messages: None,
active_usernames: None,
is_forum: false,
}), }),
description: None, description: None,
invite_link: None, invite_link: None,

View file

@ -332,6 +332,7 @@ mod test {
kind: UpdateKind::Message(Message { kind: UpdateKind::Message(Message {
via_bot: None, via_bot: None,
id: MessageId(6557), id: MessageId(6557),
thread_id: None,
date, date,
chat: Chat { chat: Chat {
id: ChatId(218_485_655), id: ChatId(218_485_655),
@ -342,6 +343,7 @@ mod test {
bio: None, bio: None,
has_private_forwards: None, has_private_forwards: None,
has_restricted_voice_and_video_messages: None, has_restricted_voice_and_video_messages: None,
emoji_status_custom_emoji_id: None,
}), }),
photo: None, photo: None,
pinned_message: None, pinned_message: None,
@ -368,6 +370,7 @@ mod test {
reply_markup: None, reply_markup: None,
sender_chat: None, sender_chat: None,
author_signature: None, author_signature: None,
is_topic_message: false,
is_automatic_forward: false, is_automatic_forward: false,
has_protected_content: false, has_protected_content: false,
}), }),