diff --git a/src/dispatching/dispatcher_handler_ctx.rs b/src/dispatching/dispatcher_handler_ctx.rs index c48e53fc..f697ce3d 100644 --- a/src/dispatching/dispatcher_handler_ctx.rs +++ b/src/dispatching/dispatcher_handler_ctx.rs @@ -5,6 +5,7 @@ use crate::{ Bot, }; use std::sync::Arc; +use crate::types::{ChatId, InputFile, InputMedia}; /// A [`Dispatcher`]'s handler's context of a bot and an update. /// @@ -27,7 +28,7 @@ where } impl DispatcherHandlerCtx { - pub async fn reply(&self, text: T) -> ResponseResult<()> + pub async fn answer(&self, text: T) -> ResponseResult where T: Into, { @@ -35,6 +36,122 @@ impl DispatcherHandlerCtx { .send_message(self.chat_id(), text) .send() .await - .map(|_| ()) + } + + pub async fn reply_to(&self, text: T) -> ResponseResult + where + T: Into + { + self.bot + .send_message(self.chat_id(), text) + .reply_to_message_id(self.update.id) + .send() + .await + } + + pub async fn answer_photo(&self, photo: InputFile) -> ResponseResult + { + self.bot + .send_photo(self.update.chat.id, photo) + .send() + .await + } + + pub async fn answer_audio(&self, audio: InputFile) -> ResponseResult + { + self.bot + .send_audio(self.update.chat.id, audio) + .send() + .await + } + + pub async fn answer_animation(&self, animation: InputFile) -> ResponseResult + { + self.bot + .send_animation(self.update.chat.id, animation) + .send() + .await + } + + pub async fn answer_document(&self, document: InputFile) -> ResponseResult + { + self.bot + .send_document(self.update.chat.id, document) + .send() + .await + } + + pub async fn answer_video(&self, video: InputFile) -> ResponseResult + { + self.bot + .send_video(self.update.chat.id, video) + .send() + .await + } + + pub async fn answer_voice(&self, voice: InputFile) -> ResponseResult + { + self.bot + .send_voice(self.update.chat.id, voice) + .send() + .await + } + + pub async fn answer_media_group(&self, media_group: T) -> ResponseResult> + where + T: Into> + { + self.bot + .send_media_group(self.update.chat.id, T) + .send() + .await + } + + pub async fn answer_location(&self, latitude: f32, longitude: f32) -> ResponseResult + { + self.bot + .send_location(self.update.chat.id, latitude, longitude) + .send() + .await + } + + pub async fn answer_venue(&self, latitude: f32, longitude: f32, title: T, address: U) -> ResponseResult + where + T: Into, + U: Into + { + self.bot + .send_venue(self.update.chat.id, latitude, longitude, title, address) + .send() + .await + } + + pub async fn answer_video_note(&self, video_note: InputFile) -> ResponseResult + { + self.bot + .send_video_note(self.update.chat.id, video_note) + .send() + .await + } + + pub async fn answer_contact(&self, phone_number: T, first_name: U) -> ResponseResult + where + T: Into, + U: Into + { + self.bot + .send_contact(self.chat_id(), phone_number, first_name) + .send() + .await + } + + pub async fn forward_to(&self, chat_id: T) -> ResponseResult + where + T: Into + { + self.bot + .forward_message(chat_id, self.update.chat.id, self.update.id) + .send() + .await } }