Merge branch 'master' into tune-markups

This commit is contained in:
Hirrolot 2022-04-24 01:10:08 +06:00 committed by GitHub
commit 1a12dd2388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1241 additions and 238 deletions

View file

@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## unreleased
### Added
- Support for Telegram Bot API [version 6.0](https://core.telegram.org/bots/api#april-16-2022)
- Note that some field were renamed
### Changed
- Accept `IntoIterator` in `KeyboardMarkup::append_row`.

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%205.7%20(inclusively)-green.svg">
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%206.0%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

@ -83,30 +83,103 @@ where
type Err = B::Err;
requester_forward! {
get_me, log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
forward_message, copy_message, send_message, send_photo, send_audio, send_document,
send_video, send_animation, send_voice, send_video_note, send_media_group, send_location,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline, send_venue,
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title,
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
get_sticker_set, upload_sticker_file, create_new_sticker_set,
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request => f, fty
get_me,
log_out,
close,
get_updates,
set_webhook,
delete_webhook,
get_webhook_info,
forward_message,
copy_message,
send_message,
send_photo,
send_audio,
send_document,
send_video,
send_animation,
send_voice,
send_video_note,
send_media_group,
send_location,
edit_message_live_location,
edit_message_live_location_inline,
stop_message_live_location,
stop_message_live_location_inline,
send_venue,
send_contact,
send_poll,
send_dice,
send_chat_action,
get_user_profile_photos,
get_file,
kick_chat_member,
ban_chat_member,
unban_chat_member,
restrict_chat_member,
promote_chat_member,
set_chat_administrator_custom_title,
ban_chat_sender_chat,
unban_chat_sender_chat,
set_chat_permissions,
export_chat_invite_link,
create_chat_invite_link,
edit_chat_invite_link,
revoke_chat_invite_link,
set_chat_photo,
delete_chat_photo,
set_chat_title,
set_chat_description,
pin_chat_message,
unpin_chat_message,
unpin_all_chat_messages,
leave_chat,
get_chat,
get_chat_administrators,
get_chat_members_count,
get_chat_member_count,
get_chat_member,
set_chat_sticker_set,
delete_chat_sticker_set,
answer_callback_query,
set_my_commands,
get_my_commands,
set_chat_menu_button,
get_chat_menu_button,
set_my_default_administrator_rights,
get_my_default_administrator_rights,
delete_my_commands,
answer_inline_query,
answer_web_app_query,
edit_message_text,
edit_message_text_inline,
edit_message_caption,
edit_message_caption_inline,
edit_message_media,
edit_message_media_inline,
edit_message_reply_markup,
edit_message_reply_markup_inline,
stop_poll,
delete_message,
send_sticker,
get_sticker_set,
upload_sticker_file,
create_new_sticker_set,
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
set_sticker_set_thumb,
send_invoice,
answer_shipping_query,
answer_pre_checkout_query,
set_passport_data_errors,
send_game,
set_game_score,
set_game_score_inline,
get_game_high_scores,
approve_chat_join_request,
decline_chat_join_request
=> f, fty
}
}

View file

@ -90,30 +90,102 @@ where
}
requester_forward! {
log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
forward_message, copy_message, send_message, send_photo, send_audio, send_document,
send_video, send_animation, send_voice, send_video_note, send_media_group, send_location,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline, send_venue,
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title,
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
get_sticker_set, upload_sticker_file, create_new_sticker_set,
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request => f, fty
log_out,
close,
get_updates,
set_webhook,
delete_webhook,
get_webhook_info,
forward_message,
copy_message,
send_message,
send_photo,
send_audio,
send_document,
send_video,
send_animation,
send_voice,
send_video_note,
send_media_group,
send_location,
edit_message_live_location,
edit_message_live_location_inline,
stop_message_live_location,
stop_message_live_location_inline,
send_venue,
send_contact,
send_poll,
send_dice,
send_chat_action,
get_user_profile_photos,
get_file,
kick_chat_member,
ban_chat_member,
unban_chat_member,
restrict_chat_member,
promote_chat_member,
set_chat_administrator_custom_title,
ban_chat_sender_chat,
unban_chat_sender_chat,
set_chat_permissions,
export_chat_invite_link,
create_chat_invite_link,
edit_chat_invite_link,
revoke_chat_invite_link,
set_chat_photo,
delete_chat_photo,
set_chat_title,
set_chat_description,
pin_chat_message,
unpin_chat_message,
unpin_all_chat_messages,
leave_chat,
get_chat,
get_chat_administrators,
get_chat_members_count,
get_chat_member_count,
get_chat_member,
set_chat_sticker_set,
delete_chat_sticker_set,
answer_callback_query,
set_my_commands,
get_my_commands,
set_chat_menu_button,
get_chat_menu_button,
set_my_default_administrator_rights,
get_my_default_administrator_rights,
delete_my_commands,
answer_inline_query,
answer_web_app_query,
edit_message_text,
edit_message_text_inline,
edit_message_caption,
edit_message_caption_inline,
edit_message_media,
edit_message_media_inline,
edit_message_reply_markup,
edit_message_reply_markup_inline,
stop_poll,
delete_message,
send_sticker,
get_sticker_set,
upload_sticker_file,
create_new_sticker_set,
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
set_sticker_set_thumb,
send_invoice,
answer_shipping_query,
answer_pre_checkout_query,
set_passport_data_errors,
send_game,
set_game_score,
set_game_score_inline,
get_game_high_scores,
approve_chat_join_request,
decline_chat_join_request
=> f, fty
}
}

View file

