use crate::{
contexts::fields::Message,
methods::*,
types::{
chat,
input_file::{
Animation, Audio, ChatPhoto, Document, EditableMedia, GroupMedia,
Photo, Sticker, Video, VideoNote, Voice,
},
keyboard::inline,
message,
parameters::{ImplicitChatId, Poll, Text},
user, LabeledPrice,
},
};
pub trait ChatMethods<'b, C: 'static>: Message<C> {
fn delete_chat_photo(&self) -> DeleteChatPhoto<'_, C> {
self.bot().delete_chat_photo(self.chat().id)
}
fn delete_chat_sticker_set(&self) -> DeleteChatStickerSet<'_, C> {
self.bot().delete_chat_sticker_set(self.chat().id)
}
fn delete_message(&self, message_id: message::Id) -> DeleteMessage<'_, C> {
self.bot().delete_message(self.chat().id, message_id)
}
fn delete_this_message(&self) -> DeleteMessage<'_, C> {
self.delete_message(self.message_id())
}
fn edit_message_caption<'a>(
&'a self,
message_id: message::Id,
caption: impl Into<Text<'a>>,
) -> EditMessageCaption<'a, C> {
self.bot()
.edit_message_caption(self.chat().id, message_id, caption)
}
fn edit_message_location(
&self,
message_id: message::Id,
location: (f64, f64),
) -> EditMessageLocation<'_, C> {
self.bot()
.edit_message_location(self.chat().id, message_id, location)
}
fn edit_message_media<'a>(
&'a self,
message_id: message::Id,
media: impl Into<EditableMedia<'a>>,
) -> EditMessageMedia<'a, C> {
self.bot()
.edit_message_media(self.chat().id, message_id, media)
}
fn edit_message_reply_markup<'a>(
&'a self,
message_id: message::Id,
reply_markup: inline::Keyboard<'a>,
) -> EditMessageReplyMarkup<'a, C> {
self.bot().edit_message_reply_markup(
self.chat().id,
message_id,
reply_markup,
)
}
fn edit_message_text<'a>(
&'a self,
message_id: message::Id,
text: impl Into<Text<'a>>,
) -> EditMessageText<'a, C> {
self.bot()
.edit_message_text(self.chat().id, message_id, text)
}
fn export_chat_invite_link(&self) -> ExportChatInviteLink<'_, C> {
self.bot().export_chat_invite_link(self.chat().id)
}
fn forward_here<'a>(
&'a self,
from_chat_id: impl ImplicitChatId<'a>,
message_id: message::Id,
) -> ForwardMessage<'a, C> {
self.bot()
.forward_message(self.chat().id, from_chat_id, message_id)
}
fn get_chat(&self) -> GetChat<'_, C> {
self.bot().get_chat(self.chat().id)
}
fn get_chat_administrators(&self) -> GetChatAdministrators<'_, C> {
self.bot().get_chat_administrators(self.chat().id)
}
fn get_chat_member(&self, user_id: user::Id) -> GetChatMember<'_, C> {
self.bot().get_chat_member(self.chat().id, user_id)
}
fn get_chat_members_count(&self) -> GetChatMembersCount<'_, C> {
self.bot().get_chat_members_count(self.chat().id)
}
fn get_message_game_high_scores(
&self,
message_id: message::Id,
user_id: user::Id,
) -> GetMessageGameHighScores<'_, C> {
self.bot().get_message_game_high_scores(
self.chat().id,
message_id,
user_id,
)
}
fn kick_chat_member(&self, user_id: user::Id) -> KickChatMember<'_, C> {
self.bot().kick_chat_member(self.chat().id, user_id)
}
fn leave_chat(&self) -> LeaveChat<'_, C> {
self.bot().leave_chat(self.chat().id)
}
fn pin_chat_message(
&self,
message_id: message::Id,
) -> PinChatMessage<'_, C> {
self.bot().pin_chat_message(self.chat().id, message_id)
}
fn promote_chat_member(
&self,
user_id: user::Id,
) -> PromoteChatMember<'_, C> {
self.bot().promote_chat_member(self.chat().id, user_id)
}
fn restrict_chat_member(
&self,
user_id: user::Id,
permissions: chat::Permissions,
) -> RestrictChatMember<'_, C> {
self.bot()
.restrict_chat_member(self.chat().id, user_id, permissions)
}
fn send_animation<'a>(
&'a self,
animation: Animation<'a>,
) -> SendAnimation<'a, C> {
self.bot().send_animation(self.chat().id, animation)
}
fn send_animation_in_reply<'a>(
&'a self,
animation: Animation<'a>,
) -> SendAnimation<'a, C> {
self.send_animation(animation)
.reply_to_message_id(self.message_id())
}
fn send_audio<'a>(&'a self, audio: Audio<'a>) -> SendAudio<'a, C> {
self.bot().send_audio(self.chat().id, audio)
}
fn send_audio_in_reply<'a>(&'a self, audio: Audio<'a>) -> SendAudio<'a, C> {
self.send_audio(audio)
.reply_to_message_id(self.message_id())
}
fn send_chat_action(&self, action: chat::Action) -> SendChatAction<C> {
self.bot().send_chat_action(self.chat().id, action)
}
fn send_contact<'a>(
&'a self,
phone_number: &'a str,
first_name: &'a str,
) -> SendContact<'a, C> {
self.bot()
.send_contact(self.chat().id, phone_number, first_name)
}
fn send_contact_in_reply<'a>(
&'a self,
phone_number: &'a str,
first_name: &'a str,
) -> SendContact<'a, C> {
self.send_contact(phone_number, first_name)
.reply_to_message_id(self.message_id())
}
fn send_game<'a>(&'a self, game_short_name: &'a str) -> SendGame<'a, C> {
self.bot().send_game(self.chat().id, game_short_name)
}
fn send_game_in_reply<'a>(
&'a self,
game_short_name: &'a str,
) -> SendGame<'a, C> {
self.send_game(game_short_name)
.reply_to_message_id(self.message_id())
}
fn send_dice(&self) -> SendDice<'_, C> {
self.bot().send_dice(self.chat().id)
}
fn send_document<'a>(
&'a self,
document: Document<'a>,
) -> SendDocument<'a, C> {
self.bot().send_document(self.chat().id, document)
}
fn send_document_in_reply<'a>(
&'a self,
document: Document<'a>,
) -> SendDocument<'a, C> {
self.send_document(document)
.reply_to_message_id(self.message_id())
}
#[allow(clippy::too_many_arguments)]
fn send_invoice<'a>(
&'a self,
title: &'a str,
description: &'a str,
payload: &'a str,
provider_token: &'a str,
start_parameter: &'a str,
currency: &'a str,
prices: &'a [LabeledPrice<'a>],
) -> SendInvoice<'a, C> {
self.bot().send_invoice(
self.chat().id,
title,
description,
payload,
provider_token,
start_parameter,
currency,
prices,
)
}
#[allow(clippy::too_many_arguments)]
fn send_invoice_in_reply<'a>(
&'a self,
title: &'a str,
description: &'a str,
payload: &'a str,
provider_token: &'a str,
start_parameter: &'a str,
currency: &'a str,
prices: &'a [LabeledPrice<'a>],
) -> SendInvoice<'a, C> {
self.send_invoice(
title,
description,
payload,
provider_token,
start_parameter,
currency,
prices,
)
.reply_to_message_id(self.message_id())
}
fn send_location(&self, location: (f64, f64)) -> SendLocation<C> {
self.bot().send_location(self.chat().id, location)
}
fn send_location_in_reply(&self, location: (f64, f64)) -> SendLocation<C> {
self.send_location(location)
.reply_to_message_id(self.message_id())
}
fn send_media_group<'a>(
&'a self,
media: &'a [GroupMedia<'a>],
) -> SendMediaGroup<'a, C> {
self.bot().send_media_group(self.chat().id, media)
}
fn send_media_group_in_reply<'a>(
&'a self,
media: &'a [GroupMedia<'a>],
) -> SendMediaGroup<'a, C> {
self.send_media_group(media)
.reply_to_message_id(self.message_id())
}
fn send_message<'a>(
&'a self,
text: impl Into<Text<'a>>,
) -> SendMessage<'a, C> {
self.bot().send_message(self.chat().id, text)
}
fn send_message_in_reply<'a>(
&'a self,
text: impl Into<Text<'a>>,
) -> SendMessage<'a, C> {
self.send_message(text)
.reply_to_message_id(self.message_id())
}
fn send_photo<'a>(&'a self, photo: Photo<'a>) -> SendPhoto<'a, C> {
self.bot().send_photo(self.chat().id, photo)
}
fn send_photo_in_reply<'a>(&'a self, photo: Photo<'a>) -> SendPhoto<'a, C> {
self.send_photo(photo)
.reply_to_message_id(self.message_id())
}
fn send_poll<'a>(&'a self, poll: &'a Poll<'a>) -> SendPoll<'a, C> {
self.bot().send_poll(self.chat().id, poll)
}
fn send_poll_in_reply<'a>(&'a self, poll: &'a Poll<'a>) -> SendPoll<'a, C> {
self.send_poll(poll).reply_to_message_id(self.message_id())
}
fn send_sticker<'a>(&'a self, sticker: Sticker<'a>) -> SendSticker<'a, C> {
self.bot().send_sticker(self.chat().id, sticker)
}
fn send_sticker_in_reply<'a>(
&'a self,
sticker: Sticker<'a>,
) -> SendSticker<'a, C> {
self.send_sticker(sticker)
.reply_to_message_id(self.message_id())
}
fn send_venue<'a>(
&'a self,
location: (f64, f64),
title: &'a str,
address: &'a str,
) -> SendVenue<'a, C> {
self.bot()
.send_venue(self.chat().id, location, title, address)
}
fn send_venue_in_reply<'a>(
&'a self,
location: (f64, f64),
title: &'a str,
address: &'a str,
) -> SendVenue<'a, C> {
self.send_venue(location, title, address)
.reply_to_message_id(self.message_id())
}
fn send_video<'a>(&'a self, video: Video<'a>) -> SendVideo<'a, C> {
self.bot().send_video(self.chat().id, video)
}
fn send_video_in_reply<'a>(&'a self, video: Video<'a>) -> SendVideo<'a, C> {
self.send_video(video)
.reply_to_message_id(self.message_id())
}
fn send_video_note<'a>(
&'a self,
video_note: VideoNote<'a>,
) -> SendVideoNote<'a, C> {
self.bot().send_video_note(self.chat().id, video_note)
}
fn send_video_note_in_reply<'a>(
&'a self,
video_note: VideoNote<'a>,
) -> SendVideoNote<'a, C> {
self.send_video_note(video_note)
.reply_to_message_id(self.message_id())
}
fn send_voice<'a>(&'a self, voice: Voice<'a>) -> SendVoice<'a, C> {
self.bot().send_voice(self.chat().id, voice)
}
fn send_voice_in_reply<'a>(&'a self, voice: Voice<'a>) -> SendVoice<'a, C> {
self.send_voice(voice)
.reply_to_message_id(self.message_id())
}
fn set_chat_administrator_custom_title<'a>(
&'a self,
user_id: user::Id,
custom_title: &'a str,
) -> SetChatAdministratorCustomTitle<'a, C> {
self.bot().set_chat_administrator_custom_title(
self.chat().id,
user_id,
custom_title,
)
}
fn set_chat_description<'a>(
&'a self,
description: &'a str,
) -> SetChatDescription<'a, C> {
self.bot().set_chat_description(self.chat().id, description)
}
fn set_chat_permissions(
&self,
permissions: chat::Permissions,
) -> SetChatPermissions<'_, C> {
self.bot().set_chat_permissions(self.chat().id, permissions)
}
fn set_chat_photo<'a>(
&'a self,
photo: ChatPhoto<'a>,
) -> SetChatPhoto<'a, C> {
self.bot().set_chat_photo(self.chat().id, photo)
}
fn set_chat_sticker_set<'a>(
&'a self,
sticker_set_name: &'a str,
) -> SetChatStickerSet<'a, C> {
self.bot()
.set_chat_sticker_set(self.chat().id, sticker_set_name)
}
fn set_chat_title<'a>(&'a self, title: &'a str) -> SetChatTitle<'a, C> {
self.bot().set_chat_title(self.chat().id, title)
}
fn set_message_game_score(
&self,
message_id: message::Id,
user_id: user::Id,
score: u32,
) -> SetMessageGameScore<'_, C> {
self.bot().set_message_game_score(
self.chat().id,
message_id,
user_id,
score,
)
}
fn unban_chat_member(&self, user_id: user::Id) -> UnbanChatMember<'_, C> {
self.bot().unban_chat_member(self.chat().id, user_id)
}
fn unpin_chat_message(&self) -> UnpinChatMessage<'_, C> {
self.bot().unpin_chat_message(self.chat().id)
}
}
impl<C: 'static, T: Message<C>> ChatMethods<'_, C> for T {}