@ -156,30 +156,103 @@ where
type Err = Err;
requester_forward! {
get_me, log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
forward_message, copy_message, send_message, send_photo, send_audio, send_document,
send_video, send_animation, send_voice, send_video_note, send_media_group, send_location,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline, send_venue,
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title,
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
get_sticker_set, upload_sticker_file, create_new_sticker_set,
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request => fwd_erased, fty
get_me,
log_out,
close,
get_updates,
set_webhook,
delete_webhook,
get_webhook_info,
forward_message,
copy_message,
send_message,
send_photo,
send_audio,
send_document,
send_video,
send_animation,
send_voice,
send_video_note,
send_media_group,
send_location,
edit_message_live_location,
edit_message_live_location_inline,
stop_message_live_location,
stop_message_live_location_inline,
send_venue,
send_contact,
send_poll,
send_dice,
send_chat_action,
get_user_profile_photos,
get_file,
kick_chat_member,
ban_chat_member,
unban_chat_member,
restrict_chat_member,
promote_chat_member,
set_chat_administrator_custom_title,
ban_chat_sender_chat,
unban_chat_sender_chat,
set_chat_permissions,
export_chat_invite_link,
create_chat_invite_link,
edit_chat_invite_link,
revoke_chat_invite_link,
set_chat_photo,
delete_chat_photo,
set_chat_title,
set_chat_description,
pin_chat_message,
unpin_chat_message,
unpin_all_chat_messages,
leave_chat,
get_chat,
get_chat_administrators,
get_chat_members_count,
get_chat_member_count,
get_chat_member,
set_chat_sticker_set,
delete_chat_sticker_set,
answer_callback_query,
set_my_commands,
get_my_commands,
set_chat_menu_button,
get_chat_menu_button,
set_my_default_administrator_rights,
get_my_default_administrator_rights,
delete_my_commands,
answer_inline_query,
answer_web_app_query,
edit_message_text,
edit_message_text_inline,
edit_message_caption,
edit_message_caption_inline,
edit_message_media,
edit_message_media_inline,
edit_message_reply_markup,
edit_message_reply_markup_inline,
stop_poll,
delete_message,
send_sticker,
get_sticker_set,
upload_sticker_file,
create_new_sticker_set,
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
set_sticker_set_thumb,
send_invoice,
answer_shipping_query,
answer_pre_checkout_query,
set_passport_data_errors,
send_game,
set_game_score,
set_game_score_inline,
get_game_high_scores,
approve_chat_join_request,
decline_chat_join_request
=> fwd_erased, fty
}
}
@ -523,6 +596,18 @@ trait ErasableRequester<'a> {
fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err>;
fn set_chat_menu_button(&self) -> ErasedRequest<'a, SetChatMenuButton, Self::Err>;
fn get_chat_menu_button(&self) -> ErasedRequest<'a, GetChatMenuButton, Self::Err>;
fn set_my_default_administrator_rights(
&self,
) -> ErasedRequest<'a, SetMyDefaultAdministratorRights, Self::Err>;
fn get_my_default_administrator_rights(
&self,
) -> ErasedRequest<'a, GetMyDefaultAdministratorRights, Self::Err>;
fn delete_my_commands(&self) -> ErasedRequest<'a, DeleteMyCommands, Self::Err>;
fn answer_inline_query(
@ -531,6 +616,12 @@ trait ErasableRequester<'a> {
results: Vec<InlineQueryResult>,
) -> ErasedRequest<'a, AnswerInlineQuery, Self::Err>;
fn answer_web_app_query(
&self,
web_app_query_id: String,
result: InlineQueryResult,
) -> ErasedRequest<'a, AnswerWebAppQuery, Self::Err>;
fn edit_message_text(
&self,
chat_id: Recipient,
@ -1169,6 +1260,26 @@ where
Requester::get_my_commands(self).erase()
}
fn set_chat_menu_button(&self) -> ErasedRequest<'a, SetChatMenuButton, Self::Err> {
Requester::set_chat_menu_button(self).erase()
}
fn get_chat_menu_button(&self) -> ErasedRequest<'a, GetChatMenuButton, Self::Err> {
Requester::get_chat_menu_button(self).erase()
}
fn set_my_default_administrator_rights(
&self,
) -> ErasedRequest<'a, SetMyDefaultAdministratorRights, Self::Err> {
Requester::set_my_default_administrator_rights(self).erase()
}
fn get_my_default_administrator_rights(
&self,
) -> ErasedRequest<'a, GetMyDefaultAdministratorRights, Self::Err> {
Requester::get_my_default_administrator_rights(self).erase()
}
fn delete_my_commands(&self) -> ErasedRequest<'a, DeleteMyCommands, Self::Err> {
Requester::delete_my_commands(self).erase()
}
@ -1181,6 +1292,14 @@ where
Requester::answer_inline_query(self, inline_query_id, results).erase()
}
fn answer_web_app_query(
&self,
web_app_query_id: String,
result: InlineQueryResult,
) -> ErasedRequest<'a, AnswerWebAppQuery, Self::Err> {
Requester::answer_web_app_query(self, web_app_query_id, result).erase()
}
fn edit_message_text(
&self,
chat_id: Recipient,

View file

@ -96,28 +96,91 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
}
requester_forward! {
get_me, log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
forward_message, copy_message, send_video_note, send_media_group, send_location,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline, send_venue,
send_contact, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title,
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
get_sticker_set, upload_sticker_file, create_new_sticker_set,
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request => fid, fty
get_me,
log_out,
close,
get_updates,
set_webhook,
delete_webhook,
get_webhook_info,
forward_message,
copy_message,
send_video_note,
send_media_group,
send_location,
edit_message_live_location,
edit_message_live_location_inline,
stop_message_live_location,
stop_message_live_location_inline,
send_venue,
send_contact,
send_dice,
send_chat_action,
get_user_profile_photos,
get_file,
kick_chat_member,
ban_chat_member,
unban_chat_member,
restrict_chat_member,
promote_chat_member,
set_chat_administrator_custom_title,
ban_chat_sender_chat,
unban_chat_sender_chat,
set_chat_permissions,
export_chat_invite_link,
create_chat_invite_link,
edit_chat_invite_link,
revoke_chat_invite_link,
set_chat_photo,
delete_chat_photo,
set_chat_title,
set_chat_description,
pin_chat_message,
unpin_chat_message,
unpin_all_chat_messages,
leave_chat,
get_chat,
get_chat_administrators,
get_chat_members_count,
get_chat_member_count,
get_chat_member,
set_chat_sticker_set,
delete_chat_sticker_set,
answer_callback_query,
set_my_commands,
get_my_commands,
set_chat_menu_button,
get_chat_menu_button,
set_my_default_administrator_rights,
get_my_default_administrator_rights,
delete_my_commands,
answer_inline_query,
answer_web_app_query,
edit_message_media,
edit_message_media_inline,
edit_message_reply_markup,
edit_message_reply_markup_inline,
stop_poll,
delete_message,
send_sticker,
get_sticker_set,
upload_sticker_file,
create_new_sticker_set,
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
set_sticker_set_thumb,
send_invoice,
answer_shipping_query,
answer_pre_checkout_query,
set_passport_data_errors,
send_game,
set_game_score,
set_game_score_inline,
get_game_high_scores,
approve_chat_join_request,
decline_chat_join_request
=> fid, fty
}
}

View file

@ -63,35 +63,107 @@ where
type Err = B::Err;
requester_forward! {
send_message, forward_message, copy_message, send_photo, send_audio,
send_document, send_video, send_animation, send_voice, send_video_note,
send_media_group, send_location, send_venue, send_contact, send_poll,
send_dice, send_sticker, send_invoice => f, fty
send_message,
forward_message,
copy_message,
send_photo,
send_audio,
send_document,
send_video,
send_animation,
send_voice,
send_video_note,
send_media_group,
send_location,
send_venue,
send_contact,
send_poll,
send_dice,
send_sticker,
send_invoice
=> f, fty
}
requester_forward! {
get_me, log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline,
send_chat_action, get_user_profile_photos, get_file, kick_chat_member, ban_chat_member,
unban_chat_member, restrict_chat_member, promote_chat_member,
get_me,
log_out,
close,
get_updates,
set_webhook,
delete_webhook,
get_webhook_info,
edit_message_live_location,
edit_message_live_location_inline,
stop_message_live_location,
stop_message_live_location_inline,
send_chat_action,
get_user_profile_photos,
get_file,
kick_chat_member,
ban_chat_member,
unban_chat_member,
restrict_chat_member,
promote_chat_member,
set_chat_administrator_custom_title,
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count,
get_chat_member, set_chat_sticker_set, delete_chat_sticker_set,
answer_callback_query, set_my_commands, get_my_commands, delete_my_commands, answer_inline_query,
edit_message_text, edit_message_text_inline, edit_message_caption,
edit_message_caption_inline, edit_message_media, edit_message_media_inline,
edit_message_reply_markup, edit_message_reply_markup_inline, stop_poll,
delete_message, get_sticker_set, upload_sticker_file, create_new_sticker_set,
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, answer_shipping_query, answer_pre_checkout_query,
set_passport_data_errors, send_game, set_game_score, set_game_score_inline,
approve_chat_join_request, decline_chat_join_request,
get_game_high_scores => fid, ftyid
ban_chat_sender_chat,
unban_chat_sender_chat,
set_chat_permissions,
export_chat_invite_link,
create_chat_invite_link,
edit_chat_invite_link,
revoke_chat_invite_link,
set_chat_photo,
delete_chat_photo,
set_chat_title,
set_chat_description,
pin_chat_message,
unpin_chat_message,
unpin_all_chat_messages,
leave_chat,
get_chat,
get_chat_administrators,
get_chat_members_count,
get_chat_member_count,
get_chat_member,
set_chat_sticker_set,
delete_chat_sticker_set,
answer_callback_query,
set_my_commands,
get_my_commands,
set_chat_menu_button,
get_chat_menu_button,
set_my_default_administrator_rights,
get_my_default_administrator_rights,
delete_my_commands,
answer_inline_query,
answer_web_app_query,
edit_message_text,
edit_message_text_inline,
edit_message_caption,
edit_message_caption_inline,
edit_message_media,
edit_message_media_inline,
edit_message_reply_markup,
edit_message_reply_markup_inline,
stop_poll,
delete_message,
get_sticker_set,
upload_sticker_file,
create_new_sticker_set,
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
set_sticker_set_thumb,
answer_shipping_query,
answer_pre_checkout_query,
set_passport_data_errors,
send_game,
set_game_score,
set_game_score_inline,
approve_chat_join_request,
decline_chat_join_request,
get_game_high_scores
=> fid, ftyid
}
}

View file

@ -115,30 +115,103 @@ where
type Err = B::Err;
requester_forward! {
get_me, log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
forward_message, copy_message, send_message, send_photo, send_audio, send_document,
send_video, send_animation, send_voice, send_video_note, send_media_group, send_location,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline, send_venue,
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title,
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
get_sticker_set, upload_sticker_file, create_new_sticker_set,
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request => fwd_inner, fty
get_me,
log_out,
close,
get_updates,
set_webhook,
delete_webhook,
get_webhook_info,
forward_message,
copy_message,
send_message,
send_photo,
send_audio,
send_document,
send_video,
send_animation,
send_voice,
send_video_note,
send_media_group,
send_location,
edit_message_live_location,
edit_message_live_location_inline,
stop_message_live_location,
stop_message_live_location_inline,
send_venue,
send_contact,
send_poll,
send_dice,
send_chat_action,
get_user_profile_photos,
get_file,
kick_chat_member,
ban_chat_member,
unban_chat_member,
restrict_chat_member,
promote_chat_member,
set_chat_administrator_custom_title,
ban_chat_sender_chat,
unban_chat_sender_chat,
set_chat_permissions,
export_chat_invite_link,
create_chat_invite_link,
edit_chat_invite_link,
revoke_chat_invite_link,
set_chat_photo,
delete_chat_photo,
set_chat_title,
set_chat_description,
pin_chat_message,
unpin_chat_message,
unpin_all_chat_messages,
leave_chat,
get_chat,
get_chat_administrators,
get_chat_members_count,
get_chat_member_count,
get_chat_member,
set_chat_sticker_set,
delete_chat_sticker_set,
answer_callback_query,
set_my_commands,
get_my_commands,
set_chat_menu_button,
get_chat_menu_button,
set_my_default_administrator_rights,
get_my_default_administrator_rights,
delete_my_commands,
answer_inline_query,
answer_web_app_query,
edit_message_text,
edit_message_text_inline,
edit_message_caption,
edit_message_caption_inline,
edit_message_media,
edit_message_media_inline,
edit_message_reply_markup,
edit_message_reply_markup_inline,
stop_poll,
delete_message,
send_sticker,
get_sticker_set,
upload_sticker_file,
create_new_sticker_set,
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
set_sticker_set_thumb,
send_invoice,
answer_shipping_query,
answer_pre_checkout_query,
set_passport_data_errors,
send_game,
set_game_score,
set_game_score_inline,
get_game_high_scores,
approve_chat_join_request,
decline_chat_join_request
=> fwd_inner, fty
}
}

View file

@ -689,6 +689,36 @@ impl Requester for Bot {
Self::GetMyCommands::new(self.clone(), payloads::GetMyCommands::new())
}
type SetChatMenuButton = JsonRequest<payloads::SetChatMenuButton>;
fn set_chat_menu_button(&self) -> Self::SetChatMenuButton {
Self::SetChatMenuButton::new(self.clone(), payloads::SetChatMenuButton::new())
}
type GetChatMenuButton = JsonRequest<payloads::GetChatMenuButton>;
fn get_chat_menu_button(&self) -> Self::GetChatMenuButton {
Self::GetChatMenuButton::new(self.clone(), payloads::GetChatMenuButton::new())
}
type SetMyDefaultAdministratorRights = JsonRequest<payloads::SetMyDefaultAdministratorRights>;
fn set_my_default_administrator_rights(&self) -> Self::SetMyDefaultAdministratorRights {
Self::SetMyDefaultAdministratorRights::new(
self.clone(),
payloads::SetMyDefaultAdministratorRights::new(),
)
}
type GetMyDefaultAdministratorRights = JsonRequest<payloads::GetMyDefaultAdministratorRights>;
fn get_my_default_administrator_rights(&self) -> Self::GetMyDefaultAdministratorRights {
Self::GetMyDefaultAdministratorRights::new(
self.clone(),
payloads::GetMyDefaultAdministratorRights::new(),
)
}
type DeleteMyCommands = JsonRequest<payloads::DeleteMyCommands>;
fn delete_my_commands(&self) -> Self::DeleteMyCommands {
@ -708,6 +738,22 @@ impl Requester for Bot {
)
}
type AnswerWebAppQuery = JsonRequest<payloads::AnswerWebAppQuery>;
fn answer_web_app_query<W>(
&self,
web_app_query_id: W,
result: InlineQueryResult,
) -> Self::AnswerWebAppQuery
where
W: Into<String>,
{
Self::AnswerWebAppQuery::new(
self.clone(),
payloads::AnswerWebAppQuery::new(web_app_query_id, result),
)
}
type EditMessageText = JsonRequest<payloads::EditMessageText>;
fn edit_message_text<C, T>(&self, chat_id: C, message_id: i32, text: T) -> Self::EditMessageText

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 `5.3` is supported) with ease. The library is fully
//! (Currently, version `6.0` is supported) with ease. The library is fully
//! asynchronous and built using [`tokio`].
//!
//!```toml

View file

@ -943,6 +943,38 @@ macro_rules! requester_forward {
$body!(get_my_commands this ())
}
};
(@method set_chat_menu_button $body:ident $ty:ident) => {
type SetChatMenuButton = $ty![SetChatMenuButton];
fn set_chat_menu_button(&self) -> Self::SetChatMenuButton {
let this = self;
$body!(set_chat_menu_button this ())
}
};
(@method get_chat_menu_button $body:ident $ty:ident) => {
type GetChatMenuButton = $ty![GetChatMenuButton];
fn get_chat_menu_button(&self) -> Self::GetChatMenuButton {
let this = self;
$body!(get_chat_menu_button this ())
}
};
(@method set_my_default_administrator_rights $body:ident $ty:ident) => {
type SetMyDefaultAdministratorRights = $ty![SetMyDefaultAdministratorRights];
fn set_my_default_administrator_rights(&self) -> Self::SetMyDefaultAdministratorRights {
let this = self;
$body!(set_my_default_administrator_rights this ())
}
};
(@method get_my_default_administrator_rights $body:ident $ty:ident) => {
type GetMyDefaultAdministratorRights = $ty![GetMyDefaultAdministratorRights];
fn get_my_default_administrator_rights(&self) -> Self::GetMyDefaultAdministratorRights {
let this = self;
$body!(get_my_default_administrator_rights this ())
}
};
(@method delete_my_commands $body:ident $ty:ident) => {
type DeleteMyCommands = $ty![DeleteMyCommands];
@ -960,6 +992,14 @@ macro_rules! requester_forward {
$body!(answer_inline_query this (inline_query_id: I, results: R))
}
};
(@method answer_web_app_query $body:ident $ty:ident) => {
type AnswerWebAppQuery = $ty![AnswerWebAppQuery];
fn answer_web_app_query<W>(&self, web_app_query_id: W, result: InlineQueryResult) -> Self::AnswerWebAppQuery where W: Into<String> {
let this = self;
$body!(answer_web_app_query this (web_app_query_id: W, result: InlineQueryResult))
}
};
(@method edit_message_text $body:ident $ty:ident) => {
type EditMessageText = $ty![EditMessageText];

View file

@ -25,6 +25,7 @@ mod answer_callback_query;
mod answer_inline_query;
mod answer_pre_checkout_query;
mod answer_shipping_query;
mod answer_web_app_query;
mod approve_chat_join_request;
mod ban_chat_member;
mod ban_chat_sender_chat;
@ -57,10 +58,12 @@ mod get_chat_administrators;
mod get_chat_member;
mod get_chat_member_count;
mod get_chat_members_count;
mod get_chat_menu_button;
mod get_file;
mod get_game_high_scores;
mod get_me;
mod get_my_commands;
mod get_my_default_administrator_rights;
mod get_sticker_set;
mod get_updates;
mod get_user_profile_photos;
@ -92,6 +95,7 @@ mod send_video_note;
mod send_voice;
mod set_chat_administrator_custom_title;
mod set_chat_description;
mod set_chat_menu_button;
mod set_chat_permissions;
mod set_chat_photo;
mod set_chat_sticker_set;
@ -99,6 +103,7 @@ mod set_chat_title;
mod set_game_score;
mod set_game_score_inline;
mod set_my_commands;
mod set_my_default_administrator_rights;
mod set_passport_data_errors;
mod set_sticker_position_in_set;
mod set_sticker_set_thumb;
@ -117,6 +122,7 @@ pub use answer_callback_query::{AnswerCallbackQuery, AnswerCallbackQuerySetters}
pub use answer_inline_query::{AnswerInlineQuery, AnswerInlineQuerySetters};
pub use answer_pre_checkout_query::{AnswerPreCheckoutQuery, AnswerPreCheckoutQuerySetters};
pub use answer_shipping_query::{AnswerShippingQuery, AnswerShippingQuerySetters};
pub use answer_web_app_query::{AnswerWebAppQuery, AnswerWebAppQuerySetters};
pub use approve_chat_join_request::{ApproveChatJoinRequest, ApproveChatJoinRequestSetters};
pub use ban_chat_member::{BanChatMember, BanChatMemberSetters};
pub use ban_chat_sender_chat::{BanChatSenderChat, BanChatSenderChatSetters};
@ -153,10 +159,14 @@ pub use get_chat_administrators::{GetChatAdministrators, GetChatAdministratorsSe
pub use get_chat_member::{GetChatMember, GetChatMemberSetters};
pub use get_chat_member_count::{GetChatMemberCount, GetChatMemberCountSetters};
pub use get_chat_members_count::{GetChatMembersCount, GetChatMembersCountSetters};
pub use get_chat_menu_button::{GetChatMenuButton, GetChatMenuButtonSetters};
pub use get_file::{GetFile, GetFileSetters};
pub use get_game_high_scores::{GetGameHighScores, GetGameHighScoresSetters};
pub use get_me::{GetMe, GetMeSetters};
pub use get_my_commands::{GetMyCommands, GetMyCommandsSetters};
pub use get_my_default_administrator_rights::{
GetMyDefaultAdministratorRights, GetMyDefaultAdministratorRightsSetters,
};
pub use get_sticker_set::{GetStickerSet, GetStickerSetSetters};
pub use get_updates::{GetUpdates, GetUpdatesSetters};
pub use get_user_profile_photos::{GetUserProfilePhotos, GetUserProfilePhotosSetters};
@ -190,6 +200,7 @@ pub use set_chat_administrator_custom_title::{
SetChatAdministratorCustomTitle, SetChatAdministratorCustomTitleSetters,
};
pub use set_chat_description::{SetChatDescription, SetChatDescriptionSetters};
pub use set_chat_menu_button::{SetChatMenuButton, SetChatMenuButtonSetters};
pub use set_chat_permissions::{SetChatPermissions, SetChatPermissionsSetters};
pub use set_chat_photo::{SetChatPhoto, SetChatPhotoSetters};
pub use set_chat_sticker_set::{SetChatStickerSet, SetChatStickerSetSetters};
@ -197,6 +208,9 @@ pub use set_chat_title::{SetChatTitle, SetChatTitleSetters};
pub use set_game_score::{SetGameScore, SetGameScoreSetters};
pub use set_game_score_inline::{SetGameScoreInline, SetGameScoreInlineSetters};
pub use set_my_commands::{SetMyCommands, SetMyCommandsSetters};
pub use set_my_default_administrator_rights::{
SetMyDefaultAdministratorRights, SetMyDefaultAdministratorRightsSetters,
};
pub use set_passport_data_errors::{SetPassportDataErrors, SetPassportDataErrorsSetters};
pub use set_sticker_position_in_set::{SetStickerPositionInSet, SetStickerPositionInSetSetters};
pub use set_sticker_set_thumb::{SetStickerSetThumb, SetStickerSetThumbSetters};
@ -211,5 +225,3 @@ pub use unban_chat_sender_chat::{UnbanChatSenderChat, UnbanChatSenderChatSetters
pub use unpin_all_chat_messages::{UnpinAllChatMessages, UnpinAllChatMessagesSetters};
pub use unpin_chat_message::{UnpinChatMessage, UnpinChatMessageSetters};
pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters};
// end of auto generated block

View file

@ -0,0 +1,26 @@
// This file is auto generated by [`cg`] from [`schema`].
//
// **DO NOT EDIT THIS FILE**,
//
// Edit `cg` or `schema` instead.
//
// [cg]: https://github.com/teloxide/cg
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::{InlineQueryResult, SentWebAppMessage};
impl_payload! {
/// Use this method to set the result of an interaction with a [Web App] and send a corresponding message on behalf of the user to the chat from which the query originated.
///
/// [Web App]: https://core.telegram.org/bots/webapps
#[derive(Debug, PartialEq, Clone, Serialize)]
pub AnswerWebAppQuery (AnswerWebAppQuerySetters) => SentWebAppMessage {
required {
/// Unique identifier for the query to be answered
pub web_app_query_id: String [into],
/// A JSON-serialized object describing the message to be sent
pub result: InlineQueryResult,
}
}
}

View file

@ -0,0 +1,23 @@
// This file is auto generated by [`cg`] from [`schema`].
//
// **DO NOT EDIT THIS FILE**,
//
// Edit `cg` or `schema` instead.
//
// [cg]: https://github.com/teloxide/cg
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::{ChatId, MenuButton};
impl_payload! {
/// Use this method to get the current value of the bot's menu button in a private chat, or the default menu button.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub GetChatMenuButton (GetChatMenuButtonSetters) => MenuButton {
optional {
/// Unique identifier for the target private chat. If not specified, default bot's menu button will be returned
pub chat_id: ChatId [into],
}
}
}

View file

@ -0,0 +1,23 @@
// This file is auto generated by [`cg`] from [`schema`].
//
// **DO NOT EDIT THIS FILE**,
//
// Edit `cg` or `schema` instead.
//
// [cg]: https://github.com/teloxide/cg
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::ChatAdministratorRights;
impl_payload! {
/// Use this method to get the current value of the bot's menu button in a private chat, or the default menu button.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub GetMyDefaultAdministratorRights (GetMyDefaultAdministratorRightsSetters) => ChatAdministratorRights {
optional {
/// Pass _True_ to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
pub for_channels: bool,
}
}
}

View file

@ -34,7 +34,7 @@ impl_payload! {
/// Pass True, if the administrator can delete messages of other users
pub can_delete_messages: bool,
/// Pass True, if the administrator can manage voice chats, supergroups only
pub can_manage_voice_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

View file

@ -0,0 +1,25 @@
// This file is auto generated by [`cg`] from [`schema`].
//
// **DO NOT EDIT THIS FILE**,
//
// Edit `cg` or `schema` instead.
//
// [cg]: https://github.com/teloxide/cg
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::{ChatId, MenuButton, True};
impl_payload! {
/// Use this method to change the bot's menu button in a private chat, or the default menu button.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub SetChatMenuButton (SetChatMenuButtonSetters) => True {
optional {
/// Unique identifier for the target private chat. If not specified, default bot's menu button will be changed.
pub chat_id: ChatId [into],
/// An object for the new bot's menu button. Defaults to MenuButtonDefault
pub menu_button: MenuButton,
}
}
}

View file

@ -0,0 +1,25 @@
// This file is auto generated by [`cg`] from [`schema`].
//
// **DO NOT EDIT THIS FILE**,
//
// Edit `cg` or `schema` instead.
//
// [cg]: https://github.com/teloxide/cg
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::{ChatAdministratorRights, True};
impl_payload! {
/// Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub SetMyDefaultAdministratorRights (SetMyDefaultAdministratorRightsSetters) => True {
optional {
/// A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
pub rights: ChatAdministratorRights,
/// Pass _True_ to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
pub for_channels: bool,
}
}
}

View file

@ -10,20 +10,22 @@
pub use crate::payloads::{
AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _,
AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _,
ApproveChatJoinRequestSetters as _, BanChatMemberSetters as _, BanChatSenderChatSetters as _,
CloseSetters as _, CopyMessageSetters as _, CreateChatInviteLinkSetters as _,
CreateNewStickerSetSetters as _, DeclineChatJoinRequestSetters as _,
DeleteChatPhotoSetters as _, DeleteChatStickerSetSetters as _, DeleteMessageSetters as _,
DeleteMyCommandsSetters as _, DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _,
EditChatInviteLinkSetters as _, EditMessageCaptionInlineSetters as _,
EditMessageCaptionSetters as _, EditMessageLiveLocationInlineSetters as _,
EditMessageLiveLocationSetters as _, EditMessageMediaInlineSetters as _,
EditMessageMediaSetters as _, EditMessageReplyMarkupInlineSetters as _,
EditMessageReplyMarkupSetters as _, EditMessageTextInlineSetters as _,
EditMessageTextSetters as _, ExportChatInviteLinkSetters as _, ForwardMessageSetters as _,
AnswerWebAppQuerySetters as _, ApproveChatJoinRequestSetters as _, BanChatMemberSetters as _,
BanChatSenderChatSetters as _, CloseSetters as _, CopyMessageSetters as _,
CreateChatInviteLinkSetters as _, CreateNewStickerSetSetters as _,
DeclineChatJoinRequestSetters as _, DeleteChatPhotoSetters as _,
DeleteChatStickerSetSetters as _, DeleteMessageSetters as _, DeleteMyCommandsSetters as _,
DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _, EditChatInviteLinkSetters as _,
EditMessageCaptionInlineSetters as _, EditMessageCaptionSetters as _,
EditMessageLiveLocationInlineSetters as _, EditMessageLiveLocationSetters as _,
EditMessageMediaInlineSetters as _, EditMessageMediaSetters as _,
EditMessageReplyMarkupInlineSetters as _, EditMessageReplyMarkupSetters as _,
EditMessageTextInlineSetters as _, EditMessageTextSetters as _,
ExportChatInviteLinkSetters as _, ForwardMessageSetters as _,
GetChatAdministratorsSetters as _, GetChatMemberCountSetters as _, GetChatMemberSetters as _,
GetChatMembersCountSetters as _, GetChatSetters as _, GetFileSetters as _,
GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _,
GetChatMembersCountSetters as _, GetChatMenuButtonSetters as _, GetChatSetters as _,
GetFileSetters as _, GetGameHighScoresSetters as _, GetMeSetters as _,
GetMyCommandsSetters as _, GetMyDefaultAdministratorRightsSetters as _,
GetStickerSetSetters as _, GetUpdatesSetters as _, GetUserProfilePhotosSetters as _,
GetWebhookInfoSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _,
LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _,
@ -34,9 +36,10 @@ pub use crate::payloads::{
SendPhotoSetters as _, SendPollSetters as _, SendStickerSetters as _, SendVenueSetters as _,
SendVideoNoteSetters as _, SendVideoSetters as _, SendVoiceSetters as _,
SetChatAdministratorCustomTitleSetters as _, SetChatDescriptionSetters as _,
SetChatPermissionsSetters as _, SetChatPhotoSetters as _, SetChatStickerSetSetters as _,
SetChatTitleSetters as _, SetGameScoreInlineSetters as _, SetGameScoreSetters as _,
SetMyCommandsSetters as _, SetPassportDataErrorsSetters as _,
SetChatMenuButtonSetters as _, SetChatPermissionsSetters as _, SetChatPhotoSetters as _,
SetChatStickerSetSetters as _, SetChatTitleSetters as _, SetGameScoreInlineSetters as _,
SetGameScoreSetters as _, SetMyCommandsSetters as _,
SetMyDefaultAdministratorRightsSetters as _, SetPassportDataErrorsSetters as _,
SetStickerPositionInSetSetters as _, SetStickerSetThumbSetters as _, SetWebhookSetters as _,
StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _,
StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _,

View file

@ -590,6 +590,32 @@ pub trait Requester {
/// For Telegram documentation see [`GetMyCommands`].
fn get_my_commands(&self) -> Self::GetMyCommands;
type SetChatMenuButton: Request<Payload = SetChatMenuButton, Err = Self::Err>;
/// For Telegram documentation see [`SetChatMenuButton`].
fn set_chat_menu_button(&self) -> Self::SetChatMenuButton;
type GetChatMenuButton: Request<Payload = GetChatMenuButton, Err = Self::Err>;
/// For Telegram documentation see [`GetChatMenuButton`].
fn get_chat_menu_button(&self) -> Self::GetChatMenuButton;
type SetMyDefaultAdministratorRights: Request<
Payload = SetMyDefaultAdministratorRights,
Err = Self::Err,
>;
/// For Telegram documentation see [`SetMyDefaultAdministratorRights`].
fn set_my_default_administrator_rights(&self) -> Self::SetMyDefaultAdministratorRights;
type GetMyDefaultAdministratorRights: Request<
Payload = GetMyDefaultAdministratorRights,
Err = Self::Err,
>;
/// For Telegram documentation see [`GetMyDefaultAdministratorRights`].
fn get_my_default_administrator_rights(&self) -> Self::GetMyDefaultAdministratorRights;
type DeleteMyCommands: Request<Payload = DeleteMyCommands, Err = Self::Err>;
/// For Telegram documentation see [`DeleteMyCommands`].
@ -603,6 +629,17 @@ pub trait Requester {
I: Into<String>,
R: IntoIterator<Item = InlineQueryResult>;
type AnswerWebAppQuery: Request<Payload = AnswerWebAppQuery, Err = Self::Err>;
/// For Telegram documentation see [`AnswerWebAppQuery`].
fn answer_web_app_query<W>(
&self,
web_app_query_id: W,
result: InlineQueryResult,
) -> Self::AnswerWebAppQuery
where
W: Into<String>;
type EditMessageText: Request<Payload = EditMessageText, Err = Self::Err>;
/// For Telegram documentation see [`EditMessageText`].
@ -888,30 +925,103 @@ macro_rules! fwd_deref {
macro_rules! forward_all {
() => {
requester_forward! {
get_me, log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
forward_message, copy_message, send_message, send_photo, send_audio, send_document,
send_video, send_animation, send_voice, send_video_note, send_media_group, send_location,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline, send_venue,
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title,
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
get_sticker_set, upload_sticker_file, create_new_sticker_set,
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request => fwd_deref, fty
get_me,
log_out,
close,
get_updates,
set_webhook,
delete_webhook,
get_webhook_info,
forward_message,
copy_message,
send_message,
send_photo,
send_audio,
send_document,
send_video,
send_animation,
send_voice,
send_video_note,
send_media_group,
send_location,
edit_message_live_location,
edit_message_live_location_inline,
stop_message_live_location,
stop_message_live_location_inline,
send_venue,
send_contact,
send_poll,
send_dice,
send_chat_action,
get_user_profile_photos,
get_file,
kick_chat_member,
ban_chat_member,
unban_chat_member,
restrict_chat_member,
promote_chat_member,
set_chat_administrator_custom_title,
ban_chat_sender_chat,
unban_chat_sender_chat,
set_chat_permissions,
export_chat_invite_link,
create_chat_invite_link,
edit_chat_invite_link,
revoke_chat_invite_link,
set_chat_photo,
delete_chat_photo,
set_chat_title,
set_chat_description,
pin_chat_message,
unpin_chat_message,
unpin_all_chat_messages,
leave_chat,
get_chat,
get_chat_administrators,
get_chat_members_count,
get_chat_member_count,
get_chat_member,
set_chat_sticker_set,
delete_chat_sticker_set,
answer_callback_query,
set_my_commands,
get_my_commands,
set_chat_menu_button,
get_chat_menu_button,
set_my_default_administrator_rights,
get_my_default_administrator_rights,
delete_my_commands,
answer_inline_query,
answer_web_app_query,
edit_message_text,
edit_message_text_inline,
edit_message_caption,
edit_message_caption_inline,
edit_message_media,
edit_message_media_inline,
edit_message_reply_markup,
edit_message_reply_markup_inline,
stop_poll,
delete_message,
send_sticker,
get_sticker_set,
upload_sticker_file,
create_new_sticker_set,
add_sticker_to_set,
set_sticker_position_in_set,
delete_sticker_from_set,
set_sticker_set_thumb,
send_invoice,
answer_shipping_query,
answer_pre_checkout_query,
set_passport_data_errors,
send_game,
set_game_score,
set_game_score_inline,
get_game_high_scores,
approve_chat_join_request,
decline_chat_join_request
=> fwd_deref, fty
}
};
}
@ -998,7 +1108,7 @@ where
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
set_my_commands, get_my_commands, set_chat_menu_button, get_chat_menu_button, set_my_default_administrator_rights, get_my_default_administrator_rights, delete_my_commands, answer_inline_query, answer_web_app_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,

View file

@ -9,6 +9,7 @@ pub use callback_game::*;
pub use callback_query::*;
pub use chat::*;
pub use chat_action::*;
pub use chat_administrator_rights::*;
pub use chat_invite_link::*;
pub use chat_join_request::*;
pub use chat_location::*;
@ -64,6 +65,7 @@ pub use location::*;
pub use login_url::*;
pub use mask_position::*;
pub use me::*;
pub use menu_button::*;
pub use message::*;
pub use message_auto_delete_timer_changed::*;
pub use message_entity::*;
@ -83,6 +85,7 @@ pub use reply_keyboard_markup::*;
pub use reply_keyboard_remove::*;
pub use reply_markup::*;
pub use response_parameters::*;
pub use sent_web_app_message::*;
pub use shipping_address::*;
pub use shipping_option::*;
pub use shipping_query::*;
@ -103,6 +106,8 @@ pub use voice_chat_ended::*;
pub use voice_chat_participants_invited::*;
pub use voice_chat_scheduled::*;
pub use voice_chat_started::*;
pub use web_app_data::*;
pub use web_app_info::*;
pub use webhook_info::*;
mod allowed_update;
@ -114,6 +119,7 @@ mod callback_game;
mod callback_query;
mod chat;
mod chat_action;
mod chat_administrator_rights;
mod chat_invite_link;
mod chat_join_request;
mod chat_location;
@ -145,6 +151,7 @@ mod location;
mod login_url;
mod mask_position;
mod me;
mod menu_button;
mod message;
mod message_auto_delete_timer_changed;
mod message_entity;
@ -161,6 +168,7 @@ mod reply_keyboard_markup;
mod reply_keyboard_remove;
mod reply_markup;
mod response_parameters;
mod sent_web_app_message;
mod shipping_address;
mod shipping_option;
mod shipping_query;
@ -181,6 +189,8 @@ mod voice_chat_ended;
mod voice_chat_participants_invited;
mod voice_chat_scheduled;
mod voice_chat_started;
mod web_app_data;
mod web_app_info;
mod webhook_info;
mod inline_query;

View file

@ -0,0 +1,48 @@
use serde::{Deserialize, Serialize};
/// Represents the rights of an administrator in a chat.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ChatAdministratorRights {
/// `true`, if the user's presence in the chat is hidden
pub is_anonymous: bool,
/// `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,
/// `true`, if the administrator can delete messages of other users
pub can_delete_messages: bool,
/// `true`, if the administrator can manage video chats
pub can_manage_video_chats: bool,
/// `true`, if the administrator can restrict, ban or unban chat members
pub can_restrict_members: bool,
/// `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 the user)
pub can_promote_members: bool,
/// `true`, if the user is allowed to change the chat title, photo and other
/// settings
pub can_change_info: bool,
/// `true`, if the user is allowed to invite new users to the chat
pub can_invite_users: bool,
/// `true`, if the administrator can post in the channel; channels
/// only
pub can_post_messages: Option<bool>,
/// `true`, if the administrator can edit messages of other users
/// and can pin messages; channels only
pub can_edit_messages: Option<bool>,
/// `true`, if the user is allowed to pin messages; groups and
/// supergroups only
pub can_pin_messages: Option<bool>,
}

View file

@ -76,7 +76,7 @@ pub struct Administrator {
pub can_delete_messages: bool,
/// `true` if the administrator can manage voice chats.
pub can_manage_voice_chats: bool,
pub can_manage_video_chats: bool,
/// `true` if the administrator can invite new users to the chat.
pub can_invite_users: bool,
@ -403,17 +403,22 @@ impl ChatMemberKind {
/// Returns `false` otherwise.
///
/// [`can_manage_voice_chats`]: Administrator::can_manage_voice_chats
pub fn can_manage_voice_chats(&self) -> bool {
pub fn can_manage_video_chats(&self) -> bool {
match self {
Self::Owner(_) => true,
Self::Administrator(Administrator {
can_manage_voice_chats,
can_manage_video_chats,
..
}) => *can_manage_voice_chats,
}) => *can_manage_video_chats,
Self::Member | Self::Restricted(_) | Self::Left | Self::Banned(_) => false,
}
}
#[deprecated(since = "0.6.0", note = "renamed to `can_manage_video_chats`")]
pub fn can_manage_voice_chats(&self) -> bool {
self.can_manage_video_chats()
}
/// Returns `true` if the user can can invite new users to the chat.
///
/// I.e. returns `true` if the user
@ -612,7 +617,7 @@ mod tests {
"can_manage_chat": true,
"can_change_info": true,
"can_delete_messages": true,
"can_manage_voice_chats": true,
"can_manage_video_chats": true,
"can_invite_users": true,
"can_restrict_members": true,
"can_pin_messages": true,
@ -636,7 +641,7 @@ mod tests {
can_post_messages: None,
can_edit_messages: None,
can_delete_messages: true,
can_manage_voice_chats: true,
can_manage_video_chats: true,
can_invite_users: true,
can_restrict_members: true,
can_pin_messages: Some(true),

View file

@ -1,4 +1,4 @@
use crate::types::{CallbackGame, LoginUrl};
use crate::types::{CallbackGame, LoginUrl, WebAppInfo};
use serde::{Deserialize, Serialize};
/// This object represents one button of an inline keyboard.
@ -62,6 +62,15 @@ pub enum InlineKeyboardButtonKind {
/// [`CallbackQuery`]: crate::types::CallbackQuery
CallbackData(String),
/// Description of the [Web App] that will be launched when the user presses
/// the button. The Web App will be able to send an arbitrary message on
/// behalf of the user using the method [`AnswerWebAppQuery`]. Available
/// only in private chats between a user and the bot.
///
/// [Web App]: https://core.telegram.org/bots/webapps
/// [`AnswerWebAppQuery`]: crate::payloads::AnswerWebAppQuery
WebApp(WebAppInfo),
/// If set, pressing the button will prompt the user to select one of their
/// chats, open that chat and insert the bots username and the specified
/// inline query in the input field. Can be empty, in which case just the

View file

@ -1,6 +1,6 @@
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use crate::types::{KeyboardButtonPollType, True};
use crate::types::{KeyboardButtonPollType, True, WebAppInfo};
/// This object represents one button of the reply keyboard.
///
@ -15,11 +15,28 @@ pub struct KeyboardButton {
/// be sent as a message when the button is pressed.
pub text: String,
/// Request something from user.
/// Request something from user. This is available in private chats only.
///
/// - If `Some(Contact)`, the user's phone number will be sent as a contact
/// when the button is pressed. Available in private chats only
/// when the button is pressed.
/// - If `Some(Location)`, the user's current location will be sent when the
/// button is pressed. Available in private chats only
/// button is pressed.
/// - If `Some(Poll(_))`, the user will be asked to create a poll and send
/// it to the bot when the button is pressed.
/// - If `Some(WebApp(_))`, the described Web App will be launched when the
/// button is pressed. The Web App will be able to send a “web_app_data”
/// service message.
///
/// **Note:** `Contact` and `Location` options will only work in Telegram
/// versions released after 9 April, 2016. Older clients will display
/// unsupported message.
///
/// **Note:** `Poll(_)` option will only work in Telegram versions released
/// after 23 January, 2020. Older clients will display unsupported message.
///
/// **Note:** `WebApp(_)` option will only work in Telegram versions
/// released after 16 April, 2022. Older clients will display unsupported
/// message.
#[serde(flatten)]
pub request: Option<ButtonRequest>,
}
@ -45,11 +62,13 @@ impl KeyboardButton {
}
// Serialize + Deserialize are implemented by hand
// FIXME: add documentation
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum ButtonRequest {
Location,
Contact,
Poll(KeyboardButtonPollType),
WebApp(WebAppInfo),
}
/// Helper struct for (de)serializing [`ButtonRequest`](ButtonRequest)
@ -71,6 +90,11 @@ struct RawRequest {
/// chats only.
#[serde(rename = "request_poll")]
poll: Option<KeyboardButtonPollType>,
/// If specified, the described Web App will be launched when the button is
/// pressed. The Web App will be able to send a “web_app_data” service
/// message. Available in private chats only.
web_app: Option<WebAppInfo>,
}
impl<'de> Deserialize<'de> for ButtonRequest {
@ -81,13 +105,21 @@ impl<'de> Deserialize<'de> for ButtonRequest {
let raw = RawRequest::deserialize(deserializer)?;
match raw {
RawRequest {
contact: Some(_),
location: Some(_),
poll: Some(_),
} => Err(D::Error::custom(
"`request_contact` and `request_location` fields are mutually exclusive, but both \
were provided",
)),
contact,
location,
poll,
web_app,
} if 1
< (contact.is_some() as u8
+ location.is_some() as u8
+ poll.is_some() as u8
+ web_app.is_some() as u8) =>
{
Err(D::Error::custom(
"`request_contact`, `request_location`, `request_poll` and `web_app` fields \
are mutually exclusive",
))
}
RawRequest {
contact: Some(_), ..
} => Ok(Self::Contact),
@ -98,8 +130,14 @@ impl<'de> Deserialize<'de> for ButtonRequest {
poll: Some(poll_type),
..
} => Ok(Self::Poll(poll_type)),
RawRequest {
web_app: Some(web_app),
..
} => Ok(Self::WebApp(web_app)),
_ => Err(D::Error::custom(
"Either one of `request_contact` and `request_location` fields is required",
"Either one of `request_contact`, `request_location`, `request_poll` and \
`web_app` fields is required",
)),
}
}
@ -110,26 +148,21 @@ impl Serialize for ButtonRequest {
where
S: Serializer,
{
let mut raw = RawRequest {
contact: None,
location: None,
poll: None,
web_app: None,
};
match self {
Self::Contact => RawRequest {
contact: Some(True),
location: None,
poll: None,
}
.serialize(serializer),
Self::Location => RawRequest {
contact: None,
location: Some(True),
poll: None,
}
.serialize(serializer),
Self::Poll(poll_type) => RawRequest {
contact: None,
location: None,
poll: Some(poll_type.clone()),
}
.serialize(serializer),
}
Self::Contact => raw.contact = Some(True),
Self::Location => raw.location = Some(True),
Self::Poll(poll_type) => raw.poll = Some(poll_type.clone()),
Self::WebApp(web_app) => raw.web_app = Some(web_app.clone()),
};
raw.serialize(serializer)
}
}

35
src/types/menu_button.rs Normal file
View file

@ -0,0 +1,35 @@
use serde::{Deserialize, Serialize};
use crate::types::WebAppInfo;
/// This object describes the bot's menu button in a private chat.
///
/// If a menu button other than `MenuButton::Default` is set for a private chat,
/// then it is applied in the chat. Otherwise the default menu button is
/// applied. By default, the menu button opens the list of bot commands.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "type")]
pub enum MenuButton {
/// Represents a menu button, which opens the bot's list of commands.
Commands,
/// Represents a menu button, which launches a [Web App].
///
/// [Web App]: https://core.telegram.org/bots/webapps
WebApp {
/// Text on the button.
text: String,
/// Description of the Web App that will be launched when the user
/// presses the button. The Web App will be able to send an arbitrary
/// message on behalf of the user using the method
/// [`AnswerWebAppQuery`].
///
/// [`AnswerWebAppQuery`]: crate::payloads::AnswerWebAppQuery
web_app: WebAppInfo,
},
/// Describes that no specific value for the menu button was set.
Default,
}

View file

@ -7,8 +7,8 @@ use crate::types::{
Animation, Audio, BareChatId, Chat, ChatId, Contact, Dice, Document, Game,
InlineKeyboardMarkup, Invoice, Location, MessageAutoDeleteTimerChanged, MessageEntity,
PassportData, PhotoSize, Poll, ProximityAlertTriggered, Sticker, SuccessfulPayment, True, User,
Venue, Video, VideoNote, Voice, VoiceChatEnded, VoiceChatParticipantsInvited,
VoiceChatScheduled, VoiceChatStarted,
Venue, Video, VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled,
VideoChatStarted, VideoNote, Voice, WebAppData,
};
/// This object represents a message.
@ -58,6 +58,7 @@ pub enum MessageKind {
VoiceChatStarted(MessageVoiceChatStarted),
VoiceChatEnded(MessageVoiceChatEnded),
VoiceChatParticipantsInvited(MessageVoiceChatParticipantsInvited),
WebAppData(MessageWebAppData),
}
#[serde_with_macros::skip_serializing_none]
@ -494,25 +495,31 @@ pub struct MessageProximityAlertTriggered {
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVoiceChatScheduled {
/// Service message: voice chat scheduled
pub voice_chat_scheduled: VoiceChatScheduled,
pub video_chat_scheduled: VideoChatScheduled,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVoiceChatStarted {
/// Service message: voice chat started.
pub voice_chat_started: VoiceChatStarted,
pub video_chat_started: VideoChatStarted,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVoiceChatEnded {
/// Service message: voice chat ended.
pub voice_chat_ended: VoiceChatEnded,
pub video_chat_ended: VideoChatEnded,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVoiceChatParticipantsInvited {
/// Service message: new participants invited to a voice chat.
pub voice_chat_participants_invited: VoiceChatParticipantsInvited,
pub video_chat_participants_invited: VideoChatParticipantsInvited,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageWebAppData {
/// Service message: data sent by a Web App.
pub web_app_data: WebAppData,
}
mod getters {
@ -1455,7 +1462,7 @@ mod tests {
/// Regression test for <https://github.com/teloxide/teloxide/issues/475>
#[test]
fn issue_475() {
let json = r#"{"message_id":198295,"from":{"id":1087968824,"is_bot":true,"first_name":"Group","username":"GroupAnonymousBot"},"sender_chat":{"id":-1001331354980,"title":"C++ Together 2.0","username":"cpptogether","type":"supergroup"},"chat":{"id":-1001331354980,"title":"C++ Together 2.0","username":"cpptogether","type":"supergroup"},"date":1638236631,"voice_chat_started":{}}"#;
let json = r#"{"message_id":198295,"from":{"id":1087968824,"is_bot":true,"first_name":"Group","username":"GroupAnonymousBot"},"sender_chat":{"id":-1001331354980,"title":"C++ Together 2.0","username":"cpptogether","type":"supergroup"},"chat":{"id":-1001331354980,"title":"C++ Together 2.0","username":"cpptogether","type":"supergroup"},"date":1638236631,"video_chat_started":{}}"#;
let message: Message = serde_json::from_str(json).unwrap();

View file

@ -0,0 +1,13 @@
use serde::{Deserialize, Serialize};
/// Contains information about an inline message sent by a [Web App] on behalf
/// of a user.
///
/// [Web App]: https://core.telegram.org/bots/webapps
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct SentWebAppMessage {
/// Identifier of the sent inline message. Available only if there is an
/// inline keyboard attached to the message.
pub inline_message_id: Option<String>,
}

View file

@ -3,4 +3,4 @@ use serde::{Deserialize, Serialize};
/// This object represents a service message about a voice chat ended in the
/// chat.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatEnded {}
pub struct VideoChatEnded {}

View file

@ -5,7 +5,7 @@ use crate::types::User;
/// This object represents a service message about new members invited to a
/// voice chat.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatParticipantsInvited {
pub struct VideoChatParticipantsInvited {
/// New members that were invited to the voice chat
pub users: Option<Vec<User>>,
}

View file

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
/// This object represents a service message about a voice chat scheduled in the
/// chat.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatScheduled {
pub struct VideoChatScheduled {
/// Point in time when the voice chat is supposed to be started by a chat
/// administrator.
#[serde(with = "crate::types::serde_date_from_unix_timestamp")]

View file

@ -3,4 +3,4 @@ use serde::{Deserialize, Serialize};
/// This object represents a service message about a voice chat started in the
/// chat. Currently holds no information.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatStarted {}
pub struct VideoChatStarted {}

13
src/types/web_app_data.rs Normal file
View file

@ -0,0 +1,13 @@
use serde::{Deserialize, Serialize};
/// Contains data sent from a Web App to the bot.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct WebAppData {
/// The data. Be aware that a bad client can send arbitrary data in this
/// field.
pub data: String,
/// Text of the web_app keyboard button, from which the Web App was opened.
/// Be aware that a bad client can send arbitrary data in this field.
pub button_text: String,
}

14
src/types/web_app_info.rs Normal file
View file

@ -0,0 +1,14 @@
use serde::{Deserialize, Serialize};
use url::Url;
/// Contains information about a [Web App].
///
/// [Web App]: https://core.telegram.org/bots/webapps
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct WebAppInfo {
/// An HTTPS URL of a Web App to be opened with additional data as specified
/// in [Initializing Web Apps].
///
/// [Initializing Web Apps]: https://core.telegram.org/bots/webapps#initializing-web-apps
pub url: Url,
}

View file

@ -34,6 +34,11 @@ pub struct WebhookInfo {
/// happened when trying to deliver an update via webhook.
pub last_error_message: Option<String>,
/// Time of the most recent error that happened when trying to synchronize
/// available updates with Telegram data-centers.
#[serde(default, with = "crate::types::serde_opt_date_from_unix_timestamp")]
pub last_synchronization_error_date: Option<DateTime<Utc>>,
/// Maximum allowed number of simultaneous HTTPS connections to the webhook
/// for update delivery.
pub max_connections: Option<u32>,
@ -55,6 +60,7 @@ fn empty_url() {
ip_address: None,
last_error_date: None,
last_error_message: None,
last_synchronization_error_date: None,
max_connections: None,
allowed_updates: Some(vec![AllowedUpdate::Message]),
};